diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-02-10 20:35:12 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-02-10 20:35:12 +0900 |
commit | 4b11dc566a5bbfa1378d6266525c281b028abcc8 (patch) | |
tree | b48831a898906734f8884d08b6e18f1144ee2b82 /src/ildasm/dasm.cpp | |
parent | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (diff) | |
download | coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.gz coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.tar.bz2 coreclr-4b11dc566a5bbfa1378d6266525c281b028abcc8.zip |
Imported Upstream version 1.0.0.9910upstream/1.0.0.9910
Diffstat (limited to 'src/ildasm/dasm.cpp')
-rw-r--r-- | src/ildasm/dasm.cpp | 227 |
1 files changed, 15 insertions, 212 deletions
diff --git a/src/ildasm/dasm.cpp b/src/ildasm/dasm.cpp index 86ff5a8932..7b6bca926e 100644 --- a/src/ildasm/dasm.cpp +++ b/src/ildasm/dasm.cpp @@ -17,7 +17,6 @@ #include "dasmenum.hpp" #include "dis.h" -#include "dasmgui.h" #include "resource.h" #include "dasm_sz.h" @@ -35,13 +34,6 @@ #include <corcompile.h> #endif -#ifndef FEATURE_CORECLR -// Define also LegacyActivationShim::CoInitializeEE wrapper around CoInitializeEE -#define LEGACY_ACTIVATION_SHIM_DEFINE_CoInitializeEE -#include "LegacyActivationShim.h" -#include "clrinternal.h" -#endif - #ifdef FEATURE_PAL #include "coreclrloader.h" #include "resourcestring.h" @@ -119,7 +111,6 @@ BOOL g_fHidePrivScope = TRUE; BOOL g_fProject = FALSE; // if .winmd file, transform to .NET view extern BOOL g_fQuoteAllNames; // declared in formatType.cpp, init to FALSE -BOOL g_fShowProgressBar = TRUE; BOOL g_fForwardDecl=FALSE; char g_szAsmCodeIndent[MAX_MEMBER_LENGTH]; @@ -170,8 +161,6 @@ void DisplayFile(__in __nullterminated wchar_t* szFile, __in_opt __nullterminated wchar_t* szObjFile, strPassBackFn pDisplayString); extern mdMethodDef g_tkEntryPoint; // integration with MetaInfo -// Abort disassembly flag: -BOOL g_fAbortDisassembly = FALSE; DWORD DumpResourceToFile(__in __nullterminated WCHAR* wzFileName); // see DRES.CPP @@ -319,12 +308,6 @@ extern CQuickBytes * g_szBuf_JUMPPT; extern CQuickBytes * g_szBuf_UnquotedProperName; extern CQuickBytes * g_szBuf_ProperName; -#ifndef FEATURE_CORECLR -// CLR internal hosting API -ICLRRuntimeHostInternal *g_pCLRRuntimeHostInternal = NULL; -#endif - -#ifdef FEATURE_CORECLR #ifdef FEATURE_PAL CoreCLRLoader *g_loader; #endif @@ -332,11 +315,9 @@ MetaDataGetDispenserFunc metaDataGetDispenser; GetMetaDataInternalInterfaceFunc getMetaDataInternalInterface; GetMetaDataInternalInterfaceFromPublicFunc getMetaDataInternalInterfaceFromPublic; GetMetaDataPublicInterfaceFromInternalFunc getMetaDataPublicInterfaceFromInternal; -#endif BOOL Init() { -#ifdef FEATURE_CORECLR #ifdef FEATURE_PAL g_loader = CoreCLRLoader::Create(g_pszExeFile); if (g_loader == NULL) @@ -353,37 +334,7 @@ BOOL Init() getMetaDataInternalInterfaceFromPublic = (GetMetaDataInternalInterfaceFromPublicFunc)GetMetaDataInternalInterfaceFromPublic; getMetaDataPublicInterfaceFromInternal = (GetMetaDataPublicInterfaceFromInternalFunc)GetMetaDataPublicInterfaceFromInternal; #endif // FEATURE_PAL -#else // FEATURE_CORECLR - if (FAILED(CoInitialize(NULL))) - { - return FALSE; - } - - if (FAILED(LegacyActivationShim::CoInitializeCor(COINITCOR_DEFAULT))) - { - return FALSE; - } - - if (FAILED(LegacyActivationShim::CoInitializeEE(COINITEE_DEFAULT))) - { - return FALSE; - } - - ICLRRuntimeInfo *pCLRRuntimeInfo = NULL; - if (FAILED(LegacyActivationShim::Util::GetCLRRuntimeInfo(&pCLRRuntimeInfo))) - { - return FALSE; - } - - if (FAILED(pCLRRuntimeInfo->GetInterface( - CLSID_CLRRuntimeHostInternal, - IID_ICLRRuntimeHostInternal, - (LPVOID *)&g_pCLRRuntimeHostInternal))) - { - return FALSE; - } -#endif // FEATURE_CORECLR - + g_szBuf_KEYWORD = new CQuickBytes(); g_szBuf_COMMENT = new CQuickBytes(); g_szBuf_ERRORMSG = new CQuickBytes(); @@ -482,10 +433,6 @@ void Cleanup() void Uninit() { -#ifndef FEATURE_CORECLR - GUIAddOpcode(NULL,NULL); -#endif - if (g_pPtrTags != NULL) { SDELETE(g_pPtrTags); @@ -541,24 +488,12 @@ void Uninit() SDELETE(g_szBuf_ProperName); } -#ifdef FEATURE_CORECLR #ifdef FEATURE_PAL if (g_loader != NULL) { g_loader->Finish(); } #endif -#else - if (g_pCLRRuntimeHostInternal != NULL) - { - g_pCLRRuntimeHostInternal->Release(); - g_pCLRRuntimeHostInternal = NULL; - } - - LegacyActivationShim::CoUninitializeEE(COUNINITEE_DEFAULT); - LegacyActivationShim::CoUninitializeCor(); - CoUninitialize(); -#endif } // Uninit HRESULT IsClassRefInScope(mdTypeRef classref) @@ -1695,17 +1630,10 @@ mdToken TypeRefToTypeDef(mdToken tk, IMDInternalImport *pIMDI, IMDInternalImport IUnknown *pUnk; if(FAILED(pIAMDI[0]->QueryInterface(IID_IUnknown, (void**)&pUnk))) goto AssignAndReturn; -#ifdef FEATURE_CORECLR if (FAILED(getMetaDataInternalInterfaceFromPublic( pUnk, IID_IMDInternalImport, (LPVOID *)ppIMDInew))) -#else - if (FAILED(g_pCLRRuntimeHostInternal->GetMetaDataInternalInterfaceFromPublic( - pUnk, - IID_IMDInternalImport, - (LPVOID *)ppIMDInew))) -#endif { goto AssignAndReturn; } @@ -4650,7 +4578,7 @@ BOOL DumpClass(mdTypeDef cl, DWORD dwEntryPointToken, void* GUICookie, ULONG Wha #if (0) - if((!IsTdNested(dwClassAttrs))&&(!(g_Mode & MODE_GUI))) // don't dump namespaces in GUI mode! + if((!IsTdNested(dwClassAttrs))) { // take care of namespace, if any if(strcmp(pszNamespace,g_szNamespace)) @@ -4905,11 +4833,6 @@ BOOL DumpClass(mdTypeDef cl, DWORD dwEntryPointToken, void* GUICookie, ULONG Wha if(g_cl_enclosing[i] == cl) { DumpClass(g_cl_list[i],dwEntryPointToken,GUICookie,WhatToDumpOrig); - if(g_fAbortDisassembly) - { - g_Mode = dwMode; - return FALSE; - } fRegetClassLayout = TRUE; } } @@ -4920,9 +4843,6 @@ BOOL DumpClass(mdTypeDef cl, DWORD dwEntryPointToken, void* GUICookie, ULONG Wha if(WhatToDump & 4) { DumpMembers(cl, pszNamespace, pszClassName, dwClassAttrs, dwEntryPointToken,GUICookie); -#ifndef FEATURE_CORECLR - if(!ProgressStep()) g_fAbortDisassembly = TRUE; -#endif } if(g_szAsmCodeIndent[0]) g_szAsmCodeIndent[strlen(g_szAsmCodeIndent)-2] = 0; @@ -4931,10 +4851,7 @@ BOOL DumpClass(mdTypeDef cl, DWORD dwEntryPointToken, void* GUICookie, ULONG Wha if(*pszNamespace != 0) szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr),"%s.",ProperName(pszNamespace)); sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr),"%s%s", ProperName(pszClassName),COMMENT((char*)-1)); printLine(GUICookie,szString); - if(!(g_Mode & MODE_GUI)) - { - printLine(GUICookie,""); - } + printLine(GUICookie,""); g_tkVarOwner = tkVarOwner; return TRUE; } @@ -4953,7 +4870,7 @@ void DumpGlobalMethods(DWORD dwEntryPointToken) for (i = 0; g_pImport->EnumNext(&hEnumMethod, &FuncToken); i++) { - if ((i == 0)&&(!(g_Mode & MODE_GUI))) + if (i == 0) { printLine(g_pFile,""); printLine(g_pFile,COMMENT("// ================== GLOBAL METHODS =========================")); @@ -4961,14 +4878,6 @@ void DumpGlobalMethods(DWORD dwEntryPointToken) } if(DumpMethod(FuncToken, NULL, dwEntryPointToken, g_pFile, TRUE)&& (g_Mode == MODE_DUMP_CLASS_METHOD || g_Mode == MODE_DUMP_CLASS_METHOD_SIG)) break; - -#ifndef FEATURE_CORECLR - if(!ProgressStep()) - { - g_fAbortDisassembly = TRUE; - break; - } -#endif } g_pImport->EnumClose(&hEnumMethod); if(i) @@ -4991,7 +4900,7 @@ void DumpGlobalFields() for (i = 0; g_pImport->EnumNext(&hEnum, &FieldToken); i++) { - if ((i == 0)&&(!(g_Mode & MODE_GUI))) + if (i == 0) { printLine(g_pFile,""); printLine(g_pFile,COMMENT("// ================== GLOBAL FIELDS ==========================")); @@ -5019,8 +4928,6 @@ void DumpVTables(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) if (VAL32(CORHeader->VTableFixups.VirtualAddress) == 0) return; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode - sprintf_s(szString,SZSTRING_SIZE,"// VTableFixup Directory:"); printLine(GUICookie,szStr); @@ -5087,7 +4994,6 @@ void DumpEATTable(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) DWORD BufferRVA; DWORD i; char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode sprintf_s(szString,SZSTRING_SIZE,"// Export Address Table Jumps:"); printLine(GUICookie,szStr); @@ -5143,7 +5049,6 @@ exit: void DumpCodeManager(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) { char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode sprintf_s(szString,SZSTRING_SIZE,"// Code Manager Table:"); printLine(GUICookie,szStr); if (!VAL32(CORHeader->CodeManagerTable.Size)) @@ -5180,7 +5085,6 @@ void DumpSectionHeaders(IMAGE_SECTION_HEADER* pSH, USHORT nSH, void* GUICookie) { char* szStr = &szString[0]; char name[16]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode printLine(GUICookie,""); strcpy_s(szString,SZSTRING_SIZE,"// Image sections:"); printLine(GUICookie,szStr); @@ -5280,7 +5184,6 @@ void DumpSectionHeaders(IMAGE_SECTION_HEADER* pSH, USHORT nSH, void* GUICookie) void DumpBaseReloc(const char *szName, IMAGE_DATA_DIRECTORY *pDir, void* GUICookie) { char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode sprintf_s(szString,SZSTRING_SIZE,"// %s", szName); printLine(GUICookie,szStr); if (!VAL32(pDir->Size)) @@ -5322,7 +5225,7 @@ void DumpBaseReloc(const char *szName, IMAGE_DATA_DIRECTORY *pDir, void* GUICook void DumpIAT(const char *szName, IMAGE_DATA_DIRECTORY *pDir, void* GUICookie) { char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode + sprintf_s(szString,SZSTRING_SIZE,"// %s", szName); printLine(GUICookie,szStr); if (!VAL32(pDir->Size)) @@ -5398,7 +5301,7 @@ struct MDStreamHeader void DumpMetadataHeader(const char *szName, IMAGE_DATA_DIRECTORY *pDir, void* GUICookie) { char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode + printLine(GUICookie,""); sprintf_s(szString,SZSTRING_SIZE,"// %s", szName); printLine(GUICookie,szStr); @@ -5501,7 +5404,7 @@ void DumpEntryPoint(DWORD dwAddrOfEntryPoint,DWORD dwEntryPointSize,void* GUICoo char* szStr = &szString[0]; char* szptr = szStr+2; DWORD i; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode + printLine(GUICookie,""); strcpy_s(szString,SZSTRING_SIZE,"// Entry point code:"); printLine(GUICookie,szStr); @@ -5531,7 +5434,7 @@ void DumpEntryPoint(DWORD dwAddrOfEntryPoint,DWORD dwEntryPointSize,void* GUICoo void DumpHeader(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) { char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode + DWORD dwAddrOfEntryPoint=0, dwEntryPointSize=0; PIMAGE_DOS_HEADER pDOSHeader = g_pPELoader->dosHeader(); @@ -5905,8 +5808,6 @@ void DumpTable(unsigned long Table, const char *TableName, void* GUICookie) int size; ULONG sizeRec, count; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode - // Record that this table has been seen. TableSeen(Table); @@ -5942,7 +5843,6 @@ void DumpStatistics(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) ULONG sizeRec, count; char buf[MAX_MEMBER_LENGTH]; char* szStr = &szString[0]; - if(g_Mode & MODE_GUI) szStr += 2; // no need for "//" in GUI mode TableSeenReset(); metaSize = 0; @@ -6965,7 +6865,7 @@ void DumpMI(__in __nullterminated const char *str) strcpy_s(szString,5,"// "); fInit = FALSE; GUICookie = (void*)str; - if(g_Mode & MODE_GUI) szStr = &szString[3]; // don't need "//" in GUI mode + return; } // Normal work @@ -7011,18 +6911,8 @@ void DumpMetaInfo(__in __nullterminated const WCHAR* pwzFileName, __in_opt __nul if(pch && (!_wcsicmp(pch+1,W("lib")) || !_wcsicmp(pch+1,W("obj")))) { // This works only when all the rest does not // Init and run. -#ifdef FEATURE_CORECLR if (metaDataGetDispenser(CLSID_CorMetaDataDispenser, IID_IMetaDataDispenserEx, (void **)&g_pDisp)) -#else - if(SUCCEEDED(CoInitialize(0))) - { - if(SUCCEEDED(LegacyActivationShim::CoInitializeCor(0))) - { - if (SUCCEEDED(LegacyActivationShim::ClrCoCreateInstance( - CLSID_CorMetaDataDispenser, NULL, CLSCTX_INPROC_SERVER, - IID_IMetaDataDispenserEx, (void **) &g_pDisp))) -#endif { WCHAR *pwzObjFileName=NULL; if (pszObjFileName) @@ -7037,39 +6927,25 @@ void DumpMetaInfo(__in __nullterminated const WCHAR* pwzFileName, __in_opt __nul g_pDisp = NULL; if (pwzObjFileName) VDELETE(pwzObjFileName); } -#ifndef FEATURE_CORECLR - LegacyActivationShim::CoUninitializeCor(); - } - CoUninitialize(); - } -#endif } else { HRESULT hr = S_OK; if(g_pDisp == NULL) { -#ifdef FEATURE_CORECLR hr = metaDataGetDispenser(CLSID_CorMetaDataDispenser, IID_IMetaDataDispenserEx, (void **)&g_pDisp); -#else - hr = LegacyActivationShim::ClrCoCreateInstance( - CLSID_CorMetaDataDispenser, NULL, CLSCTX_INPROC_SERVER, - IID_IMetaDataDispenserEx, (void **) &g_pDisp); -#endif } if(SUCCEEDED(hr)) { g_ValModuleType = ValidatorModuleTypePE; if(g_pAssemblyImport==NULL) g_pAssemblyImport = GetAssemblyImport(NULL); - if(!(g_Mode & MODE_GUI)) - printLine(GUICookie,RstrUTF(IDS_E_MISTART)); + printLine(GUICookie,RstrUTF(IDS_E_MISTART)); //MDInfo metaDataInfo(g_pPubImport, g_pAssemblyImport, (LPCWSTR)pwzFileName, DumpMI, g_ulMetaInfoFilter); MDInfo metaDataInfo(g_pDisp,(LPCWSTR)pwzFileName, DumpMI, g_ulMetaInfoFilter); metaDataInfo.SetVEHandlerReporter((__int64) (size_t) VEHandlerReporter); metaDataInfo.DisplayMD(); - if(!(g_Mode & MODE_GUI)) - printLine(GUICookie,RstrUTF(IDS_E_MIEND)); + printLine(GUICookie,RstrUTF(IDS_E_MIEND)); } } DumpMI((char*)-1); // reset the print function for DumpMetaInfo @@ -7442,7 +7318,6 @@ BOOL DumpFile() const char *pszFilename = g_szInputFile; const DWORD openFlags = ofRead | (g_fProject ? 0 : ofNoTransform); - if(!(g_Mode & MODE_GUI)) { if(g_fDumpHTML) { @@ -7465,8 +7340,7 @@ BOOL DumpFile() char* pch = strrchr(g_szInputFile,'.'); if(pch && (!_stricmp(pch+1,"lib") || !_stricmp(pch+1,"obj"))) { - if(!(g_Mode & MODE_GUI)) - DumpMetaInfo(g_wszFullInputFile,g_pszObjFileName,g_pFile); + DumpMetaInfo(g_wszFullInputFile,g_pszObjFileName,g_pFile); return FALSE; } } @@ -7542,21 +7416,12 @@ BOOL DumpFile() g_cbMetaData = VAL32(g_CORHeader->MetaData.Size); } -#ifdef FEATURE_CORECLR if (FAILED(getMetaDataInternalInterface( (BYTE *)g_pMetaData, g_cbMetaData, openFlags, IID_IMDInternalImport, (LPVOID *)&g_pImport))) -#else - if (FAILED(g_pCLRRuntimeHostInternal->GetMetaDataInternalInterface( - (BYTE *)g_pMetaData, - g_cbMetaData, - openFlags, - IID_IMDInternalImport, - (LPVOID *)&g_pImport))) -#endif { if (g_fDumpHeader) DumpHeader(g_CORHeader, g_pFile); @@ -7565,11 +7430,7 @@ BOOL DumpFile() } TokenSigInit(g_pImport); -#ifdef FEATURE_CORECLR if (FAILED(metaDataGetDispenser(CLSID_CorMetaDataDispenser, IID_IMetaDataDispenser, (LPVOID*)&pMetaDataDispenser))) -#else - if (FAILED(CoCreateInstance(CLSID_CorMetaDataDispenser, 0, CLSCTX_INPROC_SERVER, IID_IMetaDataDispenser, (LPVOID*)&pMetaDataDispenser))) -#endif { if (g_fDumpHeader) DumpHeader(g_CORHeader, g_pFile); @@ -7584,31 +7445,6 @@ BOOL DumpFile() goto exit; } -#ifndef FEATURE_CORECLR - // Get a symbol binder. - ISymUnmanagedBinder *binder; - HRESULT hr; - - hr = CoCreateInstance(CLSID_CorSymBinder_SxS, NULL, - CLSCTX_INPROC_SERVER, - IID_ISymUnmanagedBinder, - (void**)&binder); - - if (SUCCEEDED(hr)) - { - hr = binder->GetReaderForFile(g_pPubImport, - wzInputFileName, - NULL, - &g_pSymReader); - - // Release the binder - binder->Release(); - } - - if (FAILED(hr)) - g_fShowSource = FALSE; -#endif - if((g_uNCA = g_pImport->GetCountWithTokenKind(mdtCustomAttribute))) { g_rchCA = new char[g_uNCA+1]; @@ -7636,13 +7472,6 @@ DoneInitialization: } #endif -#ifndef FEATURE_CORECLR - if (g_Mode & MODE_GUI) - { - GUIAddItemsToList(); - } - else -#endif { // Dump the CLR header info if requested. printLine(g_pFile,COMMENT((char*)0)); // start multiline comment @@ -7682,16 +7511,8 @@ DoneInitialization: ulNumGlobalFunc = g_pImport->EnumGetCount(&hEnumMethod); g_pImport->EnumClose(&hEnumMethod); } -#ifndef FEATURE_CORECLR - if(g_fShowProgressBar) - CreateProgressBar((LONG) (g_NumClasses + ulNumGlobalFunc)); -#endif } -#ifndef FEATURE_CORECLR - ProgressStep(); -#endif - g_fAbortDisassembly = FALSE; //DumpVtable(g_pFile); DumpMscorlib(g_pFile); if(g_fDumpTypeList) DumpTypelist(g_pFile); @@ -7734,13 +7555,6 @@ DoneInitialization: if(g_cl_enclosing[i] == mdTypeDefNil) // nested classes are dumped within enclosing ones { DumpClass(g_cl_list[i], VAL32(IMAGE_COR20_HEADER_FIELD(*g_CORHeader, EntryPointToken)),g_pFile,7); //7=everything - if(g_fAbortDisassembly) - { - printError(g_pFile,""); - printError(g_pFile,RstrUTF(IDS_E_DASMABORT)); - fSuccess = FALSE; - goto CloseFileAndExit; - } } } CloseNamespace(szString); @@ -7756,16 +7570,6 @@ DoneInitialization: if(g_rchCA[i] == 0) DumpCustomAttribute(TokenFromRid(i,mdtCustomAttribute),g_pFile,true); } } - if(g_fAbortDisassembly) - { - printError(g_pFile,""); - printError(g_pFile,RstrUTF(IDS_E_DASMABORT)); - fSuccess = FALSE; - goto CloseFileAndExit; - } -#ifndef FEATURE_CORECLR - ProgressStep(); -#endif #if (0) /* Third, dump GC/EH info about the native methods, using the IPMap */ @@ -7947,15 +7751,14 @@ ReportAndExit: DumpRTFPostfix(g_pFile); } +#ifndef _DEBUG CloseFileAndExit: +#endif if(g_pFile) { fclose(g_pFile); g_pFile = NULL; } -#ifndef FEATURE_CORECLR - DestroyProgressBar(); -#endif } exit: |