Delayload won't work for DLL itself?
-
Hi, I've been writing application for Windows 95/98/Me which loads private DLL. In that DLL, I need to call functions in oleacc.dll that is not supported in Windows 95. To let single binary work on 3 different Windows, I tried Delayload option. /delayload:oleacc.dll option seems worked, since dependency walker didn't show oleacc.dll is used. Though, when I tried to load my private DLL by LoadLibrary(), it failed. (I'm using LoadLibrary() and GetProcAddress() to control my DLL to handle any error regarding to this DLL.) And of course, it worked fine on 98/Me. I'm quite sure any function belongs to oleacc was not called in DllMain(). If I commented out those functions, linker warned me that /delayload:oleacc.dll had no effect (which is supposed to be), and I could load my DLL. So, for me, it looks like Delaylod won't work for DLL itslef. Thinking about a background of this mechanism, I can't understand why it didn't work. Can anyone help me out? (Please forget about installing some optional kit on Windows 95, since my target is Japanese version and no one is available for that.) I love Code Project, do you? Kurotora
-
Hi, I've been writing application for Windows 95/98/Me which loads private DLL. In that DLL, I need to call functions in oleacc.dll that is not supported in Windows 95. To let single binary work on 3 different Windows, I tried Delayload option. /delayload:oleacc.dll option seems worked, since dependency walker didn't show oleacc.dll is used. Though, when I tried to load my private DLL by LoadLibrary(), it failed. (I'm using LoadLibrary() and GetProcAddress() to control my DLL to handle any error regarding to this DLL.) And of course, it worked fine on 98/Me. I'm quite sure any function belongs to oleacc was not called in DllMain(). If I commented out those functions, linker warned me that /delayload:oleacc.dll had no effect (which is supposed to be), and I could load my DLL. So, for me, it looks like Delaylod won't work for DLL itslef. Thinking about a background of this mechanism, I can't understand why it didn't work. Can anyone help me out? (Please forget about installing some optional kit on Windows 95, since my target is Japanese version and no one is available for that.) I love Code Project, do you? Kurotora
Hello, the codegurus around the world.;) Actually, I can't understand your question very well. However, if you try to use DelayLoadProfile.exe from Matt in MSJ, DelayLoadProfile can't hook DLL calling from LoadLibrary as some ppls pointed out DLL site of this CodeProject. DelayLoadProfile only works for import table defined *.def to DLL. But, we can hook LoadLibrary and GetProcAddress from kernel32.dll by DelayLoadProfile.exe.:cool: Have a nice day!
-Masaaki Onishi-
-
Hello, the codegurus around the world.;) Actually, I can't understand your question very well. However, if you try to use DelayLoadProfile.exe from Matt in MSJ, DelayLoadProfile can't hook DLL calling from LoadLibrary as some ppls pointed out DLL site of this CodeProject. DelayLoadProfile only works for import table defined *.def to DLL. But, we can hook LoadLibrary and GetProcAddress from kernel32.dll by DelayLoadProfile.exe.:cool: Have a nice day!
-Masaaki Onishi-
-
Hi, I've been writing application for Windows 95/98/Me which loads private DLL. In that DLL, I need to call functions in oleacc.dll that is not supported in Windows 95. To let single binary work on 3 different Windows, I tried Delayload option. /delayload:oleacc.dll option seems worked, since dependency walker didn't show oleacc.dll is used. Though, when I tried to load my private DLL by LoadLibrary(), it failed. (I'm using LoadLibrary() and GetProcAddress() to control my DLL to handle any error regarding to this DLL.) And of course, it worked fine on 98/Me. I'm quite sure any function belongs to oleacc was not called in DllMain(). If I commented out those functions, linker warned me that /delayload:oleacc.dll had no effect (which is supposed to be), and I could load my DLL. So, for me, it looks like Delaylod won't work for DLL itslef. Thinking about a background of this mechanism, I can't understand why it didn't work. Can anyone help me out? (Please forget about installing some optional kit on Windows 95, since my target is Japanese version and no one is available for that.) I love Code Project, do you? Kurotora
I'm quite sure any function belongs to oleacc was not called in DllMain(). Maybe there are some global objects with c'tors calling oleacc functions? What's the error code after LoadLibrary? Tomasz Sowinski -- http://www.shooltz.com
-
Masaaki, I'm not interested in Delayloadprofile.exe at all.:confused: My question is, can DLL load another DLL when needed by using /delayload linker option as we do with EXE. Getting idea? I love Code Project, do you? Kurotora
Hello, the codegurus around the world.;) Eventually, I understood your question.:rolleyes: I didn't make DLL with loading DLL with delayload option. X| However, I got some reference about delayload in MSDN help.
Constraints of Delay Loading DLLs
There are constraints regarding the delay loading of imports.Imports of data cannot be supported. A workaround is to explicitly handle the data import yourself using LoadLibrary (or GetModuleHandle after you know the delay-load helper has loaded the DLL) and GetProcAddress.
Delay loading Kernel32.dll not supported. This DLL is necessary for the delay-load helper routines to perform the delay loading.
Binding of entry points that are forwarded is not supported.
Delay loading of a DLL may not result in the same behavior of the process if there are per-process initializations that occur in the entry point of the delay-loaded DLL. Other cases include static TLS (thread local storage, declared using __declspec(thread) which is not handled when the DLL is loaded via LoadLibrary. Dynamic TLS, using TlsAlloc,TlsFree,TlsGetValue,TlsSetValue is still available for use in either static or delay-loaded DLLs.
Static (global) function pointers should be reinitialized to imported functions after the first call to the function. This is because the first use of the function pointer will point to the thunk.
Have a nice day!
-Masaaki Onishi-
-
I'm quite sure any function belongs to oleacc was not called in DllMain(). Maybe there are some global objects with c'tors calling oleacc functions? What's the error code after LoadLibrary? Tomasz Sowinski -- http://www.shooltz.com
-
Tomasz, o No, there is no such objects related to oleacc. o LoadLibrary() returned zero. I'm mostly giving up to make single binary work on 3 different Windows.:(( I love Code Project, do you? Kurotora
LoadLibrary() returned zero. Check the value returned by GetLastError. BTW: below you'll find the Win95-related note from LoadLibrary docs. Windows 95: If you are using LoadLibrary to load a module that contains a resource whose numeric identifier is greater than 0x7FFF, LoadLibrary fails. Tomasz Sowinski -- http://www.shooltz.com
-
LoadLibrary() returned zero. Check the value returned by GetLastError. BTW: below you'll find the Win95-related note from LoadLibrary docs. Windows 95: If you are using LoadLibrary to load a module that contains a resource whose numeric identifier is greater than 0x7FFF, LoadLibrary fails. Tomasz Sowinski -- http://www.shooltz.com
-
Tomasz, GetLastError() returns 0x1f (ERROR_GEN_FAILURE). Same code works on Windows 98 (but it could be loading oleacc). Thanks. I love Code Project, do you? Kurotora
There's a KB article Q200767 dealing with ERROR_GEN_FAILURE and LoadLibrary. However, it applies to both Win95 and Win98. Last idea: try adding /delay:nobind to linker options. Tomasz Sowinski -- http://www.shooltz.com
-
There's a KB article Q200767 dealing with ERROR_GEN_FAILURE and LoadLibrary. However, it applies to both Win95 and Win98. Last idea: try adding /delay:nobind to linker options. Tomasz Sowinski -- http://www.shooltz.com