[C++] Wired complier errors
Hello guys, I'm coding a dll to attach to my Gunz Online Server. It is meant to change the gravity vaule:
Code:
//Headers
#include <windows.h>
#include <stdio.h>
#define UpdateGravityADDR 0x004861F0 //Function Pointer
//Call Pointer
typedef VOID (__cdecl *ZModule_Movable)(float*);
ZModule_Movable UpdateGravity = (ZModule_Movable)UpdateGravityADDR;
//Gravidade
if (GetAsyncKeyState(VK_HOME)&0x8000){
UpdateGravity(10.00); // W00t 10 de gravidade FTW
}
if (reason == DLL_PROCESS_ATTACH){
//Show a message that the DLL was injected!
MessageBox(NULL,"Oia, ateh parece q deu certo...","DLL Beta",MB_OK);
//Create different Threads to prevent target process from stopping!
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&MainLoop,NULL,0,NULL);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&MainCheck,NULL,0,NULL);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&Respawn,0,NULL,NULL);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&ShotSpam1,0,NULL,NULL);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&ShotSpam2,0,NULL,NULL);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&Questing,0,NULL,NULL);
}
But I'm getting a wired error:
Code:
12 C:\Dev-Cpp\main.cpp expected unqualified-id before "if"
The code looks to be ok, what can be wrong? Thanks!
Re: [C++] Wired complier errors
Code:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#define UpdateGravityADDR 0x004861F0 //Function Pointer
void Gravity();
bool APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved){
if(dwReason == DLL_PROCESS_ATTACH){
DisableThreadLibraryCalls(hModule);
CreateThread(NULL, 0, (unsigned long(__stdcall*)(void*))Gravity, NULL, 0, NULL);
}
return TRUE;
}
void Gravity()
{
float GravityValue = 4.00;
bool i = true;
typedef VOID (__cdecl *ZModule_Movable)(float*);
ZModule_Movable UpdateGravity = (ZModule_Movable)UpdateGravityADDR;
//Gravidade
while(i == true)
{
if (GetAsyncKeyState('g')&0x8000)
{
UpdateGravity(&GravityValue); // W00t 10 de gravidade FTW
i = !i;
}
}
}
}
I compiled that successfully in VC++. I had to add user32.lib to the project manually though.
I believe you can add additional libraries in DevCPP by going to project options/properties, parameters and then linker. Add user32.lib.
Edit: It didn't work in-game though. - Edit again forgot to update code with dllmain.
Re: [C++] Wired complier errors
xD Thanks for the help. It might be not working for you because my runnable adresses are different from yours. If i get this to work, i will post it on Gunz Releases.
Going to test it, then I will post the results
Re: [C++] Wired complier errors
Good Luck Cereal, i'm waiting for you release! :D
Re: [C++] Wired complier errors
Good to know you got it fixed - but why are you using DevCPP as a IDE now? I'm pretty sure the last time I looked at it, it was outdated?!?
Re: [C++] Wired complier errors
Quote:
Originally Posted by
office.boy
Good to know you got it fixed - but why are you using DevCPP as a IDE now? I'm pretty sure the last time I looked at it, it was outdated?!?
Like you care. You just wanted to say that you're smart because you know some other IDE your coolness factor goes up with. Guess what? Some still us a plain text editor as IDE and they're happy with it. Go tell them their software is outdated.
Re: [C++] Wired complier errors
Quote:
Originally Posted by
Negata
Like you care. You just wanted to say that you're smart because you know some other IDE your coolness factor goes up with. Guess what? Some still us a plain text editor as IDE and they're happy with it. Go tell them their software is outdated.
I don't care - it was just a matter of question. So, before you bite by head of you little faggot - maybe interpret my post properly.
Re: [C++] Wired complier errors
Quote:
Originally Posted by
office.boy
Good to know you got it fixed - but why are you using DevCPP as a IDE now? I'm pretty sure the last time I looked at it, it was outdated?!?
Well, it can actually complie cpp code, and that's enough for me =P.
Ok, I have already fixed it, you can check the dll development on Gunz Section. Thanks for the help.