LdrLoadDll 状态失败

发布于 2024-09-06 12:07:44 字数 922 浏览 1 评论 0原文

我正在尝试计算 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);

当我执行上述操作时,我没有得到句柄,也没有有效状态。请帮助我。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囍孤女 2024-09-13 12:07:45

当我像下面这样初始化 Unicode 字符串时,它对我有用

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

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

RtlInitUnicodeString(&input,L"myDll.dll");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文