Условие: есть библиотека которая загружается разными потоками. Затем она динамически погружает другую библиотеку (h = LoadLibrary(), where h is the base address and handle at the same time, let it be for example 0x16e000000) пользуется ее и выгружает ее когда считает нужным:
FreeLibrary(h) ;
UnmapViewOfFile() - имеено эта фунция ответвенна за выгрузку блиотеки из памяти, занятые адреса освобождаются. Я физически вижу что после этого вызова все сегменты библиотки в памяти не присутсвуют и это что требывалось.
А вот теперь наступает плохо - после второго вызова h = LoadLibrary(), h is again set to 0x16e000000 (as if the library was loaded at the same address), but memory examination confirms that this region is not present in the memory

Therefore, all further calls referring to the handle of the library make the main library/app crash with the message that you cannot access invalid memory at 0x16e000000
Question: How can it be that the second call returns something that looks like a valid handle/base address but the library itself is not loaded in the memory ??
Я вначале думал что при втором вызове OS пытается relocate the library (because the previously used region is already occupied) but cannot since the library is not relocatable - that's not true, the previous range of addresses is free and can be used again. Why does the API return the handle of the DLL that points to nowhere? A bug?
Может есть какой то способ использовать LoadLibraryEX with a flag meaning "now please load the library no matter what" ?