我一直在努力创建一个通用的DLL,我可以把它注入到一个进程中。会弹出一个窗口。我有所有必需的功能,如WinMain(我命名为我的Initiate并手动调用它),DllWindowProcedure和DllMain。但是,在编译之后,有一个警告并且没有错误 - 我认为这是一个逻辑错误。如果您发现任何问题或我可以改进的任何问题,请告诉我们!
警告:
1> Main.cpp(43):警告C4060:switch语句不包含' case'或者'默认'标签
代码:
#include <Windows.h>
HINSTANCE InjectedModuleHandle;
LRESULT CALLBACK DllWindowProcedure(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI DllThreadProcedure(void * Data)
{
MessageBoxA(NULL, (LPCSTR)"Welcome to Flames v1.1!", (LPCSTR)"Startup Message", NULL);
MSG Messages;
WNDCLASSEX WindowClass;
WindowClass.hInstance = InjectedModuleHandle;
WindowClass.lpszClassName = L"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 = NULL;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hbrBackground = (HBRUSH)RGB(255, 255, 255);
RegisterClassEx(&WindowClass);
HWND Window = CreateWindowEx(0, L"DllWindowClass", L"Flames v1.1 - By XenoSaga3000", (WS_SYSMENU | WS_MINIMIZEBOX), 200, 200, 500, 450, FindWindow(NULL, L"ROBLOX"), CreateMenu(), InjectedModuleHandle, NULL);
ShowWindow(Window, SW_SHOWNORMAL);
while (GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
};
return 1;
};
LRESULT CALLBACK DllWindowProcedure(HWND Window, UINT Message, WPARAM WParameter, LPARAM LParameter)
{
switch (Message)
{
case WM_COMMAND:
switch(WParameter)
{
//Check for commands here.
};
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(Window, Message, WParameter, LParameter);
};
return 0;
};
bool APIENTRY DllMain(HMODULE DllInstance, DWORD Reason, LPVOID Reserved)
{
if(Reason == DLL_PROCESS_ATTACH)
{
InjectedModuleHandle = DllInstance;
CreateThread(0, NULL, DllThreadProcedure, NULL, NULL, NULL);
};
return TRUE;
};