Permalink
Browse files

ReviveInjector: Set the LIBOVR_DLL_DIR env variable.

  • Loading branch information...
1 parent a84467b commit 96e678747c51a4f5d021abede1fd40ba7dfa9ac1 @LibreVR committed May 21, 2016
Showing with 17 additions and 7 deletions.
  1. +17 −7 ReviveInjector/main.cpp
View
@@ -29,6 +29,19 @@ int wmain(int argc, wchar_t *argv[]) {
LOG("Launched injector with: %ls\n", GetCommandLine());
+
+ DWORD BaseSize = MAX_PATH;
+ WCHAR BasePath[MAX_PATH];
+ HKEY oculusKey;
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Oculus VR, LLC\\Oculus", 0, KEY_READ | KEY_WOW64_32KEY, &oculusKey);
+ RegQueryValueEx(oculusKey, L"Base", NULL, NULL, (PBYTE)BasePath, &BaseSize);
+ RegCloseKey(oculusKey);
+
+ WCHAR runtime[MAX_PATH];
+ wcsncpy(runtime, BasePath, MAX_PATH);
+ wcsncat(runtime, L"Support\\oculus-runtime", MAX_PATH);
+ SetEnvironmentVariable(L"LIBOVR_DLL_DIR", runtime);
+
for (int i = 0; i < argc - 1; i++)
{
if (wcscmp(argv[i], L"/handle") == 0)
@@ -42,13 +55,10 @@ int wmain(int argc, wchar_t *argv[]) {
for (wchar_t* ptr = arg; *ptr != L'\0'; ptr++)
if (*ptr == L'/') *ptr = L'\\';
- DWORD size = MAX_PATH;
- WCHAR path[MAX_PATH];
- HKEY oculusKey;
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Oculus VR, LLC\\Oculus", 0, KEY_READ | KEY_WOW64_32KEY, &oculusKey);
- RegQueryValueEx(oculusKey, L"Base", NULL, NULL, (PBYTE)path, &size);
- wcsncat(path, arg, MAX_PATH);
- return CreateProcessAndInject(path);
+ WCHAR launch[MAX_PATH];
+ wcsncpy(launch, BasePath, MAX_PATH);
+ wcsncat(launch, arg, MAX_PATH);
+ return CreateProcessAndInject(launch);
}
}

0 comments on commit 96e6787

Please sign in to comment.