我发现了这段代码,用于注入dll文件并从中调用函数。我有一个exe和源代码。 exe工作正常,但是当我尝试编译源代码时,出现此错误:
LoadDll.cpp: In Funktion »bool ExecuteRemoteThread(HANDLE, BOOL, BOOL, wchar_t*, wchar_t*)«:
LoadDll.cpp:313:62: Fehler: ungültige Umwandlung von »DWORD (__attribute__((__stdcall__)) *)(RemoteThreadBlock*) {aka long unsigned int (__attribute__((__stdcall__)) *)(RemoteThreadBlock*)}« in »LPCVOID {aka const void*}« [-fpermissive]
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/windows.h:50:0,
from LoadDll.cpp:16:
c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/winbase.h:2215:24: Fehler: Argument 3 von »BOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*)« wird initialisiert [-fpermissive]
可以在以下位置找到源代码:https://pastebin.com/AuZpy57U
错误似乎在第313行
if ( ! WriteProcessMemory( hProcess, p, &RemoteThread, 0, 0 ) )
希望您能帮助我进行编译。
答案 0 :(得分:1)
if ( ! WriteProcessMemory( hProcess, p, &RemoteThread, 0, 0 ) )
您必须转换第三个参数:
if ( !WriteProcessMemory( hProcess, p, reinterpret_cast<LPCVOID>(&RemoteThread), 0, 0 ) )
要摆脱undefined reference to 'WinMain@16'
,您应该使用
int main()
{
int argc;
wchar_t **argv = CommandLineToArgvW(GetCommandLineW(), &argc);
// ...
代替
int wmain(int argc, wchar_t *argv[])
{
// ...