It's a start, a little one...
#include <windows.h>
#include <iostream>
#include <ntsecAPI.h> //"PUNICODE_STRING"
using namespace std;
typedef int(__cdecl* RtlIntegerToUnicodeString)(ULONG, ULONG, PUNICODE_STRING);
const ULONG STATUS_SUCCESS = 0;
// ****************************************************************************
std::wstring uLongToString(ULONG dwValue, ULONG dwBase) {
// Base: 2 binary, 8 octal, 10 decimal, 16 hexadecimal
HMODULE hLib = LoadLibrary(L"NTDLL.DLL");
if (hLib != NULL)
{
RtlIntegerToUnicodeString pProc = (RtlIntegerToUnicodeString) GetProcAddress(hLib, "RtlIntegerToUnicodeString");
if (pProc != NULL)
{
UNICODE_STRING UnicodeString;
wchar_t wBuffer[33]; //Longuest binary DWORD will be 32 characters
UnicodeString.Buffer = wBuffer;
UnicodeString.Length = 32;
UnicodeString.MaximumLength = 32;
NTSTATUS RetVal = (pProc) (dwValue, dwBase, &UnicodeString);
if (STATUS_SUCCESS == RetVal) {
std::wstring wString = wBuffer;
return wString;
}
}
FreeLibrary(hLib);
}
return NULL;
}
// ****************************************************************************
int main()
{
std::wstring wString;
wString = L"0x" + uLongToString(15, 16); //Num, Base: 2, 8, 10, 16";
MessageBoxW(HWND_DESKTOP, (LPCWSTR) &wString, L"RtlIntegerToUnicodeString", MB_OK | MB_TOPMOST);
}
// ****************************************************************************
//