Skip to content

Commit

Permalink
Replace xinput proxy with an IFEO hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Feb 10, 2021
1 parent 75a70aa commit ecaa69f
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 508 deletions.
4 changes: 4 additions & 0 deletions Installer/Revive.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ install:

; Main application files
File "..\LICENSE"
File "..\hook.cmd"
File "${DASH_DIR}\app.vrmanifest"
File "${DASH_DIR}\support.vrmanifest"
File /r "${BASE_DIR}\*.exe"
Expand Down Expand Up @@ -118,6 +119,9 @@ install:
; Delete the old Revive injector
RMDir /r "$INSTDIR\Revive"

; Delete the old XInput proxy
RMDir /r "$INSTDIR\xinput"

; Delete outdated dependencies
Delete "$INSTDIR\LibRXRRT64.dll"
Delete "$INSTDIR\openxr_loader.dll"
Expand Down
14 changes: 0 additions & 14 deletions Revive.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReviveInjector", "ReviveInj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reviveoverlay", "ReviveOverlay\reviveoverlay.vcxproj", "{D5B03597-023D-3F4C-BEB0-19B80A700A2B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xinput", "xinput\xinput.vcxproj", "{B430F22E-96AE-4771-8DD7-E12C55231E19}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReviveXR", "ReviveXR\ReviveXR.vcxproj", "{CD882909-7404-4CFC-BC8E-47364CC4727D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvr_api", "Externals\openvr_api.vcxproj", "{8940FE26-E0D4-4977-8A24-AB26AE687432}"
Expand Down Expand Up @@ -57,18 +55,6 @@ Global
{D5B03597-023D-3F4C-BEB0-19B80A700A2B}.Release|x64.ActiveCfg = Release|x64
{D5B03597-023D-3F4C-BEB0-19B80A700A2B}.Release|x64.Build.0 = Release|x64
{D5B03597-023D-3F4C-BEB0-19B80A700A2B}.Release|x86.ActiveCfg = Release|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Debug|x64.ActiveCfg = Debug|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Debug|x64.Build.0 = Debug|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Debug|x86.ActiveCfg = Debug|Win32
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Debug|x86.Build.0 = Debug|Win32
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Nightly|x64.ActiveCfg = Nightly|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Nightly|x64.Build.0 = Nightly|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Nightly|x86.ActiveCfg = Nightly|Win32
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Nightly|x86.Build.0 = Nightly|Win32
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Release|x64.ActiveCfg = Release|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Release|x64.Build.0 = Release|x64
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Release|x86.ActiveCfg = Release|Win32
{B430F22E-96AE-4771-8DD7-E12C55231E19}.Release|x86.Build.0 = Release|Win32
{CD882909-7404-4CFC-BC8E-47364CC4727D}.Debug|x64.ActiveCfg = Debug|x64
{CD882909-7404-4CFC-BC8E-47364CC4727D}.Debug|x64.Build.0 = Debug|x64
{CD882909-7404-4CFC-BC8E-47364CC4727D}.Debug|x86.ActiveCfg = Debug|Win32
Expand Down
27 changes: 24 additions & 3 deletions ReviveInjector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ int wmain(int argc, wchar_t *argv[]) {
GetModuleFileNameA(NULL, moduleDir, MAX_PATH);
PathRemoveFileSpecA(moduleDir);

bool debug = false;
StringArray dlls;
std::string appKey;
wchar_t path[MAX_PATH] = { 0 };
Expand Down Expand Up @@ -233,6 +234,10 @@ int wmain(int argc, wchar_t *argv[]) {
}
wcsncat(path, L"\\", MAX_PATH);
}
else if (wcscmp(argv[i], L"/debug") == 0)
{
debug = true;
}
else
{
// Concatenate all other arguments
Expand All @@ -242,9 +247,7 @@ int wmain(int argc, wchar_t *argv[]) {
}

if (dlls.empty())
{
dlls.add(moduleDir + std::string("\\LibReviveXR64.dll"));
}

LOG("Command for injector is: %ls\n", path);

Expand All @@ -267,12 +270,30 @@ int wmain(int argc, wchar_t *argv[]) {
if (file)
*file = L'\0';

if (!DetourCreateProcessWithDlls(NULL, path, NULL, NULL, FALSE, 0, NULL, (file && ext) ? workingDir : NULL, &si, &pi, (DWORD)dlls.size(), dlls.c_str(), NULL))
if (!DetourCreateProcessWithDlls(NULL, path, NULL, NULL, FALSE,
debug ? CREATE_SUSPENDED | DEBUG_ONLY_THIS_PROCESS : 0,
NULL, (file && ext) ? workingDir : NULL, &si, &pi,
(DWORD)dlls.size(), dlls.c_str(), NULL))
{
LOG("Failed to create process\n");
return -1;
}

if (debug)
{
if (!DebugActiveProcessStop(pi.dwProcessId))
{
LOG("Failed to stop debugging\n");
return -1;
}

if (ResumeThread(pi.hThread) == -1)
{
LOG("Failed to resume process\n");
return -1;
}
}

LOG("Succesfully injected!\n");

if (!appKey.empty())
Expand Down
23 changes: 23 additions & 0 deletions hook.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off
if not exist "%~dp0ReviveInjector.exe" (
echo ReviveInjector.exe not found
pause
exit
)
set /p exe="Enter executable name to hook: "
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%exe%" /v Debugger 2>NUL | Find "ReviveInjector.exe"
if %errorlevel% equ 0 (
echo Removing existing hook on %exe%
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%exe%" /f
pause
exit
)
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%exe%" 2>NUL 1>NUL
if %errorlevel% equ 0 (
echo Cannot hook a system program
pause
exit
)
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%exe%" /v Debugger /t REG_SZ /d "%~dp0ReviveInjector.exe /debug"
if %errorlevel% neq 0 echo Right-click this script and select "Run as administrator" to try again
pause
38 changes: 0 additions & 38 deletions xinput/dllmain.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions xinput/stdafx.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions xinput/stdafx.h

This file was deleted.

8 changes: 0 additions & 8 deletions xinput/targetver.h

This file was deleted.

108 changes: 0 additions & 108 deletions xinput/xinput.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions xinput/xinput.def

This file was deleted.

Loading

0 comments on commit ecaa69f

Please sign in to comment.