2010-06-18 117 views
2

我'努力工作時的LdrLoadDll功能,並因與that..i沒有運氣也用Google搜索的一些例子有隻字不提知道它究竟沒有多少文檔或正確的示例..請檢查下面的代碼。狀態失敗LdrLoadDll

//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); 

當我執行上述我沒有得到處理niether有效status.Please幫助我這一點。

+0

希望我們看到更多的低層次的東西,像這樣的SO – unixman83 2011-07-01 05:05:10

回答

3

它的工作對我來說,當我intialized Unicode字符串像下面

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

爲什麼它已經否決了.. – kiddo 2011-05-16 13:29:07