• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大熊的口袋

             

            vc6下支持格式化輸出的調試輸出功能的簡單實現

            VC下沒有支持可變參數的調試輸出實現.今天搗鼓了半天做了一個簡單的:)


            // dgb_prt.h

            #include <windows.h>

            #define _DEBUG_INFO_FILE  "gfx_dbg_info.txt" // 修改這里的輸出文件

            VOID _cdecl __DPrt(
            const WCHAR *fmt, );
            VOID _cdecl __RPrt(
            const WCHAR *fmt, );
            VOID _cdecl __ADPrt(BOOL, 
            const WCHAR *fmt, );
            VOID _cdecl __ARPrt(BOOL, 
            const WCHAR *fmt, );

            #ifndef NDEBUG
            # define _DbgPrt __DPrt
            #else
            # define _DbgPrt __RPrt
            #endif

            #ifndef NDEBUG
            # define _AstPrt __ADPrt
            #else
            # define _AstPrt __ARPrt
            #endif

             

            // dbg_prt.cpp

            // -------------------------------------------------------------------------
            #define _STDOUT_FP        (1)

            #define _DEBUG_INFO_FILE  "dbg_info.txt"

            // -------------------------------------------------------------------------
            typedef struct __DbgPrtPara
            {
             FILE 
            *pfp;
             
            int   pfd;
             unsigned 
            long pret;
            }
             _DbgPrtPara, *_PDbgPrtPara;

            _PDbgPrtPara __stdcall __DPrtInit()
            {
             _PDbgPrtPara pDbgPara 
            = (_PDbgPrtPara)malloc(sizeof(_DbgPrtPara));
             pDbgPara
            ->pfd = _dup(_STDOUT_FP);
             pDbgPara
            ->pfp = freopen(_DEBUG_INFO_FILE, "a+", stdout);
             unsigned 
            short buff[128= {'\0'};
             _wstrtime(buff);
             wprintf(L
            "%s: ", buff);
             
            return pDbgPara;
            }


            void __stdcall __DPrtClose(_PDbgPrtPara pDbgPara)
            {
             fflush(pDbgPara
            ->pfp);
             fclose(pDbgPara
            ->pfp);
             _dup2(pDbgPara
            ->pfd, _STDOUT_FP);
             free(pDbgPara);
             pDbgPara 
            = NULL;
            }


            // -------------------------------------------------------------------------
            __declspec(naked) void __DPrt(const unsigned short *fmt, )
            {
             
            #ifdef _M_IX86
             
             __asm
            {
              call    __DPrtInit
              pop     ebx
              mov     dword ptr [eax 
            + 8], ebx
              mov     ebx, eax
              
              call    dword ptr [wprintf]
              
              push    ebx
              mov     eax, dword ptr [ebx 
            + 8]
              mov     ebx, eax
              call    __DPrtClose
              push    ebx
              ret
             }

             
            #endif
             
            }


            // -------------------------------------------------------------------------
            void __RPrt(const unsigned short *fmt, )
            {
             
            }



            // -------------------------------------------------------------------------
            __declspec(naked) void __ADPrt(unsigned longconst unsigned short *fmt, )
            {
             
            #ifdef _M_IX86
             
             __asm
            {
              mov     eax, dword ptr [esp 
            + 4]
              cmp     eax, 
            0
              je      EXE_TRUE
              ret
            EXE_TRUE:
              call    __DPrtInit
              pop     ebx
              mov     dword ptr [eax 
            + 8], ebx
              mov     ebx, eax
              pop     eax
              
              call    dword ptr [wprintf]
              
              push    ebx
              mov     eax, dword ptr [ebx 
            + 8]
              mov     ebx, eax
              call    __DPrtClose
              sub     esp, 
            4
              push    ebx
              ret
             }

             
            #endif
             
            }


            // -------------------------------------------------------------------------
            void _cdecl __ARPrt(unsigned longconst unsigned short *fmt, )
            {
             
            }


            // -------------------------------------------------------------------------

             

             

              當然,如果要實時看到輸出,可以用 FindFirstChangeNotification、FindNextChangeNotification、FILE_NOTIFY_CHANGE_LAST_WRITE等來實現一個動態監視并輸出的程序.

              這樣就有點象ddk里的DbgPrint了,呵呵.

            posted on 2008-08-27 12:24 大熊的口袋 閱讀(1668) 評論(0)  編輯 收藏 引用 所屬分類: cpp

            導航

            統計

            公告

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            win32 & debug

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            人妻少妇久久中文字幕一区二区| 久久99国产精一区二区三区| 欧美色综合久久久久久| 国产激情久久久久影院老熟女免费 | 99久久无色码中文字幕人妻| 亚洲欧美日韩久久精品第一区| A狠狠久久蜜臀婷色中文网| 久久激情五月丁香伊人| 狠狠综合久久综合88亚洲| 久久青草国产精品一区| 久久亚洲AV无码精品色午夜麻豆| 久久精品国产久精国产思思| 青草久久久国产线免观| 丰满少妇人妻久久久久久| 日韩电影久久久被窝网| 欧美亚洲另类久久综合| 亚洲国产一成人久久精品 | 亚洲国产小视频精品久久久三级| 亚洲日本va中文字幕久久| 国内精品久久久久久麻豆 | 91久久九九无码成人网站| 久久久无码精品亚洲日韩京东传媒| 久久国产精品久久久| 日韩精品久久久久久免费| 久久久99精品成人片中文字幕| 国产91色综合久久免费分享| 亚洲∧v久久久无码精品| 亚洲综合久久夜AV | 久久亚洲精品无码播放| 国产69精品久久久久99| 99精品久久久久久久婷婷| 久久久久免费精品国产| 97久久精品人妻人人搡人人玩| 久久青青草原亚洲av无码app| 精品伊人久久大线蕉色首页| 亚洲国产成人精品女人久久久| 久久精品国产一区二区三区| 国内精品久久久久久久久电影网| 免费国产99久久久香蕉| 久久综合综合久久97色| 久久久久国产一级毛片高清板|