home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / MetaInfo / mdinfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  6.7 KB  |  194 lines

  1. //*****************************************************************************
  2. // File: mdinfo.h
  3. //
  4. // Copyright (c) 1997-1998 Microsoft Corporation.  All Rights Reserved.
  5. // Microsoft Confidential.
  6. //*****************************************************************************
  7. #ifndef _mdinfo_h
  8. #define _mdinfo_h
  9.  
  10. #include "cor.h"
  11. #include "corhlpr.h"
  12.  
  13. #define STRING_BUFFER_LEN 1024
  14.  
  15. typedef void (*strPassBackFn)(char *str);
  16.  
  17. class MDInfo {
  18. public:
  19.     enum DUMP_FILTER
  20.     {
  21.         dumpDefault        = 0x00000000,                // Dump everything.
  22.         dumpSchema        = 0x00000002,                // Dump the metadata schema.
  23.         dumpRaw            = 0x00000004,                // Dump the metadata in raw table format.
  24.         dumpHeader        = 0x00000008,                // Dump just the metadata header info.
  25.         dumpCSV            = 0x00000010,                // Dump the metadata header info in CSV format.
  26.         dumpUnsat        = 0x00000020,                // Dump unresolved methods or memberref
  27.         dumpStats        = 0x00000040,                // Dump more statistics about tables.
  28.         dumpMoreHex        = 0x00000080,                // Dump more things in hex.
  29.         dumpRawHeaps    = 0x00000200,               // Also dump the heaps in the raw dump.
  30.         dumpNoLogo        = 0x00000400,                // Don't display the logo or MVID
  31.     };
  32.  
  33.  
  34. public:
  35.     MDInfo(IMetaDataImport* pImport, IMetaDataAssemblyImport* pAssemblyImport, LPCWSTR szScope, strPassBackFn inPBFn, ULONG DumpFilter);
  36.     MDInfo(IMetaDataDispenserEx *inDisp, LPCWSTR  szScope, strPassBackFn inPBFn, ULONG DumpFilter=dumpDefault);
  37.     MDInfo(IMetaDataDispenserEx *inDisp, PBYTE pManifest, DWORD dwSize, strPassBackFn inPBFn, ULONG DumpFilter=dumpDefault);
  38.     ~MDInfo();
  39.  
  40.     void DisplayMD(void);
  41.  
  42.     LPWSTR VariantAsString(VARIANT *pVariant);
  43.  
  44.     void DisplayVersionInfo(void);
  45.  
  46.     void DisplayScopeInfo(void);
  47.  
  48.     void DisplayGlobalFunctions(void);
  49.     void DisplayGlobalFields(void);
  50.     void DisplayFieldRVA(mdFieldDef field);
  51.     void DisplayGlobalMemberRefs(void);
  52.  
  53.     void DisplayTypeDefs(void);
  54.     void DisplayTypeDefInfo(mdTypeDef inTypeDef);
  55.     void DisplayTypeDefProps(mdTypeDef inTypeDef);
  56.     
  57.     void DisplayModuleRefs(void);
  58.     void DisplayModuleRefInfo(mdModuleRef inModuleRef);
  59.  
  60.     void DisplaySignatures(void);
  61.     void DisplaySignatureInfo(mdSignature inSignature);
  62.  
  63.     LPCWSTR TokenName(mdToken inToken, LPWSTR buffer, ULONG bufLen);
  64.  
  65.     LPCWSTR TypeDeforRefName(mdToken inToken, LPWSTR buffer, ULONG bufLen);
  66.     LPCWSTR TypeDefName(mdTypeDef inTypeDef, LPWSTR buffer, ULONG bufLen);
  67.     LPCWSTR TypeRefName(mdTypeRef tr, LPWSTR buffer, ULONG bufLen);
  68.  
  69.     LPCWSTR MemberDeforRefName(mdToken inToken, LPWSTR buffer, ULONG bufLen);
  70.     LPCWSTR MemberRefName(mdToken inMemRef, LPWSTR buffer, ULONG bufLen);
  71.     LPCWSTR MemberName(mdToken inMember, LPWSTR buffer, ULONG bufLen);
  72.  
  73.     LPCWSTR MethodName(mdMethodDef inToken, LPWSTR buffer, ULONG bufLen);
  74.     LPCWSTR FieldName(mdFieldDef inToken, LPWSTR buffer, ULONG bufLen);
  75.  
  76.     char *ClassFlags(DWORD flags, char *sFlags);
  77.  
  78.     void DisplayTypeRefs(void);
  79.     void DisplayTypeRefInfo(mdTypeRef tr);
  80.     void DisplayTypeSpecs(void);
  81.     void DisplayTypeSpecInfo(mdTypeSpec ts, const char *preFix);
  82.     
  83.     void DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix);
  84.     void DisplayCustomAttributeInfo(mdCustomAttribute inValue, const char *preFix);
  85.     void DisplayCustomAttributes(mdToken inToken, const char *preFix);
  86.  
  87.     void DisplayInterfaceImpls(mdTypeDef inTypeDef);
  88.     void DisplayInterfaceImplInfo(mdInterfaceImpl inImpl);
  89.  
  90.     LPWSTR GUIDAsString(GUID inGuid, LPWSTR guidString, ULONG bufLen);
  91.  
  92.     char *VariantTypeName(ULONG valueType, char *szAttr);
  93.     char *TokenTypeName(mdToken inToken);
  94.  
  95.     // Com99 function prototypes
  96.  
  97.     void DisplayMemberInfo(mdToken inMember);
  98.     void DisplayMethodInfo(mdMethodDef method, DWORD *pflags = 0);
  99.     void DisplayFieldInfo(mdFieldDef field, DWORD *pflags = 0);
  100.     
  101.     void DisplayMethods(mdTypeDef inTypeDef);
  102.     void DisplayFields(mdTypeDef inTypeDef, COR_FIELD_OFFSET *rFieldOffset, ULONG cFieldOffset);
  103.  
  104.     void DisplaySignature(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, const char *preFix);
  105.     HRESULT GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, ULONG *pcb);
  106.  
  107.     void DisplayMemberRefs(mdToken tkParent, const char *preFix);
  108.     void DisplayMemberRefInfo(mdMemberRef inMemRef, const char *preFix);
  109.  
  110.     void DisplayMethodImpls(mdTypeDef inTypeDef);
  111.  
  112.     void DisplayParams(mdMethodDef inMthDef);
  113.     void DisplayParamInfo(mdParamDef inParam);
  114.  
  115.     void DisplayPropertyInfo(mdProperty inProp);
  116.     void DisplayProperties(mdTypeDef inTypeDef);
  117.  
  118.     void DisplayEventInfo(mdEvent inEvent);
  119.     void DisplayEvents(mdTypeDef inTypeDef);
  120.  
  121.     void DisplayPermissions(mdToken tk, const char *preFix);
  122.     void DisplayPermissionInfo(mdPermission inPermission, const char *preFix);
  123.  
  124.     void DisplayFieldMarshal(mdToken inToken);
  125.  
  126.     void DisplayPinvokeInfo(mdToken inToken);
  127.  
  128.     void DisplayAssembly();
  129.  
  130.     void DisplayAssemblyInfo();
  131.  
  132.     void DisplayAssemblyRefs();
  133.     void DisplayAssemblyRefInfo(mdAssemblyRef inAssemblyRef);
  134.  
  135.     void DisplayFiles();
  136.     void DisplayFileInfo(mdFile inFile);
  137.  
  138.     void DisplayComTypes();
  139.     void DisplayComTypeInfo(mdComType inComType);
  140.  
  141.     void DisplayManifestResources();
  142.     void DisplayManifestResourceInfo(mdManifestResource inManifestResource);
  143.  
  144.     void DisplayExecutionLocations();
  145.     void DisplayExecutionLocationInfo(mdExecutionLocation inExecutionLocation);
  146.  
  147.     void DisplayASSEMBLYMETADATA(ASSEMBLYMETADATA *pMetaData);
  148.  
  149.     void DisplayUserStrings();
  150.  
  151.     void DisplayUnsatInfo();
  152.  
  153.     void DisplayRaw();
  154.     void DumpRawHeaps();
  155.     void DumpRaw(int iDump=1, bool bStats=false);
  156.     void DumpRawCSV();
  157.     void DumpRawCol(ULONG ixTbl, ULONG ixCol, ULONG rid, bool bStats);
  158.     ULONG DumpRawColStats(ULONG ixTbl, ULONG ixCol, ULONG cRows);
  159.     const char *DumpRawNameOfType(ULONG ulType);
  160.  
  161.     static void Error(const char *szError, HRESULT hr = S_OK);
  162. private:
  163.     int Write(char *str);
  164.     int WriteLine(char *str);
  165.  
  166.     int VWrite(char *str, ...);
  167.     int VWriteLine(char *str, ...);
  168.     
  169.     void InitSigBuffer();
  170.     HRESULT AddToSigBuffer(char *string);
  171.  
  172.     IMetaDataDispenserEx *m_pDisp;
  173.     IMetaDataImport *m_pRegImport;
  174.     IMetaDataImport *m_pImport;
  175.     IMetaDataAssemblyImport *m_pAssemblyImport;
  176.     strPassBackFn m_pbFn;
  177.     IMetaDataTables *m_pTables;
  178.  
  179.     char m_output[512];
  180.     DUMP_FILTER m_DumpFilter;
  181.  
  182.     // temporary buffer for TypeDef or TypeRef name. Consume immediately
  183.     // because other functions may overwrite it.
  184.     WCHAR            m_szTempBuf[STRING_BUFFER_LEN];
  185.  
  186.     // temporary buffer for formatted string. Consume immediately before any function calls.
  187.     char            m_tempFormatBuffer[STRING_BUFFER_LEN];
  188.  
  189.     // Signature buffer.
  190.     CQuickBytes        m_sigBuf;
  191. };
  192.  
  193. #endif
  194.