m_pEmitter = NULL;
m_pImporter = NULL;
- m_fCPlusPlus = FALSE;
- m_fWindowsCE = FALSE;
char* pszFQN = new char[16];
strcpy_s(pszFQN,16,"<Module>");
m_pModuleClass = new Class(pszFQN);
// moved to Class
//MethodList m_MethodList;
- BOOL m_fCPlusPlus;
- BOOL m_fWindowsCE;
BOOL m_fDLL;
BOOL m_fOBJ;
BOOL m_fEntryPointPresent;
if(pAsm->m_fReportProgress)
{
pParser->msg("\nAssembling '%s' ", szInputFilename);
- if(pAsm->m_fCPlusPlus) pParser->msg(" C++");
- if(pAsm->m_fWindowsCE) pParser->msg(" WINCE");
if(!pAsm->m_fAutoInheritFromObject) pParser->msg(" NOAUTOINHERIT");
pParser->msg(IsDLL ? " to DLL" : (IsOBJ? " to OBJ" : " to EXE"));
//======================================================================
if(pAsm->m_fReportProgress)
{
pParser->msg("\nAssembling delta '%s' ", szInputFilename);
- if(pAsm->m_fCPlusPlus) pParser->msg(" C++");
- if(pAsm->m_fWindowsCE) pParser->msg(" WINCE");
if(!pAsm->m_fAutoInheritFromObject) pParser->msg(" NOAUTOINHERIT");
pParser->msg(" to DMETA,DIL");
//======================================================================
pParser->msg("%d methods folded\n",pAsm->m_dwMethodsFolded);
if(pParser->Success()) exitval = 0;
else pParser->msg("Output delta files contain errors\n");
-
-#ifdef GENERATE_SUMMARY_PE_FILE
- if(pAsm->OnErrGo) exitval = 0;
-
- //if(FAILED(hr=pAsm->CreatePEFile(wzOutputFilename)))
- // pParser->msg("Could not create output file, error code=0x%08X\n",hr);
- //else
- {
- if(pAsm->m_fReportProgress) pParser->msg("Writing %s file\n", pAsm->m_fOBJ ? "COFF" : "PE");
- // Generate the file
- if (FAILED(hr = pAsm->m_pCeeFileGen->GenerateCeeFile(pAsm->m_pCeeFile)))
- {
- exitval = 1;
- pParser->msg("Failed to write output file, error code=0x%08X\n",hr);
- }
- else if (pAsm->m_pManifest->m_sStrongName.m_fFullSign)
- {
- // Strong name sign the resultant assembly.
- if(pAsm->m_fReportProgress) pParser->msg("Signing file with strong name\n");
- if (FAILED(hr=pAsm->StrongNameSign()))
- {
- exitval = 1;
- pParser->msg("Failed to strong name sign output file, error code=0x%08X\n",hr);
- }
- }
- }
-#endif
}
} // end if (pParser->Success() || pAsm->OnErrGo)
} //end if (SUCCEEDED(pAsm->InitMetaDataForENC()))
if (m_dwCeeFileFlags & ICEE_CREATE_MACHINE_I386)
COR_SET_32BIT_REQUIRED(m_dwComImageFlags);
}
- if (m_fWindowsCE)
- {
- if (FAILED(hr=m_pCeeFileGen->SetSubsystem(m_pCeeFile, IMAGE_SUBSYSTEM_WINDOWS_CE_GUI, 2, 10))) goto exit;
- if (FAILED(hr=m_pCeeFileGen->SetImageBase(m_pCeeFile, 0x10000))) goto exit;
- }
- else
+ if (m_dwCeeFileFlags & ICEE_CREATE_MACHINE_ARM || m_fAppContainer)
{
- if (m_dwCeeFileFlags & ICEE_CREATE_MACHINE_ARM || m_fAppContainer)
- {
- // For AppContainer and ARM, you must have a minimum subsystem version of 6.02
- m_wSSVersionMajor = (m_wSSVersionMajor < 6) ? 6 : m_wSSVersionMajor;
- m_wSSVersionMinor = (m_wSSVersionMinor < 2 && m_wSSVersionMajor <= 6) ? 2 : m_wSSVersionMinor;
-
- }
+ // For AppContainer and ARM, you must have a minimum subsystem version of 6.02
+ m_wSSVersionMajor = (m_wSSVersionMajor < 6) ? 6 : m_wSSVersionMajor;
+ m_wSSVersionMinor = (m_wSSVersionMinor < 2 && m_wSSVersionMajor <= 6) ? 2 : m_wSSVersionMinor;
+ }
- // Default the subsystem, instead the user doesn't set it to GUI or CUI
- if (m_dwSubsystem == (DWORD)-1)
- // The default for ILAsm previously was CUI, so that should be the default behavior...
- m_dwSubsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
+ // Default the subsystem, instead the user doesn't set it to GUI or CUI
+ if (m_dwSubsystem == (DWORD)-1)
+ // The default for ILAsm previously was CUI, so that should be the default behavior...
+ m_dwSubsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
- if (FAILED(hr=m_pCeeFileGen->SetSubsystem(m_pCeeFile, m_dwSubsystem, m_wSSVersionMajor, m_wSSVersionMinor))) goto exit;
- }
+ if (FAILED(hr=m_pCeeFileGen->SetSubsystem(m_pCeeFile, m_dwSubsystem, m_wSSVersionMajor, m_wSSVersionMinor))) goto exit;
if (FAILED(hr=m_pCeeFileGen->ClearComImageFlags(m_pCeeFile, COMIMAGE_FLAGS_ILONLY))) goto exit;
if (FAILED(hr=m_pCeeFileGen->SetComImageFlags(m_pCeeFile, m_dwComImageFlags))) goto exit;
goto exit;
}
}
- /*
- if((m_wRTVmajor < 0xFFFF)&&(m_wRTVminor < 0xFFFF))
- {
- IMAGE_COR20_HEADER* pCorH;
- if(FAILED(hr=m_pCeeFileGen->GetCorHeader(m_pCeeFile,&pCorH))) goto exit;
- pCorH->MajorRuntimeVersion = VAL16(m_wRTVmajor);
- pCorH->MinorRuntimeVersion = VAL16(m_wRTVminor);
- }
- */
- // Generate the file -- moved to main
- //if (FAILED(hr=m_pCeeFileGen->GenerateCeeFile(m_pCeeFile))) goto exit;
-
hr = S_OK;
#include "assembler.h"
-int ist=0;
-#define REPT_STEP //printf("Step %d\n",++ist);
-
HRESULT Assembler::InitMetaDataForENC(__in __nullterminated WCHAR* wzOrigFileName, BOOL generatePdb)
{
HRESULT hr = E_FAIL;
printf("Error: Cannot create a PE file with no metadata\n");
return E_FAIL;
}
-REPT_STEP
+
if(m_pManifest)
{
hr = S_OK;
}
}
}
-REPT_STEP
// All ref'ed items def'ed in this file are emitted, resolve member refs to member defs:
hr = ResolveLocalMemberRefs();
if(!OnErrGo) return E_FAIL;
}
}
-REPT_STEP
+
// Emit the rest of the metadata
hr = S_OK;
if(m_pManifest)
}
ResolveLocalMemberRefs(); // in case CAs added some
EmitUnresolvedCustomAttributes();
-REPT_STEP
hr = DoLocalMemberRefFixups();
if(FAILED(hr) &&(!OnErrGo)) goto exit;
*pEnd = 0;
}
-REPT_STEP
-
- //if (DoGlobalFixups() == FALSE)
- // return E_FAIL;
-
- //if (FAILED(hr=m_pCeeFileGen->SetOutputFileName(m_pCeeFile, pwzOutputFilename))) goto exit;
// Emit the meta-data to a separate file
IMetaDataEmit2* pENCEmitter;
return S_OK;
-REPT_STEP
-
// set managed resource entry, if any
if(m_pManifest && m_pManifest->m_dwMResSizeTotal)
{
sizeof(DWORD), (void**) &mresourceData))) goto exit;
if (FAILED(hr=m_pCeeFileGen->SetManifestEntry(m_pCeeFile, mresourceSize, 0))) goto exit;
}
-REPT_STEP
- /*
- if (m_fWindowsCE)
- {
- if (FAILED(hr=m_pCeeFileGen->SetSubsystem(m_pCeeFile, IMAGE_SUBSYSTEM_WINDOWS_CE_GUI, 2, 10))) goto exit;
-
- if (FAILED(hr=m_pCeeFileGen->SetImageBase(m_pCeeFile, 0x10000))) goto exit;
- }
- else if(m_dwSubsystem != (DWORD)-1)
- {
- if (FAILED(hr=m_pCeeFileGen->SetSubsystem(m_pCeeFile, m_dwSubsystem, 4, 0))) goto exit;
- }
-
- if (FAILED(hr=m_pCeeFileGen->ClearComImageFlags(m_pCeeFile, COMIMAGE_FLAGS_ILONLY))) goto exit;
- if (FAILED(hr=m_pCeeFileGen->SetComImageFlags(m_pCeeFile, m_dwComImageFlags & ~COMIMAGE_FLAGS_STRONGNAMESIGNED))) goto exit;
- if(m_dwFileAlignment)
- {
- if(FAILED(hr=m_pCeeFileGen->SetFileAlignment(m_pCeeFile, m_dwFileAlignment))) goto exit;
- }
- if(m_stBaseAddress)
- {
- if(FAILED(hr=m_pCeeFileGen->SetImageBase(m_pCeeFile, m_stBaseAddress))) goto exit;
- }
- */
-REPT_STEP
//Compute all the RVAs
if (FAILED(hr=m_pCeeFileGen->LinkCeeFile(m_pCeeFile))) goto exit;
-REPT_STEP
- // Fix up any fields that have RVA associated with them
-/*
- if (m_fHaveFieldsWithRvas) {
- hr = S_OK;
- ULONG dataSectionRVA;
- if (FAILED(hr=m_pCeeFileGen->GetSectionRVA(m_pGlobalDataSection, &dataSectionRVA))) goto exit;
-
- ULONG tlsSectionRVA;
- if (FAILED(hr=m_pCeeFileGen->GetSectionRVA(m_pTLSSection, &tlsSectionRVA))) goto exit;
-
- FieldDescriptor* pListFD;
- Class* pClass;
- for(int i=0; (pClass = m_lstClass.PEEK(i)); i++)
- {
- for(int j=0; (pListFD = pClass->m_FieldDList.PEEK(j)); j++)
- {
- if (pListFD->m_rvaLabel != 0)
- {
- DWORD rva;
- if(*(pListFD->m_rvaLabel)=='@')
- {
- rva = (DWORD)atoi(pListFD->m_rvaLabel + 1);
- }
- else
- {
- GlobalLabel *pLabel = FindGlobalLabel(pListFD->m_rvaLabel);
- if (pLabel == 0)
- {
- report->msg("Error:Could not find label '%s' for the field '%s'\n", pListFD->m_rvaLabel, pListFD->m_szName);
- hr = E_FAIL;
- continue;
- }
-
- rva = pLabel->m_GlobalOffset;
- if (pLabel->m_Section == m_pTLSSection)
- rva += tlsSectionRVA;
- else {
- _ASSERTE(pLabel->m_Section == m_pGlobalDataSection);
- rva += dataSectionRVA;
- }
- }
- if (FAILED(m_pEmitter->SetFieldRVA(pListFD->m_fdFieldTok, rva))) goto exit;
- }
- }
- }
- if (FAILED(hr)) goto exit;
- }
-REPT_STEP
-*/
-
-REPT_STEP
// actually output the resources
if(mresourceSize && mresourceData)
{
goto exit;
}
}
-REPT_STEP
-
- // Generate the file -- moved to main
- //if (FAILED(hr=m_pCeeFileGen->GenerateCeeFile(m_pCeeFile))) goto exit;
-
hr = S_OK;