Skip to content

Commit

Permalink
Fix UEVR not injecting if within Unicode filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jan 1, 2024
1 parent 279082b commit e55b967
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions UEVR/Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit e55b967

Please sign in to comment.