汇编(fasm)的查找带通配符的特征码的源码
format PE GUI 4.0 DLLentry DllMain
include 'win32a.inc'
section '.text' code readable executable
; DllMain函数,DLL入口点
proc DllMain, hInstance, reason, reserved
; 导出函数:SearchSignature
; 参数:
; startAddr: 搜索并搜索的起始地址
; endAddr: 搜索感搜索的结束地址
; signature: 特征码模式字符串,用'?'表示通配符
; 返回值:
; 成功时返回找到的地址,失败时返回NULL
proc SearchSignature, startAddr, endAddr, signature
pushad
; 获取搜索的内存起始和结束地址
mov eax,
test eax, eax
jz .error
mov , eax
mov eax,
test eax, eax
jz .error
mov , eax
; 在内存中搜索特征码
mov edi,
mov ecx,
sub ecx,
test ecx, ecx
jz .error
.loop:
push ecx
mov ebx, edi
mov esi,
mov edx, edi
.compare:
mov cl,
test cl, cl
jz .found
cmp cl, '?'
je .wildcard
cmp byte , cl
je .wildcard
jmp .not_found
.wildcard:
inc esi
inc ebx
jmp .compare
.found:
mov eax, edi
popad
ret
.not_found:
pop ecx
inc edi
loop .loop
.error:
popad
xor eax, eax
ret
endp
mov eax, 1
ret
endp
section '.idata' import data readable
library kernel32, 'KERNEL32.DLL'
include 'api\kernel32.inc'
section '.data' data readable writeable
hDll dd 0
hProcess dd 0
search_start dd 0
search_end dd 0
module_info dd ? 学习一下!
多谢分享 PYG20周年生日快乐! 多谢提供分享!
页:
[1]