if (!fInspectionOnly && !IsValidArchitecture(kAssemblyArchitecture))
{
// Assembly image can't be executed on this platform
+ fprintf(stderr, "@@[SR] %s:%d, fInspectionOnly(%d), IsValidArchitecture(%d)\n", __FILE__, __LINE__, fInspectionOnly, IsValidArchitecture(kAssemblyArchitecture));
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
{
// Not a PE. Shouldn't ever get here.
BINDER_LOG(W("Not a PE!"));
+ fprintf(stderr, "@@[SR] %s:%d, Not a PE\n", __FILE__, __LINE__);
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
else
{
// Invalid
BINDER_LOG(W("CLRPeKind & pe32BitRequired is true"));
+ fprintf(stderr, "@@[SR] %s:%d, Not a PE\n", __FILE__, __LINE__);
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
{
// We don't support other architectures
BINDER_LOG(W("Unknown architecture"));
+ fprintf(stderr, "@@[SR] %s:%d, Not a PE\n", __FILE__, __LINE__);
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
}
{
// Not supported
BINDER_LOG(W("32-bit, non-agnostic"));
+ fprintf(stderr, "@@[SR] %s:%d, Not a PE\n", __FILE__, __LINE__);
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
}
// Validate architecture
if (!fInspectionOnly && !Assembly::IsValidArchitecture(pAssemblyName->GetArchitecture()))
{
+ fprintf(stderr, "@@[SR] %s:%d, Not a PE\n", __FILE__, __LINE__);
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
// Validate architecture
if (!BINDER_SPACE::Assembly::IsValidArchitecture(pAssemblyName->GetArchitecture()))
{
+ fprintf(stderr, "@@[SR] %s:%d\n");
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
// Validate architecture
if (!BINDER_SPACE::Assembly::IsValidArchitecture(pAssemblyName->GetArchitecture()))
{
+ fprintf(stderr, "@@[SR] %s:%d\n");
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
if (CLRPeKind == peNot)
{ // Not a PE. Shouldn't ever get here.
*pPeKind = peInvalid;
+ fprintf(stderr, "@@[SR] %s:%d\n");
hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
goto Exit;
}
if (CLRPeKind & pe32BitRequired)
{
*pPeKind = peInvalid;
+ fprintf(stderr, "@@[SR] %s:%d\n");
hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
goto Exit;
}
else
{ // We don't support other architectures
*pPeKind = peInvalid;
+ fprintf(stderr, "@@[SR] %s:%d\n");
hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
goto Exit;
}
else
{ // Not supported
*pPeKind = peInvalid;
+ fprintf(stderr, "@@[SR] %s:%d\n");
hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
goto Exit;
}
StackSString name;
spec.GetFileOrDisplayName(0, name);
+ fprintf(stderr, "@@[SR] %s:%d\n");
COMPlusThrowHR(COR_E_FILELOAD, dwMessageID, name);
}
(hr == COR_E_LOADING_REFERENCE_ASSEMBLY) ||
(hr == META_E_BAD_SIGNATURE) ||
(hr == COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY))
+ {
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
return kBadImageFormatException;
+ }
else
{
if ((hr == E_OUTOFMEMORY) || (hr == NTE_NO_MEMORY))
HRESULT theHRESULT = GetHR();
if (theHRESULT == HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, theHRESULT);
COMPlusThrow(kBadImageFormatException);
}
else
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrow(kBadImageFormatException);
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrow(kBadImageFormatException);
}
FC_RETURN_BOOL(retVal);
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
if (FAILED(hr))
{
+ fprintf(stderr, "@@[SR] %s:%d, exception number(%ld)\n", __FILE__, __LINE__, hr);
FCThrowVoid(kBadImageFormatException);
}
}
uint EnsureOffsetInRange(uint offset, uint lookAhead)
{
if ((int)offset < 0 || offset + lookAhead >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
return offset;
}
byte ReadUInt8(uint offset)
{
if (offset >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
return *(_base + offset); // Assumes little endian and unaligned access
}
UInt16 ReadUInt16(uint offset)
{
if ((int)offset < 0 || offset + 1 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
return *dac_cast<PTR_USHORT>(_base + offset); // Assumes little endian and unaligned access
}
UInt32 ReadUInt32(uint offset)
{
if ((int)offset < 0 || offset + 3 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
return *dac_cast<PTR_UINT32>(_base + offset); // Assumes little endian and unaligned access
}
uint DecodeUnsigned(uint offset, uint * pValue)
{
if (offset >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
uint val = *(_base + offset);
if ((val & 1) == 0)
if ((val & 2) == 0)
{
if (offset + 1 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 2) |
(((uint)*(_base + offset + 1)) << 6);
offset += 2;
if ((val & 4) == 0)
{
if (offset + 2 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 3) |
(((uint)*(_base + offset + 1)) << 5) |
(((uint)*(_base + offset + 2)) << 13);
if ((val & 8) == 0)
{
if (offset + 3 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 4) |
(((uint)*(_base + offset + 1)) << 4) |
(((uint)*(_base + offset + 2)) << 12) |
}
else
{
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
}
int DecodeSigned(uint offset, int * pValue)
{
if (offset >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
int val = *(_base + offset);
if ((val & 1) == 0)
else if ((val & 2) == 0)
{
if (offset + 1 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 2) |
(((int)*(_base + offset + 1)) << 6);
offset += 2;
else if ((val & 4) == 0)
{
if (offset + 2 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 3) |
(((int)*(_base + offset + 1)) << 5) |
(((int)*(_base + offset + 2)) << 13);
else if ((val & 8) == 0)
{
if (offset + 3 >= _size)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
+ }
*pValue = (val >> 4) |
(((int)*(_base + offset + 1)) << 4) |
(((int)*(_base + offset + 2)) << 12) |
}
else
{
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
}
}
else
{
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
ThrowBadImageFormatException();
return offset;
}
int numberOfBucketsShift = (int)(header >> 2);
if (numberOfBucketsShift > 31)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
_pReader->ThrowBadImageFormatException();
+ }
_bucketMask = (uint)((1 << numberOfBucketsShift) - 1);
byte entryIndexSize = (byte)(header & 3);
if (entryIndexSize > 2)
+ {
+ fprintf(stderr, "@@[SR] %s:%d\n", __FILE__, __LINE__);
_pReader->ThrowBadImageFormatException();
+ }
_entryIndexSize = entryIndexSize;
}
else
name = StackSString(SString::Utf8, peFile->GetSimpleName());
+ fprintf(stderr, "@@[SR] %s:%d, name(%s)\n", __FILE__, __LINE__, name.GetUnicode());
COMPlusThrow(kBadImageFormatException, IDS_CLASSLOAD_WRONGCPU, name.GetUnicode());
}
if (FAILED(typeHandle.GetModule()->GetMDImport()->GetNestedClassProps(tkTypeDef, &tkTypeDef)))
{
fThrowException = TRUE;
+ fprintf(stderr, "@@[SR] %s:%d\n");
reKind = kBadImageFormatException;
argName = NULL;
goto Exit;
if (FAILED(pField->GetName_NoThrow(&szFieldName)))
{
+ fprintf(stderr, "@@[SR] %s:%d\n");
FCThrow(kBadImageFormatException);
}
return szFieldName;
{
if (FAILED(mdImport->GetAssemblyFromScope(&token)))
{
+ fprintf(stderr, "@@[SR] %s:%d\n");
FCThrow(kBadImageFormatException);
}
}
default:
{
+ fprintf(stderr, "@@[SR] %s:%d\n");
COMPlusThrow(kBadImageFormatException);
}
}