- UID
- 6086
注册时间2005-12-29
阅读权限10
最后登录1970-1-1
周游历练
该用户从未签到
|
如题,还包括怎么相加等,下面是我的HOOK API代码,就等着这个完工
==================================
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
WriteApi proto :DWORD ,:DWORD,:DWORD,:DWORD
.data
hInstance dd 0
WProcess dd 0
DllName db "user32.dll",0
ApiName db "ExitWindowsEx",0
Pmapi dd 0
template db '%lX',0
posBuffer db 10 dup (0)
.data?
hHook dd ?
hWnd dd ?
.code
DllEntry proc hInst:HINSTANCE, reason:DWORD, reserved1:DWORD
.if reason==DLL_PROCESS_ATTACH
push hInst
pop hInstance
invoke GetCurrentProcess
mov WProcess ,eax
invoke GetModuleHandle,addr DllName
invoke GetProcAddress,eax,addr ApiName
mov Pmapi,eax
invoke WriteApi,WProcess,Pmapi,90,8 ;这里的90就是我想写入的字节集,我想写这2句
;mov eax, addr MyAPI
;jmp eax
.endif
mov eax,TRUE
ret
DllEntry Endp
GetMsgProc proc nCode:DWORD,wParam:DWORD,lParam:DWORD
invoke CallNextHookEx,hHook,nCode,wParam,lParam
ret
GetMsgProc endp
InstallHook proc hwnd:DWORD
push hwnd
pop hWnd
invoke SetWindowsHookEx,WH_GETMESSAGE,addr GetMsgProc,hInstance,NULL
mov hHook,eax
ret
InstallHook endp
UninstallHook proc
invoke UnhookWindowsHookEx,hHook
ret
UninstallHook endp
WriteApi proc Process:DWORD ,Papi:DWORD,Ptype:DWORD,Psize:DWORD
LOCAL mbi:MEMORY_BASIC_INFORMATION
LOCAL msize:DWORD
;返回虚拟信息
invoke VirtualQueryEx,Process,Papi,addr mbi,SIZEOF MEMORY_BASIC_INFORMATION
.IF (!eax)
ret
.endif
;修改虚拟保护
invoke VirtualProtectEx,Process,mbi.BaseAddress,Psize,PAGE_EXECUTE_READWRITE,mbi.Protect
.IF (!eax)
ret
.endif
;修改内存字节
invoke WriteProcessMemory,Process,Papi,addr Ptype,Psize,NULL
PUSH eax
invoke VirtualProtectEx,Process,mbi.BaseAddress,Psize,PAGE_EXECUTE_READ,mbi.Protect
POP eax
ret
WriteApi endp
MyAPI proc bs:DWORD ,dwReserved:DWORD
mov eax,TRUE
ret
MyAPI endp
End DllEntry
[ 本帖最后由 hacker0058 于 2006-6-27 18:17 编辑 ] |
|