Fout tijdens compilen "missing ')' before '__stdcall' "

Status
Niet open voor verdere reacties.

helpm3pls

Gebruiker
Lid geworden
7 dec 2008
Berichten
11
Hallo ik probeer de volgende code te compilen als Dynamic Linked Library.

code:
Code:
#include <windows.h>
#include "detours.h"
int (__stdcall* HelloFunction)(void);
void HookHelloFunction(void)
{
MessageBox(0, "You called the function : \"Hello\"", "Function Called", MB_OK);
return;
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
HelloFunction = (int (__stdcall*)(void))DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
DetourRemove((PBYTE)0x00401080, (PBYTE)HelloFunction); //Remove hook
break;
}
return TRUE;
}

dit geeft het volgende:
Code:
1>------ Build started: Project: main, Configuration: Debug Win32 ------
1>Compiling...
1>main.CPP
1>d:\project's\c++\hooking voorbeeld\hookingfunctionsdetourlibs_headers\main.cpp(15) : error C2143: syntax error : missing ')' before '__stdcall'
1>d:\project's\c++\hooking voorbeeld\hookingfunctionsdetourlibs_headers\main.cpp(15) : error C2059: syntax error : ')'
1>Build log was saved at "file://d:\Project's\C++\Hooking voorbeeld\HookingFunctionsDetourLibs_headers\Debug\BuildLog.htm"
1>main - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Ik heb alles gekopieerd en geplakt dus ik snap de fout niet helemaal. :confused: ...
 
Laatst bewerkt:
Ik heb geen verstand van het maken van DLLs, maar werkt het wel als je deze regel
Code:
HelloFunction = (int (__stdcall*)(void))DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);
vervangt door
Code:
HelloFunction = (int) (__stdcall*)(void)DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);
 
Ik heb geen verstand van het maken van DLLs, maar werkt het wel als je deze regel
Code:
HelloFunction = (int (__stdcall*)(void))DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);
vervangt door
Code:
HelloFunction = (int) (__stdcall*)(void)DetourFunction((PBYTE)0x0040108 0, (PBYTE)HookHelloFunction);

Hey, Supersnail

Bedankt voor je reactie.
Nu was die fout weg maar ga hij weer een nieuwe "syntax error"

Code:
1>------ Build started: Project: main, Configuration: Debug Win32 ------
1>Compiling...
1>main.CPP
1>d:\project's\c++\hooking voorbeeld\hookingfunctionsdetourlibs_headers\main.cpp(15) : error C2059: syntax error : '__stdcall'
1>Build log was saved at "file://d:\Project's\C++\Hooking voorbeeld\HookingFunctionsDetourLibs_headers\Debug\BuildLog.htm"
1>main - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
Je moet wel het juiste type gebruiken ;)

Code:
void (__stdcall* HelloFunction)(void);
void __stdcall HookHelloFunction(void)
{
MessageBox(0, "You called the function : \"Hello\"", "Function Called", MB_OK);
}


// main
HelloFunction = &HookHelloFunction;
HelloFunction();
 
Je moet wel het juiste type gebruiken ;)

Code:
void (__stdcall* HelloFunction)(void);
void __stdcall HookHelloFunction(void)
{
MessageBox(0, "You called the function : \"Hello\"", "Function Called", MB_OK);
}


// main
HelloFunction = &HookHelloFunction;
HelloFunction();

Hey CoD_NL,

Bedankt voor je reactie.
Dit deed 't 'm.
Bedankt! :thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan