Hi all.

The other day someone ask me why the regsvr32.exe cannot register some .dll (say "a.dll").
I've realize that those "a.dll" uses some others dll's (i mean in the import table of "a.dll" there's "c.dll" and "d.dll" and some other dll's).
The point is: regsvr32 fails bcoz i dont have c.dll and d.dll, so i start to program my own regsvr, and i discover that i must make a LoadLibrary, then GetProcAddress of function DllRegisterServer and then execute those function. That's easy.
The proble is LoadLibrary fails if some dll in the import table is missing. So i try to make my own LoadLibrary function.

First OpenFile, then CreateFileMappin, MapViewOfFileEx, the search for the EP and execute the code there, and then i've programmed my GetProcAddress and the execute DllRegisterServer.

All those goes fine, until i've discovered that those shitty DllRegisterServer uses static addresses. (i mean that the MApViewOfFileEx maps from address 82xxxxxx or something like that and the code into the dll expects addresses 10xxxxxx or something).

So, anyone have some ideas to make a successfull LoadLibrary emulation?. i think it could be possible.

Greets and Thanks.
Posted on 2002-02-28 20:25:24 by r00t
using static addresses is neccessary on Windows.

You have to load the relocation section (.reloc) from the exe and correct all given addresses. I've never done this, but it could not be very difficult.
Posted on 2002-03-01 08:16:06 by beaster
why the regsvr32.exe cannot register some .dll
why not ?

to stop registry modify by homepages i use :

regsvr32.exe -u c:\Windows\system\regwizc.dll
to unload the dll

regsvr32.exe -c c:\Windows\system\regwizc.dll
to load the dll
Posted on 2002-03-01 08:23:57 by Max
I've managed make all the relocations.

The problem is the imports resolve. More or lees i've managed to resolve some imports, i've tested in some code locations that uses those imports that was resolved, but the imports relocation fails bcoz the difference between the raw offsets and virtual offsets.

It seems that i must make a MapViewOfFile for each section in the exe.

Anyone knows some trick?.
Posted on 2002-03-01 18:40:44 by r00t