Skip to content

Commit

Permalink
Fix incorrect CWD causing injection failures
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jan 2, 2024
1 parent d40626a commit 212e685
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions UEVR/Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Diagnostics;
using System.Reflection;

namespace UEVR {
class Injector {
Expand Down Expand Up @@ -38,7 +39,21 @@ class Injector {
public static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);

// Inject the DLL into the target process
// dllPath is local filename, relative to EXE.
public static bool InjectDll(int processId, string dllPath, out IntPtr dllBase) {
try {
var exeDirectory = AppContext.BaseDirectory;

if (exeDirectory != null) {
var newPath = Path.Combine(exeDirectory, dllPath);

if (System.IO.File.Exists(newPath)) {
dllPath = Path.Combine(exeDirectory, dllPath);
}
}
} catch (Exception) {
}

dllBase = IntPtr.Zero;

string fullPath = Path.GetFullPath(dllPath);
Expand Down

0 comments on commit 212e685

Please sign in to comment.