sizeof operand and undeclared identifier errors

closed account (GhqjLyTq)
I'm getting these errors when I try to compile my program:
1
2
3
4
5
6
7
8
(7): error C2065: 'percent' : undeclared identifier
(7): error C2065: 'percent' : undeclared identifier
(18): error C2065: 'percent' : undeclared identifier
(18): error C2070: ''unknown-type'': illegal sizeof operand
(19): error C2065: 'percent' : undeclared identifier
(20): error C2065: 'percent' : undeclared identifier
(22): error C2065: 'percent' : undeclared identifier
(27): warning C4551: function call missing argument list

Here's my source code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <Windows.h>
using namespace std;
int main (int argv, int argc)
{
	if(argv = NULL) {int percent = 100;} else {int percent = argv;}; // set the percent to 100 or an argument
	if(percent = argv); else {cout << "Enter the speed as a %: "; cin >> percent;}
	HWND hWnd = FindWindow(NULL, "World of Warcraft"); // get the window handle
	if(hWnd == 0) {
		cout << "\nError: WoW must be running.\n";
	} else {
		DWORD pid;
		GetWindowThreadProcessId(hWnd, &pid); // get its process id from its window handle
		HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); // open the process
		if(!hProcess) {
			cout << "Error: Could not attach.\n";
		} else {
			DWORD datasize = sizeof( percent ); // get the size of the new value
			(WriteProcessMemory(hProcess, (LPVOID) 0xE96AFFFFFF909090, &percent, datasize, NULL) // write the new speed
			(WriteProcessMemory(hProcess, (LPVOID) 0x85F60F86F2000000, &percent, datasize, NULL)));
			{
			cout << "Speed set to" << percent << "%.\n";
			}
			CloseHandle(hProcess); // close the handle to the process
		}
	}
	if (argv = NULL) {
		main; // restart 
	}
	return 0;
}

I searched google and couldn't find anything. Anyone know how to fix the errors?
Variables are destroyed at the end of their scope and are not visible outside of it.
closed account (GhqjLyTq)
Alright, that fixed it, but now im getting these errors:
 
error LNK2028: unresolved token (0A0003CC) "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

 
error LNK2028: unresolved token (0A000488) "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

 
error LNK2019: unresolved external symbol "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

 
error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
Last edited on
You probably forgot to link something, I guess googling for the error message will help you with that.
But first fix the remaining errors:
1. The main declaration should be: int main (int argc, char** argv)
2. The equality comparison operator is ==, not =.
3. main is not a function call. It just takes main's address and discards it. You cannot call main yourself anyway, since that results in undefined behavior. Use loops instead.
closed account (GhqjLyTq)
Got it to compile now, thanks for your help.
Topic archived. No new replies allowed.