The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: duebel13 on March 23, 2006, 09:46:18 AM

Title: Segments and import/export tables in a DLL
Post by: duebel13 on March 23, 2006, 09:46:18 AM
Hi,

I've searched the forum but found nothing so bear with me if the following questions have already been answered.

Looking at the PE Header in Windows 2000 SP4 sfcfiles.dll, I noticed that there is no .rdata section. Both the import and the export table are located in the .text segement. Also there are no imports from kernel32.dll, just from ntdll.dll.

How do I have to modify the DLL template and/or makeit.bat file which masm32 editor generates, so that the above behavior is enforced (wether it makes sense or not). To be more precise, how do I force export and import table to the code segment? How do I prevent a DLL from importing from kernel32.dll?

Thanks.

Regards,
Martin
Title: Re: Segments and import/export tables in a DLL
Post by: asmfan on March 23, 2006, 09:58:14 AM
try to use /SECTION option in Link.exe to merge 2/more sections with the specified attributes in one.
Title: Re: Segments and import/export tables in a DLL
Post by: duebel13 on March 23, 2006, 10:58:03 AM
Quote from: asmfan on March 23, 2006, 09:58:14 AM
try to use /SECTION option in Link.exe to merge 2/more sections with the specified attributes in one.

Thank you for pointing me to link.exe options. /merge:.rdata=.text is the answer to the first question.
I'd be happy to hear that the answer to the second question regarding kernel32 imports is simple as this one.
Title: Re: Segments and import/export tables in a DLL
Post by: asmfan on March 23, 2006, 12:08:22 PM
of course it was /merge option (i not often use it)
the answer on the second question can be one of the follows
1. dont use APIs from others DLL
2. use runtime linking (you only import 2 functions - LoadLibrary, GetProcAddress from kernel32)
3. not allowed here unusual/uncommon ways not needed for programmers
P.S. if you use API funcs why dont you want just to import them?