-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hijacked dinput8.dll instead of msimg32.dll
- Loading branch information
Showing
8 changed files
with
73 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake -BBUILD . -A Win32 -DVERSION="%1" | ||
cmake --build BUILD --config Release | ||
IF EXIST BUILD\Release\msimg32.dll DEL /f BUILD\Release\msimg32.dll | ||
copy BUILD\Release\supercow-mod.dll BUILD\Release\msimg32.dll | ||
IF EXIST BUILD\Release\dinput8.dll DEL /f BUILD\Release\dinput8.dll | ||
copy BUILD\Release\supercow-mod.dll BUILD\Release\dinput8.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <string> | ||
#include <windows.h> | ||
|
||
#include "main.h" | ||
|
||
struct dinput8_dll { | ||
HMODULE dll; | ||
FARPROC OrignalDirectInput8Create; | ||
FARPROC OrignalDllCanUnloadNow; | ||
FARPROC OrignalDllGetClassObject; | ||
FARPROC OrignalDllRegisterServer; | ||
FARPROC OrignalDllUnregisterServer; | ||
FARPROC OrignalGetdfDIJoystick; | ||
} dinput8; | ||
|
||
extern "C" | ||
{ | ||
__declspec(naked) void __stdcall FakeDirectInput8Create() { _asm { jmp[dinput8.OrignalDirectInput8Create] } } | ||
__declspec(naked) void __stdcall FakeDllCanUnloadNow() { _asm { jmp[dinput8.OrignalDllCanUnloadNow] } } | ||
__declspec(naked) void __stdcall FakeDllGetClassObject() { _asm { jmp[dinput8.OrignalDllGetClassObject] } } | ||
__declspec(naked) void __stdcall FakeDllRegisterServer() { _asm { jmp[dinput8.OrignalDllRegisterServer] } } | ||
__declspec(naked) void __stdcall FakeDllUnregisterServer() { _asm { jmp[dinput8.OrignalDllUnregisterServer] } } | ||
__declspec(naked) void __stdcall FakeGetdfDIJoystick() { _asm { jmp[dinput8.OrignalGetdfDIJoystick] } } | ||
} | ||
|
||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { | ||
char path[MAX_PATH]; | ||
switch (ul_reason_for_call) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
{ | ||
wchar_t path[MAX_PATH]; | ||
GetSystemDirectory(path, MAX_PATH); | ||
std::wstring pathname = path + std::wstring(L"\\dinput8.dll"); | ||
dinput8.dll = LoadLibrary(pathname.c_str()); | ||
if (dinput8.dll == false) | ||
{ | ||
MessageBox(0, L"Cannot load original dinput8.dll library", L"Proxy", MB_ICONERROR); | ||
ExitProcess(0); | ||
} | ||
dinput8.OrignalDirectInput8Create = GetProcAddress(dinput8.dll, "DirectInput8Create"); | ||
dinput8.OrignalDllCanUnloadNow = GetProcAddress(dinput8.dll, "DllCanUnloadNow"); | ||
dinput8.OrignalDllGetClassObject = GetProcAddress(dinput8.dll, "DllGetClassObject"); | ||
dinput8.OrignalDllRegisterServer = GetProcAddress(dinput8.dll, "DllRegisterServer"); | ||
dinput8.OrignalDllUnregisterServer = GetProcAddress(dinput8.dll, "DllUnregisterServer"); | ||
dinput8.OrignalGetdfDIJoystick = GetProcAddress(dinput8.dll, "GetdfDIJoystick"); | ||
|
||
break; | ||
} | ||
case DLL_PROCESS_DETACH: | ||
{ | ||
FreeLibrary(dinput8.dll); | ||
} | ||
break; | ||
} | ||
return main(hModule, ul_reason_for_call, lpReserved); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
LIBRARY dinput8 | ||
EXPORTS | ||
DirectInput8Create=FakeDirectInput8Create @1 | ||
DllCanUnloadNow=FakeDllCanUnloadNow @2 | ||
DllGetClassObject=FakeDllGetClassObject @3 | ||
DllRegisterServer=FakeDllRegisterServer @4 | ||
DllUnregisterServer=FakeDllUnregisterServer @5 | ||
GetdfDIJoystick=FakeGetdfDIJoystick @6 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.