fancycode/MemoryModule
Steps to reproduce:
. . .
- DllExport: 1.7.4
- Used Visual Studio / MSBuild: vs2022
Im write simple DLL with that code:
using System.Runtime.InteropServices;
namespace SampleSharpDLL
{
public class Class1
{
[DllExport]
static int TestInt()
{
return 11134;
}
}
}
and tried call LoadFromMemory from this repo https://github.com/fancycode/MemoryModule
and got this:

But when I try to load the library directly via LoadLibrary everything works. In this regard, I have a question - why is 4096 missing, is this error related to the module that I'm trying or probably I made a mistake when setting some parameters ( DllExport.bat )
Tell me, have I come to the right place or should I redirect this question to the developers of fancycode module :D
Hello,
The question is more related to the question about assembler implementation how does it work, and as I remember, PE writer evaluates SizeOfImage using VA/RVA from the last placed section such .reloc plus its size rounded up to a multiple of the section alignment. Some of the alignment, in its turn, may also relies on page size including the mentioned difference 0x1000 up to the two page size etc, or it was decoder part, never mind.
In other words, I don't recommend to compare both between (like in your code above) due to various cases. The SizeOfImage should be enough to allocate memory for image because its value must contain evaluated size of the image including all headers (CLR header is inside the well-known .text section, and so on)
On 14.02.2023 23:49, Mortan wrote:
and tried call LoadFromMemory from this repo https://github.com/fancycode/MemoryModule and got this: image https://user-images.githubusercontent.com/18101486/218858824-3dbdac66-6a14-4a51-8044-443c2e7db82d.png
But when I try to load the library directly via LoadLibrary everything works. In this regard, I have a question - why is 4096 missing, is this error related to the module that I'm trying or probably I made a mistake when setting some parameters ( DllExport.bat )
Tell me, have I come to the right place or should I redirect this question to the developers of fancycode module :D