Solved How to make a thread?

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

F4DE

Newbie
Full Member
Mar 28, 2016
17
98
0
Hi,

I am using this code to start the DirectX overlay for my hack, but now I have no idea where to make threads to run things like Aimbot etc.
This is my main / starting code;
C++:
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{

	char * value = "Counter-Strike: Global Offensive";


	RECT rc;


	if (true) {

		HWND newhwnd = FindWindow(NULL, value);
		if (newhwnd != NULL){
			GetWindowRect(newhwnd, &rc);
			s_width = rc.right - rc.left;
			s_height = rc.bottom - rc.top;
		}
		else{
			ExitProcess(0);
		}
		WNDCLASSEX wc;

		ZeroMemory(&wc, sizeof(WNDCLASSEX));

		wc.cbSize = sizeof(WNDCLASSEX);
		wc.style = CS_HREDRAW | CS_VREDRAW;
		wc.lpfnWndProc = WindowProc;
		wc.hInstance = hInstance;
		wc.hCursor = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = (HBRUSH)RGB(0, 0, 0);
		wc.lpszClassName = "WindowClass";

		RegisterClassEx(&wc);

		hWnd = CreateWindowEx(0,
			"WindowClass",
			"",
			WS_EX_TOPMOST | WS_POPUP,
			rc.left, rc.top,
			s_width, s_height,
			NULL,
			NULL,
			hInstance,
			NULL);

		SetWindowLong(hWnd, GWL_EXSTYLE, (int)GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT);
		SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 0, ULW_COLORKEY);
		SetLayeredWindowAttributes(hWnd, 0, 255, LWA_ALPHA);

		ShowWindow(hWnd, nCmdShow);


		initD3D(hWnd);

		MSG msg;
		::SetWindowPos(FindWindow(NULL, value), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

		while (TRUE)
		{
			::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

			if (!FindWindow(NULL, value))
				ExitProcess(0);
			render();
			while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}

			if (msg.message == WM_QUIT)
				exit(0);


		}

		return msg.wParam;
	}
	else {

		exit(5);

	}
}
Tried to use this in my render code, but it doesn't reconize anything;

C++:
	ThreadStart ^ t_AimBot = gcnew ThreadStart(&Aimbot);
	Thread ^ AimBotThread = gcnew Thread(t_AimBot);
	AimBotThread->Start();
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
Allright, and how can I make my aimbot working without using /CLR?
CLR = Common language runtime = .NET

If you're doing C++ you don't need it, IDK why it is enabled in your project I don't understand what you're doing
 

F4DE

Newbie
Full Member
Mar 28, 2016
17
98
0
Allright, got the thread stuff working now.
Now, I am having the issue that when I actually enable the aimbot, I get this error:

Run-Time Check Failure #3 - The variable 'index' is being used without being initialized.

So, I changed the viariable 'int index;' to 'int index = 0;' but now my aimbot is always stuck to lock on at the ground for some reason..
In my other project, I use the same source code for the aimbot, but in there I get no error when using 'int index;'
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
So, I changed the viariable 'int index;' to 'int index = 0;' but now my aimbot is always stuck to lock on at the ground for some reason..
Can't help you without the code, but using the visual studio debugger will help you find the problem. Just put a breakpoint on the function that gets the target and does the angle calculation and the aiming. You will have code in there that doesn't work correctly, you will fix it and then your aimbot will work
 

F4DE

Newbie
Full Member
Mar 28, 2016
17
98
0
Rake;43758 said:
Can't help you without the code, but using the visual studio debugger will help you find the problem. Just put a breakpoint on the function that gets the target and does the angle calculation and the aiming. You will have code in there that doesn't work correctly, you will fix it and then your aimbot will work
The weird thing is that I use the exact same code in one of my other cheats, and on that one it works perfectly fine without initializing the variable.
Code that gives the error:
C++:
int ClosestEnemyToCrosshair(float maxfov)
{
	int index;
	for (int i = 0; i < 64; i++)
	{
		DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
		DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (i * 0x10));
		if (entitybase == LocalPlayer)
			continue;
		bool entitydormant = Mem.Read<bool>(entitybase + isDormant);
		if (entitydormant)
			continue;
		int entityteam = Mem.Read<int>(entitybase + m_iTeamNum);

		int LocalTeam = Mem.Read<int>(LocalPlayer + m_iTeamNum);
		if (entityteam == LocalTeam)
			continue;


		int entitylifestate = Mem.Read<byte>(entitybase + 0x25B); //is lifestate
		if (entitylifestate != 0)
			continue;

		DWORD Engine = Mem.Module("engine.dll");
		DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
		Vec3 currentangles = Mem.Read<Vec3>(clientstate + viewAngle);
		Vec3 pos = BonePos(entitybase, 0x2698, aimbone); //bonematrix
		float entitydistance = GetFOV(currentangles, position, pos);
		if (entitydistance < maxfov)
		{
			maxfov = entitydistance;
			index = i;
		}
	}
	return index;
}
The variable 'index' gives me the error, and it points at ' return index;'
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
The weird thing is that I use the exact same code in one of my other cheats, and on that one it works perfectly fine without initializing the variable.
Code that gives the error:
C++:
int ClosestEnemyToCrosshair(float maxfov)
{
	int index;
	for (int i = 0; i < 64; i++)
	{
		DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
		DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (i * 0x10));
		if (entitybase == LocalPlayer)
			continue;
		bool entitydormant = Mem.Read<bool>(entitybase + isDormant);
		if (entitydormant)
			continue;
		int entityteam = Mem.Read<int>(entitybase + m_iTeamNum);

		int LocalTeam = Mem.Read<int>(LocalPlayer + m_iTeamNum);
		if (entityteam == LocalTeam)
			continue;


		int entitylifestate = Mem.Read<byte>(entitybase + 0x25B); //is lifestate
		if (entitylifestate != 0)
			continue;

		DWORD Engine = Mem.Module("engine.dll");
		DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
		Vec3 currentangles = Mem.Read<Vec3>(clientstate + viewAngle);
		Vec3 pos = BonePos(entitybase, 0x2698, aimbone); //bonematrix
		float entitydistance = GetFOV(currentangles, position, pos);
		if (entitydistance < maxfov)
		{
			maxfov = entitydistance;
			index = i;
		}
	}
	return index;
}
The variable 'index' gives me the error, and it points at ' return index;'
Hmm maybe you compiled with different settings on your other project, here's what I see wrong:

#1 Not all control flow paths will assign a value to index, therefore returning index will give unexpected results
#2 You're passing maxfov by value, therefore when you do "maxfov = entitydistance;" that local variable goes out of scope when the function returns and that modification does not stick
 

F4DE

Newbie
Full Member
Mar 28, 2016
17
98
0
Rake;43768 said:
Hmm maybe you compiled with different settings on your other project, here's what I see wrong:

#1 Not all control flow paths will assign a value to index, therefore returning index will give unexpected results
#2 You're passing maxfov by value, therefore when you do "maxfov = entitydistance;" that local variable goes out of scope when the function returns and that modification does not stick
The other project has /CLR enabled, but the project I am making right now doesn't support CLR, and will have loads of errors if I enable it.
I just don't understand how the exact same code is working in my other project, and not in here because there aren't any of these problems that you pointed out above in that project.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
Well it appears like /CLR is your problem. If you're not interacting with .net applications don't use /CLR
 

F4DE

Newbie
Full Member
Mar 28, 2016
17
98
0
Rake;43772 said:
Well it appears like /CLR is your problem. If you're not interacting with .net applications don't use /CLR
Allright, and how can I make my aimbot working without using /CLR?
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods