Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Delayload won't work for DLL itself?

Delayload won't work for DLL itself?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncementlearning
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kurotora
    wrote on last edited by
    #1

    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

    M T 2 Replies Last reply
    0
    • K 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

      M Offline
      M Offline
      Masaaki Onishi
      wrote on last edited by
      #2

      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-

      K 1 Reply Last reply
      0
      • M 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-

        K Offline
        K Offline
        Kurotora
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • K 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

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • K Kurotora

            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

            M Offline
            M Offline
            Masaaki Onishi
            wrote on last edited by
            #5

            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-

            1 Reply Last reply
            0
            • T Tomasz Sowinski

              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

              K Offline
              K Offline
              Kurotora
              wrote on last edited by
              #6

              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

              T 1 Reply Last reply
              0
              • K Kurotora

                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

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                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

                K 1 Reply Last reply
                0
                • T Tomasz Sowinski

                  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

                  K Offline
                  K Offline
                  Kurotora
                  wrote on last edited by
                  #8

                  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

                  T 1 Reply Last reply
                  0
                  • K Kurotora

                    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

                    T Offline
                    T Offline
                    Tomasz Sowinski
                    wrote on last edited by
                    #9

                    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

                    K 1 Reply Last reply
                    0
                    • T Tomasz Sowinski

                      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

                      K Offline
                      K Offline
                      Kurotora
                      wrote on last edited by
                      #10

                      Tomasz, /delay:nobind option didn't work. Thanks anyway. I love Code Project, do you? Kurotora

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups