diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ole32/dbgexts | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/ole32/dbgexts')
34 files changed, 7805 insertions, 0 deletions
diff --git a/private/ole32/dbgexts/daytona/makefile b/private/ole32/dbgexts/daytona/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/ole32/dbgexts/daytona/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/ole32/dbgexts/daytona/sources b/private/ole32/dbgexts/daytona/sources new file mode 100644 index 000000000..ce16e9e61 --- /dev/null +++ b/private/ole32/dbgexts/daytona/sources @@ -0,0 +1,112 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Bruce Mansfield (brucema) 01-Jun-1995 + + +!ENDIF + + +# +# The MAJORCOMP and MINORCOMP variables are defined +# so that $(MAJORCOMP)$(MINORCOMP)filename can be used in +# cross compiling to provide unique filenames in a flat namespace. +# + +MAJORCOMP=cairole +MINORCOMP=dbgexts + +# +# The TARGETNAME variable is defined by the developer. It is the name of +# the target (component) that is being built by this makefile. It +# should NOT include any path or file extension information. +# + +TARGETNAME=oleexts + +DLLBASE=0x7a000000 + +# +# The TARGETPATH and TARGETTYPE variables are defined by the developer. +# The first specifies where the target is to be build. The second specifies +# the type of target (either PROGRAM, DYNLINK, LIBRARY, UMAPPL_NOLIB or +# BOOTPGM). UMAPPL_NOLIB is used when you're only building user-mode +# apps and don't need to build a library. +# + +TARGETPATH=obj + +# Pick one of the following and delete the others +TARGETTYPE=DYNLINK + +DLLDEF= ..\ole.def + +# +# The TARGETLIBS specifies additional libraries to link with you target +# image. Each library path specification should contain an asterisk (*) +# where the machine specific subdirectory name should go. +# +UMTYPE=console +USE_CRTDLL=1 +LINKLIBS= $(BASEDIR)\public\sdk\lib\*\kernel32.lib \ + $(BASEDIR)\public\sdk\lib\*\user32.lib \ + $(BASEDIR)\public\sdk\lib\*\gdi32.lib \ + $(BASEDIR)\public\sdk\lib\*\advapi32.lib \ + $(BASEDIR)\public\sdk\lib\*\crtdll.lib \ + $(BASEDIR)\public\sdk\lib\*\uuid.lib + +# +# The INCLUDES variable specifies any include paths that are specific to +# this source directory. Separate multiple directory paths with single +# semicolons. Relative path specifications are okay. +# + +INCLUDES=..\;..\..\common\daytona;..\..\ih;..\..\com\inc;..\..\com\objact;..\..\dcom\idl\daytona;..\..\com\rot;..\..\com\dcomrem;..\..\..\dcomidl\obj + + +# +# The SOURCES variable is defined by the developer. It is a list of all the +# source files for this component. Each source file should be on a separate +# line using the line continuation character. This will minimize merge +# conflicts if two developers adding source files to the same component. +# + +SOURCES= \ + ..\oleexts.cxx \ + ..\ddllcach.cxx \ + ..\drot.cxx \ + ..\dvtbl.cxx \ + ..\derror.cxx \ + ..\dfileext.cxx \ + ..\dfilepat.cxx \ + ..\dpsclsid.cxx \ + ..\dstdid.cxx \ + ..\dchannel.cxx \ + ..\dinfolvl.cxx \ + ..\dmoniker.cxx \ + ..\dtreatas.cxx \ + ..\dclsinfo.cxx \ + ..\dclscach.cxx \ + ..\util.cxx \ + ..\doxid.cxx \ + ..\dipid.cxx \ + ..\ole.rc + + +C_DEFINES= -DNT -DWINNT \ + $(C_DEFINES) diff --git a/private/ole32/dbgexts/dchannel.cxx b/private/ole32/dbgexts/dchannel.cxx new file mode 100644 index 000000000..113a0e388 --- /dev/null +++ b/private/ole32/dbgexts/dchannel.cxx @@ -0,0 +1,152 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dchannel.cxx +// +// Contents: Ole NTSD extension routines to display the RPC channel +// associated with a remote handler. This includes the +// interestiong pieces of CRpcChannelBuffer, CRpcService and +// CEndPoint. +// +// Functions: channelHelp +// displayChannel +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dipid.h" +#include "dchannel.h" +#include "dstdid.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + + +//+------------------------------------------------------------------------- +// +// Function: channelHelp +// +// Synopsis: Display a menu for the command 'ch' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void channelHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("\nch addr - Display a CRpcChannelBuffer object:\n"); + Printf("refs stdid state clientThread processLocal? handle OXID IPID destCtx\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayChannel +// +// Synopsis: Display an RPC channel starting from the address of the +// CRpcChannelBuffer object +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [pChnlBfr] - Address of channel buffer +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayChannel(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pChannel, + char *arg) +{ + SRpcChannelBuffer chnlBfr; + SStdIdentity stdid; + SOXIDEntry oxid; + SIPIDEntry ipid; + char szClsid[CLSIDSTR_MAX]; + + // Check for help + if (arg[0] == '?') + { + Printf("refs stdid state clientThread processLocal? handle OXID IPID destCtx\n"); + return; + } + + // Read the rpc channel buffer + ReadMem(&chnlBfr, pChannel, sizeof(SRpcChannelBuffer)); + + // References + Printf("%d ", chnlBfr.ref_count); + + // Standard identity object address + Printf("%x ", chnlBfr.pStdId); + + // State + switch (chnlBfr.state) + { + case client_cs: + Printf("client_cs "); + break; + + case proxy_cs: + Printf("proxy_cs "); + break; + + case server_cs: + Printf("server_cs "); + break; + + case freethreaded_cs: + Printf("freethreaded_cs "); + break; + + default: + Printf("unknown "); + break; + } + + // Client thread + Printf("%3x ", chnlBfr.client_thread); + + // Process local + if (chnlBfr.process_local) + { + Printf("local "); + } + else + { + Printf("not-local "); + } + + // Handle + Printf("%x ", chnlBfr.handle); + + // OXID entry address + Printf("%x ", chnlBfr.pOXIDEntry); + + // IPID entry address + Printf("%x ", chnlBfr.pIPIDEntry); + + // Destination context + Printf("%x\n", chnlBfr.iDestCtx); +} diff --git a/private/ole32/dbgexts/dchannel.h b/private/ole32/dbgexts/dchannel.h new file mode 100644 index 000000000..18385585e --- /dev/null +++ b/private/ole32/dbgexts/dchannel.h @@ -0,0 +1,39 @@ + + +typedef enum EChannelState +{ + // The channel on the client side held by the remote handler. + client_cs = 1, + + // The channels on the client side held by proxies. + proxy_cs = 2, + + // The server channels held by remote handlers. + server_cs = 16, + + // Flag to indicate that the channel may be used on any thread. + freethreaded_cs = 64 +} EChannelState; + + + + +// Forward reference +struct SStdIdentity; + + + +struct SRpcChannelBuffer +{ + void *_vtbl1; + ULONG ref_count; + SStdIdentity *pStdId; + DWORD state; + DWORD client_thread; + BOOL process_local; + handle_t handle; + SOXIDEntry *pOXIDEntry; + SIPIDEntry *pIPIDEntry; + DWORD iDestCtx; +}; + diff --git a/private/ole32/dbgexts/dclscach.cxx b/private/ole32/dbgexts/dclscach.cxx new file mode 100644 index 000000000..747f9dd34 --- /dev/null +++ b/private/ole32/dbgexts/dclscach.cxx @@ -0,0 +1,370 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dclscach.cxx +// +// Contents: Ole NTSD extension routines to display the class cache in +// the scm +// +// Functions: displayClassCache +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dclscach.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: classCacheHelp +// +// Synopsis: Prints a short help menu for !ole.cc +// +// Arguments: [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 27-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void classCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("cc - Display class cache info\n"); + Printf("local-server-path[(16)] clsid debug? [handler]\n"); + Printf(" hRpc hWnd flags PSID desktop\n"); + Printf(" ...\n"); +} + + + + +//+------------------------------------------------------------------------- +// +// Function: displayClassCache +// +// Synopsis: Displays the retail scm class cache +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 27-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayClassCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG addr; + SClassCacheList sClassCacheList; + SSkipListEntry sSkipListEntry; + SClassData sClassData; + SLocalServer sLocalServer; + SStringID sStringId; + WCHAR *pwszUni; + WCHAR wszUni[128]; + char szAnsi[128]; + SArrayFValue sArrayFValue; + SSrvRegistration *pSrvReg; + + // Read the class cache + addr = GetExpression("scm!g_pcllClassCache"); + ReadMem(&addr, addr, sizeof(ULONG)); + ReadMem(&sClassCacheList, addr, sizeof(SClassCacheList)); + + // Read the initial skiplist entry + ReadMem(&sSkipListEntry, sClassCacheList._pSkipList, + sizeof(SSkipListEntry)); + + // Do over skiplist entries + do + { + // Just in case + if (CheckControlC()) + { + return; + } + + // Read the next skiplist entry + ReadMem(&sSkipListEntry, sSkipListEntry._apBaseForward, + sizeof(SSkipListEntry)); + + // Read the CClassData structure + ReadMem(&sClassData, sSkipListEntry._pvEntry, sizeof(SClassData)); + + // Read the CLocalServer structure + ReadMem(&sLocalServer, sClassData._slocalsrv, sizeof(SLocalServer)); + + // Print the path + pwszUni = (WCHAR *) OleAlloc(sLocalServer._stringId._cPath * + sizeof(WCHAR)); + ReadMem(pwszUni, sLocalServer._stringId._pwszPath, + sLocalServer._stringId._cPath * sizeof(WCHAR)); + Unicode2Ansi(szAnsi, pwszUni, sLocalServer._stringId._cPath * + sizeof(WCHAR)); + if (sClassData._fLocalServer16) + { + Printf("%s(16) ", szAnsi); + } + else + { + Printf("%s ", szAnsi); + } + OleFree(pwszUni); + + // Print the clsid + FormatCLSID(sClassData._clsid, szAnsi); + Printf("%s ", szAnsi); + + // Whether activated under a debugger + if (sClassData._fDebug) + { + Printf("*Debug*"); + } + + // Any specified handler + if (sClassData._shandlr) + { + ReadMem(&sStringId, sClassData._shandlr, sizeof(SStringID)); + + // Print the path + pwszUni = (WCHAR *) OleAlloc(sStringId._cPath * sizeof(WCHAR)); + ReadMem(pwszUni, sStringId._pwszPath, + sStringId._cPath * sizeof(WCHAR)); + Unicode2Ansi(szAnsi, pwszUni, sStringId._cPath * + sizeof(WCHAR)); + if (sClassData._fInprocHandler16) + { + Printf("%s(16) ", szAnsi); + } + else + { + Printf("%s ", szAnsi); + } + OleFree(pwszUni); + } + + // Close the print line + Printf("\n"); + + // Read the endpoint registration array base + ReadMem(&sArrayFValue, sClassData._pssrvreg, sizeof(SArrayFValue)); + + // Read the array of endpoint registrations + pSrvReg = (SSrvRegistration *) OleAlloc(sArrayFValue.m_nSize * + sizeof(SSrvRegistration)); + ReadMem(pSrvReg, sArrayFValue.m_pData, + sArrayFValue.m_nSize * sizeof(SSrvRegistration)); + + // Do over the RPC endpoints registered for this server + for (int cReg = 0; cReg < sArrayFValue.m_nSize; cReg++) + { + // Only look at non-empty binding handles + if (pSrvReg[cReg]._hRpc) + { + // The RPC binding handle + Printf(" %x ", pSrvReg[cReg]._hRpc); + + // The window handle + Printf("%x ", pSrvReg[cReg]._ulWnd); + + // Flags + Printf("%x ", pSrvReg[cReg]._dwFlags); + + // Security Id + Printf("%x ", pSrvReg[cReg]._psid); + + // The desktop + UINT cb = 0; + + // We have to read memory one WCHAR at a time because any + // av prevents any reading + do + { + ReadMem(&wszUni[cb], &pSrvReg[cReg]._lpDesktop[cb], + sizeof(WCHAR)); + cb++; + } until_(wszUni[cb - 1] == L'\0'); + Unicode2Ansi(szAnsi, wszUni, cb); + Printf("%s\n\n", szAnsi); + } + } + } until_(sSkipListEntry._apBaseForward == sClassCacheList._pSkipList); +} + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayClassCacheCk +// +// Synopsis: Displays the checked scm class cache +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 27-Jun-95 BruceMa Created +// +// Notes: This was necessary because certain of the class cache +// structures different depending on retail vs. checked +// +//-------------------------------------------------------------------------- +void displayClassCacheCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG addr; + SClassCacheList sClassCacheList; + SSkipListEntry sSkipListEntry; + SClassDataCk sClassData; + SLocalServerCk sLocalServer; + SStringIDCk sStringId; + WCHAR *pwszUni; + WCHAR wszUni[128]; + char szAnsi[128]; + SArrayFValue sArrayFValue; + SSrvRegistration *pSrvReg; + + // Read the class cache + addr = GetExpression("scm!g_pcllClassCache"); + ReadMem(&addr, addr, sizeof(ULONG)); + ReadMem(&sClassCacheList, addr, sizeof(SClassCacheList)); + + // Read the initial skiplist entry + ReadMem(&sSkipListEntry, sClassCacheList._pSkipList, + sizeof(SSkipListEntry)); + + // Do over skiplist entries + do + { + // Just in case + if (CheckControlC()) + { + return; + } + + // Read the next skiplist entry + ReadMem(&sSkipListEntry, sSkipListEntry._apBaseForward, + sizeof(SSkipListEntry)); + + // Read the CClassData structure + ReadMem(&sClassData, sSkipListEntry._pvEntry, sizeof(SClassDataCk)); + + // Read the CLocalServer structure + ReadMem(&sLocalServer, sClassData._slocalsrv, sizeof(SLocalServerCk)); + + // Print the path + pwszUni = (WCHAR *) OleAlloc(sLocalServer._stringId._cPath * + sizeof(WCHAR)); + ReadMem(pwszUni, sLocalServer._stringId._pwszPath, + sLocalServer._stringId._cPath * sizeof(WCHAR)); + Unicode2Ansi(szAnsi, pwszUni, sLocalServer._stringId._cPath * + sizeof(WCHAR)); + if (sClassData._fLocalServer16) + { + Printf("%s(16) ", szAnsi); + } + else + { + Printf("%s ", szAnsi); + } + OleFree(pwszUni); + + // Print the clsid + FormatCLSID(sClassData._clsid, szAnsi); + Printf("%s ", szAnsi); + + // Whether activated under a debugger + if (sClassData._fDebug) + { + Printf("*Debug*"); + } + + // Any specified handler + if (sClassData._shandlr) + { + ReadMem(&sStringId, sClassData._shandlr, sizeof(SStringIDCk)); + + // Print the path + pwszUni = (WCHAR *) OleAlloc(sStringId._cPath * sizeof(WCHAR)); + ReadMem(pwszUni, sStringId._pwszPath, + sStringId._cPath * sizeof(WCHAR)); + Unicode2Ansi(szAnsi, pwszUni, sStringId._cPath * + sizeof(WCHAR)); + if (sClassData._fInprocHandler16) + { + Printf("%s(16) ", szAnsi); + } + else + { + Printf("%s ", szAnsi); + } + OleFree(pwszUni); + } + + // Close the print line + Printf("\n"); + + // Read the endpoint registration array base + ReadMem(&sArrayFValue, sClassData._pssrvreg, sizeof(SArrayFValue)); + + // Read the array of endpoint registrations + pSrvReg = (SSrvRegistration *) OleAlloc(sArrayFValue.m_nSize * + sizeof(SSrvRegistration)); + ReadMem(pSrvReg, sArrayFValue.m_pData, + sArrayFValue.m_nSize * sizeof(SSrvRegistration)); + + // Do over the RPC endpoints registered for this server + for (int cReg = 0; cReg < sArrayFValue.m_nSize; cReg++) + { + // Only look at non-empty binding handles + if (pSrvReg[cReg]._hRpc) + { + // The RPC binding handle + Printf(" %x ", pSrvReg[cReg]._hRpc); + + // The window handle + Printf("%x ", pSrvReg[cReg]._ulWnd); + + // Flags + Printf("%x ", pSrvReg[cReg]._dwFlags); + + // Security Id + Printf("%x ", pSrvReg[cReg]._psid); + + // The desktop + UINT cb = 0; + + // We have to read memory one WCHAR at a time because any + // av prevents any reading + do + { + ReadMem(&wszUni[cb], &pSrvReg[cReg]._lpDesktop[cb], + sizeof(WCHAR)); + cb++; + } until_(wszUni[cb - 1] == L'\0'); + Unicode2Ansi(szAnsi, wszUni, cb); + Printf("%s\n\n", szAnsi); + } + } + } until_(sSkipListEntry._apBaseForward == sClassCacheList._pSkipList); +} diff --git a/private/ole32/dbgexts/dclscach.h b/private/ole32/dbgexts/dclscach.h new file mode 100644 index 000000000..08b3dd3d0 --- /dev/null +++ b/private/ole32/dbgexts/dclscach.h @@ -0,0 +1,109 @@ +struct SStringID +{ + void *_vtbl; + ULONG _culRefs; + int _cPathBytes; + int _cPath; + WCHAR *_pwszPath; +}; + + + +struct SStringIDCk +{ + void *_vtbl; + ULONG _ulSig; + ULONG _culRefs; + int _cPathBytes; + int _cPath; + WCHAR *_pwszPath; +}; + + + +struct SLocalServer +{ + SStringID _stringId; + SMutexSem _mxsProcessStart; + BOOL _fDebug; +}; + + + +struct SLocalServerCk +{ + SStringIDCk _stringId; + ULONG _ulSig; + SMutexSem _mxsProcessStart; + BOOL _fDebug; +}; + + + +struct SSrvRegistration +{ + HANDLE _hRpc; + ULONG _ulWnd; + DWORD _dwFlags; + PSID _psid; + WCHAR *_lpDesktop; +}; + + + +struct SClassData +{ + LPVOID _vtbl; + CLSID _clsid; + SStringID *_shandlr; + SStringID *_sinproc; + SStringID *_sinproc16; + SLocalServer *_slocalsrv; + ULONG _fActivateAtBits:1; + ULONG _fDebug:1; + ULONG _fInprocHandler16:1; + ULONG _fLocalServer16:1; + ULONG _ulInprocThreadModel:2; + ULONG _ulHandlerThreadModel:2; + HANDLE _hClassStart; + SArrayFValue *_pssrvreg; + ULONG _ulRefs; +}; + + + +struct SClassDataCk +{ + LPVOID _vtbl; + CLSID _clsid; + SStringIDCk *_shandlr; + SStringIDCk *_sinproc; + SStringIDCk *_sinproc16; + SLocalServerCk *_slocalsrv; + ULONG _fActivateAtBits:1; + ULONG _fDebug:1; + ULONG _fInprocHandler16:1; + ULONG _fLocalServer16:1; + ULONG _ulInprocThreadModel:2; + ULONG _ulHandlerThreadModel:2; + HANDLE _hClassStart; + SArrayFValue *_pssrvreg; + ULONG _ulRefs; +}; + + + +struct SSkipListEntry +{ + DWORD _UNUSED; + SClassData *_pvEntry; + SSkipListEntry *_apBaseForward; +}; + + + +struct SClassCacheList +{ + DWORD _UNUSED[2]; + SSkipListEntry *_pSkipList; +}; diff --git a/private/ole32/dbgexts/dclsinfo.cxx b/private/ole32/dbgexts/dclsinfo.cxx new file mode 100644 index 000000000..b3d96c7bd --- /dev/null +++ b/private/ole32/dbgexts/dclsinfo.cxx @@ -0,0 +1,607 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dclassInfo.cxx +// +// Contents: Display registry class information +// +// Functions: classInfoHelp +// displayclassInfo +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +// BUGBUG: Add threading model flags + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dinfolvl.h" +#include "debnot.h" + + + +BOOL ScanCLSID(char *szClsid, CLSID *pClsid); +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + +static void GetSomeClsidValues(HKEY hKey, + char *szName, + char *szInprocHandler, + char *szInprocHandler32, + char *szInprocServer, + char *szInprocServer32, + char *szLocalServer, + char *szLocalServer32, + char *szProgid, + char *szTreatAs, + char *szAutoConvertTo, + char *szOle1Class); + +static void DisplayValues(PNTSD_EXTENSION_APIS lpExtensionApis, + char *szName, + char *szInprocHandler, + char *szInprocHandler32, + char *szInprocServer, + char *szInprocServer32, + char *szLocalServer, + char *szLocalServer32, + char *szProgid, + char *szTreatAs, + char *szAutoConvertTo, + char *szOle1Class); + +static void MungePath(char *szPath); + +static DWORD dwRESERVED = 0; + + + + +//+------------------------------------------------------------------------- +// +// Function: classInfoHelp +// +// Synopsis: Display a menu for the command 'id' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void classInfoHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("ci - Display registry class information\n"); + Printf("ci clsid - Display registry class information for clsid\n"); + +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayclassInfo +// +// Synopsis: Display/set debug info levels +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [CLSID *] - Get info for this clsid +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +BOOL displayClassInfo(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + CLSID *pClsid) +{ + HKEY hKey; + char szCLSID[CLSIDSTR_MAX]; + char szClsid[5 + 1 + CLSIDSTR_MAX]; + char szName[64]; + char szInprocHandler[64]; + char szInprocHandler32[64]; + char szInprocServer[64]; + char szInprocServer32[64]; + char szLocalServer[64]; + char szLocalServer32[64]; + char szProgid[64]; + char szTreatAs[64]; + char szAutoConvertTo[64]; + char szOle1Class[64]; + + + // Information for a specific clsid? + if (pClsid) + { + // Prepare to open the "...CLSID\<clsid>" key + FormatCLSID(*pClsid, szCLSID); + lstrcpy(szClsid, "CLSID\\"); + lstrcat(szClsid, szCLSID); + + // Open the key for the specified clsid + if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szClsid, dwRESERVED, + KEY_READ, &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + // Read interesting values for this clsid + GetSomeClsidValues(hKey, + szName, + szInprocHandler, + szInprocHandler32, + szInprocServer, + szInprocServer32, + szLocalServer, + szLocalServer32, + szProgid, + szTreatAs, + szAutoConvertTo, + szOle1Class); + + // Only display "interesting" entries + if ((szInprocHandler[0] && + _stricmp(szInprocHandler, "ole2.dll") != 0) || + (szInprocHandler32[0] && + _stricmp(szInprocHandler32, "ole32.dll") != 0) || + (szInprocServer[0] && + _stricmp(szInprocServer, "ole2.dll") != 0) || + (szInprocServer32[0] && + _stricmp(szInprocServer32, "ole32.dll") != 0) || + szLocalServer[0] || + szLocalServer32[0] || + szTreatAs[0] || + szAutoConvertTo[0]) + { + // Display them + DisplayValues(lpExtensionApis, + szName, + szInprocHandler, + szInprocHandler32, + szInprocServer, + szInprocServer32, + szLocalServer, + szLocalServer32, + szProgid, + szTreatAs, + szAutoConvertTo, + szOle1Class); + } + + // Close registry handle and return success + CloseHandle(hKey); + return TRUE; + } + + // Else display all of them + else + { + HKEY hKey2; + DWORD dwErr; + DWORD cbSubKey = 0; + char szClsid[64]; + DWORD cbClsid; + DWORD cbClass; + FILETIME sLastWrite; + + // Open the key for the root "CLSID" + if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID", dwRESERVED, + KEY_ENUMERATE_SUB_KEYS, &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + // Enumerate over the keys under "HKEY_CLASSES_ROOT\CLSID" + do + { + // Enumerate the next subkey + cbClsid = 64; + dwErr = RegEnumKeyEx(hKey, cbSubKey, szClsid, &cbClsid, + NULL, NULL, NULL, &sLastWrite); + + // Prepare for next subkey + cbSubKey++; + + // If it does look like a clsid, skip it + CLSID clsid; + + if (!ScanCLSID(szClsid, &clsid)) + { + continue; + } + + // Open this clsid key + if (RegOpenKeyEx(hKey, szClsid, dwRESERVED, + KEY_READ, &hKey2) != ERROR_SUCCESS) + { + return FALSE; + } + + // Get the interesting values + GetSomeClsidValues(hKey2, + szName, + szInprocHandler, + szInprocHandler32, + szInprocServer, + szInprocServer32, + szLocalServer, + szLocalServer32, + szProgid, + szTreatAs, + szAutoConvertTo, + szOle1Class); + + // Only display "interesting" entries + if ((szInprocHandler[0] && + _stricmp(szInprocHandler, "ole2.dll") != 0) || + (szInprocHandler32[0] && + _stricmp(szInprocHandler32, "ole32.dll") != 0) || + (szInprocServer[0] && + _stricmp(szInprocServer, "ole2.dll") != 0) || + (szInprocServer32[0] && + _stricmp(szInprocServer32, "ole32.dll") != 0) || + szLocalServer[0] || + szLocalServer32[0] || + szTreatAs[0] || + szAutoConvertTo[0]) + { + // Display the clsid + Printf("%s ", szClsid); + + // Display its values + DisplayValues(lpExtensionApis, + szName, + szInprocHandler, + szInprocHandler32, + szInprocServer, + szInprocServer32, + szLocalServer, + szLocalServer32, + szProgid, + szTreatAs, + szAutoConvertTo, + szOle1Class); + } + + // Close registry handle + CloseHandle(hKey2); + + } until_(dwErr == ERROR_NO_MORE_ITEMS || dwErr != ERROR_SUCCESS); + + // Close clsid registry handle + CloseHandle(hKey); + + return TRUE; + } +} + + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: GetSomeClsidValues +// +// Synopsis: Given an open registry key to a clsid, read some of +// the more interesting subkey values +// +// Arguments: [hkey] Open registry key +// [szName] Where to store the name +// [szInprocHandler] Where to store the InprocHandler +// [szInprocHandler32] Where to store the InprocHandler32 +// [szInprocServer] Where to store the InprocServer +// [szInprocServer32] Where to store the InprocServer32 +// [szLocalServer] Where to store the LocalServer +// [szLocalServer32] Where to store the LocalServer32 +// [ProgId] Where to store the ProgId +// [TreatAs] Where to store the TreatAs +// [AutoConvertTo] Where to store the AutoConvertTo +// [Ole1Class] Where to store the Ole1Class +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void GetSomeClsidValues(HKEY hKey, + char *szName, + char *szInprocHandler, + char *szInprocHandler32, + char *szInprocServer, + char *szInprocServer32, + char *szLocalServer, + char *szLocalServer32, + char *szProgId, + char *szTreatAs, + char *szAutoConvertTo, + char *szOle1Class) +{ + DWORD dwRESERVED = 0; + HKEY hKey2; + DWORD dwValueType; + DWORD cbValue; + + // Initialize + szName[0] = '\0'; + szInprocHandler[0] = '\0'; + szInprocHandler32[0] = '\0'; + szInprocServer[0] = '\0'; + szInprocServer32[0] = '\0'; + szLocalServer[0] = '\0'; + szLocalServer32[0] = '\0'; + szProgId[0] = '\0'; + szTreatAs[0] = '\0'; + szAutoConvertTo[0] = '\0'; + szOle1Class[0] = '\0'; + + // Name + cbValue = 64; + if (RegQueryValueEx(hKey, NULL, NULL, &dwValueType, + (LPBYTE) szName, &cbValue) != ERROR_SUCCESS) + { + return; + } + + // InprocHandler + if (RegOpenKeyEx(hKey, "InprocHandler", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szInprocHandler, &cbValue); + MungePath(szInprocHandler); + CloseHandle(hKey2); + } + + // InprocHandler32 + if (RegOpenKeyEx(hKey, "InprocHandler32", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szInprocHandler32, &cbValue); + MungePath(szInprocHandler32); + CloseHandle(hKey2); + } + + // InprocServer + if (RegOpenKeyEx(hKey, "InprocServer", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szInprocServer, &cbValue); + MungePath(szInprocServer); + CloseHandle(hKey2); + } + + // InprocServer32 + if (RegOpenKeyEx(hKey, "InprocServer32", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szInprocServer32, &cbValue); + MungePath(szInprocServer32); + CloseHandle(hKey2); + } + + // LocalServer + if (RegOpenKeyEx(hKey, "LocalServer", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szLocalServer, &cbValue); + MungePath(szLocalServer); + CloseHandle(hKey2); + } + + // LocalServer32 + if (RegOpenKeyEx(hKey, "LocalServer32", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szLocalServer32, &cbValue); + MungePath(szLocalServer32); + CloseHandle(hKey2); + } + + // ProgId + if (RegOpenKeyEx(hKey, "ProgId", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szProgId, &cbValue); + CloseHandle(hKey2); + } + + // TreatAs + if (RegOpenKeyEx(hKey, "TreatAs", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szTreatAs, &cbValue); + CloseHandle(hKey2); + } + + // AutoConvertTo + if (RegOpenKeyEx(hKey, "AutoConvertTo", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + cbValue = 64; + RegQueryValueEx(hKey2, NULL, NULL, &dwValueType, + (LPBYTE) szAutoConvertTo, &cbValue); + CloseHandle(hKey2); + } + + // Ole1Class + if (RegOpenKeyEx(hKey, "Ole1Class", dwRESERVED, + KEY_READ, &hKey2) == ERROR_SUCCESS) + { + szOle1Class[0] = '1'; + CloseHandle(hKey2); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: DisplayValues +// +// Synopsis: Display the values read above +// +// Arguments: [hkey] Open registry key +// [szName] Where to store the name +// [szInprocHandler] Where to store the InprocHandler +// [szInprocHandler32] Where to store the InprocHandler32 +// [szInprocServer] Where to store the InprocServer +// [szInprocServer32] Where to store the InprocServer32 +// [szLocalServer] Where to store the LocalServer +// [szLocalServer32] Where to store the LocalServer32 +// [ProgId] Where to store the ProgId +// [TreatAs] Where to store the TreatAs +// [AutoConvertTo] Where to store the AutoConvertTo +// [Ole1Class] Where to store the Ole1Class +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void DisplayValues(PNTSD_EXTENSION_APIS lpExtensionApis, + char *szName, + char *szInprocHandler, + char *szInprocHandler32, + char *szInprocServer, + char *szInprocServer32, + char *szLocalServer, + char *szLocalServer32, + char *szProgId, + char *szTreatAs, + char *szAutoConvertTo, + char *szOle1Class) + +{ + // Display the name + Printf("%s ", szName); + + // Display ProgId (if unique) + if (szProgId[0] && lstrcmp(szProgId, szName) != 0) + { + Printf("%s ", szProgId); + } + + // Display the server executable + if (szLocalServer[0]) + { + Printf("%s ", szLocalServer32); + } + else if (szInprocServer32[0]) + { + Printf("%s ", szInprocServer32); + } + else if (szLocalServer[0]) + { + Printf("%s(16) ", szLocalServer); + } + else if (szInprocServer[0]) + { + Printf("%s(16) ", szInprocServer); + } + + // Display handler information + if (szInprocHandler32[0] && + _stricmp(szInprocHandler32, "ole32.dll") != 0) + { + Printf("Hndlr: %s ", szInprocHandler32); + } + else if (szInprocHandler[0] && + _stricmp(szInprocHandler, "ole2.dll") != 0) + { + Printf("Hndlr: %s(16) ", szInprocHandler); + } + + // Display any TreatAs or AutoConvertTo information + if (szTreatAs[0]) + { + Printf("TA: %s", szTreatAs); + } + if (szAutoConvertTo[0]) + { + Printf("ACT: %s", szAutoConvertTo); + } + + // Check if this is an ole1 class + if (szOle1Class[0]) + { + Printf("ole1 class"); + } + + // We're done + Printf("\n"); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: MungePath +// +// Synopsis: Remove directory components from a file path +// +// Arguments: [szPath] Path to munge +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void MungePath(char *szPath) +{ + int cbLen = lstrlen(szPath); + DWORD cbPath; + + for (cbPath = cbLen; cbPath > 0 && szPath[cbPath] != '\\'; cbPath--) + { + } + if (cbPath > 0) + { + lstrcpy(szPath, &szPath[cbPath + 1]); + } +} diff --git a/private/ole32/dbgexts/ddllcach.cxx b/private/ole32/dbgexts/ddllcach.cxx new file mode 100644 index 000000000..cb1196c1f --- /dev/null +++ b/private/ole32/dbgexts/ddllcach.cxx @@ -0,0 +1,232 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: ddllcach.cxx +// +// Contents: Ole NTSD extension routines to display a dll/class cache +// +// Functions: displayDllCache +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "ddllcach.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + + +//+------------------------------------------------------------------------- +// +// Function: dllCacheHelp +// +// Synopsis: Display a menu for the command 'ds' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void dllCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("\nds - Display entire Inproc Server dll/class cache:\n"); + Printf("dh - Display entire Inproc Handler dll/class cache:\n\n"); + Printf("Dll's\n"); + Printf("-----\n"); + Printf("path hModule DllGetClassObject() DllCanUnloadNow() apt ... apt \n"); + Printf(" CLSID\n"); + Printf(" ...\n"); + Printf("...\n\n"); + Printf("LocalServers\n"); + Printf("------------\n"); + Printf("CLSID IUnknown* [M|S|MS] reg_key reg_@_scm\n"); + Printf("...\n\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayDllCache +// +// Synopsis: Formats and writes a dll/class cache structure to the +// debugger terminal +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayDllCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllCache *pDllCache) +{ + SDllPathEntry *pDllPathEntries; + SClassEntry *pClassEntries; + DWORD cbSize; + +// dbt("pDllCache", pDllCache, sizeof(SDllCache)); + + // Fetch the array of dll path entries + cbSize = sizeof(SDllPathEntry) * pDllCache->_cDllPathEntries; + pDllPathEntries = (SDllPathEntry *) OleAlloc(cbSize); + ReadMem(pDllPathEntries, pDllCache->_pDllPathEntries, cbSize); + +// dbt("pDllPathEntries", pDllPathEntries, cbSize); + + // Fetch the array of class entries + cbSize = sizeof(SClassEntry) * pDllCache->_cClassEntries; + pClassEntries = (SClassEntry *) OleAlloc(cbSize); + ReadMem(pClassEntries, pDllCache->_pClassEntries, cbSize); + +// dbt("pClassEntries", pClassEntries, cbSize); + + // We do the dll's first + Printf("Dll's:\n-----\n"); + + // Do over the registered dll's + for (DWORD dwDll = pDllCache->_nDllPathEntryInUse; dwDll != NONE; + dwDll = pDllPathEntries[dwDll]._dwNext) + { + // Fetch the dll path + WCHAR wszPath[MAX_PATH + 1]; + CHAR szPath[2 * MAX_PATH + 1]; + + // We don't know the length of the path, so read one WCHAR + // at a time + INT k = -1; + + do + { + k++; + ReadMem(&wszPath[k], &pDllPathEntries[dwDll]._pwszPath[k], + sizeof(WCHAR)); + } until_(wszPath[k] == L'\0'); + Unicode2Ansi(szPath, wszPath, 2 * MAX_PATH + 1); + + // Fetch the apartment entries for this dll path entry + SDllAptEntry *pAptEntries; + + cbSize = sizeof(SDllAptEntry) * pDllPathEntries[dwDll]._cAptEntries; + pAptEntries = (SDllAptEntry *) OleAlloc(cbSize); + ReadMem(pAptEntries, pDllPathEntries[dwDll]._pAptEntries, + cbSize); + +// dbt("pAptEntries", pAptEntries, cbSize); + + // Display path + Printf("%s ", szPath); + + // Display hModule and DllGetClassObject and DllCanUnloadNow entry + // points + Printf("%08x %08x %08x ", + pAptEntries[pDllPathEntries[dwDll]._nAptInUse]._hDll, + pDllPathEntries[dwDll]._pfnGetClassObject, + pDllPathEntries[dwDll]._pfnDllCanUnload); + + // Display apartment id's + for (DWORD dwApt = pDllPathEntries[dwDll]._nAptInUse; dwApt != NONE; + dwApt = pAptEntries[dwApt]._dwNext) + { + Printf("%x ", pAptEntries[dwApt]._hApt); + } + Printf("\n"); + + // Do over CLSID's for this dll + for (DWORD dwCls = pDllPathEntries[dwDll]._dw1stClass; dwCls != NONE; + dwCls = pClassEntries[dwCls]._dwNextDllCls) + { + // Display the CLSID + CHAR szClsid[CLSIDSTR_MAX]; + + FormatCLSID(pClassEntries[dwCls]._clsid, szClsid); + Printf(" %s \n", szClsid); + } + + // Release the apartment entries for this dll + OleFree(pAptEntries); + + Printf("\n"); + } + + // Release the array of dll path entries + OleFree(pDllPathEntries); + + + + // Then we do the local servers + Printf("Local Servers:\n----------\n"); + + // Do over the locally registerd local servers + for (DWORD dwCls = pDllCache->_nClassEntryInUse; dwCls != NONE; + dwCls = pClassEntries[dwCls]._dwNext) + { + // Skip class entries associated with dll's + if (pClassEntries[dwCls]._dwDllEnt == NONE) + { + // Display the CLSID + CHAR szClsid[CLSIDSTR_MAX]; + + FormatCLSID(pClassEntries[dwCls]._clsid, szClsid); + Printf(" %s ", szClsid); + + // The class factory punk + Printf("%08x ", pClassEntries[dwCls]._pUnk); + + // The flags + if (pClassEntries[dwCls]._dwFlags == REGCLS_SINGLEUSE) + { + Printf("S "); + } + else if (pClassEntries[dwCls]._dwFlags == REGCLS_MULTIPLEUSE) + { + Printf("M "); + } + else if (pClassEntries[dwCls]._dwFlags == REGCLS_MULTI_SEPARATE) + { + Printf("MS "); + } + + // The registration key given to the user + Printf("%08x ", pClassEntries[dwCls]._dwReg); + + // The registration key at the scm + Printf("%08x ", pClassEntries[dwCls]._dwScmReg); + + // Whether this is an AtBits server + if (pClassEntries[dwCls]._fAtBits) + { + Printf("AtBits\n"); + } + else + { + Printf("\n"); + } + } + } + + Printf("\n"); + + // Release the array of class entries + OleFree(pClassEntries); +} diff --git a/private/ole32/dbgexts/ddllcach.h b/private/ole32/dbgexts/ddllcach.h new file mode 100644 index 000000000..16c4a2b9b --- /dev/null +++ b/private/ole32/dbgexts/ddllcach.h @@ -0,0 +1,99 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: ddllcach.h +// +// Contents: Contains structure definitons for the significant dll class/ +// cache ole classes which the ntsd extensions need to access. +// These ole classes cannot be accessed more cleanly because +// typically the members of interest are protected. +// +// WARNING. IF THE REFERENCED OLE CLASSES CHANGE, THEN THESE +// DEFINITIONS MUST CHANGE! +// +// History: 06-01-95 BruceMa Created +// +//-------------------------------------------------------------------------- + + +typedef HRESULT (*DLLUNLOADFNP)(void); + +const DWORD NONE = ~0UL; + + +struct SClassEntry +{ + DWORD _fAtBits; // Whether server is an at bits server + DWORD _dwNext; // Next entry in in-use or avail list + DWORD _dwSig; // Marks entry as in use + CLSID _clsid; // Class of this server + IUnknown *_pUnk; // Class factory IUnknown + DWORD _dwContext; // Class context + DWORD _dwFlags; // Single vs. multiple use + DWORD _dwReg; // Registration key for caller + DWORD _dwScmReg; // Registration ID at the SCM + HAPT _hApt; // Thread Id + DWORD _cCallOut; // Count of active call outs + DWORD _fRevokePending;// Whether revoked while calling out + DWORD _dwDllEnt; // Associated dll path entry + DWORD _dwNextDllCls; // Next class entrry for this dll + HWND _hWndDdeServer; // Handle of associated DDE window +}; + + + + + +struct SDllAptEntry +{ + DWORD _dwNext; // Next entry in avail or in use list + DWORD _dwSig; // Unique signature for apt entries + HAPT _hApt; // apartment id + HMODULE _hDll; // module handle +}; + + + + + +struct SDllPathEntry +{ + DWORD _dwNext; // Next in-use/avail entry + DWORD _dwSig; // Unique signature for safty + LPWSTR _pwszPath; // The dll pathname + DWORD _dwHash; // Hash value for searching + LPFNGETCLASSOBJECT _pfnGetClassObject; // Create object entry point + DLLUNLOADFNP _pfnDllCanUnload; // DllCanUnloadNow entry point + DWORD _dwFlags; // Internal flags + DWORD _dwDllThreadModel:2; // Threading model for the DLL + DWORD _dw1stClass; // First class entry for dll + DWORD _cUsing; // Count of using threads + DWORD _cAptEntries; // Total apt entries + DWORD _nAptAvail; // List of available apt entries + DWORD _nAptInUse; // List of in use apt entries + SDllAptEntry *_pAptEntries; // Per thread info +}; + + + + +struct SDllCache +{ + SMutexSem _mxsLoadLibrary; // Protects LoadLibrary calls + SMutexSem _mxs; // Protects from multiple threads + DWORD _cClassEntries; // Count of class entries + DWORD _nClassEntryInUse; // First in-use class entry + DWORD _nClassEntryAvail; // First available class entry + SClassEntry *_pClassEntries; // Array of class entries + DWORD _cDllPathEntries; // Count of dll path entries + DWORD _nDllPathEntryInUse; // First in-use dll path entry + DWORD _nDllPathEntryAvail; // First available dll path entry + SDllPathEntry *_pDllPathEntries; // Array of DLL path entries +}; + + + + + diff --git a/private/ole32/dbgexts/derror.cxx b/private/ole32/dbgexts/derror.cxx new file mode 100644 index 000000000..cd0275afc --- /dev/null +++ b/private/ole32/dbgexts/derror.cxx @@ -0,0 +1,135 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: derror.cxx +// +// Contents: Ole NTSD extension routines to display the error +// message for a Win32 or OLE error code +// +// Functions: displayVtbl +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayHr +// +// Synopsis: Display the mnesage for a Win32 error or OLE HRESULT +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayHr (HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg) +{ + DWORD err = 0; + BOOL fHex = FALSE; + + // Determine if it's hex or decimal. Also allow '800xxxxx' to implicitly + // be treated as hexadecimal + if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X')) + { + fHex = TRUE; + arg += 2; + } + else if (arg[0] == '8' && arg[1] == '0' && arg[2] == '0') + { + fHex = TRUE; + } + else + { + char *s = arg; + + while (*s) + { + if (('a' <= *s && *s <= 'f') || ('A' <= *s && *s <= 'F')) + { + fHex = TRUE; + break; + } + s++; + } + } + + // Parse the error number + if (fHex) + { + int k = 0; + char c; + + while (c = arg[k++]) + { + c = c - '0'; + if (c > 9) + { + if (c <= 'F' && c >= 'A') + { + c = c + '0' - 'A' + 10; + } + else + { + c = c + '0' - 'a' + 10; + } + } + err = (16 * err) + c; + } + } + else + { + int k = 0; + char c; + + while (c = arg[k++]) + { + c = c - '0'; + err = (10 * err) + c; + } + } + + // Fetch the associated error message + int cbMsgLen; + char szBuffer[512]; + + cbMsgLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + (DWORD) NULL, + szBuffer, + 511, + NULL); + + // Output the message + if (cbMsgLen == 0) + { + Printf("...No such error code\n"); + } + else + { + szBuffer[cbMsgLen] = '\0'; + Printf("%s\n", szBuffer); + } +} diff --git a/private/ole32/dbgexts/dfileext.cxx b/private/ole32/dbgexts/dfileext.cxx new file mode 100644 index 000000000..de0cca61e --- /dev/null +++ b/private/ole32/dbgexts/dfileext.cxx @@ -0,0 +1,158 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dfileext.cxx +// +// Contents: Ole NTSD extension routines to dump the clsid/file extensions +// cache +// +// Functions: fileExtHelp +// displayFileExtTbl +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dshrdmem.h" + + + + +BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2); +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: fileExtHelp +// +// Synopsis: Display a menu for the command 'fe' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void fileExtHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("fe - Display entire file extensions table\n"); + Printf("fe clsid - Display file extensions for clsid\n"); + Printf("fe .ext - Display clsid for file extension ext\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayFileExtTbl +// +// Synopsis: Display some or all of the file extensions table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [lpFileExtTbl] - Address of file extensions table +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayFileExtTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + CLSID *pClsid, + WCHAR *wszExt) +{ + SDllShrdTbl sDllTbl; + SExtTblHdr *pExtTblHdr; + SExtTblHdr sExtTblHdr; + BYTE *pExtEntry; + LPVOID pEnd; + CLSID oldClsid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + + // Read the shared table locally + ReadMem(&sDllTbl, pShrdTbl, sizeof(SDllShrdTbl)); + + // Read the table header locally + pExtTblHdr = sDllTbl._FileExtTbl._pTblHdr; + ReadMem(&sExtTblHdr, pExtTblHdr, sizeof(SExtTblHdr)); + + // Set up to read the entries + pExtEntry = sDllTbl._FileExtTbl._pStart; + pEnd = pExtEntry + sExtTblHdr.OffsEnd - sizeof(SExtTblHdr); + + // Do over the file extension entries + while (pExtEntry < pEnd) + { + ULONG ulLen; + SExtEntry sExtEnt; + WCHAR slop[16]; + char szClsid[CLSIDSTR_MAX]; + BOOL fNL = FALSE; + + // Just in case the loop gets away from us + if (CheckControlC()) + { + return; + } + + // Read the length of this entry + ReadMem(&ulLen, pExtEntry + sizeof(CLSID), sizeof(ULONG)); + + // Read the next entry locally + ReadMem(&sExtEnt, pExtEntry, ulLen); + + // Print the clsid if dumping the whole table or searching by + // extension + if ((pClsid == NULL && wszExt == NULL) || + (wszExt && !lstrcmpW(wszExt, sExtEnt.wszExt))) + { + FormatCLSID(sExtEnt.Clsid, szClsid); + Printf("%s ", szClsid); + + // Save the clisd + oldClsid = sExtEnt.Clsid; + + // Remember to printf a newline + fNL = TRUE; + } + + // Print the extension if dumping the whole table or seraching + // by clsid + if ((pClsid == NULL && wszExt == NULL) || + (pClsid && IsEqualCLSID(&sExtEnt.Clsid, pClsid))) + { + // Print the associated file extension + Printf("%ws ", sExtEnt.wszExt); + + // Remember to printf a newline + fNL = TRUE; + } + + // Check if we need to print a newline + if (fNL) + { + Printf("\n"); + fNL = FALSE; + } + + // Go to the next entry + pExtEntry += ulLen; + } +} diff --git a/private/ole32/dbgexts/dfilepat.cxx b/private/ole32/dbgexts/dfilepat.cxx new file mode 100644 index 000000000..6508e0709 --- /dev/null +++ b/private/ole32/dbgexts/dfilepat.cxx @@ -0,0 +1,162 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dfilepat.cxx +// +// Contents: Ole NTSD extension routines to dump the file type (bit +// patterns) cache +// +// Functions: filePatHelp +// displayFilePatTbl +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dshrdmem.h" + + + + +BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2); +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: filePatHelp +// +// Synopsis: Display a menu for the command 'ft' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void filePatHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("ft - Display entire file type patterns table\n"); + Printf("ft clsid - Display file type patterns for clsid\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayFilePatTbl +// +// Synopsis: Display some or all of the file type patterns table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [lpFileExtTbl] - Address of file extensions table +// [pClsid] - Only for this clsid +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayFilePatTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + CLSID *pClsid) +{ + SDllShrdTbl sDllTbl; + STblHdr *pTblHdr; + STblHdr sTblHdr; + BYTE *pStart; + LPVOID pEnd; + CLSID oldClsid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + UINT ulCnt = 0; + + + // Read the shared table locally + ReadMem(&sDllTbl, pShrdTbl, sizeof(SDllShrdTbl)); + + // Read the table header locally + pTblHdr = sDllTbl._PatternTbl._pTblHdr; + ReadMem(&sTblHdr, pTblHdr, sizeof(STblHdr)); + + // Set up to read the entries + pStart = sDllTbl._PatternTbl._pStart; + pEnd = pStart + sTblHdr.OffsEnd - sizeof(STblHdr); + + // Do over the file extension entries + while (pStart < pEnd) + { + ULONG ulLen; + SPatternEntry sPatEnt; + char szClsid[CLSIDSTR_MAX]; + + // Just in case the loop gets away from us + if (CheckControlC()) + { + return; + } + + // Read the length of this entry + ReadMem(&ulLen, pStart + sizeof(CLSID), sizeof(ULONG)); + + // Read the next entry locally + ReadMem(&sPatEnt, pStart, ulLen); + + // Print the clsid if we haven't yet + if (pClsid == NULL && !IsEqualCLSID(&sPatEnt.clsid, &oldClsid)) + { + FormatCLSID(sPatEnt.clsid, szClsid); + Printf("\n%s\n", szClsid); + + // Save the clisd + oldClsid = sPatEnt.clsid; + + // Initialize a count per clsid + ulCnt = 0; + } + + // Print only if printing the whole table or at our sought clsid + if (pClsid == NULL || IsEqualCLSID(pClsid, &sPatEnt.clsid)) + { + // Print the index of this pattern + Printf("%2d ", ulCnt++); + + // Print the file offset + Printf("%d\t", sPatEnt.lFileOffset); + + // Print the length of the pattern in bytes + Printf("%3d ", sPatEnt.ulCb); + + // Print the mask + for (UINT k = 0; k < sPatEnt.ulCb; k++) + { + Printf("%02x", sPatEnt.abData[k]); + } + Printf(" "); + + // Print the pattern + for (k = 0; k < sPatEnt.ulCb; k++) + { + Printf("%02x", sPatEnt.abData[sPatEnt.ulCb + k]); + } + Printf("\n"); + } + + // Go to the next entry + pStart += ulLen; + } +} diff --git a/private/ole32/dbgexts/dinfolvl.cxx b/private/ole32/dbgexts/dinfolvl.cxx new file mode 100644 index 000000000..5b4644215 --- /dev/null +++ b/private/ole32/dbgexts/dinfolvl.cxx @@ -0,0 +1,320 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dinfoLevel.cxx +// +// Contents: Display and/or set vaious debug info levels +// +// Functions: infoLevelHelp +// displayInfoLevel +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dinfolvl.h" +#include "debnot.h" + + +void getArgument(LPSTR *lpArgumentString, LPSTR a); +ULONG ScanAddr(char *lpsz); + +static void initInfoLevels(PNTSD_EXTENSION_APIS lpExtensionApis); +static BOOL parseVal(char *arg, ULONG *val); + + + +STable1 debFlags[NUMDEBFLAGS] = {{"error", DEB_ERROR}, + {"warn", DEB_WARN}, + {"trace", DEB_TRACE}, + {"dbgout", DEB_DBGOUT}, + {"stdout", DEB_STDOUT}, + {"ierror", DEB_IERROR}, + {"iwarn", DEB_IWARN}, + {"itrace", DEB_ITRACE}, + {"user1", DEB_USER1}, + {"user2", DEB_USER2}, + {"user3", DEB_USER3}, + {"user4", DEB_USER4}, + {"user5", DEB_USER5}, + {"user6", DEB_USER6}, + {"user7", DEB_USER7}, + {"user8", DEB_USER8}, + {"user9", DEB_USER9}, + {"user10", DEB_USER10}, + {"user11", DEB_USER11}, + {"user12", DEB_USER12}, + {"user13", DEB_USER13}, + {"user14", DEB_USER14}, + {"user15", DEB_USER15}}; + + +STable2 infoLevel[NUMINFOLEVELS] = {{"com", NULL, "ole32!_CairoleInfoLevel"}, + {"dd", NULL, "ole32!_DDInfoLevel"}, + {"hep", NULL, "ole32!_heapInfoLevel"}, + {"hk", NULL, "ole32!_hkInfoLevel"}, + {"int", NULL, "ole32!_intrInfoLevel"}, + {"le", NULL, "ole32!_LEInfoLevel"}, + {"mem", NULL, "ole32!_memInfoLevel"}, + {"mnk", NULL, "ole32!_mnkInfoLevel"}, + {"msf", NULL, "ole32!_msfInfoLevel"}, + {"ol", NULL, "ole32!_olInfoLevel"}, + {"ref", NULL, "ole32!_RefInfoLevel"}, + {"sim", NULL, "ole32!_simpInfoLevel"}, + {"stk", NULL, "ole32!_StackInfoLevel"}, + {"usr", NULL, "ole32!_UserNdrInfoLevel"}}; + + + + + + +//+------------------------------------------------------------------------- +// +// Function: infoLevelHelp +// +// Synopsis: Display a menu for the command 'id' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void infoLevelHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("in - Display current value of all debug info levels\n"); + Printf("in x - Display the current value of debug info level x\n"); + Printf("in x y z ... - Set the value of debug info level x to\n"); + Printf(" y | z | ... \n"); + Printf("\nwhere x corresponds to:\n"); + Printf(" --- --------------\n"); + Printf(" com ole32!_CairoleInfoLevel\n"); + Printf(" dd ole32!_DDInfoLevel\n"); + Printf(" hep ole32!_heapInfoLevel\n"); + Printf(" hk ole32!_hkInfoLevel\n"); + Printf(" int ole32!_intrInfoLevel\n"); + Printf(" le ole32!_LEInfoLevel\n"); + Printf(" mem ole32!_memInfoLevel\n"); + Printf(" mnk ole32!_mnkInfoLevel\n"); + Printf(" msf ole32!_msfInfoLevel\n"); + Printf(" ol ole32!_olInfoLevel\n"); + Printf(" ref ole32!_RefInfoLevel\n"); + Printf(" sim ole32!_simpInfoLevel\n"); + Printf(" stk ole32!_StackInfoLevel\n"); + Printf(" ndr ole32!_UserNdrInfoLevel\n"); + Printf("\nand y... corresponds to:\n"); + Printf(" ---- --------------\n"); + Printf(" error DEB_ERROR\n"); + Printf(" warn DEB_WARN\n"); + Printf(" trace DEB_TRACE\n"); + Printf(" dbgout DEB_DBGOUT\n"); + Printf(" stdout DEB_STDOUT\n"); + Printf(" ierror DEB_IERROR\n"); + Printf(" iwarn DEB_IWARN\n"); + Printf(" itrace DEB_ITRACE\n"); + Printf(" user1 DEB_USER1\n"); + Printf(" user2 DEB_USER2\n"); + Printf(" user3 DEB_USER3\n"); + Printf(" user4 DEB_USER4\n"); + Printf(" user5 DEB_USER5\n"); + Printf(" user6 DEB_USER6\n"); + Printf(" user7 DEB_USER7\n"); + Printf(" user8 DEB_USER8\n"); + Printf(" user9 DEB_USER9\n"); + Printf(" user10 DEB_USER10\n"); + Printf(" user11 DEB_USER11\n"); + Printf(" user12 DEB_USER12\n"); + Printf(" user13 DEB_USER13\n"); + Printf(" user14 DEB_USER14\n"); + Printf(" user15 DEB_USER15\n"); + Printf(" <hex>\n"); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayInfoLevel +// +// Synopsis: Display/set debug info levels +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [char *] - Command line argument(s) +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayInfoLevel(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + LPSTR lpArgumentString) +{ + Arg arg; + UINT k; + ULONG val; + ULONG argVal; + BOOL fSet = FALSE; + + // Fetch the addresses for the various debug info levels + initInfoLevels(lpExtensionApis); + + // Fetch the first argument + GetArg(arg); + Printf("%s %s\n", arg, lpArgumentString); + + // If no argument simply display all info levels + if (!arg[0]) + { + for (k = 0; k < NUMINFOLEVELS; k++) + { + ReadMem(&val, infoLevel[k].adr, sizeof(ULONG)); + Printf("%s\t%08x\n", infoLevel[k].name, val); + } + + return; + } + + // Check the info level name + for (k = 0; k < NUMINFOLEVELS; k++) + { + if (lstrcmp(arg, infoLevel[k].name) == 0) + { + break; + } + } + if (k == NUMINFOLEVELS) + { + Printf("...unknown debug info level name\n"); + return; + } + + // Scan any values to set + val = 0; + for (GetArg(arg); *arg; GetArg(arg)) + { + if (!parseVal(arg, &argVal)) + { + Printf("...invalid flag expresson\n"); + return; + } + val |= argVal; + fSet = TRUE; + } + + // If only an info level name, then display its value + if (!fSet) + { + ReadMem(&val, infoLevel[k].adr, sizeof(ULONG)); + Printf("%s\t%08x\n", infoLevel[k].name, val); + return; + } + + // Otherwise we're setting an info level + WriteMem(infoLevel[k].adr, &val, sizeof(ULONG)); + Printf("%s\t%08x\n", infoLevel[k].name, val); +} + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: initInfoLevels +// +// Synopsis: Find the addresses of the various infolevels +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void initInfoLevels(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + // Check whether already initialized + if (infoLevel[0].adr != NULL) + { + return; + } + + // Do over the info levels + for (UINT k = 0; k < NUMINFOLEVELS; k++) + { + infoLevel[k].adr = GetExpression(infoLevel[k].symbol); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: parseVal +// +// Synopsis: Parse the next flag expression on the command line +// +// Arguments: [char *] - Command line +// [ULONG *] - Where to return the parsed value +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static BOOL parseVal(char *arg, ULONG *val) +{ + UINT k; + + // Check whether it's a flag name + for (k = 0; k < NUMDEBFLAGS; k++) + { + if (lstrcmp(arg, debFlags[k].name) == 0) + { + *val = debFlags[k].flag; + return TRUE; + } + } + + // It's not so it better be hex + k = 0; + if (arg[0] == '0' && arg[1] == 'x') + { + k += 2; + } + while (arg[k]) + { + if (!(('0' <= arg[k] && arg[k] <= '9') || + ('a' <= arg[k] && arg[k] <= 'f'))) + { + return FALSE; + } + k++; + } + *val = ScanAddr(arg); + return TRUE; +} diff --git a/private/ole32/dbgexts/dinfolvl.h b/private/ole32/dbgexts/dinfolvl.h new file mode 100644 index 000000000..acaa1a0c0 --- /dev/null +++ b/private/ole32/dbgexts/dinfolvl.h @@ -0,0 +1,53 @@ +// Because these are not defined in retail mode +#if DBG == 0 +# define DEB_ERROR 0x00000001 // exported error paths +# define DEB_WARN 0x00000002 // exported warnings +# define DEB_TRACE 0x00000004 // exported trace messages + +# define DEB_DBGOUT 0x00000010 // Output to debugger +# define DEB_STDOUT 0x00000020 // Output to stdout + +# define DEB_IERROR 0x00000100 // internal error paths +# define DEB_IWARN 0x00000200 // internal warnings +# define DEB_ITRACE 0x00000400 // internal trace messages + +# define DEB_USER1 0x00010000 // User defined +# define DEB_USER2 0x00020000 // User defined +# define DEB_USER3 0x00040000 // User defined +# define DEB_USER4 0x00080000 // User defined +# define DEB_USER5 0x00100000 // User defined +# define DEB_USER6 0x00200000 // User defined +# define DEB_USER7 0x00400000 // User defined +# define DEB_USER8 0x00800000 // User defined +# define DEB_USER9 0x01000000 // User defined +# define DEB_USER10 0x02000000 // User defined +# define DEB_USER11 0x04000000 // User defined +# define DEB_USER12 0x08000000 // User defined +# define DEB_USER13 0x10000000 // User defined +# define DEB_USER14 0x20000000 // User defined +# define DEB_USER15 0x40000000 // User defined +#endif + + +const UINT MAXDEBFLAG = 8; +const UINT NUMDEBFLAGS = 23; +const UINT NUMINFOLEVELS = 14; +const UINT MAXSYMBOL = 32; + + +struct STable1 +{ + char name[MAXDEBFLAG]; + ULONG flag; +}; + + + + +struct STable2 +{ + char name[4]; + ULONG adr; + char symbol[MAXSYMBOL]; +}; + diff --git a/private/ole32/dbgexts/dipid.cxx b/private/ole32/dbgexts/dipid.cxx new file mode 100644 index 000000000..2ab1eb344 --- /dev/null +++ b/private/ole32/dbgexts/dipid.cxx @@ -0,0 +1,341 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dipid.cxx +// +// Contents: Ole NTSD extension routines to display CIPID table +// +// Functions: ipidHelp +// displayIpid +// +// +// History: 21-Aug-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dipid.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); +BOOL GetRegistryInterfaceName(REFIID iid, char *szValue, DWORD *pcbValue); +ULONG ScanAddr(char *lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: ipidHelp +// +// Synopsis: Display a menu for the command 'id' +// +// Arguments: - +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void ipidHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("\nip - Display entire IPID table:\n"); + Printf("index IPID oxidAddr nextIPIDsameObj\n"); + Printf("...\n\n"); + Printf("ip ipid - Display specific IPID entry:\n"); + Printf("PID TID seq IID ChnlBfr* prxy/stub realPv oxidAddr flags strongRefs weakRefs nextIPIDsameObj\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayIpid +// +// Synopsis: Display the entire IPID table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayIpid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG pAdr; + ULONG pStart; + ULONG pEnd; + UINT cPages; + SIPIDEntry **pIndexTable; + SIPIDEntry sIPIDentry[IPIDsPerPage]; + SOXIDEntry sOXIDentry; + char szGuid[CLSIDSTR_MAX]; + + + // Read the IPID page index table + pAdr = GetExpression("ole32!CIPIDTable___pTbl"); + ReadMem(&pStart, pAdr, sizeof(SIPIDEntry **)); + pAdr = GetExpression("ole32!CIPIDTable___pTblEnd"); + ReadMem(&pEnd, pAdr, sizeof(SIPIDEntry **)); + cPages = (pEnd - pStart) / sizeof(SIPIDEntry **); + pIndexTable = (SIPIDEntry **) OleAlloc(cPages * sizeof(SIPIDEntry *)); + ReadMem(pIndexTable, pStart, cPages * sizeof(SIPIDEntry *)); + + // Do over IPID entry pages + for (UINT k = 0; k < cPages; k++) + { + // Read the next page of IPID entries + ReadMem(sIPIDentry, pIndexTable[k], IPIDTBL_PAGESIZE); + + // Do over entries within this page + for (UINT j = 0; j < IPIDsPerPage; j++) + { + // Only look at non-vacant entries + if (!(sIPIDentry[j].dwFlags & IPIDF_VACANT)) + { + // Print the page/offset for this entry + Printf("%d.%d ", k, j); + + // Print the IPID + if (sIPIDentry[j].ipid.page > 1000 || + sIPIDentry[j].ipid.page < 0) + { + FormatCLSID((GUID &) sIPIDentry[j].ipid, szGuid); + Printf("%s ", szGuid); + } + else + { + Printf("[%d.%d %3x %3x %d] ", + sIPIDentry[j].ipid.page, + sIPIDentry[j].ipid.offset, + sIPIDentry[j].ipid.pid, + sIPIDentry[j].ipid.tid, + sIPIDentry[j].ipid.seq); + } + + // Print the associated OXID addr + Printf("%x ", sIPIDentry[j].pOXIDEntry); + + // Next IPID for this object + if (sIPIDentry[j].iNextOID != -1) + { + Printf("%d.%d\n", + sIPIDentry[j].iNextOID >> 16, + sIPIDentry[j].iNextOID & 0xffff); + } + else + { + Printf("NULL\n"); + } + } + } + } + + // Release resources + OleFree(pIndexTable); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayIpidEntry +// +// Synopsis: Display an entry in the IPID table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [arg] - IPID of entry to display +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayIpidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg) +{ + char *s; + IPID ipid; + ULONG ppIPIDentry;; + SIPIDEntry *pIPIDentry; + SIPIDEntry sIPIDentry; + char szGuid[CLSIDSTR_MAX]; + SOXIDEntry sOXID; + + + // Check for help + if (arg[0] == '?') + { + Printf("PID TID seq IID ChnlBfr* prxy/stub realPv oxidAddr flags strongRefs weakRefs nextIPIDsameObj\n"); + return; + } + + // arg may be either page.offset or a hex address + BOOL fAdr = TRUE; + for (s = arg; *s; s++) + { + if (*s == '.') + { + fAdr = FALSE; + } + } + + // The argument is a hex address + if (fAdr) + { + pIPIDentry = (SIPIDEntry *) ScanAddr(arg); + } + + // The argment has the form page.offset + else + { + // Make sure the argument looks like an IPID + BOOL fOk = TRUE; + UINT cPoint = 0; + if (!IsDecimal(arg[0])) + { + fOk = FALSE; + } + for (s = arg; *s; s++) + { + if (*s != '.' && !IsDecimal(*s)) + { + fOk = FALSE; + } + if (*s == '.') + { + cPoint++; + } + } + if (!IsDecimal(*(s - 1))) + { + fOk = FALSE; + } + if (!(fOk && cPoint == 1)) + { + Printf("...%s is not an IPID\n", arg); + return; + } + + // Convert the argument to an IPID + for (ipid.page = 0; *arg && *arg != '.'; arg++) + { + ipid.page = 10 * ipid.page + *arg - '0'; + } + for (arg++, ipid.offset = 0; *arg; arg++) + { + ipid.offset = 10 * ipid.offset + *arg - '0'; + } + + // Read the address of the page containing the entry we want + ppIPIDentry = GetExpression("ole32!CIPIDTable___pTbl"); + ReadMem(&ppIPIDentry, ppIPIDentry, sizeof(SIPIDEntry **)); + ppIPIDentry += ipid.page * sizeof(SIPIDEntry **); + ReadMem(&pIPIDentry, ppIPIDentry, sizeof(SIPIDEntry *)); + + // Compute the address of the entry we're seeking + pIPIDentry += ipid.offset; + } + + // Now read the entry + ReadMem(&sIPIDentry, pIPIDentry, sizeof(SIPIDEntry)); + + // Check whether the entry is vacant + if (sIPIDentry.dwFlags & IPIDF_VACANT) + { + Printf("VACANT\n"); + return; + } + + // The ipid may just be a GUID; e.g. client side scm interfaces + if (sIPIDentry.ipid.page >> 1000 || sIPIDentry.ipid.page < 0) + { + FormatCLSID((GUID &) sIPIDentry.ipid, szGuid); + Printf("%s ", szGuid); + } + else + { + // Server PID + Printf("%3x ", sIPIDentry.ipid.pid); + + // Server TID + Printf("%3x ", sIPIDentry.ipid.tid); + + // Sequence number + Printf("%d ", sIPIDentry.ipid.seq); + } + + // IID + DWORD cbValue; + if (!GetRegistryInterfaceName(sIPIDentry.iid, szGuid, &cbValue)) + { + FormatCLSID(sIPIDentry.iid, szGuid); + } + Printf("%s ", szGuid); + + // CRpcChannelBuffer * + Printf("%x ", sIPIDentry.pChnl); + + // Address of proxy/stub + Printf("%x ", sIPIDentry.pStub); + + // Real interface pinter + Printf("%x ", sIPIDentry.pv); + + // Associated OXID + Printf("%x ", sIPIDentry.pOXIDEntry); + + // Flags + if (sIPIDentry.dwFlags & IPIDF_CONNECTING) + { + Printf("C"); + } + if (sIPIDentry.dwFlags & IPIDF_DISCONNECTED) + { + Printf("D"); + } + if (sIPIDentry.dwFlags & IPIDF_SERVERENTRY) + { + Printf("S"); + } + if (sIPIDentry.dwFlags & IPIDF_NOPING) + { + Printf("N"); + } + Printf(" ole32!CCacheEnum__Skip+0x82"); + + // Strong references + Printf("%d ", sIPIDentry.cStrongRefs); + + // Weak references + Printf("%d ", sIPIDentry.cWeakRefs); + + // Next IPID for this object (if any) + if (sIPIDentry.iNextOID != -1) + { + Printf("%d.%d\n", + sIPIDentry.iNextOID >> 16, + sIPIDentry.iNextOID & 0xffff); + } + else + { + Printf("NULL\n"); + } +} diff --git a/private/ole32/dbgexts/dipid.h b/private/ole32/dbgexts/dipid.h new file mode 100644 index 000000000..3bdba1c06 --- /dev/null +++ b/private/ole32/dbgexts/dipid.h @@ -0,0 +1,107 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dipid.h +// +// Contents: Contains structure definitons for the significant OXID and +// IPID structures which the ntsd extensions need to access. +// These ole classes cannot be accessed more cleanly because +// typically the members of interest are protected. +// +// WARNING. IF THE REFERENCED OLE CLASSES CHANGE, THEN THESE +// DEFINITIONS MUST CHANGE! +// +// History: 08-11-95 BruceMa Created +// +//-------------------------------------------------------------------------- + + + +typedef GUID OXID; + + +struct IPID +{ + WORD offset; // These are reversed because of little-endian + WORD page; // These are reversed because of little-endian + DWORD pid; + DWORD tid; + DWORD seq; +}; + + +struct STRINGARRAY +{ + unsigned long size; + unsigned short awszStringArray[1]; +}; + + + +struct SOXIDEntry +{ + struct SOXIDEntry *pPrev; // previous entry on inuse list + struct SOXIDEntry *pNext; // next entry on free/inuse list + DWORD dwPid; // process id of server + DWORD dwTid; // thread id of server + OXID oxid; // object exporter identifier + STRINGARRAY *psa; // ptr to server obj exp string arrary + DWORD dwFlags; // state flags + handle_t hServer; // rpc binding handle of server + void *pRU; // proxy for Remote Unknown + IPID ipidRundown;// IPID of IRundown and Remote Unknown + LONG cRefs; // count of IPIDs using this OXIDEntry +}; + + + + +typedef enum tagOXIDFLAGS +{ + OXIDF_REGISTERED = 1, // oxid is registered with Resolver + OXIDF_MACHINE_LOCAL = 2, // oxid is local to this machine + OXIDF_STOPPED = 4, // thread can no longer receive calls + OXIDF_PENDINGRELEASE= 8 // oxid entry is already being released +} OXIDFLAGS; + + +#define OXIDTBL_PAGESIZE 4096 + + +// Forward reference +struct SRpcChannelBuffer; + + +struct SIPIDEntry +{ + IPID ipid; // interface pointer identifier + IID iid; // interface iid + SRpcChannelBuffer *pChnl; // channel pointer + IUnknown *pStub; // proxy or stub pointer + void *pv; // real interface pointer + SOXIDEntry *pOXIDEntry; // ptr to OXIDEntry in OXID Table + DWORD dwFlags; // flags (see IPIDFLAGS) + ULONG cStrongRefs;// strong reference count + ULONG cWeakRefs; // weak reference count + LONG iNextOID; // next entry in this table for same object +}; + + + +typedef enum tagIPIDFLAGS +{ + IPIDF_CONNECTING = 1, // ipid is being connected + IPIDF_DISCONNECTED = 2, // ipid is disconnected + IPIDF_SERVERENTRY = 4, // SERVER IPID vs CLIENT IPID + IPIDF_NOPING = 8, // dont need to ping the server or release + IPIDF_VACANT = 128 // entry is vacant (ie available to reuse) +} IPIDFLAGS; + + +#define IPIDTBL_PAGESIZE 4096 +#define IPIDTBL_PAGESHIFT 16 +#define IPIDTBL_PAGEMASK 0x0000ffff + +#define IPIDsPerPage (IPIDTBL_PAGESIZE / sizeof(SIPIDEntry)) diff --git a/private/ole32/dbgexts/dirs b/private/ole32/dbgexts/dirs new file mode 100644 index 000000000..52db9fdb2 --- /dev/null +++ b/private/ole32/dbgexts/dirs @@ -0,0 +1,38 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + dirs. + +Abstract: + + This file specifies the subdirectories of the current directory that + contain component makefiles. + + +Author: + + BruceMa 01-Jun-1995 + +!ENDIF + +# +# This is a list of all subdirectories that build required components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +DIRS= + +# +# This is a list of all subdirectories that build optional components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +OPTIONAL_DIRS= \ + daytona \ + + diff --git a/private/ole32/dbgexts/dmoniker.cxx b/private/ole32/dbgexts/dmoniker.cxx new file mode 100644 index 000000000..c07b2b7e4 --- /dev/null +++ b/private/ole32/dbgexts/dmoniker.cxx @@ -0,0 +1,931 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dmoniker.cxx +// +// Contents: Interpret a moniker object +// +// Functions: monikersHelp +// displayMonikers +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dmoniker.h" + + + + + +static void displayFileMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayFileMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayItemMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayItemMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayCompositeMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayCompositeMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayPointerMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayPointerMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayAntiMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static void displayAntiMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +static enum mnkType findMnkType(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + + +extern BOOL fInScm; +static BOOL fRetail; + + +//+------------------------------------------------------------------------- +// +// Function: monikerHelp +// +// Synopsis: Display a menu for the command 'mk' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void monikerHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("mk addr - Interpret addr as a moniker\n"); +} + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayMoniker +// +// Synopsis: Display a moniker +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +BOOL displayMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + ULONG pAdr; + enum mnkType mType; + + // Determine if this is checked or retail ole + if (fInScm) + { + pAdr = GetExpression("scm!_CairoleInfoLevel"); + } + else + { + pAdr = GetExpression("ole32!_CairoleInfoLevel"); + } + fRetail = pAdr == NULL ? TRUE : FALSE; + + + mType = findMnkType(hProcess, lpExtensionApis, pMoniker); + switch (mType) + { + case NOMNK: + return FALSE; + + case FILEMNK: + if (fRetail) + { + displayFileMoniker(hProcess, lpExtensionApis, pMoniker); + } + else + { + displayFileMonikerCk(hProcess, lpExtensionApis, pMoniker); + } + return TRUE; + + case POINTERMNK: + if (fRetail) + { + displayPointerMoniker(hProcess, lpExtensionApis, pMoniker); + } + else + { + displayPointerMonikerCk(hProcess, lpExtensionApis, pMoniker); + } + return TRUE; + + case ITEMMNK: + if (fRetail) + { + displayItemMoniker(hProcess, lpExtensionApis, pMoniker); + } + else + { + displayItemMonikerCk(hProcess, lpExtensionApis, pMoniker); + } + return TRUE; + + case ANTIMNK: + if (fRetail) + { + displayAntiMoniker(hProcess, lpExtensionApis, pMoniker); + } + else + { + displayAntiMonikerCk(hProcess, lpExtensionApis, pMoniker); + } + return TRUE; + + case COMPOSITEMNK: + if (fRetail) + { + displayCompositeMoniker(hProcess, lpExtensionApis, pMoniker); + } + else + { + displayCompositeMonikerCk(hProcess, lpExtensionApis, pMoniker); + } + return TRUE; + } + + return FALSE; +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayFileMoniker +// +// Synopsis: Display a retail file moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayFileMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SFileMonikerCk file; + WCHAR *pwszPath; + + // Fetch the moniker + ReadMem(&file, pMoniker, sizeof(SFileMoniker)); + + // It's a file moniker + Printf("File Moniker\n"); + + // The current references + Printf("refs = %d\n", file.m_refs); + + // The path + pwszPath = (WCHAR *) OleAlloc(2 * (file.m_ccPath + 1)); + ReadMem(pwszPath, file.m_szPath, 2 * (file.m_ccPath + 1)); + Printf("%ws", pwszPath); + OleFree(pwszPath); + if (file.m_fHashValueValid) + { + Printf(" (%d)\n", file.m_dwHashValue); + } + else + { + Printf("\n"); + } + + // The version + if (file.m_ole1 == ole1) + { + Printf("ole1\n"); + } + + // The anti count (if any) + if (file.m_cAnti) + { + Printf("CAnti count = %d\n", file.m_cAnti); + } + + // The extents (if any) + if (file.m_ExtentList.m_cbMonikerExtents) + { + BYTE *pExtent; + BYTE *pEnd ; + ULONG cbExtentBytes; + + // A header + Printf("Extents:\n"); + + // Read all the extents + pExtent = (BYTE *) OleAlloc(file.m_ExtentList.m_cbMonikerExtents); + ReadMem(pExtent, file.m_ExtentList.m_pchMonikerExtents, + file.m_ExtentList.m_cbMonikerExtents); + pEnd = pExtent; + + // Do over the extents + while (pExtent < pEnd) + { + // Fetch length + cbExtentBytes = (*pExtent++ << 16) | *pExtent++; + + // Fetch and display key + switch (*pExtent++) + { + case mnk_MAC: + Printf("mnk_MAC "); + break; + + case mnk_DFS: + Printf("mnk_DFS "); + break; + + case mnk_UNICODE: + Printf("mnk_UNICODE "); + break; + + case mnk_MacPathName: + Printf("mnk_MacPathName "); + break; + + case mnk_ShellLink: + Printf("mnk_ShellLink "); + break; + + default: + Printf("%15d "); + } + + // Display the extent in hexadecimal + UINT k = 0; + + while (cbExtentBytes--) + { + Printf("%2x ", *pExtent++); + k++; + if (k % 16 == 0) + { + Printf("\n "); + k = 0; + } + } + if (k % 8 != 0) + { + Printf("\n"); + } + } + + // Release the allocated extent buffer + OleFree(pExtent); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayFileMonikerCk +// +// Synopsis: Display a checked file moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayFileMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SFileMonikerCk file; + WCHAR *pwszPath; + + // Fetch the moniker + ReadMem(&file, pMoniker, sizeof(SFileMonikerCk)); + + // It's a file moniker + Printf("File Moniker\n"); + + // The current references + Printf("refs = %d\n", file.m_refs); + + // The path + pwszPath = (WCHAR *) OleAlloc(2 * (file.m_ccPath + 1)); + ReadMem(pwszPath, file.m_szPath, 2 * (file.m_ccPath + 1)); + Printf("%ws", pwszPath); + OleFree(pwszPath); + if (file.m_fHashValueValid) + { + Printf(" (%d)\n", file.m_dwHashValue); + } + else + { + Printf("\n"); + } + + // The version + if (file.m_ole1 == ole1) + { + Printf("ole1\n"); + } + + // The anti count (if any) + if (file.m_cAnti) + { + Printf("CAnti count = %d\n", file.m_cAnti); + } + + // The extents (if any) + if (file.m_ExtentList.m_cbMonikerExtents) + { + BYTE *pExtent; + BYTE *pEnd ; + ULONG cbExtentBytes; + + // A header + Printf("Extents:\n"); + + // Read all the extents + pExtent = (BYTE *) OleAlloc(file.m_ExtentList.m_cbMonikerExtents); + ReadMem(pExtent, file.m_ExtentList.m_pchMonikerExtents, + file.m_ExtentList.m_cbMonikerExtents); + pEnd = pExtent; + + // Do over the extents + while (pExtent < pEnd) + { + // Fetch length + cbExtentBytes = (*pExtent++ << 16) | *pExtent++; + + // Fetch and display key + switch (*pExtent++) + { + case mnk_MAC: + Printf("mnk_MAC "); + break; + + case mnk_DFS: + Printf("mnk_DFS "); + break; + + case mnk_UNICODE: + Printf("mnk_UNICODE "); + break; + + case mnk_MacPathName: + Printf("mnk_MacPathName "); + break; + + case mnk_ShellLink: + Printf("mnk_ShellLink "); + break; + + default: + Printf("%15d "); + } + + // Display the extent in hexadecimal + UINT k = 0; + + while (cbExtentBytes--) + { + Printf("%2x ", *pExtent++); + k++; + if (k % 16 == 0) + { + Printf("\n "); + k = 0; + } + } + if (k % 8 != 0) + { + Printf("\n"); + } + } + + // Release the allocated extent buffer + OleFree(pExtent); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayItemMoniker +// +// Synopsis: Display a retail item moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayItemMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SItemMonikerCk item; + WCHAR *pwszItem; + WCHAR *pwszDelimiter; + + // Fetch the moniker + ReadMem(&item, pMoniker, sizeof(SItemMoniker)); + + // It's an item moniker + Printf("Item Moniker\n"); + + // The current references + Printf("refs = %d\n", item.m_refs); + + // The delimiter plus item + pwszDelimiter = (WCHAR *) OleAlloc(2 * (item.m_ccDelimiter + 1)); + ReadMem(pwszDelimiter, item.m_lpszDelimiter, 2 * (item.m_ccDelimiter + 1)); + pwszItem = (WCHAR *) OleAlloc(2 * (item.m_ccItem + 1)); + ReadMem(pwszItem, item.m_lpszItem, 2 * (item.m_ccItem + 1)); + Printf("item = %ws%ws\n", pwszDelimiter, pwszItem); + OleFree(pwszItem); + + // The hash value + if (item.m_fHashValueValid) + { + Printf("hash = %d\n", item.m_dwHashValue); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayItemMonikerCk +// +// Synopsis: Display a checked item moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayItemMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SItemMonikerCk item; + WCHAR *pwszItem; + WCHAR *pwszDelimiter; + + // Fetch the moniker + ReadMem(&item, pMoniker, sizeof(SItemMonikerCk)); + + // It's an item moniker + Printf("Item Moniker\n"); + + // The current references + Printf("refs = %d\n", item.m_refs); + + // The delimiter plus item + pwszDelimiter = (WCHAR *) OleAlloc(2 * (item.m_ccDelimiter + 1)); + ReadMem(pwszDelimiter, item.m_lpszDelimiter, 2 * (item.m_ccDelimiter + 1)); + pwszItem = (WCHAR *) OleAlloc(2 * (item.m_ccItem + 1)); + ReadMem(pwszItem, item.m_lpszItem, 2 * (item.m_ccItem + 1)); + Printf("item = %ws%ws\n", pwszDelimiter, pwszItem); + OleFree(pwszItem); + + // The hash value + if (item.m_fHashValueValid) + { + Printf("hash = %d\n", item.m_dwHashValue); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayCompositeMoniker +// +// Synopsis: Display a retail composite moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayCompositeMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SCompositeMonikerCk composite; + + // Fetch the moniker + ReadMem(&composite, pMoniker, sizeof(SCompositeMoniker)); + + // It's a composite moniker + Printf("Composite Moniker\n"); + + // The current references + Printf("refs = %d\n", composite.m_refs); + + // Reduced? + if (composite.m_fReduced) + { + Printf("reduced\n"); + } + + // The left component + Printf("\nleft component\n"); + Printf("--------------\n"); + if (composite.m_pmkLeft) + { + displayMoniker(hProcess, lpExtensionApis, + (ULONG) composite.m_pmkLeft); + } + else + { + Printf("NULL\n"); + } + + // The right component + Printf("\nright component\n"); + Printf("---------------\n"); + if (composite.m_pmkRight) + { + displayMoniker(hProcess, lpExtensionApis, + (ULONG) composite.m_pmkRight); + } + else + { + Printf("NULL\n"); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayCompositeMonikerCk +// +// Synopsis: Display a checked composite moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayCompositeMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SCompositeMonikerCk composite; + + // Fetch the moniker + ReadMem(&composite, pMoniker, sizeof(SCompositeMonikerCk)); + + // It's a composite moniker + Printf("Composite Moniker\n"); + + // The current references + Printf("refs = %d\n", composite.m_refs); + + // Reduced? + if (composite.m_fReduced) + { + Printf("reduced\n"); + } + + // The left component + Printf("\nleft component\n"); + Printf("--------------\n"); + if (composite.m_pmkLeft) + { + displayMoniker(hProcess, lpExtensionApis, + (ULONG) composite.m_pmkLeft); + } + else + { + Printf("NULL\n"); + } + + // The right component + Printf("\nright component\n"); + Printf("---------------\n"); + if (composite.m_pmkRight) + { + displayMoniker(hProcess, lpExtensionApis, + (ULONG) composite.m_pmkRight); + } + else + { + Printf("NULL\n"); + } +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayPointerMoniker +// +// Synopsis: Display a retail pointer moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayPointerMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SPointerMoniker pointer; + + // Fetch the moniker + ReadMem(&pointer, pMoniker, sizeof(SPointerMoniker)); + + // It's a pointer moniker + Printf("Pointer Moniker\n"); + + // The current references + Printf("refs = %d\n", pointer.m_refs); + + // The pointer + Printf("IUnknown = %08x\n", pointer.m_pUnk); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayPointerMonikerCk +// +// Synopsis: Display a checked pointer moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayPointerMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SPointerMonikerCk pointer; + + // Fetch the moniker + ReadMem(&pointer, pMoniker, sizeof(SPointerMonikerCk)); + + // It's a pointer moniker + Printf("Pointer Moniker\n"); + + // The current references + Printf("refs = %d\n", pointer.m_refs); + + // The pointer + Printf("IUnknown = %08x\n", pointer.m_pUnk); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayAntiMoniker +// +// Synopsis: Display a retail anti moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayAntiMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SAntiMoniker anti; + + // Fetch the moniker + ReadMem(&anti, pMoniker, sizeof(SAntiMoniker)); + + // It's a pointer moniker + Printf("Anti Moniker\n"); + + // The current references + Printf("refs = %d\n", anti.m_refs); + + // The count + Printf("count = %d\n", anti.m_count); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayAntiMonikerCk +// +// Synopsis: Display a checked anti moniker +// +// Arguments: [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static void displayAntiMonikerCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + SAntiMonikerCk anti; + + // Fetch the moniker + ReadMem(&anti, pMoniker, sizeof(SAntiMonikerCk)); + + // It's a pointer moniker + Printf("Anti Moniker\n"); + + // The current references + Printf("refs = %d\n", anti.m_refs); + + // The count + Printf("count = %d\n", anti.m_count); +} + + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: findMnkType +// +// Synopsis: Given a moniker, compute its type +// +// Arguments: [HANDLE] - process handle +// [PNTSD_EXTENSION_APIS] Convenience routines +// [ULONG] - The moniker +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +static enum mnkType findMnkType(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker) +{ + void *vtbl; + char szSymbol[128]; + DWORD dwOffset; + + // Read the symbol for the first element in the first vtbl + ReadMem(&vtbl, pMoniker, sizeof(ULONG)); + ReadMem(&vtbl, vtbl, sizeof(ULONG)); + szSymbol[0] = '\0'; + GetSymbol(vtbl, (UCHAR *) szSymbol, &dwOffset); + + // We better be looking at a QueryInterface on a moniker + if (dwOffset != 0) + { + return NOMNK; + } + if (lstrcmp(szSymbol, "ole32!CFileMoniker__QueryInterface") == 0) + { + return FILEMNK; + } + else if (lstrcmp(szSymbol, "ole32!CItemMoniker__QueryInterface") == 0) + { + return ITEMMNK; + } + else if (lstrcmp(szSymbol, "ole32!CCompositeMoniker__QueryInterface") == 0) + { + return COMPOSITEMNK; + } + else if (lstrcmp(szSymbol, "ole32!CPointerMoniker__QueryInterface") == 0) + { + return POINTERMNK; + } + else if (lstrcmp(szSymbol, "ole32!CAntiMoniker__QueryInterface") == 0) + { + return ANTIMNK; + } + else + { + return NOMNK; + } +} diff --git a/private/ole32/dbgexts/dmoniker.h b/private/ole32/dbgexts/dmoniker.h new file mode 100644 index 000000000..70ad42a6e --- /dev/null +++ b/private/ole32/dbgexts/dmoniker.h @@ -0,0 +1,215 @@ +enum mnkType {NOMNK, FILEMNK, POINTERMNK, ITEMMNK, ANTIMNK, COMPOSITEMNK}; + + + +enum olever {undetermined, ole1, ole2 }; + + + +enum ExtentKeys +{ + mnk_MAC = 1, + mnk_DFS = 2, + mnk_UNICODE = 3, + mnk_MacPathName = 4, + mnk_ShellLink = 5 +}; + + + +struct SExtentList +{ + ULONG m_cbMonikerExtents; + BYTE *m_pchMonikerExtents; +}; + + + +struct SFileMoniker +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + CLSID m_clsid; + SExtentList m_ExtentList; + WCHAR *m_szPath; + char *m_pszAnsiPath; + USHORT m_ccPath; + USHORT m_cbAnsiPath; + DWORD m_dwHashValue; + ULONG m_fUnicodeExtent:1; + ULONG m_fClassVerified:1; + ULONG m_fHashValueValid:1; + USHORT m_cAnti; + USHORT m_endServer; + enum olever m_ole1; +}; + + + +struct SFileMonikerCk +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + void *vtbl4; + ULONG m_debug; + CLSID m_clsid; + SExtentList m_ExtentList; + WCHAR *m_szPath; + char *m_pszAnsiPath; + USHORT m_ccPath; + USHORT m_cbAnsiPath; + DWORD m_dwHashValue; + ULONG m_fUnicodeExtent:1; + ULONG m_fClassVerified:1; + ULONG m_fHashValueValid:1; + USHORT m_cAnti; + USHORT m_endServer; + enum olever m_ole1; +}; + + + + +struct SPointerMoniker +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + LPUNKNOWN m_pUnk; +}; + + + + +struct SPointerMonikerCk +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + void *vtbl4; + ULONG m_debug; + LPUNKNOWN m_pUnk; +}; + + + + +struct SItemMoniker +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + WCHAR *m_lpszItem; + char *m_pszAnsiItem; + USHORT m_ccItem; + USHORT m_cbAnsiItem; + WCHAR *m_lpszDelimiter; + char *m_pszAnsiDelimiter; + USHORT m_ccDelimiter; + USHORT m_cbAnsiDelimiter; + ULONG m_fHashValueValid:1; + DWORD m_dwHashValue; +}; + + + + +struct SItemMonikerCk +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + void *vtbl4; + ULONG m_debug; + WCHAR *m_lpszItem; + char *m_pszAnsiItem; + USHORT m_ccItem; + USHORT m_cbAnsiItem; + WCHAR *m_lpszDelimiter; + char *m_pszAnsiDelimiter; + USHORT m_ccDelimiter; + USHORT m_cbAnsiDelimiter; + ULONG m_fHashValueValid:1; + DWORD m_dwHashValue; +}; + + + + + +struct SAntiMoniker +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + ULONG m_count; +}; + + + + + +struct SAntiMonikerCk +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + void *vtbl4; + ULONG m_debug; + ULONG m_count; +}; + + + + + +struct SCompositeMoniker +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + LPMONIKER m_pmkLeft; + LPMONIKER m_pmkRight; + BOOL m_fReduced; +}; + + + + + +struct SCompositeMonikerCk +{ + void *vtbl1; + void *vtbl2; + ULONG m_refs; + void *vtbl3; + ULONG m_marshal; + void *vtbl4; + ULONG m_debug; + LPMONIKER m_pmkLeft; + LPMONIKER m_pmkRight; + BOOL m_fReduced; +}; + + + diff --git a/private/ole32/dbgexts/doxid.cxx b/private/ole32/dbgexts/doxid.cxx new file mode 100644 index 000000000..44ef0f637 --- /dev/null +++ b/private/ole32/dbgexts/doxid.cxx @@ -0,0 +1,261 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: doxid.cxx +// +// Contents: Ole NTSD extension routines to display COXID table +// +// Functions: oxidHelp +// displayOxid +// +// +// History: 21-Aug-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dipid.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); +BOOL ScanCLSID(LPSTR lpsz, CLSID *pClsid); +ULONG ScanAddr(char *lpsz); + + + +static char *aszProtSeq[] = {/* 0x00 */ 0, + /* 0x01 */ "mswmsg", + /* 0x02 */ 0, + /* 0x03 */ 0, + /* 0x04 */ "ncacn_dnet_dsp", + /* 0x05 */ 0, + /* 0x06 */ 0, + /* 0x07 */ "ncacn_ip_tcp", + /* 0x08 */ "ncadg_ip_udp", + /* 0x09 */ "ncacn_nb_tcp", + /* 0x0a */ 0, + /* 0x0b */ 0, + /* 0x0c */ "ncacn_spx", + /* 0x0d */ "ncacn_nb_ipx", + /* 0x0e */ "ncadg_ipx", + /* 0x0f */ "ncacn_np", + /* 0x10 */ "ncalrpc", + /* 0x11 */ 0, + /* 0x12 */ 0, + /* 0x13 */ "ncacn_nb_nb"}; + + + + + +//+------------------------------------------------------------------------- +// +// Function: oxidHelp +// +// Synopsis: Display a menu for the command 'id' +// +// Arguments: - +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void oxidHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("\nox - Display entire OXID table:\n"); + Printf("addr oxid\n"); + Printf("...\n\n"); + Printf("ox addr - Display specific OXID entry:\n"); + Printf("oxid serverPid serverTid flags hRpc IRemUnknown* runDownIPID refs stringBindings\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayOxid +// +// Synopsis: Display the entire OXID table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayOxid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG pAdr; + SOXIDEntry *pOXIDentry; + SOXIDEntry *pFirstOXIDentry; + SOXIDEntry sOXIDentry; + char szGuid[CLSIDSTR_MAX]; + STRINGARRAY *pBindings; + ULONG ulSize; + + + // Read the address of the first in use OXID entry + pAdr = GetExpression("ole32!COXIDTable___InUseHead"); + pFirstOXIDentry = (SOXIDEntry *) pAdr; + ReadMem(&pOXIDentry, pAdr + sizeof(ULONG), sizeof(SOXIDEntry *)); + + // Do over in use OXID entries + do + { + // Read the next OXID entry + ReadMem(&sOXIDentry, pOXIDentry, sizeof(SOXIDEntry)); + + // Print the address + Printf("%x ", pOXIDentry); + + // Print the OXID + FormatCLSID((GUID &) sOXIDentry.oxid, szGuid); + Printf("%s\n", szGuid); + + // Go to the next in use OXID entry + pOXIDentry = sOXIDentry.pNext; + + // Just in case + if (CheckControlC()) + { + return; + } + } until_(pOXIDentry == pFirstOXIDentry); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayOxidEntry +// +// Synopsis: Display an entry in the OXID table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [arg] - OXID of entry to display +// +// Returns: - +// +// History: 21-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayOxidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg) +{ + OXID oxid; + ULONG pAdr; + SOXIDEntry *pOXIDentry; + SOXIDEntry *pFirstOXIDentry; + SOXIDEntry sOXIDentry; + char szGuid[CLSIDSTR_MAX]; + STRINGARRAY *pBindings; + ULONG ulSize; + + + // Check for help + if (arg[0] == '?') + { + Printf("oxid serverPid serverTid flags hRpc IRemUnknown* runDownIPID refs stringBindings\n"); + return; + } + + // Convert the argument to an OXID + pAdr = ScanAddr(arg); + + // Read the OXID entry + ReadMem(&sOXIDentry, pAdr, sizeof(SOXIDEntry)); + + // OXID + FormatCLSID((GUID &) sOXIDentry.oxid, szGuid); + Printf("%s ", szGuid); + + // Server PID + Printf("%3x ", sOXIDentry.dwPid); + + // Server TID + Printf("%3x ", sOXIDentry.dwTid); + + // Flags + if (sOXIDentry.dwFlags & OXIDF_REGISTERED) + { + Printf("R"); + } + if (sOXIDentry.dwFlags & OXIDF_MACHINE_LOCAL) + { + Printf("L"); + } + if (sOXIDentry.dwFlags & OXIDF_STOPPED) + { + Printf("S"); + } + if (sOXIDentry.dwFlags & OXIDF_PENDINGRELEASE) + { + Printf("P"); + } + Printf(" "); + + // RPC binding handle + Printf("%x ", sOXIDentry.hServer); + + // Proxy for RemUnknown + Printf("%x ", sOXIDentry.pRU); + + // IPID of IRunDown and Remote Unknown + Printf("[%d.%d %3x %3x %d] ", + sOXIDentry.ipidRundown.page, + sOXIDentry.ipidRundown.offset, + sOXIDentry.ipidRundown.pid, + sOXIDentry.ipidRundown.tid, + sOXIDentry.ipidRundown.seq); + + // References + Printf("%d\n ", sOXIDentry.cRefs); + + // Print the string bindings + ReadMem(&ulSize, sOXIDentry.psa, sizeof(ULONG)); + pBindings = (STRINGARRAY *) OleAlloc(ulSize * sizeof(WCHAR)); + ReadMem(pBindings, sOXIDentry.psa, ulSize * sizeof(WCHAR)); + + // Do over protocol sequence/network address pairs + for (UINT k = 0; k < ulSize - 2 || + pBindings->awszStringArray[k] == 0; ) + { + char *pszProtSeq; + + // The protocol sequence + pszProtSeq = aszProtSeq[pBindings->awszStringArray[k]]; + if (pszProtSeq == NULL) + { + Printf("%d", pBindings->awszStringArray[k]); + } + else + { + Printf("%s", pszProtSeq); + } + k++; + + // The network address + Printf("%ws ", &pBindings->awszStringArray[k]); + k += lstrlenW(&pBindings->awszStringArray[k]) + 1; + } + Printf("\n"); + OleFree(pBindings); +} diff --git a/private/ole32/dbgexts/dpsclsid.cxx b/private/ole32/dbgexts/dpsclsid.cxx new file mode 100644 index 000000000..b48dc01b3 --- /dev/null +++ b/private/ole32/dbgexts/dpsclsid.cxx @@ -0,0 +1,334 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dpsclsid.cxx +// +// Contents: Ole NTSD extension routines to dump the proxy/stub +// clsid cache +// +// Functions: psClsidHelp +// displayPsClsidTbl +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dshrdmem.h" + + + + +BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2); +void FormatCLSID(REFGUID rguid, LPSTR lpsz); +BOOL GetRegistryInterfaceName(REFIID iid, char *szValue, DWORD *pcbValue); +BOOL GetRegistryClsidKey(REFCLSID clsid, char *szKey, + char *szValue, DWORD *pcbValue); + + +//+------------------------------------------------------------------------- +// +// Function: psClsidHelp +// +// Synopsis: Display a menu for the command 'ps' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void psClsidHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("ps - Display infomation for all IID's\n"); + Printf("ps IID - Display infomation for IID\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayPsClsidTbl +// +// Synopsis: Given an interface IID display the CLSID of the +// associated proxy/stub handler dll +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [lpFileExtTbl] - Address of file extensions table +// [pClsid] - Only for this clsid +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayPsClsidTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + IID *pIid) +{ + SDllShrdTbl sDllTbl; + GUIDMAP sGuidMap; + GUIDPAIR *pGuidPair; + DWORDPAIR *pDwordPair; + IID iid = {0, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}}; + char szClsid[CLSIDSTR_MAX]; + char szName[129]; + DWORD cbValue; + + // Read the shared table locally + ReadMem(&sDllTbl, pShrdTbl, sizeof(SDllShrdTbl)); + + // Read the guid map locally + ReadMem(&sGuidMap, sDllTbl._PSClsidTbl._pGuidMap, sizeof(GUIDMAP)); + + // Allocate for the guid pair list + pGuidPair = (GUIDPAIR *) OleAlloc(sGuidMap.ulCntLong * sizeof(GUIDPAIR)); + + // Allocate for the dword pair list + pDwordPair = (DWORDPAIR *) OleAlloc(sGuidMap.ulCntShort * + sizeof(DWORDPAIR)); + + // Read the guid pair list + ReadMem(pGuidPair, sDllTbl._PSClsidTbl._pLongList - + (sGuidMap.ulCntLong - 1), + sGuidMap.ulCntLong * sizeof(GUIDPAIR)); + + // Read the dword pair list + ReadMem(pDwordPair, sDllTbl._PSClsidTbl._pShortList, + sGuidMap.ulCntShort * sizeof(DWORDPAIR)); + + // Are we looking for a specific IID? + if (pIid != NULL) + { + // Search the short list first + for (UINT cCnt = 0; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++) + { + if (pIid->Data1 == pDwordPair->dw1) + { + iid.Data1 = pIid->Data1; + + // Fetch and print the interface name + cbValue = 64; + if(GetRegistryInterfaceName(iid, szName, &cbValue)) + { + Printf("%s\t", szName); + } + else + { + Printf("-\t"); + } + + // The clsid + iid.Data1 = pDwordPair->dw2; + FormatCLSID(iid, szClsid); + Printf("%s\t", szClsid); + + // Fetch and print the proxy/stub handler dll + cbValue = 128; + if (GetRegistryClsidKey(iid, "InprocServer32", szName, + &cbValue)) + { + Printf("%s\n", szName); + } + else if(GetRegistryClsidKey(iid, "InprocServer", szName, + &cbValue)) + { + Printf("%s(16)\n", szName); + } + else + { + Printf("-\n"); + } + + return; + } + } + + // Search the long list next + for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++) + { + if (IsEqualCLSID(pIid, &pGuidPair->guid1)) + { + // Fetch and print the interface name + cbValue = 64; + if(GetRegistryInterfaceName(pGuidPair->guid1, szName, + &cbValue)) + { + Printf("%s\t", szName); + } + else + { + Printf("-\t"); + } + + // The clsid + FormatCLSID(pGuidPair->guid2, szClsid); + Printf("%s\t", szClsid); + + // Fetch and print the proxy/stub handler dll + cbValue = 128; + if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32", + szName, + &cbValue)) + { + Printf("%s\n", szName); + } + else if(GetRegistryClsidKey(pGuidPair->guid2, "InprocServer", + szName, &cbValue)) + { + Printf("%s(16)\n", szName); + } + else + { + Printf("-\n"); + } + + return; + } + } + } + + // Else dump everything + else + { + // Print header + Printf("where -. = '-0000-0000-C000-000000000046}'\n\n"); + Printf(" IID interface clsid p/s dll\n"); + Printf("----------- ------------------ ----------- ---------\n"); + // Do over the short list + for (UINT cCnt = 0 ; cCnt < sGuidMap.ulCntShort; pDwordPair++, cCnt++) + { + // Print the IID + iid.Data1 = pDwordPair->dw1; + FormatCLSID(iid, szClsid); + if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0) + { + szClsid[9] = '\0'; + Printf("%s-.", szClsid); + } + else + { + Printf("%s\n", szClsid); + } + + // Fetch and print the interface name + cbValue = 64; + if(GetRegistryInterfaceName(iid, szName, &cbValue)) + { + Printf(" %s", szName); + } + else + { + Printf(" -"); + } + + // Do some pretty printing alignment + for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--) + { + Printf(" "); + } + Printf(" "); + + // The clsid + iid.Data1 = pDwordPair->dw2; + FormatCLSID(iid, szClsid); + if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0) + { + szClsid[9] = '\0'; + Printf("%s-.\t", szClsid); + } + else + { + Printf("%s\t", szClsid); + } + + // Fetch and print the proxy/stub handler dll + cbValue = 128; + if (GetRegistryClsidKey(iid, "InprocServer32", szName, &cbValue)) + { + Printf("%s\n", szName); + } + else if(GetRegistryClsidKey(iid, "InprocServer", szName, + &cbValue)) + { + Printf("%s(16)\n", szName); + } + else + { + Printf("-\n"); + } + } + + // Do over the long list + for (cCnt = 0; cCnt < sGuidMap.ulCntLong; pGuidPair++, cCnt++) + { + // Print the IID + FormatCLSID(pGuidPair->guid1, szClsid); + Printf("%s ", szClsid); + + // Fetch and print the interface name + cbValue = 64; + if(GetRegistryInterfaceName(pGuidPair->guid1, szName, &cbValue)) + { + Printf(" %s", szName); + } + else + { + Printf(" -"); + } + + // Do some pretty printing alignment + for (UINT cCh = 24 - lstrlen(szName); cCh > 0; cCh--) + { + Printf(" "); + } + Printf(" "); + + // The clsid + FormatCLSID(pGuidPair->guid2, szClsid); + if (lstrcmp(&szClsid[9], "-0000-0000-C000-000000000046}") == 0) + { + szClsid[9] = '\0'; + Printf("%s-.\t", szClsid); + } + else + { + Printf("%s\t", szClsid); + } + + // Fetch and print the proxy/stub handler dll + cbValue = 128; + if (GetRegistryClsidKey(pGuidPair->guid2, "InprocServer32", + szName, &cbValue)) + { + Printf("%s\n", szName); + } + else if(GetRegistryClsidKey(iid, "InprocServer32", szName, + &cbValue)) + { + Printf("%s(16)\n", szName); + } + else + { + Printf("-\n"); + } + } + } + + // Release allocated resources + OleFree(pGuidPair); + OleFree(pDwordPair); +} diff --git a/private/ole32/dbgexts/drot.cxx b/private/ole32/dbgexts/drot.cxx new file mode 100644 index 000000000..d6b654424 --- /dev/null +++ b/private/ole32/dbgexts/drot.cxx @@ -0,0 +1,322 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: drot.cxx +// +// Contents: Ole NTSD extension routines to display the ROT +// +// Functions: displayRot +// +// +// History: 06-01-95 BruceMa Created +// 06-26-95 BruceMa Add SCM ROT support +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "drot.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: cliRotHelp +// +// Synopsis: Display a menu for the command 'rt' +// +// Arguments: - +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void cliRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("rt - Display the Running Object Table:\n"); + Printf("Client side ROT\n"); + Printf("sig\tcall?\t(scmLoc scmId)\thApt\n"); + Printf("...\n\n"); + Printf("Client side hint table\n"); + Printf("<indices of set indicators>\n"); +} + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: scmRotHelp +// +// Synopsis: Display a menu for the command 'rt' +// +// Arguments: - +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void scmRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("rt - Display the Running Object Table:\n"); + Printf("Client side ROT\n"); + Printf("sig\tcall?\t(scmLoc scmId)\thApt\n"); + Printf("...\n\n"); + Printf("Client side hint table\n"); + Printf("<indices of set indicators>\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayCliRot +// +// Synopsis: Formats and writes an ole processes' version of the +// ROT to the debug terminal +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayCliRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG padr; + SRunningObjectTable *psRot; + SRunningObjectTable sRot; + SRotItem sRotItm; + SRotItem **ppsRotItm; + SRotItem *psRotItm; + int cSize; + + // Read the CRunningObjectTable + padr = GetExpression("ole32!pRot"); + ReadMem(&psRot, padr, sizeof(SRunningObjectTable *)); + ReadMem(&sRot, psRot, sizeof(SRunningObjectTable)); + + // Read the array of pointers to ROT items + UINT ulSize = sRot._afvRotList.m_nSize * sizeof(SRotItem *); + + ppsRotItm = (SRotItem **) OleAlloc(ulSize); + ReadMem(ppsRotItm, sRot._afvRotList.m_pData, ulSize); + + // Display the ROT items in the table + Printf("Client side ROT\n"); + for (cSize = 0; cSize < sRot._afvRotList.m_nSize; cSize++) + { + psRotItm = ppsRotItm[cSize]; + if (psRotItm != NULL) + { + // Fetch the next ROT item + ReadMem(&sRotItm, psRotItm, sizeof(SRotItem)); + + // Display this ROT item + if (sRotItm._fDontCallApp) + { + Printf("%d\tTRUE\t(%x %x)\t%x\n", + sRotItm._wItemSig, + sRotItm._scmregkey.dwEntryLoc, + sRotItm._scmregkey.dwScmId, + sRotItm._hApt); + } + else + { + Printf("%d\tFALSE\t(%x %x)\t%x\n", + sRotItm._wItemSig, + sRotItm._scmregkey.dwEntryLoc, + sRotItm._scmregkey.dwScmId, + sRotItm._hApt); + } + } + } + + + // Display the client side ROT hint table + BYTE *pHint; + UINT k, l; + + // Read the client side ROT hint table + pHint = (BYTE *) OleAlloc(SCM_HASH_SIZE * sizeof(DWORD)); + ReadMem(pHint, sRot._crht._pbHintArray, SCM_HASH_SIZE * sizeof(BYTE)); + + // Display the client side hint table + Printf("\nClient side hint table\n"); + for (l = 0, k = 0; k < SCM_HASH_SIZE; k++) + { + if (l == 16) + { + Printf("\n"); + l = 0; + } + if (pHint[k]) + { + Printf("%02d ", k); + l++; + } + } + if (l > 1) + { + Printf("\n"); + } + + + // Delete resources + OleFree(ppsRotItm); + OleFree(pHint); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayScmRot +// +// Synopsis: Formats and writes the full ROT to the debug terminal +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 26-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayScmRot(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG addr; + UINT cEnt; + char szClsid[CLSIDSTR_MAX]; + SPerMachineROT sPerMachineRot; + SRotAcctEntry sRotAcctEntry; + SScmRot sScmRot; + SScmRotEntry **ppScmHashTbl; + SScmRotEntry *pScmRotEntry; + SScmRotEntry sScmRotEntry; + WCHAR wszSID[64]; + char szSID[64]; + MNKEQBUF *pMnkEqBfr; + IFData sIFData; + SYSTEMTIME sSystemTime; + + // Get the address of the per machine ROT global + addr = GetExpression("scm!pPerMachineRot"); + + // Read the CPerMachineRot + ReadMem(&addr, addr, sizeof(ULONG)); + ReadMem(&sPerMachineRot, addr, sizeof(SPerMachineROT)); + + // Read the first CRotAcctEntry + ReadMem(&sRotAcctEntry, sPerMachineRot._safvRotAcctTable.m_pData, + sizeof(SRotAcctEntry)); + + // Read the CScmRot table + ReadMem(&sScmRot, sRotAcctEntry.pscmrot, sizeof(SScmRot)); + + // Read the hash table of CScmRotEntry *'s + ppScmHashTbl = (SScmRotEntry **) OleAlloc(sScmRot._sht._ndwHashTableSize * + sizeof(SScmRotEntry *)); + ReadMem(ppScmHashTbl, sScmRot._sht._apsheHashTable, + sScmRot._sht._ndwHashTableSize * sizeof(SScmRotEntry *)); + + // A header + ReadMem(wszSID, sRotAcctEntry.unicodestringSID, 64); + Unicode2Ansi(szSID, wszSID, 64); + szSID[32] = '\0'; + Printf("\nSCM side ROT for SID %s\n\n", szSID); + + // Do over entries in the hash table + for (cEnt = 0, pScmRotEntry = ppScmHashTbl[0]; + cEnt < sScmRot._sht._ndwHashTableSize; + cEnt++, pScmRotEntry = ppScmHashTbl[cEnt]) + { + // Only look at non-empty entries + while (pScmRotEntry) + { + // Read the CScmRotEntry + ReadMem(&sScmRotEntry, pScmRotEntry, sizeof(SScmRotEntry)); + + // Read the moniker comparison buffer + ULONG ulSize; + + ReadMem(&ulSize, sScmRotEntry._pmkeqbufKey, sizeof(ULONG)); + pMnkEqBfr = (MNKEQBUF *) OleAlloc(sizeof(ULONG) + ulSize); + ReadMem(pMnkEqBfr, sScmRotEntry._pmkeqbufKey, + sizeof(ULONG) + ulSize); + + // Read the interface data buffer + ReadMem(&sIFData, sScmRotEntry._pifdObject, + sizeof(IFData)); + + // The registration Id + Printf("RegID: %x\n", sScmRotEntry._dwScmRotId); + + // The moniker display name + Unicode2Ansi(szSID, pMnkEqBfr->_wszName, 64); + Printf("Display Name: %s\n", szSID); + + // The last time changed + FileTimeToSystemTime(&sScmRotEntry._filetimeLastChange, + &sSystemTime); + Printf("Last Change: %2d:%02d:%02d %2d/%2d/%2d\n", + sSystemTime.wHour - 7, + sSystemTime.wMinute, + sSystemTime.wSecond, + sSystemTime.wMonth, + sSystemTime.wDay, + sSystemTime.wYear - 1900); + + // The clsid of the moniker + FormatCLSID(pMnkEqBfr->_clsid, szClsid); + Printf("Moniker Type: %s\n", szClsid); + + // The server unique id (from CoGetCurrentProcess()) + Printf("Server ID: %d\n", sScmRotEntry._dwProcessID); + + // The RPC end point + Unicode2Ansi(szSID, sIFData._wszEndPoint, 64); + Printf("Endpoint: %s\n", szSID); + + // The object ID + FormatCLSID(sIFData._oid, szClsid); + Printf("Object OID: %s\n", szClsid); + + // The IID of the object + FormatCLSID(sIFData._iid, szClsid); + Printf("Object IID: %s\n\n", szClsid); + + // The hash table entry can be a list, i.e. a hash bucket, of + // ROT entries having the same hash value + pScmRotEntry = sScmRotEntry._sheNext; + + // Release the moniker compare buffer + OleFree(pMnkEqBfr); + } + } + + OleFree(ppScmHashTbl); +} diff --git a/private/ole32/dbgexts/drot.h b/private/ole32/dbgexts/drot.h new file mode 100644 index 000000000..fb9d651ab --- /dev/null +++ b/private/ole32/dbgexts/drot.h @@ -0,0 +1,160 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: drot.h +// +// Contents: Contains structure definitons for the significant ROT +// classes which the ntsd extensions need to access. +// These ole classes cannot be accessed more cleanly because +// typically the members of interest are private. +// +// WARNING. IF THE REFERENCED OLE CLASSES CHANGE, THEN THESE +// DEFINITIONS MUST CHANGE! +// +// History: 06-01-95 BruceMa Created +// 06-26-95 BruceMa Add SCM ROT support +// +//-------------------------------------------------------------------------- + + +#define SCM_HASH_SIZE 251 + + +struct SCMREGKEY +{ + DWORD dwEntryLoc; + DWORD dwScmId; +}; + + + + +struct SRotItem +{ + WORD _wItemSig; + BOOL _fDontCallApp; + SCMREGKEY _scmregkey; + HAPT _hApt; +}; + + + + + +struct SCliRotHintTable +{ + BYTE *_pbHintArray; + HANDLE _hSm; +}; + + + + + +struct SRunningObjectTable +{ + LPVOID _vtbl; + SArrayFValue _afvRotList; + SCliRotHintTable _crht; + WORD _wSigRotItem; +}; + + + + +struct SPerMachineROT +{ + SMutexSem _mxs; + DWORD _dwTotalAcctsReg; + SArrayFValue _safvRotAcctTable; +}; + + + + +struct SScmRotHintTable +{ + HANDLE _hSm; +}; + + + + +struct MNKEQBUF +{ + DWORD _cbSize; + CLSID _clsid; + WCHAR _wszName[1]; +}; + + + + +struct IFData +{ + DWORD _UNUSED[3]; + GUID _oid; + DWORD _UNUSED2; + IID _iid; + DWORD _UNUSED3[4]; + WCHAR _wszEndPoint[64]; +}; + + + + +struct SScmRotEntry +{ + LPVOID _vtbl; + SScmRotEntry *_sheNext; + DWORD _dwSig; + DWORD _dwScmRotId; + DWORD _dwProcessID; + FILETIME _filetimeLastChange; + IFData *_pifdObject; + MNKEQBUF *_pmkeqbufKey; + IFData *_pifdObjectName; + BYTE _ab[1]; +}; + + + + +struct SScmHashEntry +{ + SScmHashEntry * _sheNext; +}; + + + + +struct SScmHashTable +{ + DWORD UNUSED; + SScmHashEntry **_apsheHashTable; + DWORD _ndwHashTableSize; + DWORD _ndwCount; +}; + + + + +struct SScmRot +{ + SMutexSem _mxs; + DWORD _dwIdCntr; + SScmRotHintTable _rht; + SScmHashTable _sht; +}; + + + + +struct SRotAcctEntry +{ + DWORD UNUSED; + WCHAR *unicodestringSID; + SScmRot *pscmrot; +}; diff --git a/private/ole32/dbgexts/dshrdmem.h b/private/ole32/dbgexts/dshrdmem.h new file mode 100644 index 000000000..27aa83adc --- /dev/null +++ b/private/ole32/dbgexts/dshrdmem.h @@ -0,0 +1,179 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dshrdmem.h +// +// Contents: Contains structure definitons for the significant file +// extensions table classes which the ntsd extensions need +// to access. These ole classes cannot be accessed more +// cleanly because typically the members of interest are private. +// +// WARNING. IF THE REFERENCED OLE CLASSES CHANGE, THEN THESE +// DEFINITIONS MUST CHANGE! +// +// History: 06-01-95 BruceMa Created +// +//-------------------------------------------------------------------------- + + + + + +struct DWORDPAIR +{ + DWORD dw1; // IID + DWORD dw2; // CLSID +}; + + + + +struct GUIDPAIR +{ + GUID guid1; // IID + GUID guid2; // CLSID +}; + + + + +struct GUIDMAP +{ + ULONG ulSize; // size of table + ULONG ulFreeSpace; // Free space in table + ULONG ulCntShort; // number of entries in the short list + ULONG ulCntLong; // number of entries in the long list +}; + + + +struct SShrdTblHdr +{ + DWORD dwSeqNum; // update sequence number + ULONG OffsIIDTbl; // offset of the start of IID table + ULONG OffsPatTbl; // offset to start of file pattern table + ULONG OffsExtTbl; // offset to file extension table + ULONG OffsClsTbl; // offset to start of CLSID table + ULONG pad[1]; // pad to 8 byte boundary +}; + + + + +struct SSharedMemoryBlock +{ + HANDLE _hMem; + BYTE *_pbBase; + ULONG _culCommitSize; // current commit size + ULONG _culInitCommitSize; // initial commit size + BOOL _fCreated; // mem created vs already existed + BOOL _fReadWrite; // want read/write access +}; + + + + +struct SSmMutex +{ + BOOL _fCreated; + HANDLE _hMutex; +}; + + + + +struct SPSClsidTbl +{ + GUIDMAP * _pGuidMap; // ptr to table header + DWORDPAIR * _pShortList; // list of OLE style guids + GUIDPAIR * _pLongList; // list of non OLE style guids +}; + + + + +struct STblHdr +{ + ULONG ulSize; // size of pattern table + ULONG cbLargest; // largest pattern size + ULONG OffsStart; // offset to start of entries + ULONG OffsEnd; // offset to end of entries +}; + + + + +struct SPatternEntry +{ + CLSID clsid; // index of clsid the pattern maps to + ULONG ulEntryLen; // length of this entry + LONG lFileOffset; // offset in file where pattern begins + ULONG ulCb; // count bytes in pattern + BYTE abData[128]; // start of mask & pattern strings +}; + + + + +struct SPatternTbl +{ + STblHdr *_pTblHdr; // ptr to table header struct + BYTE *_pStart; // ptr to first entry in the memory block +}; + + + + +struct SExtTblHdr +{ + ULONG ulSize; // table size + ULONG cEntries; // count of entries in table + ULONG OffsStart; // offset to start of entries + ULONG OffsEnd; // offset to end of entries +}; + + + + + +struct SExtEntry +{ + CLSID Clsid; // clsid the extension maps to + ULONG ulEntryLen; // length of this entry + WCHAR wszExt[1]; // start of filename extension +}; + + + + + +struct SFileExtTbl +{ + SExtTblHdr *_pTblHdr; // ptr to table header structure + BYTE *_pStart; // ptr to first entry in the memory block +}; + + + + +struct SDllShrdTbl +{ + SSharedMemoryBlock _smb; // shared memory block + SSmMutex _mxs; // shared mutex + HANDLE _hRegEvent; // shared event handle + + SPSClsidTbl _PSClsidTbl; // proxy stub clsid table + SPatternTbl _PatternTbl; // file pattern table + SFileExtTbl _FileExtTbl; // file extension table + + SShrdTblHdr *_pShrdTblHdr; // shared mem copy of table + DWORD _dwSeqNum; // sequence number +}; + + + + + + diff --git a/private/ole32/dbgexts/dstdid.cxx b/private/ole32/dbgexts/dstdid.cxx new file mode 100644 index 000000000..cf9319ec1 --- /dev/null +++ b/private/ole32/dbgexts/dstdid.cxx @@ -0,0 +1,186 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dstdid.cxx +// +// Contents: Ole NTSD extension routines to display CStdIdentity table +// +// Functions: stdidHelp +// displayStdid +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dipid.h" +#include "dchannel.h" +#include "dstdid.h" + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); +ULONG ScanAddr(char *lpsz); + + + + +//+------------------------------------------------------------------------- +// +// Function: stdidHelp +// +// Synopsis: Display a menu for the command 'id' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void stdidHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("\nid - Display entire CStdIdentity table:\n"); + Printf("addr oid tid pUnkControl\n"); + Printf("...\n\n"); + Printf("\nid <stdidAdr> - Display CStdIdentity entry:\n"); + Printf("oid mrshlFlags 1stIPID chnlBfr nestedCalls mrshlTime pUnkOuter [pIEC] strongRefs\n"); + Printf("...\n\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayStdid +// +// Synopsis: Display the CStdIdentify table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayStdid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG p) +{ + SIDArray stdidtbl; + int nEnt; + IDENTRY *pStdEntries; + IDENTRY stdEntry; + SStdIdentity stdid; + char szOID[CLSIDSTR_MAX]; + SRpcChannelBuffer chanBfr; + + // Read the standard identity table + ReadMem(&stdidtbl, p, sizeof(SIDArray)); + + // Do over entries in this table + for (nEnt = 0, pStdEntries = (IDENTRY *) stdidtbl.m_afv.m_pData; + nEnt < stdidtbl.m_afv.m_nSize; + nEnt++, pStdEntries++) + { + // Read the next entry + ReadMem(&stdEntry, pStdEntries, sizeof(IDENTRY)); + + // CStdIdentity address + Printf("%x ", stdEntry.m_pStdID); + + // Display the object identifier + FormatCLSID(stdEntry.m_oid, szOID); + Printf("%s ", szOID); + + // The thread ID + Printf("%3x ", stdEntry.m_tid); + + // pUnkControl + Printf("%x\n", stdEntry.m_pUnkControl); + } + + Printf("\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayStdidEntry +// +// Synopsis: Display an entry in the CStdIdentify table +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayStdidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG p, + char *arg) +{ + ULONG pAdr; + SStdIdentity stdid; + char szOID[CLSIDSTR_MAX]; + + + // Check for help + if (arg[0] == '?') + { + Printf("oid mrshlFlags 1stIPID chnlBfr nestedCalls mrshlTime pUnkOuter [pIEC] strongRefs\n"); + return; + } + + // Read the standard identity entry + pAdr = ScanAddr(arg); + ReadMem(&stdid, pAdr, sizeof(SStdIdentity)); + + // Display the object identifier + FormatCLSID(stdid.m_oid, szOID); + Printf("%s ", szOID); + + // Marshal flags + Printf("%08x ", stdid._dwFlags); + + // First IPID + Printf("%d.%d ", stdid._iFirstIPID >> 16, stdid._iFirstIPID & 0xffff); + + // Address of CRpcChannelBuffer + Printf("%x ", stdid._pChnl); + + // Count of nested calls + Printf("%d ", stdid._cNestedCalls); + + // Marshal time + Printf("%d ", stdid._dwMarshalTime); + + // Address of pUnkOuter + Printf("%x ", stdid.m_pUnkOuter); + + // Address of IExternalConnection (if present) + if (stdid.m_pIEC) + { + Printf("%x ", stdid.m_pIEC); + } + + // Count of strong references + Printf("%d\n", stdid.m_cStrongRefs); +} diff --git a/private/ole32/dbgexts/dstdid.h b/private/ole32/dbgexts/dstdid.h new file mode 100644 index 000000000..a37b98b50 --- /dev/null +++ b/private/ole32/dbgexts/dstdid.h @@ -0,0 +1,55 @@ +typedef enum tagSTDID_FLAGS +{ + STDID_SERVER = 0, // on server side + STDID_CLIENT = 1, // on client side (non-local in RH terms) + STDID_STDMARSHAL = 2, // was created with PSTDMARSHAL + STDID_HASEC = 4, // server supports IEC for connections +} STDID_FLAGS; + + + + + +struct SIDArray +{ + SArrayFValue m_afv; +}; + + + + + +struct IDENTRY +{ + OID m_oid; + DWORD m_tid; + IUnknown *m_pUnkControl; + IStdIdentity *m_pStdID; +}; + + +// Forward reference +struct SRpcChannelBuffer; + + +struct SStdIdentity +{ + void *vtbl1; + void *vtbl2; + DWORD _dwFlags; + LONG _iFirstIPID; + SStdIdentity *_pStdId; + SRpcChannelBuffer *_pChnl; + CLSID _clsidHandler; + LONG _cNestedCalls; + DWORD _dwMarshalTime; + void *vtbl3; + DWORD m_refs; + DWORD m_flags; + IUnknown *m_pUnkOuter; + IUnknown *m_pUnkControl; + OID m_oid; + IExternalConnection *m_pIEC; + ULONG m_cStrongRefs; +}; + diff --git a/private/ole32/dbgexts/dtreatas.cxx b/private/ole32/dbgexts/dtreatas.cxx new file mode 100644 index 000000000..e9c76a80b --- /dev/null +++ b/private/ole32/dbgexts/dtreatas.cxx @@ -0,0 +1,142 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dtreatas.cxx +// +// Contents: Ole NTSD extension routines to display a dll/class cache +// +// Functions: displayTreatAsCache +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" +#include "dtreatas.h" + + +extern BOOL fInScm; + + +void FormatCLSID(REFGUID rguid, LPSTR lpsz); +BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2); + + + + +//+------------------------------------------------------------------------- +// +// Function: treatAsCacheHelp +// +// Synopsis: Display a menu for the command 'ds' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void treatAsCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("ta - Display entire TreatAs class cache:\n"); + Printf("ta clsid - Display Treat As class for clsid (if any)\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayTreatAsCache +// +// Synopsis: Formats and writes all or part of the TreatAs class cache +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// [REFCLSID] - If not CLSID_NULL only for this clsid +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayTreatAsCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + CLSID *clsid) +{ + ULONG pAdr; + BOOL fRetail; + ULONG gptrtlstTreatClasses; + ULONG pTreatAs; + STreatList sTreatList; + STreatEntry *pTreatEntry; + BOOL fInit = TRUE; + char szClsid[CLSIDSTR_MAX]; + + // Determine if this is checked or retail ole + if (fInScm) + { + pAdr = GetExpression("scm!_CairoleInfoLevel"); + } + else + { + pAdr = GetExpression("ole32!_CairoleInfoLevel"); + } + fRetail = pAdr == NULL ? TRUE : FALSE; + + // Read the pointer to the TreatAs class cache + gptrtlstTreatClasses = GetExpression("ole32!gptrtlstTreatClasses"); + ReadMem(&pTreatAs, gptrtlstTreatClasses, sizeof(ULONG)); + if (pTreatAs == NULL) + { + return; + } + + // Read the TreatAs cache header + ReadMem(&sTreatList, pTreatAs, sizeof(STreatList)); + + Printf(" clsid is treated as clsid\n"); + Printf("-------------------------------------- --------------------------------------\n"); + + if (sTreatList._centries > 0) + { + // Read the array of entries + pTreatEntry = (STreatEntry *) OleAlloc(sTreatList._centries * + sizeof(STreatEntry)); + ReadMem(pTreatEntry, sTreatList._array.m_pData, + sTreatList._centries * sizeof(STreatEntry)); + + for (DWORD i = 0; i < sTreatList._centries; i++) + { + // Display the clsid and the TreatAs clsid + if (clsid == NULL) + { + FormatCLSID(pTreatEntry[i]._clsid, szClsid); + Printf("%s ", szClsid); + FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid); + Printf("%s\n", szClsid); + } + + // We are looking for a particular clsid + else if (IsEqualCLSID(clsid, &pTreatEntry[i]._clsid)) + { + FormatCLSID(pTreatEntry[i]._clsid, szClsid); + Printf("%s ", szClsid); + FormatCLSID(pTreatEntry[i]._treatAsClsid, szClsid); + Printf("%s\n", szClsid); + return; + } + } + } +} + diff --git a/private/ole32/dbgexts/dtreatas.h b/private/ole32/dbgexts/dtreatas.h new file mode 100644 index 000000000..77ed4ed85 --- /dev/null +++ b/private/ole32/dbgexts/dtreatas.h @@ -0,0 +1,14 @@ +struct STreatEntry +{ + CLSID _clsid; + CLSID _treatAsClsid; +}; + + + +struct STreatList +{ + SArrayFValue _array; + DWORD UNUSED[7]; + DWORD _centries; +}; diff --git a/private/ole32/dbgexts/dvtbl.cxx b/private/ole32/dbgexts/dvtbl.cxx new file mode 100644 index 000000000..cf1327489 --- /dev/null +++ b/private/ole32/dbgexts/dvtbl.cxx @@ -0,0 +1,131 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: dvtbl.cxx +// +// Contents: Ole NTSD extension routines to dump a vtbl +// +// Functions: displayVtbl +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" + + + + + + + +//+------------------------------------------------------------------------- +// +// Function: vtblHelp +// +// Synopsis: Display a menu for the command 'vt' +// +// Arguments: - +// +// Returns: - +// +// History: 07-Mar-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void vtblHelp(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("vt obj - Interpret vtbl for object obj:\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: displayVtbl +// +// Synopsis: Given an object interpret its vtbl +// +// Arguments: [hProcess] - Handle of this process +// [lpExtensionApis] - Table of extension functions +// +// Returns: - +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +void displayVtbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + void *lpObj) +{ + DWORD lpVtbl = 0xdeaddead; + DWORD dwVtblOffset; + char achSymbol[256]; + + + // Get the address of the vtbl + ReadMem(&lpVtbl, lpObj, sizeof(LPVOID)); + + // Check for some reasonableness + if (lpVtbl == 0 || lpVtbl == 0xdededede || lpVtbl == 0xedededed || + lpVtbl == 0xdeaddead) + { + if (lpVtbl == 0xdeaddead) + { + Printf("...vtbl pointer could not be read\n"); + } + else + { + Printf("...vtbl pointer == 0x%x is unreasonable\n", lpVtbl); + } + return; + } + + // vtbl entries should always point at functions. Therefore, we should + // always have a displacement of zero. To check for the end of the table + // we will reevaluate the vtbl pointer. If the offset isn't what we + // expected, then we are done. + + DWORD dwIndex; + for (dwIndex = 0 ; dwIndex < 512 ; dwIndex += 4, lpVtbl += 4) + { + DWORD dwVtblEntry; + + // Just in case the loop gets away from us + if (CheckControlC()) + { + return; + } + + // Read the next vtbl entry + ReadMem(&dwVtblEntry, lpVtbl, sizeof(dwVtblEntry)); + + // If the function is at zero, then must be at end of table + if (dwVtblEntry == 0) + { + return; + } + + // Now, determine the symbol for the entry in the vtbl + GetSymbol((LPVOID) dwVtblEntry, (UCHAR *) achSymbol, &dwVtblOffset); + + // If it doesn't point to the start of a routine, then it + // probably isn't part of the vtbl + if (dwVtblOffset != 0) + { + return; + } + + // Print the vtbl entry symbolically + Printf(" 0x%08x %s\n", dwVtblEntry, achSymbol); + } +} diff --git a/private/ole32/dbgexts/ole.def b/private/ole32/dbgexts/ole.def new file mode 100644 index 000000000..ee5f49e67 --- /dev/null +++ b/private/ole32/dbgexts/ole.def @@ -0,0 +1,29 @@ +NAME OLE + +DESCRIPTION Ole32 Debugger Extensions + +EXPORTS + cc + ch + ci + ck + dh + ds + er + fe + ft + help + id + in + ip + mk + ox + pg + pl + ps + rt + ta + ts + vt + + diff --git a/private/ole32/dbgexts/ole.h b/private/ole32/dbgexts/ole.h new file mode 100644 index 000000000..4d7bf715e --- /dev/null +++ b/private/ole32/dbgexts/ole.h @@ -0,0 +1,107 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: ole.h +// +// Contents: Implements ntsd extensions to dump ole tables +// +// Functions: +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + + +#include <ntsdexts.h> + + +//////////////////////////////////////////////////////// +const UINT MAX_ARG = 64; +const UINT MAX_FILESIZE = 128; + +//////////////////////////////////////////////////////// +typedef char Arg[MAX_ARG]; + + + + +//////////////////////////////////////////////////////// +#define until_(x) while(!(x)) + +#define DEFINE_EXT(e) void e(HANDLE hProcess,HANDLE hThread,DWORD dwPc,PNTSD_EXTENSION_APIS lpExtensionApis,LPSTR lpArgumentString) + +#define Printf (*(lpExtensionApis->lpOutputRoutine)) + +#define CheckForScm() checkForScm(lpExtensionApis) + +#define GetExpression (*(lpExtensionApis->lpGetExpressionRoutine)) + +#define GetSymbol (*(lpExtensionApis->lpGetSymbolRoutine)) + +#define CheckControlC (*(lpExtensionApis->lpCheckControlCRoutine)) + +#define ReadMem(a,b,c) readMemory(hProcess, lpExtensionApis, (BYTE *) (a), (BYTE *) (b), (c)) + +#define WriteMem(a,b,c) writeMemory(hProcess, lpExtensionApis, (BYTE *) (a), (BYTE *) (b), (c)) + +#define OleAlloc(n) HeapAlloc(GetProcessHeap(),0,(n)) + +#define OleFree(p) HeapFree(GetProcessHeap(),0,(p)) + +#define GetArg(a) getArgument(&lpArgumentString, a) + +#define IsDecimal(x) ('0' <= (x) && (x) <= '9') + +#define Unicode2Ansi(x, y, z) AreFileApisANSI?WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, y, -1, x, z, NULL, NULL):WideCharToMultiByte(CP_OEMCP, WC_COMPOSITECHECK, y, -1, x, z, NULL, NULL); + +#define NOTINSCM if(fInScm){NotInScm(lpExtensionApis);return;} +#define NOTINOLE if(!fInScm){NotInOle(lpExtensionApis);return;} + +#define dbt(a, b, c) dbTrace(a, (DWORD *) b, (c) / (sizeof(DWORD)), lpExtensionApis) + +#define NOTIMPLEMENTED Printf("...Not implemented yet!\n"); + + + + +//////////////////////////////////////////////////////// +void dbTrace(char *sz, DWORD *adr, ULONG amt, + PNTSD_EXTENSION_APIS lpExtensionApis); +void getArgument(LPSTR lpArgumentString, LPSTR a); +void FormatCLSID(REFGUID rguid, LPWSTR lpsz); +void readMemory(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis, + BYTE *to, BYTE *from, INT cbSize); +void writeMemory(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis, + BYTE *to, BYTE *from, INT cbSize); + + + +// Common structures +struct SMutexSem +{ + CRITICAL_SECTION _cs; +}; + + + + +struct SArrayFValue +{ + BYTE **m_pData; + UINT m_cbValue; + int m_nSize; + int m_nMaxSize; + int m_nGrowBy; +}; + + + + + + + diff --git a/private/ole32/dbgexts/ole.rc b/private/ole32/dbgexts/ole.rc new file mode 100644 index 000000000..576fd9852 --- /dev/null +++ b/private/ole32/dbgexts/ole.rc @@ -0,0 +1,11 @@ +#include <windows.h> +#include <ntverp.h> + +#define VER_FILETYPE VFT_APP +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_FILEDESCRIPTION_STR "Ole32 Debug Extensions" +#define VER_INTERNALNAME_STR "oleexts.dll" +#define VER_ORIGINALFILENAME_STR "oleexts.dll" + +#include "common.ver" + diff --git a/private/ole32/dbgexts/oleexts.cxx b/private/ole32/dbgexts/oleexts.cxx new file mode 100644 index 000000000..36fa30072 --- /dev/null +++ b/private/ole32/dbgexts/oleexts.cxx @@ -0,0 +1,1145 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: ole.cxx +// +// Contents: Implements ntsd extensions to dump ole tables +// +// Functions: +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include <ole2.h> +#include "ole.h" +#include "ddllcach.h" +#include "dshrdmem.h" + + +#define OLE_VERSION "1.0" + + +void getArgument(LPSTR *lpArgumentString, LPSTR a); +void checkForScm(PNTSD_EXTENSION_APIS lpExtensionApis); +void NotInScm(PNTSD_EXTENSION_APIS lpExtensionApis); +void NotInOle(PNTSD_EXTENSION_APIS lpExtensionApis); +ULONG ScanAddr(char *lpsz); + +void channelHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayChannel(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pChannel, + char *arg); + +void classCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayClassCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis); +void displayClassCacheCk(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis); + +void classInfoHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +BOOL displayClassInfo(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + CLSID *clsid); + +void dllCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayDllCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllCache *p); + + +void displayHr(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg); + +void fileExtHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayFileExtTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + CLSID *pClsid, + WCHAR *wszExt); + +void filePatHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayFilePatTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + CLSID *pClsid); + +void stdidHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayStdidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG p, + char *arg); +void displayStdid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG p); + +void infoLevelHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayInfoLevel(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + LPSTR lpArgumentString); + +void monikerHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +BOOL displayMoniker(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + ULONG pMoniker); + +void psClsidHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayPsClsidTbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + SDllShrdTbl *pShrdTbl, + CLSID *clisd); + +void ipidHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayIpid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis); +void displayIpidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg); + +void oxidHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayOxid(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis); +void displayOxidEntry(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + char *arg); + +void displayCliRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis); +void displayScmRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis); +void cliRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void scmRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis); + +void vtblHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayVtbl(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + void *lpObj); + +void treatAsCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis); +void displayTreatAsCache(HANDLE hProcess, + PNTSD_EXTENSION_APIS lpExtensionApis, + CLSID *clsid); + + + +void determineIfScm(void); +BOOL ScanCLSID(LPSTR lpsz, LPGUID pguid); +void FormatCLSID(REFGUID rguid, LPSTR lpsz); + + +BOOL fScmNeedsInit = TRUE; +BOOL fInScm = FALSE; + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.help +// +// Synopsis: Display a help menu of all the supported extensions +// in this dll +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(help) +{ + Arg arg; + + // Check whether debuggee is the scm + CheckForScm(); + + // Help menu for an OLE client or server + if (!fInScm) + { + // Check for any argument + GetArg(arg); + + // CRpcChannelBuffer help + if (lstrcmpA(arg, "ch") == 0) + { + channelHelp(lpExtensionApis); + } + + // Class information help + else if (lstrcmpA(arg, "ci") == 0) + { + classInfoHelp(lpExtensionApis); + } + + // DllCache help + else if (lstrcmpA(arg, "ds") == 0 || lstrcmpA(arg, "dh") == 0) + { + dllCacheHelp(lpExtensionApis); + } + + // File extension cache help + else if (lstrcmpA(arg, "fe") == 0) + { + fileExtHelp(lpExtensionApis); + } + + // File type patterns cache help + else if (lstrcmpA(arg, "ft") == 0) + { + filePatHelp(lpExtensionApis); + } + + // Standard identity table + else if (lstrcmpA(arg, "id") == 0) + { + stdidHelp(lpExtensionApis); + } + + // Debug info levels + else if (lstrcmpA(arg, "in") == 0) + { + infoLevelHelp(lpExtensionApis); + } + + // IPID table + else if (lstrcmpA(arg, "ip") == 0) + { + ipidHelp(lpExtensionApis); + } + + // A moniker + else if (lstrcmpA(arg, "mk") == 0) + { + monikerHelp(lpExtensionApis); + } + + // OXID table + else if (lstrcmpA(arg, "ox") == 0) + { + oxidHelp(lpExtensionApis); + } + + // IID to class mapping + else if (lstrcmpA(arg, "ps") == 0) + { + psClsidHelp(lpExtensionApis); + } + + // ROT help + else if (lstrcmpA(arg, "rt") == 0) + { + cliRotHelp(lpExtensionApis); + } + + // TreatAs help + else if (lstrcmpA(arg, "ta") == 0) + { + treatAsCacheHelp(lpExtensionApis); + } + + // Vtbl help + else if (lstrcmpA(arg, "vt") == 0) + { + vtblHelp(lpExtensionApis); + } + + // Print the full help menu + else + { + Printf("Ole32 NTSD extensions - Version %s\n\n", OLE_VERSION); + + Printf("ch addr - Decode addr as an RPC channel\n"); + Printf("ci [clsid] - Display registry class information\n"); + Printf("ck - Is this a checked or retail version of ole32?\n"); + Printf("dh - Display Inproc Handler dll/class cache\n"); + Printf("ds - Display Inproc Server dll/class cache\n"); + Printf("ep - Display current RPC endpoints\n"); + Printf("er err - Display the message for error number err \n"); + Printf("fe [e|c] - Display file extensions cache\n"); + Printf("ft [clsid] - Display file type pattern(s)\n"); + Printf("help [cmd] - Display this menu or specific help\n"); + Printf("id - Display CStdIdentity table\n"); + Printf("in - Set/reset debug info level\n"); + Printf("ip - Display IPID table information\n"); + Printf("mk addr - Decode addr as a moniker\n"); + Printf("ox - Display OXID table information\n"); + Printf("pg addr - Display addr as a guid\n"); + Printf("pl - Display platform information\n"); + Printf("ps - Display proxy/stub clsid cache\n"); + Printf("rh addr - Decode addr as a remote handler\n"); + Printf("rt - Display Running Object Table\n"); + Printf("ta [clsid] - Display TreatAs cache\n"); + Printf("vt obj - Interpret vtbl for object obj\n"); + } + } + + + // Help menu for the scm + else + { + // Check for any argument + GetArg(arg); + + if (lstrcmp(arg, "rt") == 0) + { + scmRotHelp(lpExtensionApis); + } + + if (lstrcmp(arg, "cc") == 0) + { + classCacheHelp(lpExtensionApis); + } + + // Print the full help menu + else + { + Printf("Ole32 NTSD extensions - Version %s\n\n", OLE_VERSION); + + Printf("cc - Display class cache info\n"); + Printf("ck - Is this a checked or retail version of scm?\n"); + Printf("ep - Display current RPC endpoints\n"); + Printf("er err - Display the message for error number err \n"); + Printf("help [cmd] - Display this menu or specific help\n"); + Printf("in - Set/reset debug info level\n"); + Printf("mk addr - Decode addr as a moniker\n"); + Printf("pg addr - Display addr as a guid\n"); + Printf("rh - Display active remote handlers\n"); + Printf("rt - Display Running Object Table\n"); + Printf("ts - Display thread information\n"); + Printf("vt obj - Interpret vtbl for object obj\n"); + } + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.cc +// +// Synopsis: Display the scm class cache +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(cc) +{ + ULONG padr; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINOLE + + // Determine if thisis checked or retail scm + padr = GetExpression("scm!_CairoleInfoLevel"); + + // Display the scm's class cache + if (padr == NULL) + { + displayClassCache(hProcess, lpExtensionApis); + } + else + { + displayClassCacheCk(hProcess, lpExtensionApis); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ch +// +// Synopsis: Display a channel controller +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ch) +{ + Arg arg; + ULONG addr; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Fetch the argument + GetArg(arg); + if (!arg[0]) + { + Printf("...use !ole.ch <address CRpcChannelBuffer>\n"); + return; + } + + // Parse it as a hexadecimal address + if (arg[0] != '?') + { + addr = ScanAddr(arg); + if (addr == NULL) + { + Printf("...%s is not a valid address\n", arg); + return; + } + } + + // BUGBUG: Check that this is indeed an CRpcChannelBuffer + // Display the parsed address as a CRpcChannelBuffer + displayChannel(hProcess, lpExtensionApis, addr, arg); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ci +// +// Synopsis: Display registry class information +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ci) +{ + Arg arg; + CLSID clsid; + + // Check whether debuggee is the scm + CheckForScm(); + + // Fetch the argument + GetArg(arg); + + // Parse it as a clsid + if (arg[0]) + { + if (!ScanCLSID(arg, &clsid)) + { + Printf("...%s is not a valid clsid\n", arg); + return; + } + } + + // Display all or particular registry class information + if (arg[0]) + { + displayClassInfo(hProcess, lpExtensionApis, &clsid); + } + else + { + displayClassInfo(hProcess, lpExtensionApis, NULL); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ck +// +// Synopsis: Is this the checked or retail version of OLE? +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ck) +{ + ULONG padr; + + // Check whether debuggee is the scm + CheckForScm(); + + if (fInScm) + { + padr = GetExpression("scm!_CairoleInfoLevel"); + } + else + { + padr = GetExpression("ole32!_CairoleInfoLevel"); + } + if (padr == NULL) + { + Printf("Retail\n"); + } + else + { + Printf("Checked\n"); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.dh +// +// Synopsis: Display the dll/class cache for inproc handlers +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(dh) +{ + SDllCache dllCache; + ULONG padr; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Fetch the dll/class cache object + padr = GetExpression("ole32!gdllcacheHandler"); + ReadMem((void *) &dllCache, padr, sizeof(SDllCache)); + Printf("Dll/class cache for in-process handlers\n\n"); + displayDllCache(hProcess, lpExtensionApis, &dllCache); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ds +// +// Synopsis: Display the dll/class cache for inproc servers +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ds) +{ + SDllCache dllCache; + ULONG padr; + + // Check whether debuggee is the scm + CheckForScm(); + + padr = GetExpression("ole32!gdllcacheInprocSrv"); + ReadMem(&dllCache, padr, sizeof(SDllCache)); + Printf("Dll/class cache for in-process servers\n\n"); + displayDllCache(hProcess, lpExtensionApis, &dllCache); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.er +// +// Synopsis: Display a Win32 or OLE error message +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(er) +{ + Arg arg; + + // Check whether debuggee is the scm + CheckForScm(); + + GetArg(arg); + displayHr(hProcess, lpExtensionApis, arg); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.fe +// +// Synopsis: Display file extension information +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(fe) +{ + Arg arg; + ULONG pAdr; + SDllShrdTbl *pShrdTbl; + CLSID clsid; + WCHAR wszExt[16]; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Check for any argument + GetArg(arg); + if (arg[0]) + { + if (arg[0] == '{') + { + if(!ScanCLSID(arg, &clsid)) + { + Printf("...%s is not a valid CLSID\n", arg); + return; + } + } + else if (arg[0] == '.') + { + if (!MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, arg, -1, wszExt, + 16 * sizeof(WCHAR))) + { + Printf("..%ws\n", wszExt); + Printf("...invalid extension %s\n", arg); + return; + } + } + else + { + Printf("...can't understand argument\n"); + } + } + + // Fetch the address of the shared memory table + pAdr = GetExpression("ole32!g_pShrdTbl"); + ReadMem(&pShrdTbl, pAdr, sizeof(ULONG)); + if (arg[0]) + { + if (arg[0] == '{') + { + displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, &clsid, + NULL); + } + else + { + displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, NULL, + wszExt); + } + } + else + { + displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, NULL, NULL); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ft +// +// Synopsis: Display file type patterns +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ft) +{ + Arg arg; + ULONG pAdr; + SDllShrdTbl *pShrdTbl; + CLSID clsid; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Check for an argument + GetArg(arg); + if (arg[0]) + { + if (arg[0] == '{') + { + if(!ScanCLSID(arg, &clsid)) + { + Printf("...%s is not a valid CLSID\n", arg); + return; + } + } + else + { + Printf("...%s is not a valid CLSID\n", arg); + return; + } + } + + // Fetch the address of the shared memory table + pAdr = GetExpression("ole32!g_pShrdTbl"); + ReadMem(&pShrdTbl, pAdr, sizeof(ULONG)); + if (arg[0] == '{') + { + displayFilePatTbl(hProcess, lpExtensionApis, pShrdTbl, &clsid); + } + else + { + displayFilePatTbl(hProcess, lpExtensionApis, pShrdTbl, NULL); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.id +// +// Synopsis: Display the CStdIdentity taable +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(id) +{ + ULONG pAdr; + Arg arg; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Fetch the address of the standard identity table + pAdr = GetExpression("ole32!sg_idtable"); + + // Check for any argument + GetArg(arg); + + // Display all or one entry + if (arg[0]) + { + displayStdidEntry(hProcess, lpExtensionApis, pAdr, arg); + } + else + { + displayStdid(hProcess, lpExtensionApis, pAdr); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.in +// +// Synopsis: Display/change debug info levels +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(in) +{ + // Check whether debuggee is the scm + CheckForScm(); + + // Set/display an info level + displayInfoLevel(hProcess, lpExtensionApis, lpArgumentString); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ip +// +// Synopsis: Display IPID table +// +// History: 11-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ip) +{ + Arg arg; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Check for an argument + GetArg(arg); + + // The whole table or a single entry + if (arg[0]) + { + displayIpidEntry(hProcess, lpExtensionApis, arg); + } + else + { + displayIpid(hProcess, lpExtensionApis); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.mk +// +// Synopsis: Interpret a moniker object +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(mk) +{ + Arg arg; + ULONG pAdr; + + // Check whether debuggee is the scm + CheckForScm(); + + // Scan the argument + GetArg(arg); + if (!arg[0]) + { + Printf("...use !ole.mk <moniker address>\n"); + return; + } + pAdr = ScanAddr(arg); + + // Interpret this address as a moniker + if (!displayMoniker(hProcess, lpExtensionApis, pAdr)) + { + Printf("...%08x isn't a system moniker\n", pAdr); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ox +// +// Synopsis: Display OXID table +// +// History: 11-Aug-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ox) +{ + Arg arg; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Check for an argument + GetArg(arg); + + // The whole table or a single entry + if (arg[0]) + { + displayOxidEntry(hProcess, lpExtensionApis, arg); + } + else + { + displayOxid(hProcess, lpExtensionApis); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.pg +// +// Synopsis: Pretty print a guid +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(pg) +{ + Arg arg; + ULONG addr; + GUID guid; + char szGuid[CLSIDSTR_MAX]; + + // Fetch the argument + GetArg(arg); + if (!arg[0]) + { + Printf("...requires an addr argument\n"); + return; + } + addr = ScanAddr(arg); + + // Fetch the guid + ReadMem(&guid, addr, sizeof(GUID)); + + // Format and print the guid + FormatCLSID((GUID &) guid, szGuid); + Printf("%s\n", szGuid); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.pl +// +// Synopsis: Display platform information +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(pl) +{ + OSVERSIONINFO osInfo; + + osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (GetVersionEx(&osInfo)) + { + Printf("Cairo %d.%d Build %d\n", + osInfo.dwMajorVersion, + osInfo.dwMinorVersion, + osInfo.dwBuildNumber); + } + else + { + Printf("...Unable to get version/platform info\n"); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ps +// +// Synopsis: Display CLSID of proxy/stub handler dll for given IID +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ps) +{ + Arg arg; + ULONG pAdr; + SDllShrdTbl *pShrdTbl; + IID iid; + WCHAR wszExt[16]; + + // Check whether debuggee is the scm + CheckForScm(); + + NOTINSCM + + // Check for any argument + GetArg(arg); + if (arg[0]) + { + if(!ScanCLSID(arg, &iid)) + { + Printf("...%s is not a valid CLSID\n", arg); + return; + } + } + + // Fetch the address of the shared memory table + pAdr = GetExpression("ole32!g_pShrdTbl"); + ReadMem(&pShrdTbl, pAdr, sizeof(ULONG)); + if (arg[0]) + { + displayPsClsidTbl(hProcess, lpExtensionApis, pShrdTbl, &iid); + } + else + { + displayPsClsidTbl(hProcess, lpExtensionApis, pShrdTbl, NULL); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.rt +// +// Synopsis: Display the ROT +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(rt) +{ + // Check whether debuggee is the scm + CheckForScm(); + + if (fInScm) + { + displayScmRot(hProcess, lpExtensionApis); + } + else + { + displayCliRot(hProcess, lpExtensionApis); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ta +// +// Synopsis: Display TreatAs cache +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ta) +{ + Arg arg; + CLSID clsid; + + // Check whether debuggee is the scm + CheckForScm(); + + // Check whether a clsid was supplied + GetArg(arg); + if (arg[0]) + { + if (!ScanCLSID(arg, &clsid)) + { + Printf("..%s is not a valid CLSID\n", arg); + return; + } + displayTreatAsCache(hProcess, lpExtensionApis, &clsid); + } + + // Display the entire TreatAs class cache + else + { + displayTreatAsCache(hProcess, lpExtensionApis, NULL); + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.ts +// +// Synopsis: Display thread information +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(ts) +{ + // Check whether debuggee is the scm + CheckForScm(); + + Printf("...NOT IMPLEMENTED YET\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Extension: !ole.vt +// +// Synopsis: Display a vtbl +// +// History: 01-Jun-95 BruceMa Created +// +//-------------------------------------------------------------------------- +DEFINE_EXT(vt) +{ + Arg arg; + DWORD dwObj = NULL; + char *s; + + // Check whether debuggee is the scm + CheckForScm(); + + // Get the object + GetArg(arg); + for (s = arg; *s; s++) + { + dwObj = 16 * dwObj + *s - '0'; + if ('A' <= *s && *s <= 'F') + { + dwObj -= 7; + } + if ('a' <= *s && *s <= 'f') + { + dwObj -= 39; + } + } + + // Display the vtbl + if (dwObj != NULL) + { + displayVtbl(hProcess, lpExtensionApis, (LPVOID) dwObj); + } + else + { + Printf("...vtbl address of NULL is not meaningful\n"); + } +} diff --git a/private/ole32/dbgexts/util.cxx b/private/ole32/dbgexts/util.cxx new file mode 100644 index 000000000..255dd2d9f --- /dev/null +++ b/private/ole32/dbgexts/util.cxx @@ -0,0 +1,543 @@ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1995 +// +// File: ole.cxx +// +// Contents: Implements ntsd extensions to dump ole tables +// +// Functions: +// +// +// History: 06-01-95 BruceMa Created +// +// +//-------------------------------------------------------------------------- + + +#include <ole2int.h> +#include <windows.h> +#include "ole.h" + + + + +//+------------------------------------------------------------------------- +// +// Function: readMemory +// +// Synopsis: Transfer memory from debuggee virtual space to a local +// kernel memory +// +// Arguments: [lpArgumentString] - command line string +// [a] - where to return next argument +// +// Returns: - +// +//-------------------------------------------------------------------------- +void readMemory(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis, + BYTE *to, BYTE *from, INT cbSize) +{ + __try + { + NtReadVirtualMemory(hProcess, (void *) from, (void *) to, + cbSize , NULL); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + Printf("...Exception reading %08x-%08x\n", from, from + cbSize - 1); + } +} + + + + + +//+------------------------------------------------------------------------- +// +// Function: writeMemory +// +// Synopsis: Transfer memory from local memoryto debuggee virtual space +// +// Arguments: +// +// Returns: - +// +//-------------------------------------------------------------------------- +void writeMemory(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis, + BYTE *to, BYTE *from, INT cbSize) +{ + __try + { + NtWriteVirtualMemory(hProcess, (void *) to, (void *) from, + cbSize, NULL); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + Printf("...Exception writing %08x-%08x\n", to, to + cbSize - 1); + } +} + + + + +//+------------------------------------------------------------------------- +// +// Function: getArgument +// +// Synopsis: Return next command line argument +// +// Arguments: [lpArgumentString] - command line string +// [a] - where to return next argument +// +// Returns: - +// +//-------------------------------------------------------------------------- +void getArgument(LPSTR *lpArgumentString, LPSTR a) +{ + char *s = *lpArgumentString; + + // Skip whitespace + while (*s && (*s == ' ' || *s == '\t')) + { + s++; + } + while (*s && *s != ' ' && *s != '\t') + { + *a++ = *s++; + } + *a = '\0'; + *lpArgumentString = s; +} + + + + + +//+------------------------------------------------------------------------- +// +// Function: IsEqualGUID +// +// Synopsis: Compares two guids for equality +// +// Arguments: [pClsid1] - the first clsid +// [pClsid2] - the second clsid to compare the first one with +// +// Returns: TRUE if equal, FALSE if not. +// +//-------------------------------------------------------------------------- + +BOOL IsEqualCLSID(CLSID *pClsid1, CLSID *pClsid2) +{ + return !memcmp((void *) pClsid1,(void *) pClsid2, sizeof(CLSID)); +} + + + + + +//+------------------------------------------------------------------------- +// +// Function: ScanAddr +// +// Synopsis: Parse the indput string as a hexadecimal address +// +// Arguments: [lpsz] - the hex string to convert +// +// Returns: TRUE for success +// +//-------------------------------------------------------------------------- +ULONG ScanAddr(char *lpsz) +{ + ULONG val = NULL; + + // Peel off any leading "0x" + if (lpsz[0] == '0' && lpsz[1] == 'x') + { + lpsz += 2; + } + + // Parse as a hex address + while (*lpsz) + { + if (*lpsz >= '0' && *lpsz <= '9') + { + val = (val << 4) + *lpsz - '0'; + } + else if (*lpsz >= 'A' && *lpsz <= 'F') + { + val = (val << 4) + *lpsz - 'A' + 10; + } + else if (*lpsz >= 'a' && *lpsz <= 'f') + { + val = (val << 4) + *lpsz - 'a' + 10; + } + else + { + return NULL; + } + + lpsz++; + } + + return val; +} + + + + + +//+------------------------------------------------------------------------- +// +// Function: HexStringToDword +// +// Synopsis: scan lpsz for a number of hex digits (at most 8); update lpsz +// return value in Value; check for chDelim; +// +// Arguments: [lpsz] - the hex string to convert +// [Value] - the returned value +// [cDigits] - count of digits +// +// Returns: TRUE for success +// +//-------------------------------------------------------------------------- +static BOOL HexStringToDword(LPSTR &lpsz, DWORD &Value, + int cDigits, WCHAR chDelim) +{ + int Count; + + Value = 0; + for (Count = 0; Count < cDigits; Count++, lpsz++) + { + if (*lpsz >= '0' && *lpsz <= '9') + Value = (Value << 4) + *lpsz - '0'; + else if (*lpsz >= 'A' && *lpsz <= 'F') + Value = (Value << 4) + *lpsz - 'A' + 10; + else if (*lpsz >= 'a' && *lpsz <= 'f') + Value = (Value << 4) + *lpsz - 'a' + 10; + else + return(FALSE); + } + + if (chDelim != 0) + return *lpsz++ == chDelim; + else + return TRUE; +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: CLSIDFromString +// +// Synopsis: Parse above format; always writes over *pguid. +// +// Arguments: [lpsz] - the guid string to convert +// [pguid] - guid to return +// +// Returns: TRUE if successful +// +//-------------------------------------------------------------------------- +BOOL ScanCLSID(LPSTR lpsz, CLSID *pClsid) +{ + DWORD dw; + if (*lpsz++ != '{') + return FALSE; + + if (!HexStringToDword(lpsz, pClsid->Data1, sizeof(DWORD)*2, '-')) + return FALSE; + + if (!HexStringToDword(lpsz, dw, sizeof(WORD)*2, '-')) + return FALSE; + + pClsid->Data2 = (WORD)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(WORD)*2, '-')) + return FALSE; + + pClsid->Data3 = (WORD)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[0] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, '-')) + return FALSE; + + pClsid->Data4[1] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[2] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[3] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[4] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[5] = (BYTE)dw; + + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, 0)) + return FALSE; + + pClsid->Data4[6] = (BYTE)dw; + if (!HexStringToDword(lpsz, dw, sizeof(BYTE)*2, /*(*/ '}')) + return FALSE; + + pClsid->Data4[7] = (BYTE)dw; + + return TRUE; +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: FormatCLSID +// +// Synopsis: converts GUID into {...} form without leading identifier; +// +// Arguments: [rguid] - the guid to convert +// [lpszy] - buffer to hold the results +// [cbMax] - sizeof the buffer +// +// Returns: amount of data copied to lpsz if successful +// 0 if buffer too small. +// +//-------------------------------------------------------------------------- +void FormatCLSID(REFGUID rguid, LPSTR lpsz) +{ + wsprintf(lpsz, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\0", + rguid.Data1, rguid.Data2, rguid.Data3, + rguid.Data4[0], rguid.Data4[1], + rguid.Data4[2], rguid.Data4[3], + rguid.Data4[4], rguid.Data4[5], + rguid.Data4[6], rguid.Data4[7]); +} + + + + + + +extern BOOL fScmNeedsInit; +extern BOOL fInScm; + + +//+------------------------------------------------------------------------- +// +// Function: CheckForScm +// +// Synopsis: Checks whether the debuggee is 'scm' +// +// Arguments: - +// +// Returns: Sets global boolean fInScm to TRUE if this is the scm; +// FALSE otherwise +// +//-------------------------------------------------------------------------- +void checkForScm(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + ULONG padr = NULL; + + if (fScmNeedsInit) + { + fScmNeedsInit = FALSE; + padr = GetExpression("scm!CPerMachineROT__CPerMachineROT"); + fInScm = padr != NULL ? TRUE : FALSE; + } +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: NotInScm +// +// Synopsis: Prints error message +// +// Arguments: - +// +// Returns: +// +//-------------------------------------------------------------------------- +void NotInScm(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("...not meaningful in the scm\n"); +} + + + + + + +//+------------------------------------------------------------------------- +// +// Function: NotInOle +// +// Synopsis: Prints error message +// +// Arguments: - +// +// Returns: +// +//-------------------------------------------------------------------------- +void NotInOle(PNTSD_EXTENSION_APIS lpExtensionApis) +{ + Printf("...only meaningful in the scm\n"); +} + + + + + + +/////////////////////////////////////////////////////////////////// +// F O R D E B U G G I N G + + +void dbTrace(char *sz, DWORD *adr, ULONG amt, + PNTSD_EXTENSION_APIS lpExtensionApis) +{ + UINT k; + + Printf("\n%s", sz); + for (k = 0; k < amt; k++) + { + if (k % 8 == 0) + { + Printf("\n"); + } + Printf("%08x ", *adr++); + } + Printf("\n"); +} + + + + + + + + + +//+-------------------------------------------------------- +// +// Function: GetRegistryInterfaceName +// +// Algorithm: Fetch the name from the registry for the specified interface +// +// History: 21-Jun-95 BruceMa Created +// +//--------------------------------------------------------- +BOOL GetRegistryInterfaceName(REFIID iid, char *szValue, DWORD *pcbValue) +{ + DWORD dwRESERVED = 0; + HKEY hKey; + char szIID[CLSIDSTR_MAX]; + char szInterface[32 + 1 + CLSIDSTR_MAX]; + DWORD dwValueType; + HKEY hClsidKey; + HKEY hInproc32Key; + + // Prepare to open the "...Interface\<iid>" key + FormatCLSID(iid, szIID); + lstrcpy(szInterface, "Interface\\"); + lstrcat(szInterface, szIID); + + // Open the key for the specified interface + if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szInterface, dwRESERVED, + KEY_READ, &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + // Read the value as the interface name + if (RegQueryValueEx(hKey, NULL, NULL, &dwValueType, + (LPBYTE) szValue, pcbValue) != ERROR_SUCCESS) + { + CloseHandle(hKey); + return FALSE; + } + + // Close registry handle and return success + CloseHandle(hKey); + return TRUE; +} + + + + + + + + + +//+-------------------------------------------------------- +// +// Function: GetRegistryClsidKey +// +// Algorithm: Fetch the value from the registry for the specified clsid +// and key +// +// History: 21-Jun-95 BruceMa Created +// +//--------------------------------------------------------- +BOOL GetRegistryClsidKey(REFCLSID clsid, char *szKey, + char *szValue, DWORD *pcbValue) +{ + DWORD dwRESERVED = 0; + HKEY hKey; + char szCLSID[CLSIDSTR_MAX]; + char szClsid[5 + 1 + CLSIDSTR_MAX + 1 + 32]; + DWORD dwValueType; + HKEY hClsidKey; + HKEY hInproc32Key; + + // Prepare to open the "...Interface\<clsid>" key + FormatCLSID(clsid, szCLSID); + lstrcpy(szClsid, "CLSID\\"); + lstrcat(szClsid, szCLSID); + lstrcat(szClsid,"\\"); + lstrcat(szClsid, szKey); + + // Open the key for the specified clsid and key + if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szClsid, dwRESERVED, + KEY_READ, &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + // Read the value for the specified key + if (RegQueryValueEx(hKey, NULL, NULL, &dwValueType, + (LPBYTE) szValue, pcbValue) != ERROR_SUCCESS) + { + CloseHandle(hKey); + return FALSE; + } + + // Close registry handle and return success + CloseHandle(hKey); + return TRUE; +} |