FIX x86 COM trampoline
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -132,7 +132,7 @@ namespace VisualStudioMock
|
||||
|
||||
private static IntPtr CreateThunk(IntPtr @this, IntPtr jmpTarget)
|
||||
{
|
||||
int allocSize = Environment.Is64BitProcess ? 22 : 13;
|
||||
int allocSize = Environment.Is64BitProcess ? 22 : 15;
|
||||
|
||||
if (_execBlockSize - _execBlockNext < allocSize)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ namespace VisualStudioMock
|
||||
_execBlockNext = 0;
|
||||
|
||||
#if LOG_CALLS
|
||||
Ext.Log("Allocated thunk page at 0x" + _execBlockBase.ToString("X"));
|
||||
Ext.Log("Allocated thunk page at 0x" + _execBlockBase.ToString("X") + " (" + (Environment.Is64BitProcess ? "x64" : "x86") + ")");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -175,12 +175,15 @@ namespace VisualStudioMock
|
||||
else
|
||||
{
|
||||
// NOT tested!
|
||||
// pop eax
|
||||
// push this
|
||||
Marshal.WriteByte(_execBlockBase, _execBlockNext, 0x58);
|
||||
Marshal.WriteByte(_execBlockBase, _execBlockNext + 1, 0x68);
|
||||
Marshal.WriteIntPtr(_execBlockBase, _execBlockNext + 2, @this);
|
||||
_execBlockNext += 1 + 1 + IntPtr.Size;
|
||||
// 0x58 pop eax // return address
|
||||
// 0x59 pop ecx // this to be replaced
|
||||
// 0x68 ... push this
|
||||
// 0x50 push eax // restore return address
|
||||
Marshal.WriteInt16(_execBlockBase, _execBlockNext, unchecked((short)(0x5958)));
|
||||
Marshal.WriteByte(_execBlockBase, _execBlockNext + 2, 0x68);
|
||||
Marshal.WriteIntPtr(_execBlockBase, _execBlockNext + 3, @this);
|
||||
Marshal.WriteByte(_execBlockBase, _execBlockNext + 7, 0x50);
|
||||
_execBlockNext += 3 + IntPtr.Size + 1;
|
||||
|
||||
// mov eax target_address
|
||||
// jmp eax
|
||||
|
||||
Reference in New Issue
Block a user