4343#include " conventions/x86GccCdecl.h"
4444#include " conventions/x86GccThiscall.h"
4545
46+ // Source.Python
47+ #include " utilities/call_python.h"
48+
4649
4750// ============================================================================
4851// >> EXTERNALS
@@ -304,7 +307,7 @@ object CFunction::SkipHooks(tuple args, dict kw)
304307}
305308
306309CHook* HookFunctionHelper (void * addr, ICallingConvention* pConv)
307- {
310+ {
308311 CHook* result;
309312 TRY_SEGV ()
310313 result = GetHookManager ()->HookFunction (addr, pConv);
@@ -319,6 +322,35 @@ void CFunction::AddHook(HookType_t eType, PyObject* pCallable)
319322
320323 Validate ();
321324 CHook* pHook = GetHookManager ()->FindHook ((void *) m_ulAddr);
325+
326+ // Prepare arguments for log message
327+ str type = str (eType);
328+ const char * szType = extract<const char *>(type);
329+
330+ str convention = str (m_eCallingConvention);
331+ const char * szConvention = extract<const char *>(convention);
332+
333+ str args = str (m_tArgs);
334+ const char * szArgs = extract<const char *>(args);
335+
336+ str return_type = str (m_eReturnType);
337+ const char * szReturnType = extract<const char *>(return_type);
338+
339+ object oCallback = object (handle<>(borrowed (pCallable)));
340+ str callback = str (oCallback);
341+ const char * szCallback = extract<const char *>(callback);
342+
343+ PythonLog (
344+ 4 ,
345+ " Hooking function: type=%s, addr=%u, conv=%s, args=%s, rtype=%s, callback=%s" ,
346+ szType,
347+ m_ulAddr,
348+ szConvention,
349+ szArgs,
350+ szReturnType,
351+ szCallback
352+ );
353+
322354 if (!pHook) {
323355 pHook = HookFunctionHelper ((void *) m_ulAddr, m_pCallingConvention);
324356 }
0 commit comments