| View previous topic :: View next topic |
| Author |
Message |
cleiton Newbie cheater
Reputation: 0
Joined: 05 Mar 2014 Posts: 21
|
Posted: Wed Mar 05, 2014 1:25 pm Post subject: Please Help with ApiHook |
|
|
I'm coding an Anti Hack for a game, the hackers usually use DLL Injection to hack my game, so I decided to code an Anti DLL Injection that hooks LoadLibrary API, I'm having a problem, when I hook LoadLibrary API my game does not load itself, because the game needs LoadLibrary API.
Look what I'm doing:
| Code: |
var
TLoadLibrary: function (lpLibFileName: PChar): HMODULE; stdcall;
function OLoadLibrary(lpLibFileName: PChar): HMODULE; stdcall;
begin
result:=0;
end;
procedure DllMain(reason: integer);
begin
case reason of
DLL_PROCESS_DETACH:;
end;
DLL_PROCESS_ATTACH:
ApiHook('KERNEL32.DLL', 'LoadLibrary', @OLoadLibrary, @TLoadLibrary);
end;
end; |
How to add an exception that only allow my game to use LoadLibrary? And does not allow external process to use that against my game?
Thank u all
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Wed Mar 05, 2014 11:44 pm Post subject: |
|
|
Try using a flag that allows modules to be loaded, until the game has been fully loaded.
it won't block dll injections that start before your game is loaded, but nothing can stop that. (if they wish you could even make the system dll's auto load that)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
cleiton Newbie cheater
Reputation: 0
Joined: 05 Mar 2014 Posts: 21
|
Posted: Fri Mar 07, 2014 9:06 am Post subject: |
|
|
| Code: | function OLdrLoadDll(szcwPath: PWideChar; pdwLdrErr: dword; pUniModuleName: PUnicodeString; pResultInstance: PDWORD): Cardinal;stdcall;
const
ALLOWED_MODULES : array [0..9] of string = ('ADVAPI32.dll', 'GDI32.dll', 'IMM32.dll',
'KERNEL32.dll', 'OLEAUT32.dll', 'SHELL32.dll',
'USER32.dll', 'WINMM.dll', 'ws2_32.dll', 'ole32.dll');
var
s : string;
found : boolean;
i : integer;
begin
s := LowerCase(ExtractFileName(String(szcwPath)));
found := false;
for i := 0 to length(ALLOWED_MODULES) do
begin
if s = ALLOWED_MODULES[i] then
begin
found := true;
break;
end;
end;
if not found then
begin
pResultInstance:=0;
end;
end; |
tried that but doesn't work still blocking game dll's
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Fri Mar 07, 2014 9:23 am Post subject: |
|
|
That's not allowing all modules till the game has been loaded, that's just an exclusion list. (and I think you're missing a few, like nvidia's dll's...)
You should use a global flag used by the game to indicate it's loaded
Also, your code won't work because you're never calling the original loader (and on failure you're setting pResultInstance to 0 which is a local parameter, you need to set pResultInstance^ to 0)
OutputDebugString is useful here
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
cleiton Newbie cheater
Reputation: 0
Joined: 05 Mar 2014 Posts: 21
|
Posted: Fri Mar 07, 2014 9:35 am Post subject: |
|
|
don't know how to do that
can u give me some tips?
|
|
| Back to top |
|
 |
cleiton Newbie cheater
Reputation: 0
Joined: 05 Mar 2014 Posts: 21
|
Posted: Sat Mar 08, 2014 6:05 pm Post subject: |
|
|
| Can anyone help me?
|
|
| Back to top |
|
 |
|