⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w2k_dump.c

📁 Undocumented Windows 2000 Secrets简体中文版.+源码光盘
💻 C
📖 第 1 页 / 共 2 页
字号:

// __________________________________________________________
//
//                         w2k_dump.c
//          SBS Windows 2000 Hex Dump Utility V1.00
//                08-27-2000 Sven B. Schreiber
//                       sbs@orgon.com
// __________________________________________________________

#include "w2k_dump.h"

// =================================================================
// DISCLAIMER
// =================================================================

/*

This software is provided "as is" and any express or implied
warranties, including, but not limited to, the implied warranties of
merchantability and fitness for a particular purpose are disclaimed.
In no event shall the author Sven B. Schreiber be liable for any
direct, indirect, incidental, special, exemplary, or consequential
damages (including, but not limited to, procurement of substitute
goods or services; loss of use, data, or profits; or business
interruption) however caused and on any theory of liability,
whether in contract, strict liability, or tort (including negligence
or otherwise) arising in any way out of the use of this software,
even if advised of the possibility of such damage.

*/

// =================================================================
// REVISION HISTORY
// =================================================================

/*

08-27-2000 V1.00 Original version (SBS).

*/

// =================================================================
// GLOBAL STRINGS
// =================================================================

WORD awArguments      [] = L"{ [+-bwdqp] <path> }";

WORD awMoreInfo       [] = L"\r\n"
                           L"       +   enable  option\r\n"
                           L"       -   disable option\r\n"
                           L"       b   display BYTEs\r\n"
                           L"       w   display WORDs\r\n"
                           L"       d   display DWORDs\r\n"
                           L"       q   display QWORDs\r\n"
                           L"       p   display PDB streams\r\n";

WORD awFileOk         [] = L"\r\nFile: %s\r\n"
                           L"Size: 0x%08lX (%lu)\r\n";

WORD awFileError      [] = L"\r\nFile: %s\r\n"
                           L"Unable to load this file\r\n";

WORD awFileType       [] = L"Type: %hs";

WORD awPdbStream      [] = L"\r\nPDB stream #%lu (range 0..%hu)\r\n"
                           L"Size: 0x%08lX (%lu)\r\n";

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

WORD awTableAddress   [] = L"Address "; // 8 characters

WORD awTableSpace1    [] = L" ";
WORD awTableSpace2    [] = L"  ";

WORD awTableHex1      [] = L"%01lX";
WORD awTableHex2      [] = L"%02lX";
WORD awTableHex8      [] = L"%08lX";

WORD awByte           [] = L"byte";
WORD awBytes          [] = L"bytes";
WORD awNot            [] = L"not ";
WORD awUndefined      [] = L"???";
WORD awNewLine        [] = L"\r\n";
WORD awString         [] = L"%s";
WORD awNull           [] = L"";

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

WORD awTableDataByte  [] =
    L"\r\n%s | "
    L"%s %s %s %s-%s %s %s %s : %s %s %s %s-%s %s %s %s | "
    L"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s";

WORD awTableBarByte   [] =
    L"\r\n---------|-"
    L"------------------------:-------------------------|-"
    L"----------------";

WORD awTableDataWord  [] =
    L"\r\n%s | "
    L"%s%s %s%s-%s%s %s%s : %s%s %s%s-%s%s %s%s | "
    L"%s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s";

WORD awTableBarWord   [] =
    L"\r\n---------|-"
    L"--------------------:---------------------|-"
    L"-----------------------";

WORD awTableDataDword [] =
    L"\r\n%s | "
    L"%s%s%s%s - %s%s%s%s : %s%s%s%s - %s%s%s%s | "
    L"%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s";

WORD awTableBarDword  [] =
    L"\r\n---------|-"
    L"--------------------:---------------------|-"
    L"-------------------";

WORD awTableDataQword [] =
    L"\r\n%s | "
    L"%s%s%s%s-%s%s%s%s : %s%s%s%s-%s%s%s%s | "
    L"%s%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s";

WORD awTableBarQword  [] =
    L"\r\n---------|-"
    L"------------------:-------------------|-"
    L"-----------------";

// =================================================================
// DISPLAY ROUTINES
// =================================================================

VOID WINAPI DisplayMemory (PBYTE pbData,
                           DWORD dData,
                           PVOID pBase,
                           DWORD dOptions)
    {
    DATA_ROW dr;
    PWORD    pwTableData, pwTableBar;
    DWORD    dGroup, dValue, i, j, k;

    if (dData)
        {
        switch (dOptions & DISPLAY_OPTION_FORMAT)
            {
            default:
            case DISPLAY_OPTION_BYTE:
                {
                pwTableData = awTableDataByte;
                pwTableBar  = awTableBarByte;
                dGroup      = sizeof (BYTE);
                break;
                }
            case DISPLAY_OPTION_WORD:
                {
                pwTableData = awTableDataWord;
                pwTableBar  = awTableBarWord;
                dGroup      = sizeof (WORD);
                break;
                }
            case DISPLAY_OPTION_DWORD:
                {
                pwTableData = awTableDataDword;
                pwTableBar  = awTableBarDword;
                dGroup      = sizeof (DWORD);
                break;
                }
            case DISPLAY_OPTION_QWORD:
                {
                pwTableData = awTableDataQword;
                pwTableBar  = awTableBarQword;
                dGroup      = sizeof (QWORD);
                break;
                }
            }
        dr.pArguments = &dr.pwAddress;
        dr.pwAddress  = dr.awAddress;

        for (j = 0; j < 16; j++)
            {
            dr.apwHex  [j] = dr.awHex  + (j * (2+1));
            dr.apwText [j] = dr.awText + (j * (1+1));
            }
        lstrcpy (dr.pwAddress, awTableAddress);

        for (j = 0; j < 16; j++)
            {
            k = (((j / dGroup) + 1) * dGroup) - ((j % dGroup) + 1);

            dValue = (k % dGroup == 0
                      ? ((DWORD_PTR) pBase & 0x0F) + k
                      : 0);

            sprintf (dr.apwHex  [j], awTableHex2, dValue);

            dValue = (k % dGroup == 0
                      ? ((DWORD_PTR) pBase + k) & 0x0F
                      : (k % dGroup == 1
                         ? (((DWORD_PTR) pBase & 0x0F) + k - 1) >> 4
                         : 0));

            sprintf (dr.apwText [j], awTableHex1, dValue);
            }
        vsprintf (dr.awBuffer, pwTableData, dr.pArguments);
        printf   (dr.awBuffer);
        printf   (pwTableBar);
        }
    for (i = 0; i < dData; i += j)
        {
        sprintf (dr.pwAddress, awTableHex8, (PBYTE) pBase + i);

        for (j = 0; j < 16; j++)
            {
            k = (((j / dGroup) + 1) * dGroup) - ((j % dGroup) + 1);

            if (i+k < dData)
                {
                dValue = pbData [i+k];
                sprintf (dr.apwHex [j], awTableHex2, dValue);

                if ((dValue < 0x20) ||
                    (dValue == 0x7F)) dValue = '.';

                dr.apwText [j] [0] = (WORD) dValue;
                dr.apwText [j] [1] = 0;
                }
            else
                {
                lstrcpy (dr.apwHex  [j], awTableSpace2);
                lstrcpy (dr.apwText [j], awTableSpace1);
                }
            }
        vsprintf (dr.awBuffer, pwTableData, dr.pArguments);
        printf   (awString, dr.awBuffer);
        }
    if (dData) printf (awNewLine);
    return;
    }

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

VOID WINAPI DisplayPdb (PIMG_PDB pip,
                        PVOID    pBase,
                        DWORD    dOptions)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -