变量名 | 类 型 | 静态 | 数组 | 备 注 | hModule | 整数型 | | | pLdrLoadDll | 整数型 | | | str | 整数型 | | | wzPath | 字节集 | | | wzName | 字节集 | | | ulong | 整数型 | | | hUser32 | 整数型 | | | pMessage | 整数型 | | |
hModule = GetModuleHandleA (“ntdll.dll”)pLdrLoadDll = GetProcAddress (hModule, “LdrLoadDll”) 如果真 (pLdrLoadDll = 0 ) 返回 () str = LocalAlloc ( #LMEM_ZEROINIT, 8 ) wzName = A2W (“user32.dll”, )wzPath = A2W (“C:\Windows\syswow64”, )__set_short (str, 0, lstrlenW (取指针_字节集型 (wzName )) × 2 ) __set_short (str, 2, __get_short (str, 0 ) + 2 ) __set (str, 4, 取指针_字节集型 (wzName )) 如果真 (call_4 (pLdrLoadDll, 取指针_字节集型 (wzPath ), 取指针_通用型 (ulong ), str, 取指针_通用型 (hUser32 )) ≠ 0 ) LocalFree (str ) 信息框 (“失败”, 0, , ) 返回 () LocalFree (str )pMessage = GetProcAddress (hUser32, “MessageBoxA”) 如果真 (pMessage = 0 ) 返回 ()call_4 (pMessage, 0, 取指针_文本型 (“使用 LdrLoadDll 加载dll测试结果,能弹这个信息框表示成功”), 取指针_文本型 (“LdrLoadDll”), #MB_OK )
c++代码
- typedef struct _UNICODE_STRING {
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
- } UNICODE_STRING, *PUNICODE_STRING;
- typedef NTSTATUS(NTAPI *LdrLoadDll)(PWSTR SearchPath, PULONG DllCharacteristics,
- PUNICODE_STRING DllName, PVOID *BaseAddress);
- typedef int(WINAPI *fun_MessageBox)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
- int _tmain(int argc, _TCHAR* argv[])
- {
- UNICODE_STRING str = { 0 };
- str.Buffer = L"user32.dll";
- str.Length = lstrlenW(str.Buffer) * sizeof(WCHAR);
- str.MaximumLength = str.Length + 2;
- HMODULE hModule = GetModuleHandleW(L"ntdll.dll");
- LdrLoadDll pFun = (LdrLoadDll)GetProcAddress(hModule, "LdrLoadDll");
- if (!pFun)return 0;
- HMODULE hUser32 = 0;
- ULONG ulong = 0;
- HRESULT hr = pFun(L"C:\\Windows\\syswow64", &ulong, &str, (PVOID*)&hUser32);
- if (hr != S_OK)
- {
- cout << "载入dll失败" << endl;
- return 0;
- }
- fun_MessageBox pMessage = (fun_MessageBox)GetProcAddress(hUser32, "MessageBoxA");
- if (!pMessage)return 0;
- pMessage(NULL, "使用 LdrLoadDll 加载dll测试结果,能弹这个信息框表示成功", "LdrLoadDll", MB_OK);
- return 0;
- }
复制代码
|