Skip to content

Commit

Permalink
Switch to UTF8 string literals for GetProcAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
dongle-the-gadget committed Aug 3, 2023
1 parent c577234 commit 52924e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions WinverUWP/Helpers/RegistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,28 @@ private static void Initialize()
}
if (_NtClose == null)
{
fixed (byte* test = Encoding.ASCII.GetBytes("NtClose"))
fixed (byte* test = "NtClose"u8)
{
_NtClose = (delegate* unmanaged[Stdcall]<HANDLE, int>)GetProcAddress(_ntdll, (sbyte*)test);
}
}
if (_NtOpenKey == null)
{
fixed (byte* test = Encoding.ASCII.GetBytes("NtOpenKey"))
fixed (byte* test = "NtOpenKey"u8)
{
_NtOpenKey = (delegate* unmanaged[Stdcall]<HANDLE*, uint, OBJECT_ATTRIBUTES*, int>)GetProcAddress(_ntdll, (sbyte*)test);
}
}
if (_NtQueryValueKey == null)
{
fixed (byte* test = Encoding.ASCII.GetBytes("NtQueryValueKey"))
fixed (byte* test = "NtQueryValueKey"u8)
{
_NtQueryValueKey = (delegate* unmanaged[Stdcall]<HANDLE, UNICODE_STRING*, uint, void*, uint, uint*, int>)GetProcAddress(_ntdll, (sbyte*)test);
}
}
if (_RtlInitUnicodeString == null)
{
fixed (byte* test = Encoding.ASCII.GetBytes("RtlInitUnicodeString"))
fixed (byte* test = "RtlInitUnicodeString"u8)
{
_RtlInitUnicodeString = (delegate* unmanaged[Stdcall]<UNICODE_STRING*, ushort*, void>)GetProcAddress(_ntdll, (sbyte*)test);
}
Expand Down
2 changes: 1 addition & 1 deletion WinverUWP/Helpers/WinbrandHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static string GetWinbrand()
fixed(char* pModuleName = "Winbrand.dll")
{
HMODULE module = LoadLibraryW((ushort*)pModuleName);
fixed(byte* pProc = Encoding.ASCII.GetBytes("BrandingFormatString"))
fixed(byte* pProc = "BrandingFormatString"u8)
{
var func = (delegate* unmanaged[Stdcall]<ushort*, ushort*>)GetProcAddress(module, (sbyte*)pProc);
fixed (char* pFormatName = "%WINDOWS_LONG%")
Expand Down

0 comments on commit 52924e2

Please sign in to comment.