The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: stbfish on September 18, 2009, 01:39:11 AM

Title: runtime memory copy problem
Post by: stbfish on September 18, 2009, 01:39:11 AM
stub for inject dll to target

LoadDll proc
    push 0DEADBEEFh      ;retun address
   pushfd
    pushad               
   push 0DEADBEEFh      ;Dll dir
   mov eax, 0DEADBEEFh  ;LoadLibrary address
    call eax
    popad
    popfd
    ret
LoadDll endp
Loadend::

i need to copy this proc to target process,but before write to target process memory space, i need to  initialize the 0DEADBEEFh to right value at runtime. i tried like below
;...
;...
mov eax, OFFSET LoadDll
add eax, 1h
invoke memcpy, eax, stubret, 4
mov eax, OFFSET LoadDll
add eax, 8h
invoke memcpy, eax, stubdlldir, 4
mov eax, OFFSET LoadDll
add eax, 0Dh
invoke memcpy, eax, dwLoadLibrary, 4


now problem is memcpy not working in masm, no define. any other way to sort out this problem.
Thanks!
Title: Re: runtime memory copy problem
Post by: z941998 on September 18, 2009, 04:39:38 AM
I saw a way to solve your question in the Masm32 examples\01\dll area.  Check it out.  I also recall seeing an alternative approach in other examples.
Title: Re: runtime memory copy problem
Post by: MichaelW on September 18, 2009, 06:52:59 AM
stbfish,

Did you bother to read the forum rules and then attempt to understand the intent of the rules? This looks to me like a clear violation, so I'm locking this thread.