MemoryModule icon indicating copy to clipboard operation
MemoryModule copied to clipboard

Loading a C# Dll doesnt initialize CLR

Open dedmen opened this issue 9 years ago • 3 comments

When Loading a C# DLL the call to the first PEDecoder::CheckNTHeaders in PEDecoder::CheckFormat in _CorDllMain(mscoreei.dll) fails. I think its one of the calls to PEDecoder::CheckSection. So something is not wrong with the sections?

Also if (alignedImageSize != ALIGN_VALUE_UP(lastSectionEnd, sysInfo.dwPageSize)) fails because actually old_header->OptionalHeader.SectionAlignment is used for that. I Think atleast. SectionAlignment is 0x2000 and mscoree.dll checked that with a hardcoded 0x2000.

For ref: https://github.com/dotnet/coreclr/blob/master/src/utilcode/pedecoder.cpp

dedmen avatar Apr 16 '16 02:04 dedmen

Have you resolved?

andreakarasho avatar Dec 11 '17 16:12 andreakarasho

I don't even remember posting this. I guess I stopped using MemoryModule and rolled my own. https://gist.github.com/dedmen/d97b70556866a235e2ee3efdeb977357 This is the code I ended up with and it worked. It's a mess and I had to remove some stuff before publishing.

dedmen avatar Dec 11 '17 18:12 dedmen

mmm, i dont understand changes :(

i want load a c# dll, but stops here:

if (alignedImageSize != ALIGN_VALUE_UP(lastSectionEnd, sysInfo.dwPageSize))

andreakarasho avatar Dec 11 '17 20:12 andreakarasho