Solved Dll Injected but Code Not Running

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
So I tried injecting this dll I made, and it seems to inject just fine, I can see the dll in the process's module list, but the code isn't being executed. Visual Studio will register that it is injected, i'll attach the process and the breakpoints will change from white saying it wont hit to a solid red color, but it won't hit the breakpoint.

C++:
#include <Windows.h>
#include <iostream>
#include "hooks.h"

DWORD WINAPI MainThread(LPVOID param)
{
	DWORD_PTR sig = FindPattern("SFMW.dll", "\x75\x5A\x8B\x0F", "xxxx");
	std::cout << sig << std::endl;
	sig += 0x2D;
	std::cout << sig << std::endl;
	MessageBox(NULL, "wangmeister", "bitchxxxxs", MB_OK);

	return 0;
}

DWORD WINAPI OverwriteValues()
{

	return 0;
}

BOOL WINAPI DLLMain(
	HINSTANCE hinstDLL,
	DWORD fdReason,
	LPVOID lpReserved)
{
	HANDLE thread1 = NULL;
	HANDLE thread2 = NULL;
	MessageBox(NULL, "test1", "xxxx", MB_OK);
	switch (fdReason)
	{
	case DLL_PROCESS_ATTACH:
		thread1 = CreateThread(0, 0, MainThread, hinstDLL, 0, 0);
		thread2 = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)OverwriteValues, NULL, NULL, NULL);
		AllocConsole();
		AttachConsole(fdReason);
		freopen("CONIN$", "r", stdin);
		freopen("CONOUT$", "w", stdout);
		freopen("CONOUT$", "w", stderr);
		break;
	}

	return TRUE;
}
Not sure why it's doing this, this is almost identical code to another project I was working on and it works perfectly..
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
YOu also want to open the std channels ( in, out, err ) before you create your threa dotherwise your thread's cout wont show anywhere , also because the console wasnt allocated yet.
 

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
Do you attach, set breakpoints, THEN inject?

Also, it'd probably be better to spawn one thread from DllMain, then in your main thread, handle the other threads you want to use. This way once you want to end your program, you can signal to the other threads that it's time to clean up. Be sure to call FreeLibraryAndExitThread at the end of your main thread once everything is finished. You can call GetModuleHandle("YourDLLName.dll");, then use the return value as the parameter in FLAET.
 

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
YOu also want to open the std channels ( in, out, err ) before you create your threa dotherwise your thread's cout wont show anywhere , also because the console wasnt allocated yet.
or just use
C++:
_cprintf(text ...);
instead and dont open any channels lel

and just btw
C++:
AllocConsole();
AttachConsole(GetProcessId(hInstance));
trololo
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Thanks for the replies guys, I have no idea what the f*ck I did but it started working again, lol. Thanks for the advice though, I'll start doing that in my code!

--edit--
Solaire, I call FLAET in my main thread, and when I try to unload my module it seems to work (the name disappears at least), but I cannot rebuild my dll because I get a permissions denied error because it's "in use" by the process that I injected it in. Is there anything special I need to do in DLL_PROCESS_DETACH?
 
Last edited:

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
Free your console before freeing your library
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Thank you mambda, GAFO666, and Solaire, it's working now :D Idk what I'd do without yall :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