Solved Injecting blank DLL

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

keto

Dank Tier Donator
Nobleman
May 25, 2013
151
1,648
1
I'd like to inject an almost blank dll, just for testing purpose. However, I'd like to know if there is a neat way to output if the injection has been successful or failed.

Can someone offer me his idea? :yo:
 

Syntax Error

Coder
Silenced
Meme Tier VIP
Nov 6, 2014
239
2,928
6
C++:
// _CRT_SECURE_NO_WARNINGS -- C++ -> Preprocessor
// multibyte
#include <Windows.h>
#include <iostream>
#include <cstdio>

void createConsole();
DWORD WINAPI myThread();

HMODULE g_hModule;

bool APIENTRY DllMain(HMODULE hMod, DWORD reason, LPVOID useless)
{

	switch (reason) {
	case DLL_PROCESS_ATTACH:
		g_hModule = hMod;
		DisableThreadLibraryCalls(hMod);
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&myThread, 0, 0, 0);
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_PROCESS_DETACH:
		break;
	case DLL_THREAD_DETACH:
		break;
	}
	return true;
}

DWORD WINAPI myThread()
{
	createConsole();
	std::cout << "Successfully Injected" << std::endl;

	FreeConsole();
	FreeLibraryAndExitThread(g_hModule, 0);
	return 0;
}

void createConsole()
{
	AllocConsole();
	freopen("CONOUT$", "w", stdout); // for standard output
	freopen("CONIN$", "r", stdin); // for standard input
	freopen("CONOUT$", "w", stdout); // for standard error output
}

C++:
// multibyte
#include <Windows.h>

bool APIENTRY DllMain(HMODULE hMod, DWORD reason, LPVOID useless)
{

	switch (reason) {
	case DLL_PROCESS_ATTACH:
		MessageBox(0, "Injected Successfully", "Epic DLL", MB_OK);
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_PROCESS_DETACH:
		MessageBox(0, "No longer injected", "Goodbye", MB_OK);
		break;
	case DLL_THREAD_DETACH:
		break;
	}
	return true;
}
 
Status
Not open for further replies.
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