📄 w2k_obj.c
字号:
// __________________________________________________________
//
// w2k_obj.c
// SBS Windows 2000 Object Browser V1.00
// 08-27-2000 Sven B. Schreiber
// sbs@orgon.com
// __________________________________________________________
#include "w2k_obj.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 VARIABLES
// =================================================================
BOOL gfMemoryStatus = FALSE;
// =================================================================
// GLOBAL STRINGS
// =================================================================
WORD awArguments [] =
L"[+-atf] [<type>] [<#>|-1] [/root] [/types]";
WORD awMoreInfo [] =
L"\r\n"
L" +a -a : show/hide object addresses (default: -a)\r\n"
L" +t -t : show/hide object type names (default: -t)\r\n"
L" +f -f : show/hide object flags (default: -f)\r\n"
L" <type> : show <type> objects only (default: *)\r\n"
L" <#> : show <#> directory levels (default: -1)\r\n"
L" -1 : show all directory levels\r\n"
L" /root : show ObpRootDirectoryObject tree\r\n"
L" /types : show ObpTypeDirectoryObject tree\r\n"
L"\r\n"
L"Example: " SW(MAIN_MODULE) L" +atf *port 2 /root\r\n"
L"\r\n"
L"This command displays all Port and WaitablePort objects,\r\n"
L"starting in the root and scanning two directory levels.\r\n"
L"Each line includes address, type, and flag information.\r\n";
WORD awModuleNotFound [] =
L"\r\n"
L"Unable to locate the module ntoskrnl.exe\r\n";
WORD awLoadError [] =
L"\r\n"
L"Unable to load the symbol table\r\n";
WORD awChecksumError [] =
L"\r\n"
L"The symbol files don't match your installed system\r\n";
WORD awUnknownError [] =
L"\r\n"
L"Unknown symbol table initialization error\r\n";
// =================================================================
// OBJECT BROWSER
// =================================================================
DWORD WINAPI DisplayDirectory (POBJECT_DIRECTORY pDirectory,
DWORD dOptions,
PWORD pwType,
DWORD dLevel,
DWORD dMaxLevel,
PDIR_LEVEL pLevels)
{
POBJECT_DIRECTORY pDirectory1;
POBJECT_DIRECTORY_ENTRY pEntry;
DWORD dSize, dIndex, i, j;
DWORD n = 0;
if ((dLevel < dMaxLevel) &&
((pDirectory1 = w2kDirectoryOpen (pDirectory)) != NULL))
{
dSize = w2kDirectorySize (pDirectory1, pwType);
dIndex = 0;
for (i = 0; i < OBJECT_HASH_TABLE_SIZE; i++)
{
for (pEntry = pDirectory1->HashTable [i];
pEntry != NULL;
pEntry = pEntry->NextEntry)
{
pLevels [dLevel].fLastEntry = (dIndex+1 == dSize);
if (j = DisplayObject (pEntry->Object, dOptions,
pwType, dLevel+1, dMaxLevel,
pLevels, FALSE))
{
n += j;
dIndex++;
}
}
}
for (i = 0; i < OBJECT_HASH_TABLE_SIZE; i++)
{
for (pEntry = pDirectory1->HashTable [i];
pEntry != NULL;
pEntry = pEntry->NextEntry)
{
pLevels [dLevel].fLastEntry = (dIndex+1 == dSize);
if (j = DisplayObject (pEntry->Object, dOptions,
pwType, dLevel+1, dMaxLevel,
pLevels, TRUE))
{
n += j;
dIndex++;
}
}
}
w2kDirectoryClose (pDirectory1);
}
return n;
}
// -----------------------------------------------------------------
DWORD WINAPI DisplayObject (PW2K_OBJECT pObject,
DWORD dOptions,
PWORD pwType,
DWORD dLevel,
DWORD dMaxLevel,
PDIR_LEVEL pLevels,
BOOL fDirectories)
{
BOOL fDirectory, fMatch;
DWORD dBytes, i;
DWORD n = 0;
dBytes = OBJECT_NAME_INFORMATION_ + (1000 * WORD_);
if (pObject != NULL)
{
fDirectory = !lstrcmp (pObject->pwType, L"Directory");
fMatch = w2kStringFilter (pwType, pObject->pwType, TRUE);
if ((fDirectory && fDirectories) ||
(!(fDirectory || fDirectories || (!fMatch))))
{
_printf (lstrcmp (pwType, L"*") && fMatch
? L">"
: L" ");
for (i = 0; i < dLevel; i++)
{
printf (i+1 == dLevel
? (pLevels [i].fLastEntry
? L" \\_ "
: L" |_ ")
: (pLevels [i].fLastEntry
? L" "
: L" | "));
}
if (dOptions & OPTION_ADDRESS)
{
_printf (L"%08lX ",
pObject->pObject);
}
if (dOptions & OPTION_TYPE)
{
_printf (L"%+_-14s ",
pObject->pwType);
}
if (dOptions & OPTION_FLAGS)
{
_printf (L"<%02lX> ",
(DWORD) pObject->pHeader->ObjectFlags);
}
if (fDirectory)
{
pLevels [dLevel].pwName = pObject->pwName;
for (i = 0; i <= dLevel; i++)
{
_printf (L"%s%s",
pLevels [i].pwName,
(i && (i < dLevel) ? L"\\" : L""));
}
printf (L"\r\n");
n += DisplayDirectory (pObject->pObject, dOptions,
pwType, dLevel, dMaxLevel,
pLevels);
}
else
{
_printf (L"%s\r\n", pObject->pwName);
}
n++;
}
}
return n;
}
// -----------------------------------------------------------------
DWORD WINAPI DisplayObjects (DWORD dOptions,
PWORD pwType,
DWORD dMaxLevel,
BOOL fTypeDirectory)
{
PW2K_OBJECT pObject;
WORD awMaxLevel [N_DECIMAL32];
DIR_LEVEL aLevels [256];
DWORD n = 0;
if (dMaxLevel != MAXDWORD)
{
_sprintf (awMaxLevel, L"%lu", dMaxLevel);
}
else
{
lstrcpyn (awMaxLevel, L"all", N_DECIMAL32);
}
_printf (L"\r\n"
L"%s directory contents: (%s level%s shown)\r\n"
L"------------------------\r\n"
L"\r\n",
(fTypeDirectory ? L"Type" : L"Root"),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -