From e55b96745670b60e4911329101789f29415e2511 Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jan 2024 12:18:09 -0800 Subject: [PATCH] Fix UEVR not injecting if within Unicode filepaths --- UEVR/Injector.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UEVR/Injector.cs b/UEVR/Injector.cs index 8717589..cab6bf9 100644 --- a/UEVR/Injector.cs +++ b/UEVR/Injector.cs @@ -52,10 +52,10 @@ public static bool InjectDll(int processId, string dllPath, out IntPtr dllBase) } // Get the address of the LoadLibrary function - IntPtr loadLibraryAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA"); + IntPtr loadLibraryAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryW"); if (loadLibraryAddress == IntPtr.Zero) { - MessageBox.Show("Could not obtain LoadLibraryA address in the target process."); + MessageBox.Show("Could not obtain LoadLibraryW address in the target process."); return false; } @@ -67,10 +67,10 @@ public static bool InjectDll(int processId, string dllPath, out IntPtr dllBase) return false; } - // Write the DLL path to the allocated memory + // Write the DLL path in UTF-16 int bytesWritten = 0; - var bytes = Encoding.ASCII.GetBytes(fullPath); - WriteProcessMemory(processHandle, dllPathAddress, bytes, (uint)fullPath.Length, out bytesWritten); + var bytes = Encoding.Unicode.GetBytes(fullPath); + WriteProcessMemory(processHandle, dllPathAddress, bytes, (uint)(fullPath.Length * 2), out bytesWritten); // Create a remote thread in the target process that calls LoadLibrary with the DLL path IntPtr threadHandle = CreateRemoteThread(processHandle, IntPtr.Zero, 0, loadLibraryAddress, dllPathAddress, 0, IntPtr.Zero);