autoitter Posted October 19, 2008 Share Posted October 19, 2008 So, this is my first UDF that I like to share with you all. It can be used to capture debug information written by programs using the OutputDebugString API. A lot of programs write useful information using OutputDebugString.I searched for a way to capture this information and came across this link. This describes a way to read debug information using C++. My first attempt was to try and rewrite this in pure AutoIt using DllCalls. But I guessed it was to much work, especially converting all the structures that are needed.So I decided to take a different approach and use a helper DLL. I used the code by Randy Charles Morin and rewritten it as a DLL. Additionally I made a wrapper UDF.I have put the DLL, UDF and a simple example of a viewer in this ZIP:DebugCapture.zipThe DLL is written using Visual Studio 6. For those who are interested, I included the source:DebugCaptureDLLSource.zipThe UDF contains 3 functions:_StartDebugCapture()This function loads the helper DLL and starts the capturing process. As soon as this function successfully returns, you have to call _GetDebugOutput() regularly to read the debug information. If you don't read the debug information, you will block the processes trying to write this information for a while (the OutputDebugString() API will block for a maximum time of 10 seconds). _StopDebugCapture()Call this function if you don't want to process debug information anymore. _GetDebugOutput()Call this on a regular basis, to read the debug information. The function is non blocking. If there is nothing to read it will just return an empty string. If you call this function with no parameters it will return all debug information. Optionally you can call it with a PID (for example returned by Run). That way you will only get the debug information written by that specific process. @extended is always set to the PID of the process that outputted the information.That's about it. Hope it's useful. Comments and suggestions are welcome!Steve Trong and mLipok 2 Link to comment Share on other sites More sharing options...
FranckG Posted October 19, 2008 Share Posted October 19, 2008 Great I miss the other part ... How to send an OutputDebugString from AutoIt ? Link to comment Share on other sites More sharing options...
autoitter Posted October 19, 2008 Author Share Posted October 19, 2008 GreatI miss the other part ... How to send an OutputDebugString from AutoIt ? Well, that's the easy part:http://www.autoitscript.com/forum/index.ph...ost&p=46080 Link to comment Share on other sites More sharing options...
FranckG Posted October 20, 2008 Share Posted October 20, 2008 Well, that's the easy part:http://www.autoitscript.com/forum/index.ph...ost&p=46080 Marvelous ... Thank you Link to comment Share on other sites More sharing options...
Andrew Peacock Posted March 3, 2010 Share Posted March 3, 2010 Hi all, Quite an old post, but I'm wondering if anyone can get this to work still? I'm getting no debug lines being displayed - the debug DLL seems to be starting/ending the debug capture, but no strings are being returned on the debug event. Any ideas? Regards, Andy Link to comment Share on other sites More sharing options...
autoitter Posted March 3, 2010 Author Share Posted March 3, 2010 It should still work. Just tested using the latest release version of AutoIt (v3.3.4.0) and found no problems. Also tested with Windows 7 and it looks like that is working fine also. Are you sure that anything gets written using OutputDebugString? Link to comment Share on other sites More sharing options...
Andrew Peacock Posted March 3, 2010 Share Posted March 3, 2010 Hi, Ah, that's strange. I just tested on this machine (which is different from the one I was testing on last night) and it works fine. Must be my bad. I'll re-test on the original machine tonight and re-post here with an update. Thanks autoitter, Andy Link to comment Share on other sites More sharing options...
wraithdu Posted March 3, 2010 Share Posted March 3, 2010 (edited) Try merging this registry entry on your problem machine and rebooting. This is a known change in Vista/7. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter] "DEFAULT"=dword:ffffffff Edited March 3, 2010 by wraithdu Link to comment Share on other sites More sharing options...
Andrew Peacock Posted March 4, 2010 Share Posted March 4, 2010 Oh I'm such an idiot. I was running the compiled older version of the script, not the newer version of which I was in mid-development. Guess which one didn't have the outputdebugstring function...? Thanks for your help all, and sorry to be such a pain. Wraithdu - that's good to know. I'm using a modified version of the debug viewer to capture only strings from my software, and giving it to customers to help diagnose problems (such as the infamous "error in line -1" error). It's always useful to know where things are different from XP, which I develop on. Much appreciated. Regards, Andy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now