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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to use "LDRLoadDll" to load a dll in DDK?

how to use "LDRLoadDll" to load a dll in DDK?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestioncsharpc++
5 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    bahareh655
    wrote on last edited by
    #1

    Hi all I do appologize in advance for my question, because I couldn't find a related forum with my question!! I'm writting a program in DDK for secure booting of windows XP. I use NT-Native functions in kernel mode, but unfortunately there is not any reference or example of using these functions! I want to load some kernel mode dlls there(such as "hal.dll" in system32 folder) and use of "LDRLoadDLL" function whereas there is no good example of it's usage! I don't know how should I pass those dlls path address in the first input argument of this function? when I set NULL in it, I get error to load some kernel mode dll (Error such as "File not found" where it succeeds in loading only "ntdll.dll"!) and also I don't know how should be the dll's "path" format in first argument of function? I've seen ntdll.dll's source code for this function, but the correct format of path is some complex for me!! Here is the ntdll's source including "LDRLoadDll" function: http://source.winehq.org/source/dlls/ntdll/loader.c#L2007 I extremely hope you could help me!!!! Thanks in Advance.

    S 1 Reply Last reply
    0
    • B bahareh655

      Hi all I do appologize in advance for my question, because I couldn't find a related forum with my question!! I'm writting a program in DDK for secure booting of windows XP. I use NT-Native functions in kernel mode, but unfortunately there is not any reference or example of using these functions! I want to load some kernel mode dlls there(such as "hal.dll" in system32 folder) and use of "LDRLoadDLL" function whereas there is no good example of it's usage! I don't know how should I pass those dlls path address in the first input argument of this function? when I set NULL in it, I get error to load some kernel mode dll (Error such as "File not found" where it succeeds in loading only "ntdll.dll"!) and also I don't know how should be the dll's "path" format in first argument of function? I've seen ntdll.dll's source code for this function, but the correct format of path is some complex for me!! Here is the ntdll's source including "LDRLoadDll" function: http://source.winehq.org/source/dlls/ntdll/loader.c#L2007 I extremely hope you could help me!!!! Thanks in Advance.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      bahareh655 wrote:

      Here is the ntdll's source including "LDRLoadDll" function: http://source.winehq.org/source/dlls/ntdll/loader.c#L2007

      Well....that's Wine's source, which is not necessarily going to be the same as the Microsoft original.... Looking at a quick Google search for LdrLoadDLL[^] brings up this page[^], which documents A path format. There's also this page[^], which indicates that the Wine source is definitely very different to the Microsoft source.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      B 1 Reply Last reply
      0
      • S Stuart Dootson

        bahareh655 wrote:

        Here is the ntdll's source including "LDRLoadDll" function: http://source.winehq.org/source/dlls/ntdll/loader.c#L2007

        Well....that's Wine's source, which is not necessarily going to be the same as the Microsoft original.... Looking at a quick Google search for LdrLoadDLL[^] brings up this page[^], which documents A path format. There's also this page[^], which indicates that the Wine source is definitely very different to the Microsoft source.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        B Offline
        B Offline
        bahareh655
        wrote on last edited by
        #3

        Hello and Thanks of your reply! I saw "http://www.matcode.com/undocwin.h.txt" address, but it only declares the "LdrLoadDll" as below and doesn't use of it with providing a valid path for a dll! DWORD __stdcall LdrLoadDll( PWSTR *szcwPath, // Optional PDWORD pdwLdrErr, // Optional PUNICODE_STRING pUniModuleName, PHINSTANCE pResultInstance );

        S 1 Reply Last reply
        0
        • B bahareh655

          Hello and Thanks of your reply! I saw "http://www.matcode.com/undocwin.h.txt" address, but it only declares the "LdrLoadDll" as below and doesn't use of it with providing a valid path for a dll! DWORD __stdcall LdrLoadDll( PWSTR *szcwPath, // Optional PDWORD pdwLdrErr, // Optional PUNICODE_STRING pUniModuleName, PHINSTANCE pResultInstance );

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Did you look in the comments? There, it says this:

          szcwPath - Points to a null-terminated
          // wide character string that containes the "path"
          // variable where the system will look for the module.
          // szcwPath should have following format:
          // L"Path1;Path2;Path3;....;PathN;".
          // If szcwPath equal NULL, LdrLoadDll function
          // will perform search as LoadLibrary.

          So, setting szcwPath to something like L"C:\\Windows\\System32;C:\\Windows;" should be what you want?

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          B 1 Reply Last reply
          0
          • S Stuart Dootson

            Did you look in the comments? There, it says this:

            szcwPath - Points to a null-terminated
            // wide character string that containes the "path"
            // variable where the system will look for the module.
            // szcwPath should have following format:
            // L"Path1;Path2;Path3;....;PathN;".
            // If szcwPath equal NULL, LdrLoadDll function
            // will perform search as LoadLibrary.

            So, setting szcwPath to something like L"C:\\Windows\\System32;C:\\Windows;" should be what you want?

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            B Offline
            B Offline
            bahareh655
            wrote on last edited by
            #5

            Hi and thanks! Unfortunately it doesn't work! I have already examined this normal way of specifying a module path, but kernel mode is so sensitive and doesn't accept this format. This comment suggests how to seperate different paths of dlls. I think it should be in a different way to load dlls in "kernel mode(DDK)" specifically!

            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