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

📄 w2k_sym.c

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

// __________________________________________________________
//
//                         w2k_sym.c
//           SBS Windows 2000 Symbol Browser V1.00
//                08-27-2000 Sven B. Schreiber
//                       sbs@orgon.com
// __________________________________________________________

#include "w2k_sym.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 gawArguments [] =
    L"{ <mode> [ /f | /F <filter> ] <operation> }";

WORD gawOptions   [] =
    L"\r\n"
    L"<mode> is a series of options for the next <operation>:\r\n"
    L"\r\n"
    L"        /a : sort by address\r\n"
    L"        /s : sort by size\r\n"
    L"        /i : sort by ID (process/module lists only)\r\n"
    L"        /n : sort by name\r\n"
    L"        /c : sort by name (case-sensitive)\r\n"
    L"        /r : reverse order\r\n"
    L"        /l : load  checkpoint file (see below)\r\n"
    L"        /w : write checkpoint file (see below)\r\n"
    L"        /e : display end address instead of size\r\n"
    L"        /v : verbose mode\r\n"
    L"\r\n"
    L"/f <filter> applies a case-insensitive search pattern.\r\n"
    L"/F <filter> works analogous, but case-sensitive.\r\n"
    L"In <filter>, the wildcards * and ? are allowed.\r\n"
    L"\r\n"
    L"<operation> is one of the following:\r\n"
    L"\r\n"
    L"        /p : display processes      - checkpoint: %s\r\n"
    L"        /m : display modules        - checkpoint: %s\r\n"
    L"        /d : display drivers        - checkpoint: %s\r\n"
    L"    <file> : display <file> symbols - checkpoint: %s\r\n"
    L"\r\n"
    L"<file> is a file name, a relative path, or a fully qualified "
    L"path.\r\n"
    L"Checkpoint files are loaded from and written to the current "
    L"directory.\r\n"
    L"A checkpoint is an on-disk image of a DBG_LIST structure "
    L"(see w2k_dbg.h).\r\n";

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

WORD gawTitleProcesses [] =
    L"\r\n"
    L"PROCESSES\r\n"
    L"=========\r\n";

WORD gawTableProcesses [] =
    L"\r\n"
    L"    #  ADDRESS  %s   PID   MOD NAME\r\n"
    L"----------------------------------------"
    L"---------------------------------------\r\n";

WORD gawTotalProcesses [] =
    L"----------------------------------------"
    L"---------------------------------------\r\n"
    L"    TOTAL SIZE: %8lX (%lu bytes / %lu KB / %lu MB)\r\n";

WORD gawFileProcesses  [] = L"processes.dbgl";

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

WORD gawTitleModules [] =
    L"\r\n"
    L"MODULES\r\n"
    L"=======\r\n";

WORD gawTableModules [] =
    L"\r\n"
    L"    #  ADDRESS  %s NAME\r\n"
    L"----------------------------------------"
    L"---------------------------------------\r\n";

WORD gawTotalModules [] =
    L"----------------------------------------"
    L"---------------------------------------\r\n"
    L"    TOTAL SIZE: %8lX (%lu bytes / %lu KB / %lu MB)\r\n";

WORD gawTotalSystem  [] =
    L"\r\n"
    L"  OVERALL SIZE: %8lX (%lu bytes / %lu KB / %lu MB)\r\n";

WORD gawFileModules  [] = L"modules.dbgl";

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

WORD gawTitleDrivers [] =
    L"\r\n"
    L"DRIVERS\r\n"
    L"=======\r\n";

WORD gawTableDrivers [] =
    L"\r\n"
    L"    #  ADDRESS  %s NAME\r\n"
    L"----------------------------------------"
    L"---------------------------------------\r\n";

WORD gawTotalDrivers [] =
    L"----------------------------------------"
    L"---------------------------------------\r\n"
    L"    TOTAL SIZE: %8lX (%lu bytes / %lu KB / %lu MB)\r\n";

WORD gawFileDrivers  [] = L"drivers.dbgl";

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

WORD gawTitleSymbols [] =
    L"\r\n"
    L"SYMBOLS\r\n"
    L"=======\r\n";

WORD gawTableSymbols [] =
    L"\r\n"
    L"    #  ADDRESS  %s NAME\r\n"
    L"----------------------------------------"
    L"---------------------------------------\r\n";

WORD gawTotalSymbols [] =
    L"----------------------------------------"
    L"---------------------------------------\r\n"
    L"    TOTAL SIZE: %8lX (%lu bytes / %lu KB / %lu MB)\r\n";

WORD gawFileSymbols  [] = L"symbols.dbgl";

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

WORD gawSize [] = L"    SIZE";
WORD gawEnd  [] = L"END     ";
WORD gawNull [] = L"";

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

DWORD WINAPI DisplayTime (PSYSTEMTIME pst)
    {
    SYSTEMTIME st;
    DWORD n = 0;

    if (SystemTimeToTzSpecificLocalTime (NULL, pst, &st))
        {
        n = printf (L"%s, %02hd-%02hd-%04hd, %02hd:%02hd:%02hd\r\n",
                    dbgStringDay (st.wDayOfWeek),
                    st.wMonth, st.wDay,    st.wYear,
                    st.wHour,  st.wMinute, st.wSecond);
        }
    return n;
    }

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

DWORD WINAPI DisplayCount (PWORD pwSingular,
                           PWORD pwPlural,
                           DWORD dCount,
                           PWORD pwInfo)
    {
    return printf (L"\r\n%lu %s%s\r\n", dCount,
                   (dCount == 1    ? pwSingular : pwPlural),
                   (pwInfo != NULL ? pwInfo     : gawNull ));
    }

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

DWORD WINAPI DisplayFilter (PWORD pwFilter)
    {
    return (pwFilter != NULL
            ? printf (L"Filter: <%s>\r\n", pwFilter)
            : 0);
    }

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

DWORD WINAPI DisplayTotal (PWORD pwFormat,
                           DWORD dTotal)
    {
    return printf (pwFormat, dTotal, dTotal,
                   dbgSizeKB (dTotal, FALSE, FALSE),
                   dbgSizeMB (dTotal, FALSE, FALSE));
    }

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

DWORD WINAPI DisplayMatches (DWORD dMatches)
    {
    return (dMatches

            ? DisplayCount (L"matching entry", L"matching entries",
                            dMatches, NULL)

            : printf (L"No matching entries\r\n"));
    }

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

DWORD WINAPI DisplayError (PWORD pwType)
    {
    return printf (L"\r\nUnable to obtain the %s list\r\n", pwType);
    }

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

void WINAPI DisplayProcesses (PWORD pwFilter,
                              DWORD dSort,
                              BOOL  fReverse,
                              BOOL  fLoad,
                              BOOL  fWrite,
                              BOOL  fEnd,
                              BOOL  fVerbose,
                              BOOL  fCase)
    {
    PDBG_INDEX   pdi;
    PDBG_PROCESS pdp;
    PWORD        pwPath;
    DWORD        dEnd, dTotal, i, n;

    printf (gawTitleProcesses);

    if ((pdi = dbgProcessIndex ((fLoad ? gawFileProcesses : NULL),
                                dSort, fReverse))
        != NULL)
        {
        DisplayCount (L"process", L"processes", pdi->dEntries,
                      (!fVerbose
                       ? L" - use the /v switch to view full paths"
                       : NULL));

        DisplayTime   (&pdi->pdl->st);
        DisplayFilter (pwFilter);

        for (i = n = dTotal = 0; i < pdi->dEntries; i++)
            {
            pdp = pdi->ppdp [i];

            pwPath = (pdp->awPath [0] 
                      ? pdp->awPath + (fVerbose ? 0 : pdp->dFile)
                      : dbgProcessGuess (i));

            if (dbgStringMatch (pwFilter, pwPath, fCase))
                {
                if (fEnd)
                    {
                    if (!n++) printf (gawTableProcesses, gawEnd);

                    dEnd = (DWORD_PTR) pdp->pBase + pdp->dSize;

                    printf (L"%5lu: %08lX %08lX %5lu %5lu %s\r\n",
                            i+1, pdp->pBase, dEnd,
                            pdp->dId, pdp->dModules, pwPath);
                    }
                else
                    {
                    if (!n++) printf (gawTableProcesses, gawSize);

                    printf (L"%5lu: %08lX %8lX %5lu %5lu %s\r\n",
                            i+1, pdp->pBase, pdp->dSize,
                            pdp->dId, pdp->dModules, pwPath);
                    }
                dTotal += pdp->dSize;
                }
            }
        if (n) DisplayTotal (gawTotalProcesses, dTotal);
        if (pwFilter != NULL) DisplayMatches (n);

        if (fWrite) dbgIndexSave (gawFileProcesses, pdi);
        dbgIndexDestroy (pdi);
        }
    else
        {
        DisplayError (L"process");
        }
    return;
    }

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

void WINAPI DisplayModules (PWORD pwFilter,
                            DWORD dSort,
                            BOOL  fReverse,
                            BOOL  fLoad,
                            BOOL  fWrite,
                            BOOL  fEnd,
                            BOOL  fVerbose,
                            BOOL  fCase)
    {
    PDBG_INDEX   pdi, pdi1;
    PDBG_PROCESS pdp;
    PDBG_MODULE  pdm;
    PWORD        pwPath1, pwPath2;
    DWORD        dEnd, dTotal1, dTotal2, i, j, n;

    printf (gawTitleModules);

    if ((pdi = dbgProcessIndexEx ((fLoad ? gawFileModules : NULL),
                                  dSort, fReverse))
        != NULL)
        {
        DisplayCount (L"process", L"processes", pdi->dEntries,
                      (!fVerbose
                       ? L" - use the /v switch to view full paths"
                       : NULL));

        DisplayTime   (&pdi->pdl->st);
        DisplayFilter (pwFilter);

        for (i = dTotal1 = 0; i < pdi->dEntries; i++)
            {
            pdi1 = pdi->ppdi [i];
            pdp  = pdi1->pContext;

            pwPath1 = (pdp->awPath [0]
                       ? pdp->awPath + (fVerbose ? 0 : pdp->dFile)
                       : dbgProcessGuess (i));

            for (j = n = dTotal2 = 0; j < pdi1->dEntries; j++)
                {
                pdm     = pdi1->ppdm [j];
                pwPath2 = pdm->awPath + (fVerbose ? 0 : pdm->dFile);

                if (dbgStringMatch (pwFilter, pwPath2, fCase))
                    {
                    if (!n)
                        {
                        printf (L"\r\nPROCESS #%lu (%lu/%lu): "
                                L"%s (%lu MODULES)\r\n",
                                pdp->dId, i+1, pdi->dEntries,
                                pwPath1, pdp->dModules);
                        }
                    if (fEnd)
                        {
                        if (!n++) printf (gawTableModules, gawEnd);

                        dEnd = (DWORD_PTR) pdm->pBase + pdm->dSize;

                        printf (L"%5lu: %08lX %08lX %s\r\n",
                                j+1, pdm->pBase, dEnd,
                                pwPath2);
                        }
                    else
                        {
                        if (!n++) printf (gawTableModules, gawSize);

                        printf (L"%5lu: %08lX %8lX %s\r\n",
                                j+1, pdm->pBase, pdm->dSize,
                                pwPath2);
                        }
                    dTotal2 += pdm->dSize;
                    }

⌨️ 快捷键说明

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