• <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下支持格式化輸出的調(diào)試輸出功能的簡單實現(xiàn)

            VC下沒有支持可變參數(shù)的調(diào)試輸出實現(xiàn).今天搗鼓了半天做了一個簡單的:)


            // 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, )
            {
             
            }


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

             

             

              當(dāng)然,如果要實時看到輸出,可以用 FindFirstChangeNotification、FindNextChangeNotification、FILE_NOTIFY_CHANGE_LAST_WRITE等來實現(xiàn)一個動態(tài)監(jiān)視并輸出的程序.

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

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

            導(dǎo)航

            統(tǒng)計

            公告

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            win32 & debug

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久婷婷成人综合色综合| 熟妇人妻久久中文字幕| 国产成人精品久久亚洲| 热99RE久久精品这里都是精品免费| 久久亚洲中文字幕精品有坂深雪| 久久久久AV综合网成人| 久久人人爽人人爽人人片AV东京热| 久久精品无码午夜福利理论片| 91久久精品91久久性色| 日本久久久久亚洲中字幕| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 情人伊人久久综合亚洲| 久久精品国产亚洲αv忘忧草 | 国产精品久久久久久搜索| 一级做a爰片久久毛片毛片| 久久久久久久国产免费看| 精品久久久久久综合日本| 韩国免费A级毛片久久| 日本欧美久久久久免费播放网 | 伊人久久大香线蕉AV色婷婷色| 伊人色综合久久天天网| A级毛片无码久久精品免费| 麻豆亚洲AV永久无码精品久久| 国产午夜精品久久久久九九电影 | 久久国产欧美日韩精品| 久久99热这里只频精品6| 香蕉99久久国产综合精品宅男自| 91秦先生久久久久久久| 国产精品久久波多野结衣| 午夜天堂av天堂久久久| 国产激情久久久久久熟女老人| 久久夜色撩人精品国产| 久久天天日天天操综合伊人av| 国产视频久久| 久久精品国产WWW456C0M| 国内精品欧美久久精品| 国产福利电影一区二区三区久久老子无码午夜伦不 | 亚洲婷婷国产精品电影人久久| 久久久黄片| 中文成人无码精品久久久不卡 | 精品久久人人妻人人做精品 |