我正在尝试创建一个dll注入代码,测试进程是记事本,进程ID是硬编码的
代码是:
.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\masm32.inc
includelib \masm32\lib\masm32.lib
include \masm32\include\masm32rt.inc
.data
hand db "Kernel32.dll",0
band db "LoadLibraryA",0
dll db "C:\masm32\kntillusion.dll",0
msg db "failed",0
pd dd 840
.data?
var dd ?
handle dd ?
base dd ?
written dd ?
pr dword ?
dr dword ?
thd dword ?
.code
start:
invoke OpenProcess,PROCESS_ALL_ACCESS,TRUE,pd
TEST EAX, EAX
JE CodeFail
mov handle,eax
invoke VirtualAllocEx,handle,NULL,sizeof dll,MEM_COMMIT,PAGE_READWRITE
TEST EAX, EAX
JE CodeFail
mov base,eax
invoke WriteProcessMemory,handle,base,addr dll,sizeof dll,offset written
TEST EAX, EAX
JE CodeFail
invoke GetModuleHandle,hand
TEST EAX, EAX
JE CodeFail
mov dr,eax
invoke GetProcAddress,dr,band
TEST EAX, EAX
JE CodeFail
mov pr,eax
invoke CreateRemoteThread,handle,0,0,pr,addr dll,0,addr thd
invoke ExitProcess,0
CodeFail:
invoke StdOut, addr msg
invoke ExitProcess,0
end start
当我运行它时,出现以下错误
kinject.exe 遇到问题,需要关闭。对此造成的不便,我们表示歉意。
所以建议plaftrom是windows xp sp3