Solved CreateThread() causing crash

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Hey guys,
i'm a little puzzled by this. I'm trying to inject this dll into counterstrike source and for some reason whenever I use CreateThread it crashes on me (access violation).
Here's a screenshot https://prntscr.com/ar2d2p
I'm using the Extreme Injector v3.6.1 with standard injection method
Here's the code, most of it is commented out because I was trying to figure out what was causing the crash.

C++:
#define _USE_MATH_DEFINES
#define F6_KEY 0x75
#include <Windows.h>
//#include <iostream>
#include <algorithm>
#include <math.h>
#include <Psapi.h>
//#include "HackStructs.h"
//#include "functions.h"

DWORD WINAPI MainThread(LPVOID param)
{
	/*while (!GetAsyncKeyState(F6_KEY))
	{
		MyPlayer.ReadInformation();

		Aimbot();
	}*/
	//Sleep(2000);
	//FreeLibraryAndExitThread(NULL, 0);
	return 0;
}

BOOL WINAPI DllMain(
	HINSTANCE hInstance,
	DWORD dwReason,
	LPVOID lpReserved)
{
	switch (dwReason)
	{
	case DLL_PROCESS_ATTACH:
		CreateThread(0, 0, MainThread, hInstance, 0, 0);
		//AllocConsole();
		//AttachConsole(dwReason);
		//freopen("CONIN$", "r", stdin);
		//freopen("CONOUT$", "w", stdout);
		//freopen("CONOUT$", "w", stderr);
		break;
	
	}
}
plz ignore muh bad codenz kthx :fleep:
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Wow...
ok so turns out mambda was right to begin with. I'm so used to putting return 0 at the end of my main and forgot that I needed to put return true at the end and that was causing a crash...
Such a noobie mistake :facepalm:
Thanks @mamda and @rake
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
1. Add a default clause to your switch statement ( default: break; )
2. DllMain needs to return a value, not sure why VS hasnt yelled at you for that
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Thanks for fixing my noobie mistakes :p Unfortunately the crash is def caused by CreateThread or something called by CreateThread. When I try to break at the exception, visual studios opens up another window and it says "Frame not in module"

Surely this is some sort of anti-debug?

-edit-
I don't know if this is related but my injector keeps giving me this error too:
https://prntscr.com/ara2v3
Even after a successful injection
 
Last edited:

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
So your original code is never hit then? What you could instead do is repurpose an injector to createremotethread on your actual hack function, have it exported for ease of use, or hijack a thread and have it call your coide

Never hacked css, but i dont recall them having anything like that.
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
So your original code is never hit then? What you could instead do is repurpose an injector to createremotethread on your actual hack function, have it exported for ease of use, or hijack a thread and have it call your code

Never hacked css, but i dont recall them having anything like that.
https://prntscr.com/arhujc
The code hits just fine, but for whatever reason after executing the createthread function, it just crashes, and after it crashes the injector will show me that popup saying it returned null. And this only happens when I use createthread. I can call functions I write just fine, and if I comment out createthread it will run and exit just fine.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
no i mean the code in your HackThread, the thing youre running via CreateThread
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
no i mean the code in your HackThread, the thing youre running via CreateThread
Ah, no that never gets hit. I commented most everything out trying to figure out what was causing the crash. It's a very bare bones skeleton of a program at the moment lol
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,164
78,998
2,399
Ah, no that never gets hit. I commented most everything out trying to figure out what was causing the crash. It's a very bare bones skeleton of a program at the moment lol
inject it into a different process, if it works fine the problem lies with hl2.exe
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
But the problem's fixed so thats all that matters :p
 
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