Hello Thomas, While using the comtypes 0.6.2 library with Python 2.5 I encountered the following problem. I am using the PyDbgEng library<http://pydbgeng.sourceforge.net/>(v0.12) to hook API functions including kernel32.dll. PyDbgEng can hook in (AFAIK at least) 2 ways: 1. Setting a breakpoint on a function (bp_set<http://pedram.redhive.com/PyDbg/docs/PyDbg/public/pydbg.pydbg.pydbg-class.html#bp_set>) / 2. Setting a hook on a function which can also enumerate passed parameters (PyDbgEng.Hooking.hook_container()).
As a test I created hook.py which is also included in the attachment (* hook.py*). In this test setting both types of hooks using dbgeng.dll library (part of the Debugging Tools for Windows<http://www.microsoft.com/whdc/devtools/debugging/default.mspx>package) works without any problems and when using the first type of hooking works very good (*bp_set.png* <http://i44.tinypic.com/fy1lw2.png>). However when using the hooking function which can also enumerate the parameters given by the callee (to in this case kernel32!WriteConsoleW<http://msdn.microsoft.com/en-us/library/ms687401%28VS.85%29.aspx>), I get following exception (full stacktrace in *ex.txt*, screenshot in * hook_container.png <http://i39.tinypic.com/4jazjl.png>*): > AttributeError: 'str' object has no attribute 'from_param' > File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 596, in > call_with_inout > v = atyp.from_param(v) > Values of variables in the 'call_with_inout' function (in Wing IDE): > atyp: u"P" > type(atyp).__name__: u"str" > v (=args[i=1]): <ctypes.c_char_Array_4 0xc24260; len=13> > getattr(v, "_type_", None): <_ctypes.SimpleType 0xc55e20; len=14> > v[0]+v[1]+v[2]+v[3]: u"\x 0\x 0\x 0\x 0" > Looking at the function and callstack, it looks like something goes wrong while fetching the function arguments from the stack, but I'm not sure what's exactly the problem. I also tested it on other executables and API functions, but all have the same problem. I hope you can give me any clues about how to fix this... :-) Thanks for your hard work in this great project! Kind Regards, Arris Huijgen http://www.fox-it.com/<http://www.google.com/url?sa=D&q=http://www.fox-it.com/&usg=AFQjCNHpDin0Iq2Il52n18tXV6ffdY8-_g>
AttributeError: 'str' object has no attribute 'from_param' File "C:\hook2.py", line 55, in <module> dbg.event_loop_with_quit_event(Event()) File "C:\Python25\Lib\site-packages\PyDbgEng\UserModeSession.py", line 64, in event_loop_with_quit_event if (self.wait_for_event(200) == False): File "C:\Python25\Lib\site-packages\PyDbgEng\UserModeSession.py", line 27, in wait_for_event self.idebug_control.WaitForEvent(DbgEng.DEBUG_WAIT_DEFAULT, timeout_ms) File "C:\Python25\Lib\site-packages\comtypes\_comobject.py", line 157, in call_without_this _error("Exception in %s.%s implementation:", interface.__name__, mthname, exc_info=True) File "C:\Python25\Lib\site-packages\comtypes\_comobject.py", line 127, in call_without_this result = mth(*inargs) File "C:\Python25\Lib\site-packages\PyDbgEng\DbgEngEvent.py", line 121, in IDebugEventCallbacks_Breakpoint return self._pyDbgEng.Breakpoint(unknown, bp) File "C:\Python25\Lib\site-packages\PyDbgEng\PyDbgEng.py", line 332, in Breakpoint handler(self) File "C:\Python25\Lib\site-packages\PyDbgEng\Hooking.py", line 64, in __proxy_on_entry self.arguments[tid].append(dbg.get_arg(i)) File "C:\Python25\Lib\site-packages\PyDbgEng\PyDbgEng.py", line 609, in get_arg return self.read_dword(esp_value + index * 4) File "C:\Python25\Lib\site-packages\PyDbgEng\PyDbgEng.py", line 583, in read_dword buffer = self.read_virtual_memory(pdword, 4) File "C:\Python25\Lib\site-packages\PyDbgEng\PyDbgEng.py", line 575, in read_virtual_memory self.idebug_data_spaces.ReadVirtual( address, read_buf, length, byref(bytes_read) ) File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 596, in call_with_inout v = atyp.from_param(v)
hook.py
Description: Binary data
------------------------------------------------------------------------------
_______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users