diff --git a/src/driver/std_include.hpp b/src/driver/std_include.hpp index d5a6eba..011dde1 100644 --- a/src/driver/std_include.hpp +++ b/src/driver/std_include.hpp @@ -2,6 +2,7 @@ #include #include +#include #pragma warning(push) #pragma warning(disable: 4201) diff --git a/src/driver/string.cpp b/src/driver/string.cpp index de1d59e..6414682 100644 --- a/src/driver/string.cpp +++ b/src/driver/string.cpp @@ -11,4 +11,14 @@ namespace string RtlInitUnicodeString(&unicode_string, string); return unicode_string; } + + char* get_va_buffer() + { + constexpr auto va_buffer_count = 0x10; + static char buffers[va_buffer_count][VA_BUFFER_SIZE]; + static volatile long current_buffer = 0; + + const auto index = InterlockedIncrement(¤t_buffer); + return buffers[index % va_buffer_count]; + } } diff --git a/src/driver/string.hpp b/src/driver/string.hpp index 985c768..b25c3c6 100644 --- a/src/driver/string.hpp +++ b/src/driver/string.hpp @@ -1,7 +1,20 @@ #pragma once +#include "type_traits.hpp" + +#define VA_BUFFER_SIZE 0x1000 namespace string { _IRQL_requires_max_(DISPATCH_LEVEL) UNICODE_STRING get_unicode_string(const wchar_t* string); + + char* get_va_buffer(); + + template + const char* va(const char* message, Args&&... args) + { + auto* buffer = get_va_buffer(); + RtlStringCchPrintfA(buffer, VA_BUFFER_SIZE, message, std::forward(args)...); + return buffer; + } }