Solved How to inject dll located same directory

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

uixhc94

Newbie
Full Member
Nov 11, 2012
12
182
0
i saw this tutorial video. : C++ HOW TO HACK any game TUTORIAL [Trainer & DLL Injection] DIFFICULTY [2/10]

now i want to change dll directory from C:\\HACKS\\ to current one. i revised code but seems dont work.

char dllPath[250]="c:\\HACKS\\"; ----> char dllPath[250]; GetCurrentDirectory(MAX_PATH,dllpath) ;

yes, im a noob and not a native english speaker...anyone help me...
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,188
12,638
76
If you don't have a path, it will search for the file from the directory .exe is located at. Just give the filename and it will look in the same directory as the injector
 
Last edited by a moderator:

uixhc94

Newbie
Full Member
Nov 11, 2012
12
182
0
SOURCE CODE:

#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 secs." <<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\\";




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;




}
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,188
12,638
76
For relative folder, change
C++:
"c:\\HACKS\\"
to
C++:
"\\dllfolder"
, where injectable dll is located in the dllfolder and executable in a previous folder
 
  • Like
Reactions: uixhc94

velreine

Newbie
Full Member
Aug 27, 2012
36
504
0
char dllPath[250]; GetCurrentDirectory(MAX_PATH,dllpath) ;

First of all you're making the char array without assigning it a value because you put ;
Second, then you call a function "GetCurrentDirectory(x,x);" but it's not being used for anything.

Correct way to do it:

char dllPath[250] = GetCurrentDirectory(MAX_PATH, dllPath); // I havn't checked the functions parameters, but i suppose they are right.

EDIT: Nevermind i should've read GetCurrentDirectory's parameters before posting, on a side note i noted the output from GetCurrentDirectory is in format:

C:\FolderA\SubFolderA\

Instead of

C:\\FolderA\\SubFolderA\\

As the dllPath[250] is assigned. (By Fleep)
 
Last edited:

uixhc94

Newbie
Full Member
Nov 11, 2012
12
182
0
char dllPath[250] = GetCurrentDirectory(MAX_PATH, dllPath);

you cant do this. because return value is dword type.... not char.


DWORD GetCurrentDirectory(
DWORD nBufferLength,
LPTSTR lpBuffer );
 

velreine

Newbie
Full Member
Aug 27, 2012
36
504
0
This works just fine, just make sure that you're using Multi-Byte Character Set in your project.

Project -> 'Project Name' Properties -> Use Multi-Byte Character Set

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

using namespace std;


int main()
{

	char dllPath[250];

	GetCurrentDirectory(MAX_PATH, dllPath);

	

	cout << dllPath << endl;

	Sleep(15000);


}
 
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 League of Legends Accounts