CopyFunction fails with memory access exception on x64

delphi package - getting into other processes

CopyFunction fails with memory access exception on x64

Postby wassily » Mon Dec 24, 2012 5:21 pm

As the subject says, my attempt to copy functions in x64 builds fail while everything works perfect for x86 builds. I use VC++ 2010 compiler and the copied functions are (mostly) simple thunks like
Code: Select all
STDMETHODIMP DropTargetProxy_DragLeave(IDropTargetProxy *self)
{
    return self->DropTarget->DragLeave();
}

It is necessary to set "acceptUnknownTargets" to true for such code, and I want copy inside of the current process so the call looks like
Code: Select all
   PVOID copy = CopyFunction(DropTargetProxy_DragLeave, NULL, TRUE);

Stepping into the implemention with the built in debugger shows that my function is copied just fine but after calling VirtualProtectEx(copyBuffer, ...) CopyFunction tries to write a value by pointer equal to 1 (ProcessMemory[1] = value), and naturally everything breaks
wassily
 
Posts: 12
Joined: Sun Dec 16, 2012 6:37 pm

Re: CopyFunction fails with memory access exception on x64

Postby madshi » Wed Jan 09, 2013 6:16 pm

Hello,

and sorry for the late reply. Would it be possible for you to create a (very) small test project with which I could reproduce the issue? That would help a lot!
madshi
Site Admin
 
Posts: 9384
Joined: Sun Mar 21, 2004 5:25 pm


Return to madRemote

Who is online

Users browsing this forum: No registered users and 2 guests

cron