forked from moccajoghurt/MemWars
-
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.
- Loading branch information
1 parent
6897f06
commit a645dc6
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+97.5 KB
AntiCheatMethods/DLLInjectionPrevention/LoadLibraryHook/InjectedDLL.dll
Binary file not shown.
53 changes: 53 additions & 0 deletions
53
AntiCheatMethods/DLLInjectionPrevention/LoadLibraryHook/LoadLibraryHook.cpp
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,53 @@ | ||
#include <windows.h> | ||
#include <iostream> | ||
#include "../../../libs/PolyHook/PolyHook.hpp" | ||
|
||
using namespace std; | ||
|
||
typedef HMODULE(__stdcall* tLoadLibraryA)(LPCTSTR lpFileName); | ||
tLoadLibraryA oLoadLibraryA; | ||
|
||
typedef HMODULE(__stdcall* tLoadLibraryW)(LPWSTR lpFileName); | ||
tLoadLibraryW oLoadLibraryW; | ||
|
||
HMODULE __stdcall hLoadLibraryA(LPCTSTR lpFileName) { | ||
cout << "got called" << endl; | ||
if (strcmp(lpFileName, "allowed.dll") == 0) { | ||
return oLoadLibraryA(lpFileName); | ||
} else { | ||
cout << "invalid DLL detected" << endl; | ||
SetLastError(ERROR_ACCESS_DENIED); | ||
return NULL; | ||
} | ||
} | ||
|
||
HMODULE __stdcall hLoadLibraryW(LPWSTR lpFileName) { | ||
cout << "got called" << endl; | ||
if (wcscmp(lpFileName, L"allowed.dll") == 0) { | ||
return oLoadLibraryW(lpFileName); | ||
} else { | ||
cout << "invalid DLL detected" << endl; | ||
SetLastError(ERROR_ACCESS_DENIED); | ||
return NULL; | ||
} | ||
} | ||
|
||
|
||
int main() { | ||
shared_ptr<PLH::Detour> Detour_Ex(new PLH::Detour); | ||
Detour_Ex->SetupHook((BYTE*)&LoadLibraryA,(BYTE*) &hLoadLibraryA); | ||
Detour_Ex->Hook(); | ||
oLoadLibraryA = Detour_Ex->GetOriginal<tLoadLibraryA>(); | ||
|
||
Detour_Ex->SetupHook((BYTE*)&LoadLibraryW,(BYTE*) &hLoadLibraryW); | ||
Detour_Ex->Hook(); | ||
oLoadLibraryW = Detour_Ex->GetOriginal<tLoadLibraryW>(); | ||
|
||
// LoadLibraryA("InjectedDLL.dll"); | ||
// LoadLibraryW(L"InjectedDLL.dll"); | ||
for (;;) { | ||
// try to inject me | ||
TlsGetValue(0); | ||
Sleep(10); | ||
} | ||
} |
Binary file added
BIN
+2.84 MB
AntiCheatMethods/DLLInjectionPrevention/LoadLibraryHook/LoadLibraryHook.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
AntiCheatMethods/DLLInjectionPrevention/LoadLibraryHook/buildLoadLibraryHook.bat
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,2 @@ | ||
@ECHO OFF | ||
cl.exe /EHsc LoadLibraryHook.cpp ../../../Core/MemWarsServicesCore.cpp ../../../Core/MemWarsCore.c /link /LTCG /LIBPATH:"C:\Users\marius\git\MemWars\libs\Capstone\msvc\x64\Release" user32.lib ntdll.lib Advapi32.lib Shlwapi.lib |