
Originally Posted by
bluedog9
hi!
i have a small request - what is wrong with my hook code?
Code:
hook proc from:dword, to:dword, len:word
mov edx, dword ptr ds:from
mov eax, dword ptr ds:to
sub eax, edx
sub eax, dword ptr ds:len
mov [ofs], eax
mov byte ptr ds:[from], 0e9h
inc from
mov [from], eax
ret 0ch
hook endp
nothing happens upon injection

First of this is the Cpp section, take the asm questions to the assembler section.
Next, there are a few things wrong with this code, for instance:
Code:
hook proc from:dword, to:dword, len:word
mov edx, dword ptr ds:from
mov eax, dword ptr ds:to
I assume that to and from are not pointers to the addresses you want to hook. So if you supply the addresses like:
Code:
push 401000h
push 41h00kh
call hook
Code:
mov edx, dword ptr ds:from
Will not hold 401000h as the address to be hooked, but the dword this address points to. The same is true for the to variable.