_MemSearch proc uses edx esi edi lpAddr:DWORD,lpSize:DWORD,lpBuff:DWORD,hLen:DWORD
mov esi,lpAddr
mov eax,lpSize
_loop1:
cmp eax,hLen
jb _notfound
mov dl,[esi]
cmp dl,80h
ja _loop2
inc esi
dec eax
jmp short _loop1
_loop2:
mov dl,[esi+1]
cmp dl,80h
ja _loop3
add esi,2
sub eax,2
jmp short _loop1
_loop3:
mov edi,lpBuff
mov ecx,hLen
push esi
pop edx
cld
repz cmpsb
jnz _loop1
push edx
pop eax
jmp short _exit
_notfound:
or eax, -1
_exit:
ret
_MemSearch endp