muta...@gmail.com
2021-08-28 19:23:00 UTC
I am having trouble building a DLL via what appears
to be the documented process, and I thought I would
use this opportunity to find out what a DLL actually is.
If I have two independent source files, foo.c and bar.c,
each with one function in it, ie foo() and bar()
respectively, is this something that is suitable to put
into a DLL, or is there an expectation that it all be
linked in to a single executable?
I ask because I have this code in dllcrt.c:
BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDll,
DWORD fdwReason,
LPVOID lpvReserved)
{
BOOL bRet;
/* DllMain() is optional, so it would be good to handle that case too. */
bRet = DllMain(hinstDll, fdwReason, lpvReserved);
return (bRet);
}
(apparently written by Alica).
Although the code works fine with gccwin, when I
tried to build my own kernel32.dll using the old
version of Visual Studio I have installed, I got a
link error which was resolved by adding an
underscore to the above name.
But the DLL being produced is very small and doesn't
contain the functions I want, and that is confirmed
by the link map.
Any idea what a DLL actually is?
Thanks. Paul.
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__EXPORT__ -I ../pdpclib -I . ../pdpclib/dllcrt.c
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__EXPORT__ -I ../pdpclib -I . kernel32.c
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__32BIT__ -I ../pdpclib -I . pos.c
rem ml -c -coff support.s
aswin -o support.obj support.s
rem ldwin -s -o kernel32.dll --shared --kill-at dllcrt.o kernel32.o pos.o support.o
rem dlltwin -S aswin -k --export-all-symbols -D kernel32.dll kernel32.o -l kernel32.a
cl -LD -Fm -Fekernel32.dll dllcrt.obj kernel32.obj pos.obj support.obj
kernel32
Timestamp is 612a6f08 (Sun Aug 29 03:14:48 2021)
Preferred load address is 10000000
Start Length Name Class
0001:00000000 00000200H .text CODE
0002:00000000 00000000H .data DATA
0002:00000000 00000010H .bss DATA
Address Publics by Value Rva+Base Lib:Object
0000:00000000 ___safe_se_handler_table 00000000 <absolute>
0000:00000000 ___safe_se_handler_count 00000000 <absolute>
0001:00000000 ***@12 10001000 f dllcrt.obj
0001:00000010 _int86 10001010 support.obj
0001:00000010 _int86x 10001010 support.obj
0001:00000135 _enable 10001135 support.obj
0001:00000137 _disable 10001137 support.obj
0001:00000139 _inp 10001139 support.obj
0001:00000149 _inpw 10001149 support.obj
0001:0000015a _inpd 1000115a support.obj
0001:0000016a _outp 1000116a support.obj
0001:00000178 _outpw 10001178 support.obj
0001:00000187 _outpd 10001187 support.obj
0001:00000195 ___setj 10001195 support.obj
0001:000001c6 ___longj 100011c6 support.obj
0002:00000000 ___needdum 10002000 dllcrt.obj
entry point at 0001:00000000
Static symbols
to be the documented process, and I thought I would
use this opportunity to find out what a DLL actually is.
If I have two independent source files, foo.c and bar.c,
each with one function in it, ie foo() and bar()
respectively, is this something that is suitable to put
into a DLL, or is there an expectation that it all be
linked in to a single executable?
I ask because I have this code in dllcrt.c:
BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDll,
DWORD fdwReason,
LPVOID lpvReserved)
{
BOOL bRet;
/* DllMain() is optional, so it would be good to handle that case too. */
bRet = DllMain(hinstDll, fdwReason, lpvReserved);
return (bRet);
}
(apparently written by Alica).
Although the code works fine with gccwin, when I
tried to build my own kernel32.dll using the old
version of Visual Studio I have installed, I got a
link error which was resolved by adding an
underscore to the above name.
But the DLL being produced is very small and doesn't
contain the functions I want, and that is confirmed
by the link map.
Any idea what a DLL actually is?
Thanks. Paul.
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__EXPORT__ -I ../pdpclib -I . ../pdpclib/dllcrt.c
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__EXPORT__ -I ../pdpclib -I . kernel32.c
cl -c -O2 -Oi- -Zl -GS- -nologo -D__WIN32__ -D__32BIT__ -I ../pdpclib -I . pos.c
rem ml -c -coff support.s
aswin -o support.obj support.s
rem ldwin -s -o kernel32.dll --shared --kill-at dllcrt.o kernel32.o pos.o support.o
rem dlltwin -S aswin -k --export-all-symbols -D kernel32.dll kernel32.o -l kernel32.a
cl -LD -Fm -Fekernel32.dll dllcrt.obj kernel32.obj pos.obj support.obj
kernel32
Timestamp is 612a6f08 (Sun Aug 29 03:14:48 2021)
Preferred load address is 10000000
Start Length Name Class
0001:00000000 00000200H .text CODE
0002:00000000 00000000H .data DATA
0002:00000000 00000010H .bss DATA
Address Publics by Value Rva+Base Lib:Object
0000:00000000 ___safe_se_handler_table 00000000 <absolute>
0000:00000000 ___safe_se_handler_count 00000000 <absolute>
0001:00000000 ***@12 10001000 f dllcrt.obj
0001:00000010 _int86 10001010 support.obj
0001:00000010 _int86x 10001010 support.obj
0001:00000135 _enable 10001135 support.obj
0001:00000137 _disable 10001137 support.obj
0001:00000139 _inp 10001139 support.obj
0001:00000149 _inpw 10001149 support.obj
0001:0000015a _inpd 1000115a support.obj
0001:0000016a _outp 1000116a support.obj
0001:00000178 _outpw 10001178 support.obj
0001:00000187 _outpd 10001187 support.obj
0001:00000195 ___setj 10001195 support.obj
0001:000001c6 ___longj 100011c6 support.obj
0002:00000000 ___needdum 10002000 dllcrt.obj
entry point at 0001:00000000
Static symbols