Skip to content

Commit

Permalink
Added backup & fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
v3ctra authored Jul 13, 2020
1 parent abfe675 commit 842419b
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
#include <Windows.h>
#include <iostream>

#include "memory.hpp"
#include "ifexist.hpp"

using namespace std;

Injector inj;

DWORD pid;

bool DoesFileExist(const char* name) {
if (FILE* file = fopen(name, "r")) {
fclose(file);
return true;
}
else {
return false;
}
}
//now it's global
LPVOID ntOpenFile = GetProcAddress(LoadLibraryW(L"ntdll"), "NtOpenFile");

void bypass()
{
// Restore original NtOpenFile from external process
//credits: Daniel Krupiñski(pozdro dla ciebie byczku <3)
LPVOID ntOpenFile = GetProcAddress(LoadLibraryW(L"ntdll"), "NtOpenFile");
if (ntOpenFile) {
char originalBytes[5];
memcpy(originalBytes, ntOpenFile, 5);
Expand All @@ -31,6 +25,24 @@ void bypass()
else
{
cout << "Unable to bypass :(\n";
Sleep(2000);
exit(-1);
}
}

void Backup()
{
if (ntOpenFile) {
//So, when I patching first 5 bytes I need to backup them to 0? (I think)
char originalBytes[5];
memcpy(originalBytes, ntOpenFile, 5);
WriteProcessMemory(inj.process, ntOpenFile, originalBytes, 0, NULL);
}
else
{
cout << "Unable to backup :(\n";
Sleep(2000);
exit(-1);
}
}

Expand All @@ -49,26 +61,28 @@ int main()
inj.clientDLL = inj.GetModule(pid, "client.dll");

if (DoesFileExist("cheat.dll")) {
bypass();
bypass();

if (inj.inject(pid, "cheat.dll")) {
cout << "module injected!\n\n" << endl;
Backup();
Sleep(2000);
exit(0);
}
else
{
cout << "Injection failed!\n\n" << endl;
Backup();
Sleep(2000);
exit(0);
exit(-1);
}

}
else
{
cout << "cannot find cheat.dll\n\n";
Sleep(2000);
exit(0);
exit(-1);
}

return 0;
Expand Down

0 comments on commit 842419b

Please sign in to comment.