diff --git a/src/DivaGL/print.cpp b/src/DivaGL/print.cpp index c3ad4f2d..36ca77af 100644 --- a/src/DivaGL/print.cpp +++ b/src/DivaGL/print.cpp @@ -5,7 +5,7 @@ #include "print.hpp" -void printf_divagl(const char* fmt, ...) { +void printf_divagl(_In_z_ _Printf_format_string_ const char* const fmt, ...) { char buf[0x1000]; va_list args; va_start(args, fmt); @@ -14,7 +14,7 @@ void printf_divagl(const char* fmt, ...) { va_end(args); } -void printf_proxy(const char* fmt, ...) { +void printf_proxy(_In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); vprintf(fmt, args); diff --git a/src/DivaGL/print.hpp b/src/DivaGL/print.hpp index cfd4939a..256c84d1 100644 --- a/src/DivaGL/print.hpp +++ b/src/DivaGL/print.hpp @@ -7,5 +7,5 @@ #include "../KKdLib/default.hpp" -extern void printf_divagl(const char* fmt, ...); -extern void printf_proxy(const char* fmt, ...); +extern void printf_divagl(_In_z_ _Printf_format_string_ const char* const fmt, ...); +extern void printf_proxy(_In_z_ _Printf_format_string_ const char* const fmt, ...); diff --git a/src/KKdLib/default.cpp b/src/KKdLib/default.cpp index 13046363..df7a7078 100644 --- a/src/KKdLib/default.cpp +++ b/src/KKdLib/default.cpp @@ -428,7 +428,7 @@ std::string string_to_upper(const std::string& str) { return _str; } -std::string sprintf_s_string(const char* fmt, ...) { +std::string sprintf_s_string(_In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); std::string buf = vsprintf_s_string(fmt, args); @@ -436,7 +436,7 @@ std::string sprintf_s_string(const char* fmt, ...) { return buf; } -std::wstring swprintf_s_string(const wchar_t* fmt, ...) { +std::wstring swprintf_s_string(_In_z_ _Printf_format_string_ const wchar_t* const fmt, ...) { va_list args; va_start(args, fmt); std::wstring buf = vswprintf_s_string(fmt, args); @@ -444,7 +444,7 @@ std::wstring swprintf_s_string(const wchar_t* fmt, ...) { return buf; } -std::string vsprintf_s_string(const char* fmt, va_list args) { +std::string vsprintf_s_string(_In_z_ _Printf_format_string_ const char* const fmt, va_list args) { char _buf[0x100]; int32_t len = vsprintf_s(_buf, sizeof(_buf), fmt, args); if (len < 0) @@ -458,7 +458,7 @@ std::string vsprintf_s_string(const char* fmt, va_list args) { return buf; } -std::wstring vswprintf_s_string(const wchar_t* fmt, va_list args) { +std::wstring vswprintf_s_string(_In_z_ _Printf_format_string_ const wchar_t* const fmt, va_list args) { wchar_t _buf[0x100]; int32_t len = vswprintf_s(_buf, sizeof(_buf) / sizeof(wchar_t), fmt, args); if (len < 0) diff --git a/src/KKdLib/default.hpp b/src/KKdLib/default.hpp index c696cd06..5fe67309 100644 --- a/src/KKdLib/default.hpp +++ b/src/KKdLib/default.hpp @@ -548,7 +548,7 @@ extern std::string utf16_to_utf8(const std::wstring& s); extern std::string string_to_lower(const std::string& str); extern std::string string_to_upper(const std::string& str); -extern std::string sprintf_s_string(const char* fmt, ...); -extern std::wstring swprintf_s_string(const wchar_t* fmt, ...); -extern std::string vsprintf_s_string(const char* fmt, va_list args); -extern std::wstring vswprintf_s_string(const wchar_t* fmt, va_list args); +extern std::string sprintf_s_string(_In_z_ _Printf_format_string_ const char* const fmt, ...); +extern std::wstring swprintf_s_string(_In_z_ _Printf_format_string_ const wchar_t* const fmt, ...); +extern std::string vsprintf_s_string(_In_z_ _Printf_format_string_ const char* const fmt, va_list args); +extern std::wstring vswprintf_s_string(_In_z_ _Printf_format_string_ const wchar_t* const fmt, va_list args); diff --git a/src/KKdLib/key_val.cpp b/src/KKdLib/key_val.cpp index c8f8e60c..3180fc0d 100644 --- a/src/KKdLib/key_val.cpp +++ b/src/KKdLib/key_val.cpp @@ -227,7 +227,7 @@ bool key_val::open_scope_fmt(uint32_t i) { return open_scope(buf); } -bool key_val::open_scope_fmt(const char* fmt, ...) { +bool key_val::open_scope_fmt(_In_z_ _Printf_format_string_ const char* const fmt, ...) { char buf[0x200]; va_list args; va_start(args, fmt); diff --git a/src/KKdLib/key_val.hpp b/src/KKdLib/key_val.hpp index 003d9e0b..5752b0a3 100644 --- a/src/KKdLib/key_val.hpp +++ b/src/KKdLib/key_val.hpp @@ -46,7 +46,7 @@ struct key_val { bool open_scope(std::string& str); bool open_scope_fmt(int32_t i); bool open_scope_fmt(uint32_t i); - bool open_scope_fmt(const char* fmt, ...); + bool open_scope_fmt(_In_z_ _Printf_format_string_ const char* const fmt, ...); void parse(const void* data, size_t size); bool read(bool& value); bool read(float_t& value); diff --git a/src/KKdLib/mat.hpp b/src/KKdLib/mat.hpp index 194c9362..39c4d811 100644 --- a/src/KKdLib/mat.hpp +++ b/src/KKdLib/mat.hpp @@ -320,7 +320,7 @@ inline void mat4_mul_scale(const mat4* in_m1, float_t s, mat4* out_m) { mat4_mul_scale(in_m1, s, s, s, s, out_m); } -inline void mat4_mul_scale(const mat4* in_m1, vec4* s, mat4* out_m) { +inline void mat4_mul_scale(const mat4* in_m1, const vec4* s, mat4* out_m) { mat4_mul_scale(in_m1, s->x, s->y, s->z, s->w, out_m); } diff --git a/src/ReDIVA/imgui_helper.cpp b/src/ReDIVA/imgui_helper.cpp index ab71a2f9..087c9296 100644 --- a/src/ReDIVA/imgui_helper.cpp +++ b/src/ReDIVA/imgui_helper.cpp @@ -1901,28 +1901,26 @@ namespace ImGui { return true; } - void TextCentered(const char* fmt, ...) { + void TextCentered(_In_z_ _Printf_format_string_ const char* const fmt, ...) { ImGuiContext& g = *GImGui; va_list args; va_start(args, fmt); - vsprintf_s(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); + std::string tex_buf = vsprintf_s_string(fmt, args); va_end(args); - std::string tex_buf(g.TempBuffer.Data, g.TempBuffer.Size); ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize(tex_buf.c_str()).x) * 0.5f); ImGui::Text("%s", tex_buf.c_str()); } - void TextRight(const char* fmt, ...) { + void TextRight(_In_z_ _Printf_format_string_ const char* const fmt, ...) { ImGuiContext& g = *GImGui; va_list args; va_start(args, fmt); - vsprintf_s(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); + std::string tex_buf = vsprintf_s_string(fmt, args); va_end(args); - std::string tex_buf(g.TempBuffer.Data, g.TempBuffer.Size); ImGui::SetCursorPosX(ImGui::GetWindowWidth() - ImGui::CalcTextSize(tex_buf.c_str()).x); ImGui::Text("%s", tex_buf.c_str()); } diff --git a/src/ReDIVA/imgui_helper.hpp b/src/ReDIVA/imgui_helper.hpp index 77334ac7..dee3943d 100644 --- a/src/ReDIVA/imgui_helper.hpp +++ b/src/ReDIVA/imgui_helper.hpp @@ -237,6 +237,6 @@ namespace ImGui { extern bool ColumnSliderVec4I(const char* label, vec4i* val, int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag); - extern void TextCentered(const char* fmt, ...); - extern void TextRight(const char* fmt, ...); + extern void TextCentered(_In_z_ _Printf_format_string_ const char* const fmt, ...); + extern void TextRight(_In_z_ _Printf_format_string_ const char* const fmt, ...); } diff --git a/src/ReDIVA/information/dw_console.cpp b/src/ReDIVA/information/dw_console.cpp index 9c04edb6..45e9a5e9 100644 --- a/src/ReDIVA/information/dw_console.cpp +++ b/src/ReDIVA/information/dw_console.cpp @@ -14,8 +14,8 @@ struct c_buff_data { void init(char* data, size_t size, size_t position); void move(int32_t size); - void printf(const char* fmt, ...); - void vprintf(const char* fmt, va_list args); + void printf(_In_z_ _Printf_format_string_ const char* const fmt, ...); + void vprintf(_In_z_ _Printf_format_string_ const char* const fmt, va_list args); }; struct c_buff { @@ -83,14 +83,16 @@ void dw_console_init() { dw_console->Disp(); } -void dw_console_printf(dw_console_index index, const char* fmt, ...) { +void dw_console_printf(dw_console_index index, + _In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); dw_console_vprintf(index, fmt, args); va_end(args); } -void dw_console_vprintf(dw_console_index index, const char* fmt, va_list args) { +void dw_console_vprintf(dw_console_index index, + _In_z_ _Printf_format_string_ const char* const fmt, va_list args) { /*if (!main_thread_id_check()) return;*/ @@ -244,14 +246,14 @@ void c_buff_data::move(int32_t size) { this->position -= v5 - buf; } -void c_buff_data::printf(const char* fmt, ...) { +void c_buff_data::printf(_In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); vprintf(fmt, args); va_end(args); } -void c_buff_data::vprintf(const char* fmt, va_list args) { +void c_buff_data::vprintf(_In_z_ _Printf_format_string_ const char* const fmt, va_list args) { char* pos = &position[vsprintf_s(position, buf_end - position, fmt, args)]; position = min_def(pos, buf_end); } diff --git a/src/ReDIVA/information/dw_console.hpp b/src/ReDIVA/information/dw_console.hpp index 5d3b9179..42e15f4b 100644 --- a/src/ReDIVA/information/dw_console.hpp +++ b/src/ReDIVA/information/dw_console.hpp @@ -32,8 +32,10 @@ enum dw_console_index { }; extern void dw_console_init(); -extern void dw_console_printf(dw_console_index index, const char* fmt, ...); -extern void dw_console_vprintf(dw_console_index index, const char* fmt, va_list args); +extern void dw_console_printf(dw_console_index index, + _In_z_ _Printf_format_string_ const char* const fmt, ...); +extern void dw_console_vprintf(dw_console_index index, + _In_z_ _Printf_format_string_ const char* const fmt, va_list args); extern void dw_console_c_buff_array_init(); extern void dw_console_c_buff_array_free(); diff --git a/src/ReDIVA/print_work.cpp b/src/ReDIVA/print_work.cpp index 44c4b093..05476f72 100644 --- a/src/ReDIVA/print_work.cpp +++ b/src/ReDIVA/print_work.cpp @@ -428,40 +428,44 @@ void PrintWork::set_text_position(float_t column, float_t line) { text_current_loc = line_origin_loc; } -void PrintWork::printf(app::text_flags flags, const char* fmt, ...) { +void PrintWork::printf(app::text_flags flags, + _In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); vprintf(flags, fmt, args); va_end(args); } -void PrintWork::printf_align_left(const char* fmt, ...) { +void PrintWork::printf_align_left(_In_z_ _Printf_format_string_ const char* const fmt, ...) { va_list args; va_start(args, fmt); vprintf(app::TEXT_FLAG_ALIGN_FLAG_LEFT, fmt, args); va_end(args); } -void PrintWork::wprintf(app::text_flags flags, const wchar_t* fmt, ...) { +void PrintWork::wprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const wchar_t* const fmt, ...) { va_list args; va_start(args, fmt); vwprintf(flags, fmt, args); va_end(args); } -void PrintWork::wprintf_align_left(const wchar_t* fmt, ...) { +void PrintWork::wprintf_align_left(_In_z_ _Printf_format_string_ const wchar_t* const fmt, ...) { va_list args; va_start(args, fmt); vwprintf(app::TEXT_FLAG_ALIGN_FLAG_LEFT, fmt, args); va_end(args); } -void PrintWork::vprintf(app::text_flags flags, const char* fmt, va_list args) { +void PrintWork::vprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const char* const fmt, va_list args) { std::string buf = vsprintf_s_string(fmt, args); PrintText(flags, buf.data(), buf.size()); } -void PrintWork::vwprintf(app::text_flags flags, const wchar_t* fmt, va_list args) { +void PrintWork::vwprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const wchar_t* const fmt, va_list args) { std::wstring buf = vswprintf_s_string(fmt, args); PrintText(flags, buf.data(), buf.data() + buf.size()); } diff --git a/src/ReDIVA/print_work.hpp b/src/ReDIVA/print_work.hpp index 2e7740ae..19fd277f 100644 --- a/src/ReDIVA/print_work.hpp +++ b/src/ReDIVA/print_work.hpp @@ -88,12 +88,16 @@ struct PrintWork { void SetResolutionMode(::resolution_mode value); void set_text_position(float_t column, float_t line); - void printf(app::text_flags flags, const char* fmt, ...); - void printf_align_left(const char* fmt, ...); - void wprintf(app::text_flags flags, const wchar_t* fmt, ...); - void wprintf_align_left(const wchar_t* fmt, ...); - void vprintf(app::text_flags flags, const char* fmt, va_list args); - void vwprintf(app::text_flags flags, const wchar_t* fmt, va_list args); + void printf(app::text_flags flags, + _In_z_ _Printf_format_string_ const char* const fmt, ...); + void printf_align_left(_In_z_ _Printf_format_string_ const char* const fmt, ...); + void wprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const wchar_t* const fmt, ...); + void wprintf_align_left(_In_z_ _Printf_format_string_ const wchar_t* const fmt, ...); + void vprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const char* const fmt, va_list args); + void vwprintf(app::text_flags flags, + _In_z_ _Printf_format_string_ const wchar_t* const fmt, va_list args); static void ClampPosToClipBox(float_t pos_min, float_t pos_max, float_t clip_box_min, float_t clip_box_max, float_t& clip_pos_min, float_t& clip_pos_max);