我对C ++很陌生,而且我正在制作一个培训师(植物大战僵尸)我之前尝试为这个游戏制作一个培训师但是它没有记忆写作没有用,所以我尝试了另一种方法但是用这种方法它给了我一些错误:
54 |错误:从'DWORD {aka long unsigned int}'无效转换为'PDWORD
{aka long unsigned int *}'[-fpermissive] |1780 |错误:初始化参数2>'DWORDGetWindowThreadProcessId(HWND,PDWORD)'[-fpermissive] |
我只是不明白,但这三个更奇怪:
62 |错误:在'else'|
之前预期'}'70 |错误:'else'没有先前的'if'|
76 |错误:'else'没有先前的'if'|
我知道那些意思是什么,但在其他方面显然有一个}。并且在else之前有if语句
以下是代码:
/*
Plants vs Zombies Game of the year edition trainer
*/
#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[],DWORD BaseAddress);
void WriteToMemory(HANDLE hProcHandle);
std::string GameName = "PlantsVsZombies";
LPCSTR LGameWindow = "Plants vs. Zombies";
std::string GameStatus;
bool IsGameAvail;
bool UpdateOnNextRun;
//Zon var.
bool SunStatus;
BYTE SunValue[] = {0xA3, 0X1C, 0X0, 0X0};
DWORD SunBaseAddress = {0x025A9E00};
DWORD SunOffsets[] = {0x5560, 0x768, 0x0};
//Geld var.
bool MoneyStatus;
BYTE MoneyValue[] = {0xA3, 0X1C, 0X0, 0X0};
DWORD MoneyBaseAddress = {0x02589E00};
DWORD MoneyOffsets[] = {0x28, 0x82C, 0x0};
int main()
{
HWND hGameWindow = NULL;
int timeSinceLastUpdate = clock();
int GameAvailTMR = clock();
int OnePressTMR = clock();
DWORD dwProcID = NULL;
HANDLE hProcHandle = NULL;
UpdateOnNextRun = true;
std::string sSunStatus = "UIT";
std::string sMoneyStatus = "UIT";
while(!GetAsyncKeyState(VK_NUMPAD0));
{
if(clock() - GameAvailTMR > 100);
{
GameAvailTMR = clock();
IsGameAvail = false;
hGameWindow = FindWindow(NULL, LGameWindow);
if(hGameWindow)
{
GetWindowThreadProcessId( hGameWindow, dwProcID);
if(dwProcID != 0)
{
hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
if(hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL);
{
GameStatus = "Plants vs. Zombies.exe kon niet worden geopend";
}
else
{
GameStatus = "Plants vs. Zombies.exe is geopend en klaar om gehackt te worden";
IsGameAvail = true;
system("color 0A");
}
}
}
else
{
GameStatus = "Kon het process ID niet vinden";
system("color 0C");
}
}
else
{
GameStatus = "Plants vs. Zombies is niet gevonden";
system("color 0C");
}
if(UpdateOnNextRun || clock() - timeSinceLastUpdate > 5000)
{
system("cls");
std::cout << "---------------------------------------------------------------------------" << std::endl;
std::cout << " Plants vs Zombies Trainer" << std::endl;
std::cout << "---------------------------------------------------------------------------" << std::endl << std::endl;
std::cout << "Game Status: " << GameStatus << std::endl << std::endl;
std::cout <<"[NUMPAD1] Oneindig Zon: " << sSunStatus << std::endl;
std::cout <<"[NUMPAD2] Oneindig Geld: " << sMoneyStatus << std::endl;
std::cout <<"[NUMPAD0] Sluit de trainer";
}
if(IsGameAvail)
{
if(GetAsyncKeyState(VK_NUMPAD1))
{
OnePressTMR = clock();
SunStatus = !SunStatus;
UpdateOnNextRun = true;
if(SunStatus)sSunStatus = "ON";
else sSunStatus = "OFF";
}
else if(GetAsyncKeyState(VK_NUMPAD2))
{
OnePressTMR = clock();
MoneyStatus = !MoneyStatus;
UpdateOnNextRun = true;
if(MoneyStatus)sMoneyStatus = "ON";
else sMoneyStatus = "OFF";
}
}
if(clock() - OnePressTMR > 400)
{
if(IsGameAvail)
{
//Zon
if(GetAsyncKeyState(VK_NUMPAD1))
{
OnePressTMR = clock ();
SunStatus = !SunStatus;
UpdateOnNextRun = true;
if(SunStatus)sSunStatus = "AAN";
else sSunStatus = "UIT";
}
//Geld
else if(GetAsyncKeyState(VK_NUMPAD2))
{
OnePressTMR = clock ();
MoneyStatus = !MoneyStatus;
UpdateOnNextRun = true;
if(MoneyStatus)sMoneyStatus = "AAN";
else sMoneyStatus = "UIT";
}
}
}
CloseHandle(hProcHandle);
CloseHandle(hGameWindow);
return ERROR_SUCCESS;
}
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress)
{
DWORD pointer = BaseAddress;
DWORD pTemp;
DWORD pointerAddr;
for(int i = 0; i <PointerLevel; i++)
{
if(i == 0)
{
ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
}
pointerAddr = pTemp + Offsets[i];
ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, sizeof(pTemp), NULL);
}
}
void WriteToMemory(HANDLE hProcHandle)
{
DWORD AddressToWrite;
if(SunStatus)
{
AddressToWrite = FindDmaAddy(2, hProcHandle, SunOffsets, SunBaseAddress);
WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite, &SunValue, sizeof(SunValue), NULL);
}
if(MoneyStatus)
{
AddressToWrite = FindDmaAddy(2, hProcHandle, MoneyOffsets, MoneyBaseAddress);
WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite, &MoneyValue, sizeof(MoneyValue), NULL);
}
}
提前致谢
答案 0 :(得分:1)
编译器通常在其消息中是正确的,您还应该阅读其警告。你的代码实际上充满了愚蠢的小错误。
if(clock() - GameAvailTMR > 100);
结尾;
在此关闭if
,因此其他内容不会附加到其中
GetWindowThreadProcessId( hGameWindow, dwProcID);
当函数签名需要LPDWORD时,dwProcID是一个DWORD,即DWORD *。只需写下GetWindowThreadProcessId( hGameWindow, &dwProcID);
不要忘记,当你在一行上看到错误时,也请阅读上面的错误。只需修复所有错误和警告,如果仍有问题,请回到此处