首页
社区
课程
招聘
[旧帖] [求助]请点评一下这两个代码,谢谢 0.00雪花
发表于: 2010-6-22 15:39 1370

[旧帖] [求助]请点评一下这两个代码,谢谢 0.00雪花

2010-6-22 15:39
1370
程序的功能是在自身的导入表中搜索 ExitProcess函数。然后调用它。
我写了两个代码,不知道哪个好一点。最好能说一下为什么,谢谢

.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib


;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szText db 'szText',0
szCaption db 'szCaption',0
hModule dd ?
hFristOrg dd ?
_isize dd ?
_MessageBox db 'ExitProcess',0
hFrist dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
_dingwei proc

invoke GetModuleHandle,NULL
mov hModule,eax
.if eax
mov esi,eax
assume esi:ptr IMAGE_DOS_HEADER
.if [esi].e_magic == IMAGE_DOS_SIGNATURE
add esi,[esi].e_lfanew
assume esi:ptr IMAGE_NT_HEADERS
.if [esi].Signature==IMAGE_NT_SIGNATURE
mov ebx,[esi].OptionalHeader.DataDirectory[8].isize
add ebx,eax
mov _isize,ebx
mov esi,[esi].OptionalHeader.DataDirectory[8].VirtualAddress

.if esi
add esi,eax
assume esi:ptr IMAGE_IMPORT_DESCRIPTOR
mov ebx,[esi].FirstThunk
add ebx,eax
mov hFrist,ebx
mov ebx ,[esi].OriginalFirstThunk
add ebx,eax
mov hFristOrg,ebx
mov eax,0
.while _isize>0
.if dword ptr[ebx]!=0
mov edx,[ebx]
add edx,hModule

assume edx:ptr IMAGE_IMPORT_BY_NAME
cld
lea esi,[edx].Name1
lea edi,offset _MessageBox
mov ecx,11
repe cmpsb
je _ok
.endif
add ebx,4
add eax,1
.endw
_ok:
sal eax,2
add eax,hFrist

push 0
call dword ptr[eax]


.endif
.endif
.endif
.endif
ret

_dingwei endp
start:
call _dingwei
invoke MessageBox,NULL,addr szText,addr szCaption,MB_OK
invoke ExitProcess,0
end start


;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib


;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szText db 'szText',0
szCaption db 'szCaption',0
szDll db 'kernel32.dll',0
hModule dd ?
hFirstOrg dd ?
_isize dd ?
_MessageBox db 'ExitProcess',0
hFirst dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
_dingwei proc

invoke GetModuleHandle,NULL
mov hModule,eax
.if eax
mov esi,eax
assume esi:ptr IMAGE_DOS_HEADER
.if [esi].e_magic == IMAGE_DOS_SIGNATURE
add esi,[esi].e_lfanew
assume esi:ptr IMAGE_NT_HEADERS
.if [esi].Signature==IMAGE_NT_SIGNATURE
mov ebx,[esi].OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT * sizeof IMAGE_DATA_DIRECTORY].isize
add ebx,eax
mov _isize,ebx
mov esi,[esi].OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT * sizeof IMAGE_DATA_DIRECTORY].VirtualAddress

.if esi
add esi,eax
finddll:
assume esi:ptr IMAGE_IMPORT_DESCRIPTOR
mov edi,[esi].Name1
add edi,hModule
invoke lstrcmp,edi,addr szDll
.if eax !=0
add esi,14h
jmp finddll
.endif
mov eax,hModule
mov ebx,[esi].FirstThunk
add ebx,eax
mov hFirst,ebx
mov ebx ,[esi].OriginalFirstThunk
add ebx,eax
mov hFirstOrg,ebx
mov eax,0
findapi:
mov edx,[ebx]
add edx,hModule
assume edx:ptr IMAGE_IMPORT_BY_NAME
cld
lea esi,[edx].Name1
lea edi,offset _MessageBox
mov ecx,11
repe cmpsb
je _ok
inc eax
add ebx,4
jmp findapi
_ok:
sal eax,2
add eax,hFirst
push 0
call dword ptr[eax]
.endif
.endif
.endif
.endif
ret
_dingwei endp
start:
call _dingwei
invoke MessageBox,NULL,addr szText,addr szCaption,MB_OK ;上面的函数调用ExitProecess退出了,这句不会执行到
invoke ExitProcess,0
end start


;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 780
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
楼主一来就提这么高深的问题,让我等菜鸟汗颜
2010-6-22 15:41
0
雪    币: 205
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
begin09 学员,路过...
2010-6-22 15:42
0
雪    币: 187
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
哎~2个同班同学,坐等高人
2010-6-22 15:45
0
雪    币: 19
活跃值: (1086)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
顶顶 坐等高人
2010-6-22 15:49
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
呵呵.我也支持一下.我还需要.努力
2010-6-22 15:59
0
游客
登录 | 注册 方可回帖
返回
//