Solved Change Char path?

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

t3fury

Newbie
Silenced
Jun 12, 2016
3
31
0
hi i was wondering if anyone can help me with this
C++:
#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>

using namespace std;
bool InjectDLL(DWORD ProcessID);

char FileToInject[] = "ACubeDLL.dll";
char ProcessName[] = "ac_client.exe";
typedef HINSTANCE(*fpLoadLibrary)(char*);


int main()
{
	DWORD processId = NULL;

	PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
	HANDLE hProcSnap;

	while (!processId)
	{
		system("CLS");
		cout << "Searching for " << ProcessName << "..." << endl;
		cout << "Make sure your game is running" << endl;
		hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

		if (Process32First(hProcSnap, &pe32))
		{
			do
			{
				if (!strcmp(pe32.szExeFile, ProcessName))
				{
					processId = pe32.th32ProcessID;
					break;
				}
			} while (Process32Next(hProcSnap, &pe32));
		}
		Sleep(1000);
	}


	while (!InjectDLL(processId))
	{
		system("CLS");
		cout << "DLL failed to inject" << endl;
		Sleep(1000);
	}

	cout << "DLL Injected successfuly!" << endl << endl;
	cout << "Closing Injector in 5 seconds" << endl;

	CloseHandle(hProcSnap);
	Sleep(5000);

	return 0;
}


bool InjectDLL(DWORD ProcessID)
{
	HANDLE hProc;
	LPVOID paramAddr;

	HINSTANCE hDll = LoadLibrary("KERNEL32");

	fpLoadLibrary LoadLibraryAddr = (fpLoadLibrary)GetProcAddress(hDll, "LoadLibraryA");

	hProc = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);

	char dllPath[250] = "C:\\HACKS\\";
	//char dllPath[250]; 

	strcat(dllPath, FileToInject);

	paramAddr = VirtualAllocEx(hProc, 0, strlen(dllPath) + 1, MEM_COMMIT, PAGE_READWRITE);
	bool memoryWritten = WriteProcessMemory(hProc, paramAddr, dllPath, strlen(dllPath) + 1, NULL);

	CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryAddr, paramAddr, 0, 0);

	CloseHandle(hProc);

	return memoryWritten;
}
Basically i'm trying remove the hardcoded location from this

C++:
char dllPath[250] = "C:\\HACKS\\";
to this

C++:
char dllPath[250] = "\\HACKS";
so it runs from the hacks folder in the exe directory, i have done before with other things i have coded but it doesn't seem to be working here. any suggestions?
 
Last edited:

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
remove the first \\

char dllPath[250] = "HACKS";
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
Few things, running directly from visual studio runs in i believe the same directory the source files are in, so ensure your Hacks folder is there.

Easy way to test, in main, print out argv[ 0 ], thats the file location of the binary, there is where you should create your hacks folder
 

bYt3_w4LK3r

Jr.Coder
Full Member
Nobleman
Nov 20, 2014
58
283
1
use the string returned by GetCurrentDirectory and append your "//HACKS" string. GetCurrentDirectory will return the directory where your program is executing... i think.
 

t3fury

Newbie
Silenced
Jun 12, 2016
3
31
0
sorry for the late reply, neither of them worked. its cool i'll write one from scratch ;)
 
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