d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Im Bored
123Next
Closed New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 22 2013 02:06pm
so i think i may start a diary or blog or something on my journey through game hacking. dll injection and function hooking of course patching game memory is lame and gay and pretty easily detectable.

who thinks i should blog about it.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 22 2013 04:14pm
well, there are already good info pages about that stuff in the internet. i think you should not do this, because it would be just redundancy.

if you still want to do it, write it good and understandable.
if you go for something that isnt yet "well" documented, pm me url to blog.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 22 2013 04:49pm
Quote (Richter @ Mar 22 2013 06:14pm)
well, there are already good info pages about that stuff in the internet. i think you should not do this, because it would be just redundancy.

if you still want to do it, write it good and understandable.
if you go for something that isnt yet "well" documented, pm me url to blog.


i havent found to many well documented informative websites for game hacking tbh. sure there is allot of code out there that might do a specific thing but there isnt a actual tutorial or anything that takes you through the motions. or at least i havent found one yet.

i am still looking for information on directx hooking so i can draw my own menus into the game. i have no experience with directx at all. i might just do some global hotkey shit instead... much easier.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 22 2013 05:05pm
you're right, the thing about directx could be a good topic to blog about.

if i were you, i first would create a dummy application which creates a basic directx output in a window. (so it is legal to make a dll injection)
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Mar 22 2013 05:15pm
I think you should do it. There's not a lot of blogs / tutorials on game hacking / memory editing.

You might even make a few bucks from ads.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 22 2013 05:23pm
you could write the stuff under linux and compile it with winelib, so that the result may end up cross-platform-compatible ;)
that would be even cooler :)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 22 2013 05:32pm
Quote (Richter @ Mar 22 2013 07:23pm)
you could write the stuff under linux and compile it with winelib, so that the result may end up cross-platform-compatible ;)
that would be even cooler :)


cross platform game hacks lmfao.

i think ill start off simple then work ahead. ill create my own little console rpg where a cpu and you the player each has 100 life and then you each take turns hitting each other. then ill show the process of finding memory addresses and pointers to things such as damage (generated via rand()), your hp, your opponents hp and your opponents damage.

then from there i will show how to use olly to debug functions so you can hook them so you can say increase your damage to 1000 a hit, or reduce your opponents damage to 0, or simply give yourself 1000 hp.

should be fairly interesting.

maybe ill do a pvp version over the network as well and do one that hooks the send info function (that sends current hp, and damage to other player) so that you can modify that before sending it down the wire.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Mar 22 2013 08:52pm
I think you should. I've been wanting to get into this for a while but just haven't got around to it, maybe now's the time. It'd be nice to be able to ask questions instead of getting stumped on tutorials and not have that option.

Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 22 2013 10:42pm
Quote (SelfTaught @ Mar 22 2013 10:52pm)
I think you should. I've been wanting to get into this for a while but just haven't got around to it, maybe now's the time. It'd be nice to be able to ask questions instead of getting stumped on tutorials and not have that option.


i jsut finished my game ill will be doing tests/documents on.

not the funnest game in the world but it will show the basics of function hooking and general game modifying.

i will prolly make another game later on to show how to parse/find structs of information like in most FPS games where theres a giant array of structs for every player in the game showing their position, hp, armor, etc.

Code
#include <stdio.h>
#include <stdlib.h>

char print_intro();
void print_directions();
char ask_attack();
void do_turn(int *HP, int *EN, int player);

int main()
{
   int pHP = 100, pEN = 20;
   int cHP = 100;
   int turn = 0;

   if(print_intro() == 'n')
   {
       printf("Thanks for playing!\n");
       return 0;
   }

   system("cls");

   print_directions();

   system("cls");

   do
   {
       if(turn == 0)
       {
           do_turn(&cHP, &pEN, turn);
           turn++;
       }
       else if(turn == 1)
       {
           do_turn(&pHP, 0, turn);
           turn--;
       }
   }while(pHP >= 0 && cHP >= 0);

   if(cHP >= 0)
   {
       printf("Sorry you lost!\n");
   }
   else if(pHP >= 0)
   {
       printf("Congrats you won!\n");
   }

   return 0;
}

char print_intro()
{
   char input;

   printf("Welcome to the most awesome best game ever made!\n");
   printf("Purpose of this game is to kill the npc before he kills you\nin a turn based fashion\n\n");
   printf("Would you like to play? y/n: ");

   input = fgetc(stdin);
   getchar();

   return input;
}

void print_directions()
{
   printf("To play simply enter in a command and it will attack your oponent.\n");
   printf("You have two attacks. A basic punch and a special energy attack which consumes 5 energy per attack but deals more damage.\n");
   printf("The first one to zero HP loses good luck!\n\nPress any key to continue...\n\n");
   getchar();
}

char ask_attack()
{
   char input;

   printf("\n[1] Punch\n");
   printf("[2] Kick\n");
   printf("[3] Fireball\n");
   printf("Which attack do you want to do: ");

   input = fgetc(stdin);
   getchar();

   printf("\n\n");

   return input;
}

void do_turn(int *HP, int *EN, int player)
{
   char attack = 0;
   int dmg = 0;

   if(player == 0)
   {
       attack = ask_attack();
       while(attack != '1' && attack != '2' && attack != '3')
       {
           printf("Invalid attack. Please try again.\n");
           attack = ask_attack();
       }

       if(attack == '1') //punch
       {
           dmg = rand()%5;
       }
       else if(attack == '2') //kick
       {
           dmg = rand()%10+2;
       }
       else if(attack == '3' && *EN >= 2)
       {
           dmg = rand()%20+10;
           *EN -= 2;
       }

       printf("You delt %d damage!\n", dmg);
       *HP -= dmg;
       if(*HP <=0)
       {
           printf("NPC HP is at %d/100 and you have %d energy\n\n", 0, *EN);
       }
       else
       {
           printf("NPC HP is at %d/100 and you have %d energy\n\n", *HP, *EN);
       }
   }
   else
   {
       dmg = rand()%20+1;
       printf("NPC delt %d damage!\n", dmg);
       *HP -= dmg;
       if(*HP <=0)
       {
           printf("Your HP is at %d/100\n\n", 0);
       }
       else
       {
           printf("Your HP is at %d/100\n\n", *HP);
       }
   }
}


This post was edited by AbDuCt on Mar 22 2013 10:52pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 23 2013 11:39am
my dll injector. i stole a few pieces of code but all dll injectors work the same way pretty much.

Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

BOOL InjectLibrary(HANDLE hProcess, char *fnDll) {

BOOL success = FALSE;
HANDLE hThread = NULL;
char *fnRemote = NULL;
FARPROC procLoadLibraryA = NULL;

size_t lenFilename = strlen(fnDll) + 1;

/* Allocate space in the remote process */
fnRemote = (char *)VirtualAllocEx(hProcess, NULL, lenFilename, MEM_COMMIT, PAGE_READWRITE);

if (fnRemote) {
 if (WriteProcessMemory(hProcess, fnRemote, fnDll, lenFilename, NULL)) {  //write the dll to the processes memory

  procLoadLibraryA = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA");  //load the get process address functions address
  hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)procLoadLibraryA, fnRemote, 0, NULL);  //create a remote thread in the process to start the dll

  if (hThread) {
   WaitForSingleObject(hThread, INFINITE);
   success = TRUE;
  }
 }

 VirtualFreeEx(hProcess, fnRemote, 0, MEM_RELEASE);  //release memory
}

return success;
}

int main() {
DWORD pid;

HWND hwnd = FindWindow(0, "ABCD");  //find this HWND of the game
GetWindowThreadProcessId(hwnd, &pid);  //get its process id to send to the injector function.
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

if(InjectLibrary(handle, "GameHack.dll"))  //inject our dll by passing it to our function
{
    printf("Game successfully injected!\n");
} else {
       printf("Game unsuccessfully injected!");
}

return 0;
}
Go Back To Programming & Development Topic List
123Next
Closed New Topic New Poll