• <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

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久久午夜精品| 久久伊人亚洲AV无码网站| 一本色道久久88—综合亚洲精品| 一本色道久久88精品综合| 精品国产99久久久久久麻豆| 国产伊人久久| 99久久国产热无码精品免费| 久久久噜噜噜久久中文字幕色伊伊| 日韩久久无码免费毛片软件 | 久久久无码精品亚洲日韩按摩| 久久久久国产一级毛片高清板| 久久er国产精品免费观看2| 欧美精品国产综合久久| 国产精品久久久久久久久久影院| 少妇久久久久久被弄高潮| 一本久道久久综合狠狠躁AV| 99久久国产综合精品五月天喷水| 一本久久a久久精品综合夜夜| 久久久久久精品无码人妻| 国产午夜福利精品久久2021| 久久久久人妻一区精品| 中文字幕亚洲综合久久2| 精品久久久久久亚洲精品 | 亚洲精品高清国产一久久| 久久精品亚洲福利| 久久91这里精品国产2020| 久久超乳爆乳中文字幕| 少妇久久久久久被弄高潮| 国产A级毛片久久久精品毛片| 欧美激情一区二区久久久| 久久久久久久国产免费看| 亚洲一区二区三区日本久久九| 久久亚洲欧美日本精品| 91精品国产综合久久香蕉 | 久久亚洲中文字幕精品一区| 久久久久久久99精品免费观看| 国产Av激情久久无码天堂| 亚洲AV无码1区2区久久| 精品久久久久久久久午夜福利| 无码精品久久久久久人妻中字| 精品少妇人妻av无码久久|