mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 13:42:55 +00:00
Add va function
This commit is contained in:
parent
1f986d5588
commit
4f2b1e79a7
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#include <Ntstrsafe.h>
|
||||||
|
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4201)
|
#pragma warning(disable: 4201)
|
||||||
|
@ -11,4 +11,14 @@ namespace string
|
|||||||
RtlInitUnicodeString(&unicode_string, string);
|
RtlInitUnicodeString(&unicode_string, string);
|
||||||
return unicode_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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "type_traits.hpp"
|
||||||
|
|
||||||
|
#define VA_BUFFER_SIZE 0x1000
|
||||||
|
|
||||||
namespace string
|
namespace string
|
||||||
{
|
{
|
||||||
_IRQL_requires_max_(DISPATCH_LEVEL)
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
||||||
UNICODE_STRING get_unicode_string(const wchar_t* string);
|
UNICODE_STRING get_unicode_string(const wchar_t* string);
|
||||||
|
|
||||||
|
char* get_va_buffer();
|
||||||
|
|
||||||
|
template<typename ...Args>
|
||||||
|
const char* va(const char* message, Args&&... args)
|
||||||
|
{
|
||||||
|
auto* buffer = get_va_buffer();
|
||||||
|
RtlStringCchPrintfA(buffer, VA_BUFFER_SIZE, message, std::forward<Args>(args)...);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user