Hard code packet inside function instead of using variable.

I've been trying to find a solution for that, but nothing worked so far, so I will ask here. This is the code I have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Source\ClientCore.cpp"


BYTE heal[9] = {0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

bool cSet = FALSE;
bool pCopied = FALSE;
bool iCopied = FALSE;
bool gmStart = FALSE;
bool gmOn = FALSE;


BOOL PRIVATE OnGameCommandSet(char** argv, int argc);
BOOL PRIVATE OnGameCommandStop(char** argv, int argc);


MODULECOMMANDSTRUCT ModuleCommands[]={
{"help",OnGameCommandHelp,"Displays help text"},
{"set",OnGameCommandSet,"Sets module for exploit."},
{"stop",OnGameCommandStop,"Stops module."},
{NULL}};


VOID EXPORT OnGameJoin(THISGAMESTRUCT* thisgame){
cSet = TRUE;
pCopied = FALSE;
iCopied = FALSE;
gmOn = FALSE;
return;}

BOOL EXPORT OnClientStart(){

return TRUE;}


DWORD EXPORT OnGamePacketBeforeReceived(BYTE* aPacket, DWORD aLen){

if ((aPacket[0] == 0x95) && (gmOn == TRUE)) {
   server->GameSendPacketToServer(heal,9);
   return 0;}

return aLen;}



DWORD EXPORT OnGamePacketBeforeSent(BYTE* aPacket, DWORD aLen){

if ((aPacket[0] == 0x24) && (cSet == TRUE)) {
   memcpy(heal+5,aPacket+1,4);
   server->GamePrintInfo("PID ready.");
   pCopied = TRUE;}

if ((aPacket[0] == 0x19) && (cSet == TRUE)) {
   memcpy(heal+1,aPacket+1,4);
   server->GamePrintInfo("IID ready.");
   iCopied = TRUE;}

if ((cSet == TRUE) && (iCopied == TRUE) && (pCopied == TRUE)){
    cSet = FALSE;
    gmOn = TRUE;
    server->GamePrintInfo("Have fun!");}

return aLen;}

BOOL PRIVATE OnGameCommandStop(char** argv, int argc){
server->GamePrintInfo("Disabled.");
cSet = FALSE;
pCopied = FALSE;
iCopied = FALSE;
gmOn = FALSE;
return TRUE;}


Take a loot at this part of the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
DWORD EXPORT OnGamePacketBeforeSent(BYTE* aPacket, DWORD aLen){

if ((aPacket[0] == 0x24) && (cSet == TRUE)) {
   memcpy(heal+5,aPacket+1,4);
   server->GamePrintInfo("PID ready.");
   pCopied = TRUE;}

if ((aPacket[0] == 0x19) && (cSet == TRUE)) {
   memcpy(heal+1,aPacket+1,4);
   server->GamePrintInfo("IID ready.");
   iCopied = TRUE;}

if ((cSet == TRUE) && (iCopied == TRUE) && (pCopied == TRUE)){
	cSet = FALSE;
	gmOn = TRUE;
	server->GamePrintInfo("Have fun!");}

return aLen;}


This is a god module for an old game called Diablo II. To activate the module first you have to pick an item from your inventary and the module will copy the item id:

1
2
3
4
if ((aPacket[0] == 0x24) && (cSet == TRUE)) {
   memcpy(heal+5,aPacket+1,4);
   server->GamePrintInfo("PID ready.");
   pCopied = TRUE;}


This will check the game for sending packet that starts with 24. 24 = lift/pick item from inventory, then it will copy the that item id and will store it into the variable aPacket. Let's asume that the packet looks like this (242d00000004000000 - where 24 is the packet for lift/pick item and 2d00000004000000 is the item id). Now if I keep this item in the same place in my inventory the ID will stay the same and never change. What I want to do here is instead of checking for item ID, remove the whole checking procedure and just hard code the packet 242d00000004000000 instead of using the aPacket variable. Hope that makes sense. Thanks in advance.
Last edited on
bump~
Topic archived. No new replies allowed.