Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Catching OutputDebugStrings

Catching OutputDebugStrings

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adrian cooper
    wrote on last edited by
    #1

    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()); }

    J J 2 Replies Last reply
    0
    • A adrian cooper

      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()); }

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      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 ) ;

      A 1 Reply Last reply
      0
      • J jmkhael

        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 ) ;

        A Offline
        A Offline
        adrian cooper
        wrote on last edited by
        #3

        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()); }

        D 1 Reply Last reply
        0
        • A adrian cooper

          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()); }

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • A adrian cooper

            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()); }

            D Offline
            D Offline
            Daniel Turini
            wrote on last edited by
            #5

            Try these sources: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpdbmon.asp[^] Q261186 - Computer Randomly Plays Classical Music

            A 1 Reply Last reply
            0
            • D Daniel Turini

              Try these sources: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpdbmon.asp[^] Q261186 - Computer Randomly Plays Classical Music

              A Offline
              A Offline
              adrian cooper
              wrote on last edited by
              #6

              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()); }

              1 Reply Last reply
              0
              • J Joaquin M Lopez Munoz

                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

                A Offline
                A Offline
                adrian cooper
                wrote on last edited by
                #7

                cheers Joaquín.. Im just having a quick read now AdrianCooper me; while(CKitchen::beerInFridge()) { me.watchTV(); me.consumeBeer(myKitchen.getBeerCan()); }

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups