• <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 大熊的口袋 閱讀(1665) 評論(0)  編輯 收藏 引用 所屬分類: cpp

            導航

            統計

            公告

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            win32 & debug

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品久久久久久久app| 久久国产精品国产自线拍免费| 狠狠色婷婷久久一区二区三区| 久久亚洲春色中文字幕久久久| 久久精品成人国产午夜| 伊人久久大香线蕉av不卡| 成人a毛片久久免费播放| 久久精品中文字幕一区| 亚洲国产成人久久一区WWW| 国产成人综合久久综合| 狠狠色婷婷综合天天久久丁香| 国产综合免费精品久久久| 久久精品综合一区二区三区| 伊人久久综合热线大杳蕉下载| 久久99国产精品尤物| 亚洲AV日韩精品久久久久 | 久久婷婷成人综合色综合| 久久性生大片免费观看性| 国产精品99久久不卡| 99久久综合狠狠综合久久| 久久成人18免费网站| 香蕉久久夜色精品国产2020| 日韩电影久久久被窝网| 久久噜噜久久久精品66| 亚洲日本久久久午夜精品| 久久亚洲AV成人无码软件| 久久久老熟女一区二区三区| 国产精品久久成人影院| 久久久久亚洲AV无码去区首| 一极黄色视频久久网站| 久久99精品国产麻豆| 久久无码精品一区二区三区| 久久久久久精品久久久久| 91精品国产91久久综合| 看全色黄大色大片免费久久久| 午夜福利91久久福利| 亚洲精品无码久久千人斩| 人人狠狠综合久久亚洲婷婷 | 国产成人精品久久免费动漫| 精品熟女少妇av免费久久| 国产99久久久国产精免费|