Catching OutputDebugStrings
-
I though about creating a Edit window in my app that when called at runtime would catch all OutputDebugStrings that my program was making. After some nosing about on MSDN about catching OutPutDebugStrings i wrote a thread function as below and called it from a menu option. The idea was to eventually create a small window that would be updated with any OutPutDebugStrings that were caught.
UINT catchDebugString(LPVOID param) { TCHAR myChar[1024]; DWORD dwProcessId = GetCurrentProcessId(); HANDLE hHandle = OpenProcess( PROCESS_ALL_ACCESS, false, dwProcessId ); if ( DebugActiveProcess( dwProcessId ) == 0 ) return 0; DEBUG_EVENT de; while ( WaitForDebugEvent( &de, INFINITE ) ) { if ( de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT ) { OUTPUT_DEBUG_STRING_INFO deStr = de.u.DebugString; ReadProcessMemory(hHandle, deStr.lpDebugStringData, myChar, 1024, NULL); } if ( EXIT_PROCESS_DEBUG_EVENT == de.dwDebugEventCode ) break; ContinueDebugEvent( de.dwProcessId, de.dwThreadId, DBG_CONTINUE ); } return 1; }
All was well until i found out i cant call DebugActiveProcess( dwProcessId ) with my own process id , there by making it so i cant catch my own OutputDebugStrings. I just wondered if anyone out there had any ideas of how i could overcome this problem or if there is another way to catch OutputDebugStrings?? cheers AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); } -
I though about creating a Edit window in my app that when called at runtime would catch all OutputDebugStrings that my program was making. After some nosing about on MSDN about catching OutPutDebugStrings i wrote a thread function as below and called it from a menu option. The idea was to eventually create a small window that would be updated with any OutPutDebugStrings that were caught.
UINT catchDebugString(LPVOID param) { TCHAR myChar[1024]; DWORD dwProcessId = GetCurrentProcessId(); HANDLE hHandle = OpenProcess( PROCESS_ALL_ACCESS, false, dwProcessId ); if ( DebugActiveProcess( dwProcessId ) == 0 ) return 0; DEBUG_EVENT de; while ( WaitForDebugEvent( &de, INFINITE ) ) { if ( de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT ) { OUTPUT_DEBUG_STRING_INFO deStr = de.u.DebugString; ReadProcessMemory(hHandle, deStr.lpDebugStringData, myChar, 1024, NULL); } if ( EXIT_PROCESS_DEBUG_EVENT == de.dwDebugEventCode ) break; ContinueDebugEvent( de.dwProcessId, de.dwThreadId, DBG_CONTINUE ); } return 1; }
All was well until i found out i cant call DebugActiveProcess( dwProcessId ) with my own process id , there by making it so i cant catch my own OutputDebugStrings. I just wondered if anyone out there had any ideas of how i could overcome this problem or if there is another way to catch OutputDebugStrings?? cheers AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }DebugView do that and lot more http://www.sysinternals.com/ntw2k/freeware/debugview.shtml U have to change ur process privilege to debug mode first if u still wanna do it :) Papa while (TRUE) Papa.WillLove ( Bebe ) ;
-
DebugView do that and lot more http://www.sysinternals.com/ntw2k/freeware/debugview.shtml U have to change ur process privilege to debug mode first if u still wanna do it :) Papa while (TRUE) Papa.WillLove ( Bebe ) ;
hey there papa... yes i am aware of debug output viewer applications but want to do this programatically.. AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }
-
I though about creating a Edit window in my app that when called at runtime would catch all OutputDebugStrings that my program was making. After some nosing about on MSDN about catching OutPutDebugStrings i wrote a thread function as below and called it from a menu option. The idea was to eventually create a small window that would be updated with any OutPutDebugStrings that were caught.
UINT catchDebugString(LPVOID param) { TCHAR myChar[1024]; DWORD dwProcessId = GetCurrentProcessId(); HANDLE hHandle = OpenProcess( PROCESS_ALL_ACCESS, false, dwProcessId ); if ( DebugActiveProcess( dwProcessId ) == 0 ) return 0; DEBUG_EVENT de; while ( WaitForDebugEvent( &de, INFINITE ) ) { if ( de.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT ) { OUTPUT_DEBUG_STRING_INFO deStr = de.u.DebugString; ReadProcessMemory(hHandle, deStr.lpDebugStringData, myChar, 1024, NULL); } if ( EXIT_PROCESS_DEBUG_EVENT == de.dwDebugEventCode ) break; ContinueDebugEvent( de.dwProcessId, de.dwThreadId, DBG_CONTINUE ); } return 1; }
All was well until i found out i cant call DebugActiveProcess( dwProcessId ) with my own process id , there by making it so i cant catch my own OutputDebugStrings. I just wondered if anyone out there had any ideas of how i could overcome this problem or if there is another way to catch OutputDebugStrings?? cheers AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }Maybe Ivo Ivanov's API hooking revealed[^] can be of help here. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
hey there papa... yes i am aware of debug output viewer applications but want to do this programatically.. AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }
-
cheers mate... I'll have a look at that, as it looks like it will provide valuable info for me.. AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }
-
Maybe Ivo Ivanov's API hooking revealed[^] can be of help here. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
cheers Joaquín.. Im just having a quick read now AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }