开发者

status failed for LdrLoadDll

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.


It worked for me when I intialized the Unicode string like the following

RtlInitUnicodeString(&input,L"myDll.dll");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜