d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Informational Progress Blog
Prev12
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 25 2013 08:34pm
Quote (SelfTaught @ Mar 25 2013 10:24pm)
Np, it was my fault lol.

What games do you plan on using in your future tutorials?

I'd personally like to see some tutorials involving D2 solely for the fact that there is a ton of information about hacking that game.

That being said it'd be a good place to build a foundation and gain some experience for newbies with close to none like myself.

Just a suggestion though. I'll follow the tuts either way.


i think i am going to go after some not so well know fps when im dont making this tutorial thing. would be kinda cool to learn how to parse player entities to create an aimbot.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 26 2013 06:46am
Code
//A simple define to reduce typing? auto generated by codeblocks pretty useless.

thats not true imo

usually you want to use the "h" file of the dll-code for two things:

1) create a export list in the dll
this must be done only at compile time of the dll
in this step the BUILD_DLL needs to be set
so the compiling only the dll gets:
g++ -c -DBUILDING_MYDLL mydll.cpp

2) import that list in other c files
this is used as soon as you use the library (linking time)
in this step the BUILD_DLL must not be set
so the linking command will be something like this:
g++ -shared -o mydll.dll mydll.o -Wl,--out-implib,libmydll.a

without the define-code-lines, you would need 2 different "h" files which you include in your dll-c-file and in your main-c-file... and i'm not even sure if that works with 2 files...
i'm not 100% sure if everything i said is right, but the define is really required ^^
Member
Posts: 2,478
Joined: Jan 4 2007
Gold: 7,545.00
Mar 26 2013 07:26am
Cool, this is one thing I've always wanted to do but never had the time.
Definitely tracked,
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 26 2013 11:11am
Quote (Richter @ Mar 26 2013 08:46am)
Code
//A simple define to reduce typing? auto generated by codeblocks pretty useless.

thats not true imo

usually you want to use the "h" file of the dll-code for two things:

1) create a export list in the dll
this must be done only at compile time of the dll
in this step the BUILD_DLL needs to be set
so the compiling only the dll gets:
g++ -c -DBUILDING_MYDLL mydll.cpp

2) import that list in other c files
this is used as soon as you use the library (linking time)
in this step the BUILD_DLL must not be set
so the linking command will be something like this:
g++ -shared -o mydll.dll mydll.o -Wl,--out-implib,libmydll.a

without the define-code-lines, you would need 2 different "h" files which you include in your dll-c-file and in your main-c-file... and i'm not even sure if that works with 2 files...
i'm not 100% sure if everything i said is right, but the define is really required ^^


thats true in a sense for the most part but that auto generated line is actually useless.

Code
#define DLL_EXPORT __declspec(dllexport)


to me it doesnt matter if i have to type __declspec(dllexport) or DLL_EXPORT so to me the define is useless. although i guess it does make reading the prototypes a bit easier.

Quote (DirtyRasa @ Mar 26 2013 09:26am)
Cool, this is one thing I've always wanted to do but never had the time.
Definitely tracked,


thanks. ive been a bit busier then i would like so im not sure when i will do the next installment of this. i might do a quick write up on the "game" i made that i am going to be testing on.

then ill prolly do a youtube video to describe how to obtain memory addresses/functions in ollydbg and how to modify game code to suit our needs.

This post was edited by AbDuCt on Mar 26 2013 11:13am
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 26 2013 11:37am
Quote (AbDuCt @ 26 Mar 2013 18:11)
to me it doesnt matter if i have to type __declspec(dllexport) or DLL_EXPORT so to me the define is useless. although i guess it does make reading the prototypes a bit easier.

well, there are actually two defines, depending on if-the-building-flag-was-set. in one the DLL_EXPORT gets a __asdfasdf(asdfEXPORT) and in the other case a __asdfasdf(asdfIMPORT) ;) so you would actually need two prototypes, and depending on the flag you have to chose which prototype is right... so you're absolutely right, its just for readability. though i thought i'd mention it, because the sentence is more confusing than helping, at least imo :)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 30 2013 12:37pm
http://forums.d2jsp.org/topic.php?t=66868328&f=276&p=448581585

added new code to my blog and commented it and explained what it does, how to use it and why you need to use it in the world of game/program hacking.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 30 2013 01:15pm
i've got no idea what u are doing and why u are doing it...
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 30 2013 01:54pm
Quote (Richter @ Mar 30 2013 03:15pm)
i've got no idea what u are doing and why u are doing it...


when game hacking you try to follow your variable back to a static base address (an address that never changes) so that no matter how many times you restart your game you will find your variables again. the reason why you need this is because ASLR randomizes where all your variables in memory so each game restart your variables will be in a different location.

what this code does is once you find your base pointer and the static offsets you can follow the pointers back to your variable no matter where it is in memory. without this you would have to reprogram your hack every game restart and would have to find the variable addresses over and over again by hand.
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Mar 30 2013 02:29pm
ok thx! now i i see it ;)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 21 2013 11:24pm
kind of gave up on my blog seeing how i would need to make a youtube video to describe half the shit im doing and i simply do not have the bandwidth to upload it at the moment.

instead ill just post some code to learn by well not really learn more like look at. this is some pretty basic stuff and anything advanced was already talked about in my blog.

this just shows that once you have access to a struct youre after how easy it is to make these things. im in the process of currently tracking down nearby players and finding their stats/buffs so that i can make my app suggest skills to use.

Code
#include "main.h"

bool AutoPot = false;
bool PvPAid  = false;

typedef struct {
   BYTE Unknown01[0x488]; //Unknown stuff
   DWORD Id;
   DWORD Level;
   DWORD Cultivation;  //create defines for cultivations 0-22
   DWORD Current_HP;
   DWORD Current_MP;
   DWORD Exp;
   DWORD Spirit;
   DWORD Attribute_Points;
   DWORD Current_Chi;
   DWORD Attack_Level;
   DWORD Defence_Level;
   DWORD Critical_Rate;
   DWORD Rage_Damage; //200% + Rage_Damage
   DWORD Stealth_Level;
   DWORD Stealth_Detection_Level;
   DWORD Slaying_Level;
   DWORD Warding_level;
   DWORD Vitality_Points;
   DWORD Magic_Points;
   DWORD Strength_Points;
   DWORD Dextarity_Points;
   DWORD Max_HP;
   DWORD Max_MP;
   DWORD HP_Regen;
   DWORD MP_Regen;
   float Walk_Speed;
   float Run_Speed;
   float Swim_Speed;
   float Fly_Speed;
   DWORD Accuracy;
   DWORD Min_Attack_Damage;
   DWORD Max_Attack_Damage;
   DWORD Attack_Rate; // 20/value
   float Range;
   DWORD Min_Metal_Damage;
   DWORD Max_Metal_Damage;
   DWORD Min_Wood_Damage;
   DWORD Max_Wood_Damage;
   DWORD Min_Water_Damage;
   DWORD Max_Water_Damage;
   DWORD Min_Fire_Damage;
   DWORD Max_Fire_Damage;
   DWORD Min_Earth_Damage;
   DWORD Max_Earth_Damage;
   DWORD Min_Magic_Damage;
   DWORD Max_Magic_Damage;
   DWORD Metal_Defence;
   DWORD Wood_Defence;
   DWORD Water_Defence;
   DWORD Fire_Defence;
   DWORD Earth_Defence;
   DWORD Physical_Defence;
   DWORD Evasion;
   DWORD Max_Chi;
   DWORD Coins;
   DWORD Max_Coins;
} PLAYER;

DWORD *ReadPointer(void* base, unsigned int level, ...) {
   unsigned long *output = (unsigned long*)base;
   va_list        offsets;

   va_start(offsets, level);

   for (unsigned int i = 0; i <= level; i++) {
       output = ((unsigned long*)(*output + va_arg(offsets, unsigned int)));
   }

   va_end(offsets);
   return (DWORD*)output;
}

void MenuPrompt() {

   char input[10] = {0};

   printf("Welcome to lol stuff\n");
   printf("Please select one or more of the options\n");
   printf("To stop selecting options and enable all selected enter -\n\n");

   printf("[ ] 1. Auto potter\n");
   printf("[ ] 2. PvP Buff Analyser Aid\n");

   while(1) {
       printf("Input your choice: ");
       fgets(input, 9, stdin);
       system("cls");

       if(strncmp(input, "1", 1) == 0 && AutoPot == true) {
           printf("[ ] 1. Auto potter\n");
           AutoPot = false;
       } else if(strncmp(input, "1", 1) == 0 || AutoPot == true) {
           printf("[x] 1. Auto potter\n");
           AutoPot = true;
       } else {
           printf("[ ] 1. Auto potter\n");
       }

       if(strncmp(input, "2", 1) == 0 && PvPAid == true) {
           printf("[ ] 2. PvP Buff Analyser Aid\n");
           PvPAid = false;
       } else if(strncmp(input, "2", 1) == 0 || PvPAid == true) {
           printf("[x] 2. PvP Buff Analyser Aid\n");
           PvPAid = true;
       } else {
           printf("[ ] 2. PvP Buff Analyser Aid\n");
       }

       if(strncmp(input, "-", 1) == 0) {
           break;
       }

   }
}

DWORD WINAPI Main() {
   //(void*)ReadPointer((void*)0x00BBC9CC, 1, 0x34);
   //REALBASEADDRESS = 0x00BBC26C
   //BASEADDRESS = 0x00BBC9CC

   if(AllocConsole()) {
       freopen("CONOUT$", "w", stdout);
       freopen("CONIN$", "r", stdin);

       MenuPrompt();

       if(AutoPot) {
           CreateThread(0, 0, (LPTHREAD_START_ROUTINE)AutoPotMain, 0, 0, 0);
       }

       //if(PvPAid) {
       //    CreateThread(0, 0, (LPTHREAD_START_ROUTINE)PvPAidMain, 0, 0, 0);
       //}

       Sleep(10000);
   }

   return NULL;
}

DWORD WINAPI AutoPotMain() {
   float CurrentHP = 0, MinimumHP = 0;
   HWND hWindow;

   PLAYER *Player_Stats = (PLAYER*)ReadPointer((void*)0x00BBC9CC, 1, 0x34);

   MinimumHP = (float)Player_Stats->Max_HP;
   MinimumHP *= 0.75;

   if((hWindow = FindWindow(NULL, TEXT("REDACTED"))) != NULL) {
       while(1) {
           CurrentHP = (float)Player_Stats->Current_HP;
           if(CurrentHP <= MinimumHP) {
               PostMessage(hWindow, WM_KEYDOWN, VK_F2, NULL);
               Sleep(75);
               PostMessage(hWindow, WM_KEYUP, VK_F2, NULL);
           }

           Sleep(5000);
       }
   }

   return NULL;
}

DLL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
   switch (fdwReason) {
   case DLL_PROCESS_ATTACH:
       DisableThreadLibraryCalls(hinstDLL);
       MessageBox(0, "Creating thread", "Successful Injection!", 0);
       CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Main, 0, 0, 0);
       break;
   }
   return TRUE;
}


Code
#ifndef __MAIN_H__
#define __MAIN_H__

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

/*  To use this exported function of dll, include this header
*  in your project.
*/

#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"{
#endif

   DLL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
   DWORD *ReadPointer(void* base, unsigned int level, ...);
   DWORD WINAPI Main();
   void MenuPrompt();
   DWORD WINAPI AutoPotMain();

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__


This post was edited by AbDuCt on Apr 21 2013 11:25pm
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll