API hooking: inject dll in all processes

Just starting out? Need help? Post your questions and find answers here.
Machiavelli
User
User
Posts: 26
Joined: Sun May 24, 2009 2:38 pm

API hooking: inject dll in all processes

Post by Machiavelli »

Hi.

I want use that dll:

Code: Select all

Global Dim Backup.b(5)

Procedure HookedMouse_Event(a,b,c,d) 
 MessageBox_(0,"mouse_eveit hooked","Title",0)
 ;ProcedureReturn 0
EndProcedure 

Procedure HookedSetCursorPos(a,b) 
 MessageBox_(0,"SetCursorPos hooked","Title",0)
; ProcedureReturn 0
EndProcedure 

Procedure HookedKeybd_Event(a,b,c,d) 
 MessageBox_(0,"keybd_event hooked","Title",0)
 ;ProcedureReturn 0
EndProcedure 

Procedure Hook(library$,function$,HookedProcAddr) 
  dwAddr=GetProcAddress_(GetModuleHandle_(library$),function$) 
  ReadProcessMemory_(GetCurrentProcess_(),dwAddr,@Backup(0),6,@readbytes) 
  Dim a.b(6) : a(0)=$E9 : a(5)=$C3 : dwCalc=HookedProcAddr-dwAddr-5 
  CopyMemory(@dwCalc,@a(1),4) 
  WriteProcessMemory_(GetCurrentProcess_(),dwAddr,@a(0),6,@written) 
EndProcedure 

Hook("C:\WINDOWS\system32\user32.dll","mouse_event",@HookedMouse_Event())
Hook("C:\WINDOWS\system32\user32.dll","SetCursorPos",@HookedSetCursorPos())
Hook("C:\WINDOWS\system32\user32.dll","keybd_event",@HookedKeybd_Event())
for hooking and block 3 functions: keyb_event, mouse_event, setCursorPos.

If i place path to that dll in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs and then i can't load my windows OS :oops:
where is my mistake?

sorry for my bad english :oops:
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

where is my mistake?
you ask in an honest programmers' forum how to program malware.
... this is a mistake.
oh... and have a nice day.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Actually, based on the functions he's hooking, he appears to be trying to defend against something. Possibly trying to bot-proof a game by the look of it.
BERESHEIT
Machiavelli
User
User
Posts: 26
Joined: Sun May 24, 2009 2:38 pm

Post by Machiavelli »

you ask in an honest programmers' forum how to program malware.
This is not a malware. I need write bot\clicker protection for a game.
Actually, based on the functions he's hooking, he appears to be trying to defend against something. Possibly trying to bot-proof a game by the look of it.
Right :)

upd: problem solved by adding AttachProcess procedure:)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Machiavelli wrote:This is not a malware. I need write bot\clicker protection for a game.
I'm sorry... was a bit confused by the "inject ALL processess"
oh... and have a nice day.
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

netmaestro wrote:Possibly trying to bot-proof a game by the look of it.
That is impossible to achieve by many commercial developers with big teams, how is he trying to do it? If he succeeds, he will be very rich man. 8)
Machiavelli
User
User
Posts: 26
Joined: Sun May 24, 2009 2:38 pm

Post by Machiavelli »

i dont create ideal protection :) i'm just want block some popular bots.
Last edited by Machiavelli on Tue Jul 14, 2009 12:31 pm, edited 1 time in total.
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

OK then, sorry for hijacking your thread :oops:
You will have a lot of work by updating game every often because bots will eventually bypass your protection.
Post Reply