我假设文件崩溃,因为在注入时,我得到一个等待光标,窗口永远不会弹出。它完美编译,没有警告或错误,然后在运行时不起作用。任何解释为什么我得到这个将对我修复它有很大帮助。谢谢!
代码(今天更新):
#include <windows.h>
LRESULT CALLBACK DllWindowProcedure(HWND ParentWindow, UINT Message, WPARAM WParam, LPARAM LParam)
{
switch (Message)
{
case WM_COMMAND:
//Do stuff.
break;
case WM_DESTROY:
ExitThread(0);
break;
case WM_QUIT:
ExitThread(0);
break;
default:
return DefWindowProc(ParentWindow, Message, WParam, LParam);
}
return 0;
}
DWORD __stdcall Initiate(void * PData)
{
WNDCLASSEX WindowClass;
WindowClass.hInstance = GetModuleHandle(NULL);
WindowClass.lpszClassName = "DllWindowClass";
WindowClass.lpfnWndProc = DllWindowProcedure;
WindowClass.style = CS_DBLCLKS;
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WindowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.lpszMenuName = "DllMenuClass";
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
HINSTANCE Instance = GetModuleHandle(NULL);
HWND ParentWindow = CreateWindowEx(
NULL,
"DllWindowClass",
"Agsploit - v1.1 - By: Agluk15",
(WS_SYSMENU | WS_MINIMIZEBOX),
200,
200,
500,
400,
NULL,
NULL,
Instance,
NULL
);
ShowWindow(ParentWindow, SW_SHOWNORMAL);
MSG Messages;
while (GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
};
return NULL;
};
bool WINAPI DllMain(HINSTANCE DllInstance, DWORD Reason, LPVOID Reserved)
{
DisableThreadLibraryCalls(DllInstance);
if (Reason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, Initiate, 0, 0, 0);
};
return true;
};
答案 0 :(得分:3)
这是一个明显的问题。
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Initiate, 0, 0, 0);
Initiate
对LPTHREAD_START_ROUTINE的明确演员表是死的赠品。
宣布启动如下:
DWORD __stdcall Initiate(void* pData)
{
...
}
从CreateThread中删除显式强制转换:
CreateThread(0, 0, Initiate, 0, 0, 0);
无论您的良好意图是什么,Dll注入都会导致系统不稳定。看来你不了解Windows上的线程调用以及系统程序员应该 - 这就是你不应该进行DLL注入的原因。小心翼翼。