Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2005, 02:45
killy
 
Posts: n/a
implementing hotkey in exe

hi

Is it possible to implementing hotkey function in exe itself by asm code injection ,so pressing on the key does some code injection in memory. i have only some idea like get the main loop->create some asm function to detect specific keys->if key pressed do some editing in memory Is there any api to look for?

regards
Reply With Quote
  #2  
Old 01-07-2005, 16:47
redbull redbull is offline
Friend
 
Join Date: Mar 2004
Posts: 160
Rept. Given: 17
Rept. Rcvd 5 Times in 4 Posts
Thanks Given: 3
Thanks Rcvd at 6 Times in 6 Posts
redbull Reputation: 5
There is an API function called "RegisterHotKey()" for defining a system-wide hot key. [ Dont forget it's partner UnRegisterHotkey() ]
Code:
BOOL RegisterHotKey(      
HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);
hxxp://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput
/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp

It generates a WM_HOTKEY and sends it to the supplied HWND so you need to setup a message listener for WM_HOTKEY.
Quick delphi example I found
Code:
/In the main forms OnCreate
//handler assign the hotkey:
If not RegisterHotkey
(Handle, 1, MOD_ALT or MOD_SHIFT, VK_F9) Then
ShowMessage('Unable to assign Alt-Shift-F9 as hotkey.') ;
//In the main forms
//OnClose event remove the handler:
UnRegisterHotkey( Handle, 1 ) ;
//Add a handler for the
//WM_HOTKEY message to the form:
private // form declaration
Procedure WMHotkey( Var msg: TWMHotkey ) ;
message WM_HOTKEY;
Procedure TForm1.WMHotkey( Var msg: TWMHotkey ) ;
Begin
If msg.hotkey = 1 Then Begin
If IsIconic( Application.Handle ) Then
Application.Restore;
BringToFront;
End;
End;
Reply With Quote
  #3  
Old 01-08-2005, 00:39
ArC ArC is offline
VIP
 
Join Date: Jan 2003
Location: NTOSKRNL.EXE
Posts: 172
Rept. Given: 0
Rept. Rcvd 1 Time in 1 Post
Thanks Given: 5
Thanks Rcvd at 17 Times in 12 Posts
ArC Reputation: 1
Quote:
Originally Posted by killy
hi
Is it possible to implementing hotkey function in exe itself by asm code injection ,so pressing on the key does some code injection in memory. i have only some idea like get the main loop->create some asm function to detect specific keys->if key pressed do some editing in memory Is there any api to look for?
regards
Just wondering why you want to inject this code directly into the executable?
What about creating an (external) app which checks for a particular key being pressed and if it is it writes sth into the process you want to hack (via WriteProcessMemory). I believe this is better than writing it directly into the exe...
Reply With Quote
  #4  
Old 01-08-2005, 01:23
killy
 
Posts: n/a
yes this is what everyone does mainly in trainers. i wanted something different which can be done within the exe.
redbull,thanks for your api help but badly those api are'nt in the imports and then how do we capture the key?
Reply With Quote
  #5  
Old 01-13-2005, 17:56
redbull redbull is offline
Friend
 
Join Date: Mar 2004
Posts: 160
Rept. Given: 17
Rept. Rcvd 5 Times in 4 Posts
Thanks Given: 3
Thanks Rcvd at 6 Times in 6 Posts
redbull Reputation: 5
Both RegisterHotKey and UnRegisterHotKey are found in "user32.dll"

You need to hope that the app you are hooking into (for evil purposes) has LoadLibrary and GetProcAddress...

Otherwise you have to hard-code the calls into your program or have a range of calls hard coded for each operating system and service pack...

You can find out which function these are in User32.dll and walk through user32.dll 's PE header export section and get the address of the function that way.

Other than that you are going to have to do things the hard way. There are a number of papers on this writtern by the virus writers or rootkit authors ....
Reply With Quote
  #6  
Old 01-17-2005, 20:29
killl
 
Posts: n/a
if the software itself has some hotkeys, I think it's easy to do.

use exescope to open the software, u may find : accelarate... or sth like this , can we change here to build our own hotkeys?
Reply With Quote
  #7  
Old 01-17-2005, 21:31
dmownz
 
Posts: n/a
Look at SetWindowsHook(ex). You can write a dll which will be loaded into all gui processes, intercept the keypress, and do whatever you need to in the context of the process that received the keypress. The hotkey message would leave you in the context of your own process.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 04:50.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )