status failed for LdrLoadDll
        Posted  
        
            by kiddo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kiddo
        
        
        
        Published on 2010-06-18T11:34:15Z
        Indexed on 
            2010/06/18
            12:03 UTC
        
        
        Read the original article
        Hit count: 286
        
hello all,I'am trying to work-out the LdrLoadDll function and am having no luck with that..i also googled for some examples there is no much documentation or correct example about this.I know what it exactly does..Please check the code below.
//declaration function pointer for LdrLoadDll
typedef NTSTATUS (_stdcall*fp_LdrLoadDll)(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL, 
IN PUNICODE_STRING ModuleFileName, 
OUT PHANDLE ModuleHandle ); 
//calling LdrLoadDll using getprocaddress
 HANDLE handle;
  HMODULE module = LoadLibrary(L"ntdll.dll");
    fp_LdrLoadDll loadDll;
    loadDll = (fp_LdrLoadDll)GetProcAddress(module,"LdrLoadDll");
    if(loadDll == NULL)
    {
        MessageBox(0,L"Not able to load the function",L"LdrLoadDll",&handle);
    }
    UNICODE_STRING input;
    input.Buffer = L"C:\\Desktop\\myDll.dll";
    input.Length = wcslen(input.Buffer)*2;
    input.MaximumLength = wcslen(input.Buffer) +2;
    NTSTATUS status = loadDll(NULL,LOAD_WITH_ALTERED_SEARCH_PATH,&input,0);
When i execute the above am not getting the handle niether valid status.Please help me with this.
© Stack Overflow or respective owner