Lexikos wrote:
:?
Code:
LowLevel_init()
AdviseBIF("VarSetCapacity","Debugger")
{...
AdviseBIF(advisee, advice)
{
__mcode(advisee, ""
. "8B442404" ; mov eax,dword ptr [esp+4]
. "8B08" ; mov ecx,dword ptr [eax]
. "51" ; push ecx
. "FF742410" ; push dword ptr [esp+10h]
. "FF742410" ; push dword ptr [esp+10h]
. "50" ; push eax
. "B9" mcodeptr(RegisterCallback(advice,"Cdecl",4,0)) ; mov ecx, ...
. "FFD1" ; call ecx
. "B9" mcodeptr(NumGet(__findFunc(advisee)+4)) ; mov ecx, ...
. "FFD1" ; call ecx
. "B9" mcodeptr(RegisterCallback(advice,"Cdecl",4,1)) ; mov ecx, ...
. "FFD1" ; call ecx
. "83C410" ; add esp,10h
. "C3") ; ret
}
It seems that you need to add a parameter to the 3 params from
BuiltInFunctionType(ResultToken, Param, ParamCount)
to fill the params for
Debugger(aResultToken, aParam, aParamCount, aName)
Is the aName in ecx here?:
. "51" ; push ecx
What is in eax? before the calls?
I am still a little lost after reading:
http://www.rorydriscoll.com/2008/05/19/mockitnow-redirecting-function-calls-in-c/ and the LowLevel Reference chm file.
Lexikos: could you please help me understand your asm wizardry here?
Can this technique be used to hook c functions directly if you have pointers to them, rather than hooking dllcall?
Also, I have no idea even how to begin trying to understand this part from your DebugBIF in here:
http://www.autohotkey.com/forum/topic36665.html&highlight=debugbifCode:
if !VarSetCapacity(DebugErrorLevel)
{
VarSetCapacity(DebugErrorLevel, 56), NumPut(0xC35D5E5F, NumPut(0x10C4830C, NumPut(0x55FF5756, NumPut(0x1C75FF20, NumPut(0x75FF0E74, NumPut(0x3038800C, NumPut(0xC4830840, NumPut(0x8B08458B, NumPut(0x1055FF56, NumPut(0x1C75FF3E, NumPut(0x8B2075FF, NumPut(0x5718758B, NumPut(0x56EC8B55, NumPut(&DebugErrorLevel+4, DebugErrorLevel))))))))))))))
VarSetCapacity(DebugResult, 60), NumPut(0x0000C35D, NumPut(0x5E5F10C4, NumPut(0x830855FF, NumPut(0x57561875, NumPut(0xFF1C75FF, NumPut(0x0E750038, NumPut(0x80068B15, NumPut(0x7500087E, NumPut(0x830CC483, NumPut(0x0C55FF56, NumPut(0x1875FF3E, NumPut(0x8B1C75FF, NumPut(0x5714758B, NumPut(0x56EC8B55, NumPut(&DebugResult+4, DebugResult)))))))))))))))
}