Skip to content

Commit de356a4

Browse files
authored
Merge pull request #3 from 0xvpr/dev
Main <- Dev
2 parents 21164cc + 10756f1 commit de356a4

File tree

8 files changed

+190
-123
lines changed

8 files changed

+190
-123
lines changed

Makefile

+41-31
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,61 @@
1-
PROJECT = sp3
1+
PROJECT = sp3
22

3-
CC = i686-w64-mingw32-gcc
4-
CFLAGS = -std=c99 -O2 -masm=intel -Wall -Wextra #-Werror -Wshadow -Wpedantic -Wconversion
3+
CC = i686-w64-mingw32-gcc
4+
CFLAGS = -std=c99 -O2 -m32\
5+
-Wall -Wextra -Werror -Wshadow -Wpedantic -Wconversion\
6+
-Wno-error=attributes -Wno-error=pedantic
57

6-
LD = i686-w64-mingw32-gcc
7-
LDFLAGS = -shared
8+
LD = i686-w64-mingw32-ld
9+
LDFLAGS = -shared --entry=_DllMain@12
810

9-
ASM = nasm
10-
ASFLAGS = -f win32
11+
ASM = nasm
12+
ASFLAGS = -f win32
1113

12-
BIN = bin
13-
BUILD = build
14-
DEBUG = $(OBJ)/debug
15-
RELEASE = $(OBJ)/release
14+
BIN = lib
15+
BUILD = build
16+
DEBUG = $(OBJ)/debug
17+
RELEASE = $(OBJ)/release
1618

17-
SRC = src
18-
OBJ = build
19-
SOURCES = $(wildcard $(SRC)/*.c)
19+
SRC = src
20+
OBJ = build
21+
SOURCES = $(wildcard $(SRC)/*.c)
2022
DBG_OBJECTS = $(patsubst $(SRC)/%.c,$(DEBUG)/%_d.o,$(SOURCES))
2123
REL_OBJECTS = $(patsubst $(SRC)/%.c,$(RELEASE)/%.o,$(SOURCES))
2224

23-
INCLUDE = include
24-
INCLUDES = $(addprefix -I,$(INCLUDE))
25+
INCLUDE = include
26+
INCLUDES = $(addprefix -I,$(INCLUDE))
27+
HEADERS = $(wildcard $(INCLUDE)/*.h)
2528

26-
LIB_FILES = d3d9 d3dx9
27-
LIBS = $(addprefix -l,$(LIB_FILES))
29+
LIB_FILES = d3d9 d3dx9 kernel32 user32 msvcrt
30+
LIBS = $(addprefix -l,$(LIB_FILES))
2831

2932
ASM_TARGET = health_detour
3033
ASM_SRC = $(SRC)/asm
3134
ASM_OBJ = $(BUILD)/asm
3235
ASM_SOURCES = $(wildcard $(ASM_SRC)/*.asm)
3336
ASM_OBJECTS = $(patsubst $(ASM_SRC)/%.asm,$(ASM_OBJ)/%.obj,$(ASM_SOURCES))
3437

35-
#MAKEFLAGS += $(addprefix -j,$(shell nproc))
38+
MAKEFLAGS += $(addprefix -j,$(shell nproc))
3639

37-
all: debug release
40+
all: release
3841

3942
debug: $(DEBUG)
40-
release: $(PROJECT)
41-
43+
$(DEBUG): $(BIN)/$(PROJECT)_d.dll
4244
$(DEBUG): CFLAGS += -g
43-
$(DEBUG): $(OBJ) $(BIN) $(ASM_OBJECTS) $(DBG_OBJECTS)
44-
$(LD) $(LDFLAGS) $(ASM_OBJECTS) $(DBG_OBJECTS) $(LIBS) -o $(BIN)/$(PROJECT)_d.dll
4545

46-
$(PROJECT): CFLAGS += -O3 -fno-ident -fvisibility=hidden -funroll-loops -fno-function-sections -fPIE
46+
release: $(PROJECT)
47+
$(PROJECT): $(BIN)/$(PROJECT).dll
48+
$(PROJECT): CFLAGS += -march=native -Ofast -fPIE -funsafe-math-optimizations -fomit-frame-pointer
49+
$(PROJECT): CFLAGS += -funroll-loops -funsafe-loop-optimizations -funswitch-loops -floop-parallelize-all
50+
$(PROJECT): CFLAGS += -finline-functions -falign-functions -falign-loops -falign-jumps -fno-function-sections
51+
$(PROJECT): CFLAGS += -fno-ident -fvisibility=hidden -fstrict-aliasing
4752
$(PROJECT): LDFLAGS += -s
48-
$(PROJECT): $(OBJ) $(BIN) $(ASM_OBJECTS) $(REL_OBJECTS)
49-
$(LD) $(LDFLAGS) $(ASM_OBJECTS) $(REL_OBJECTS) $(LIBS) -o $(BIN)/$(PROJECT).dll
53+
54+
$(BIN)/$(PROJECT)_d.dll: $(OBJ) $(BIN) $(ASM_OBJECTS) $(DBG_OBJECTS)
55+
$(LD) $(LDFLAGS) $(ASM_OBJECTS) $(DBG_OBJECTS) $(LIBS) -o $@
56+
57+
$(BIN)/$(PROJECT).dll: $(OBJ) $(BIN) $(ASM_OBJECTS) $(REL_OBJECTS)
58+
$(LD) $(LDFLAGS) $(ASM_OBJECTS) $(REL_OBJECTS) $(LIBS) -o $@
5059

5160
$(ASM_OBJECTS): $(ASM_OBJ)/%.obj: $(ASM_SRC)/%.asm
5261
$(ASM) $(ASFLAGS) $^ -o $@
@@ -63,12 +72,13 @@ $(OBJ):
6372
mkdir -p build/release
6473

6574
$(BIN):
66-
mkdir -p bin
75+
mkdir -p lib
6776

6877
clean:
69-
rm -f bin/*
70-
rm -f build/{asm,debug,release}/*
78+
rm -f `find ./lib -name "*.dll"`
79+
rm -f `find ./build -name "*.o"`
80+
rm -f `find ./build -name "*.obj"`
7181

7282
extra-clean:
73-
rm -fr bin
83+
rm -fr lib
7484
rm -fr build

include/entity.h

+58-44
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,78 @@
1-
#ifndef _ENTITY_H
2-
#define _ENTITY_H
1+
#ifndef ENTITY_HEADER
2+
#define ENTITY_HEADER
33

44
#ifndef TYPE
55
#define TYPE(x) ((uintptr_t)x)
66
#endif /* TYPE */
77

88
typedef struct PlayerVtable
99
{
10-
void (* function_1)(void); // To Reverse Engineer
11-
void (* function_2)(void); // To Reverse Engineer
12-
void (* function_3)(void); // To Reverse Engineer
13-
void (* function_4)(void); // To Reverse Engineer
14-
void (* function_5)(void); // To Reverse Engineer
15-
void (* function_6)(void); // To Reverse Engineer
16-
void (* function_7)(void); // To Reverse Engineer
17-
void (* function_8)(void); // To Reverse Engineer
18-
void (* function_9)(void); // To Reverse Engineer
19-
void (* function_10)(void); // To Reverse Engineer
20-
void (* function_11)(void); // To Reverse Engineer
21-
void (* function_12)(void); // To Reverse Engineer
22-
void (__thiscall * function_13)(void *, int, int); // To Reverse Engineer
10+
void (__stdcall * func_00_10CD6AF0)(int arg1, int arg2, void * unknown); // To Reverse Engineer
11+
void (__stdcall * func_01_10CD6B00)(void); // To Reverse Engineer
12+
void (__stdcall * func_02_10CD6B10)(void); // To Reverse Engineer
13+
void (__thiscall * func_03_10B8C520)(void * this, unsigned char byte); // To Reverse Engineer
14+
void (__fastcall * func_04_1098DCC0)(int arg1); // To Reverse Engineer
15+
void (__fastcall * func_05_10A7E240)(int * arg1); // To Reverse Engineer
16+
void (__stdcall * func_06_10A799B0)(void); // To Reverse Engineer
17+
void (__fastcall * func_07_10CD7AC0)(int arg1); // To Reverse Engineer
18+
void (__fastcall * func_08_10B7E0A0)(int * arg1); // To Reverse Engineer
19+
void (__fastcall * func_09_10993690)(int arg1); // To Reverse Engineer
20+
void (__thiscall * func_10_1098DD40)(void * this); // To Reverse Engineer
21+
void (__fastcall * func_11_1092B9A0)(int arg1); // To Reverse Engineer
22+
void (__thiscall * func_12_10CF51B0)(void * this, int arg1, int arg2); // arg1 == 0x2B2 and arg2 != 0
23+
void (__thiscall * func_13_10CEE8A0)(void * this, int arg1, int arg2, int arg3); // args are non-zero
24+
void (__stdcall * func_14_10A797F0)(void); // To Reverse Engineer
25+
void (__stdcall * func_15_10CD6AD0)(void); // To Reverse Engineer
26+
void (__fastcall * func_16_109957C0)(int arg1); // To Reverse Engineer
27+
void (__thiscall * func_17_1098FDE0)(void * this, int arg1); // if arg2 == _DAT_111f690c
28+
void (__thiscall * func_18_10CF4890)(void * this, int arg1, int arg2, int arg3); // WHOLE LOTTA GANG SHIT
29+
void (__thiscall * func_19_10CDB320)(void * this, int arg1, int arg2, int arg3); // WHOLE LOTTA GANG SHIT
30+
void (__thiscall * func_20_10CDFEB0)(void * this); // Maybe not a fastcall????
31+
int (__stdcall * func_21_10CDB910)(void); // To Reverse Engineer
32+
int (__stdcall * func_22_1092AF90)(void); // To Reverse Engineer
33+
int (__stdcall * func_23_1092AFA0)(void); // To Reverse Engineer
34+
int (__thiscall * func_24_10A88BD0)(void * this, int arg1, int arg2, int arg3, // wtf .......................
35+
int arg4, void * arg5,void * arg6,void * arg7, int arg8, int arg9, // ...........................
36+
int arg10); // ....................is this
37+
void (__stdcall * func_25_1092AFB0)(void); // To Reverse Engineer
38+
void (__stdcall * func_26_1092AFC0)(void); // To Reverse Engineer
39+
void (__stdcall * func_27_1092AFD0)(void); // To Reverse Engineer
40+
void (__thiscall * func_28_10B852D0)(void * unknown); // No fucking clue but its huge
2341
} PlayerVtable;
2442

25-
typedef struct Entity
43+
typedef struct _Entity
2644
{
27-
PlayerVtable* lpVtable; // + 0x0000
28-
char _0xE8[0xE4];
29-
float x; // + 0x00E8
30-
float y; // + 0x00EC
31-
float z; // + 0x00F0
32-
char _0x420[0x32C];
33-
int health; // + 0x0420
45+
PlayerVtable* lpVtable; // + 0x0000
46+
char __0x0E8__[0x0E4]; // [ padding ]
47+
float x; // + 0x00E8
48+
float y; // + 0x00EC
49+
float z; // + 0x00F0
50+
char __0x420__[0x32C]; // [ padding ]
51+
int health; // + 0x0420
3452
} Entity;
3553

36-
typedef struct EntityObject
54+
typedef struct _GameWorld
3755
{
38-
struct Entity* entity;
39-
} EntityObject;
56+
Entity** entities;
57+
unsigned n_entities;
58+
} GameWorld;
4059

41-
typedef struct EntityList
60+
typedef struct _Door
4261
{
43-
struct EntityObject entities[99];
44-
} EntityList;
45-
46-
typedef struct Door
47-
{
48-
unsigned int door_type; // + 0x0000
49-
char _0x4B8[0x4B4];
50-
int access; // + 0x04B8
62+
unsigned door_type; // + 0x0000
63+
char __0x4B8__[0x4B4]; // [ padding ]
64+
int access; // + 0x04B8
5165
} Door;
5266

53-
typedef struct Weapon
67+
typedef struct _Weapon
5468
{
55-
int current_ammo; // + 0x0000
56-
int max_clip_size; // + 0x0004
57-
int total_ammo; // + 0x0008
58-
char _0x51C[0xF0];
59-
float minimum_reticle; // + 0x051C
60-
float bloom_x; // + 0x0520
61-
float bloom_y; // + 0x0524
69+
int current_ammo; // + 0x0000
70+
int max_clip_size; // + 0x0004
71+
int total_ammo; // + 0x0008
72+
char __0x51C__[0x0F0]; // [ padding ]
73+
float minimum_reticle; // + 0x051C
74+
float bloom_x; // + 0x0520
75+
float bloom_y; // + 0x0524
6276
} Weapon;
6377

64-
#endif
78+
#endif /* ENTITY_HEADER */

include/offsets.h

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#ifndef _OFFSETS_H
2-
#define _OFFSETS_H
1+
#ifndef OFFSETS_HEADER
2+
#define OFFSETS_HEADER
33

44
#include <stddef.h>
55
#include <stdint.h>
66

7-
uint32_t offsets_entity_list_base = 0x00A0DFEC;
7+
uint32_t offsets_game_world_base = 0x00A0DFEC;
88
uint32_t offsets_weapon_base = 0x00A0F434;
99

1010
uint32_t offsets_invisibility_base = 0x0027F12C;
@@ -17,10 +17,17 @@ uint32_t offsets_shotgun_ammo_base = 0x002FCFF0;
1717
uint32_t offsets_sniper_ammo_base = 0x002FBC58;
1818
uint32_t offsets_rapid_fire_base = 0x00178FA2;
1919

20-
uint16_t offsets_entity_list_pointers[2] = { 0x78, 0x5E4 };
21-
uint16_t offsets_weapon_pointers[3] = { 0x84, 0x6E0, 0x434 };
20+
uint16_t offsets_game_world_pointers[2] = {
21+
0x78,
22+
0x5E4
23+
};
24+
size_t offsets_game_world_pointers_size = ( sizeof(offsets_game_world_pointers)/sizeof(uint16_t) );
2225

23-
size_t offsets_entity_list_pointers_size = 2;
24-
size_t offset_weapon_pointers_size = 3;
26+
uint16_t offsets_weapon_pointers[3] = {
27+
0x84,
28+
0x6E0,
29+
0x434
30+
};
31+
size_t offsets_weapon_pointers_size = ( sizeof(offsets_weapon_pointers)/sizeof(uint16_t) );
2532

26-
#endif
33+
#endif /* OFFSETS_HEADER */

inject.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# This script is intended to work with Pidjeon for a seamless injection process.
88

99
TARGET="splintercell3.exe" # Change as necessary
10-
PAYLOAD="bin/sp3.dll" # Change as necessary
10+
PAYLOAD="lib/sp3.dll" # Change as necessary
1111
PIDJEON_PATH="${HOME}/.toolkit" # Change as necessary
1212

1313
export PATH=$PATH:"${PIDJEON_PATH}"

src/d3d9hook.c

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ BOOL GetD3D9Device(void** pTable, size_t Size)
5151
d3dpp.Windowed = TRUE;
5252

5353
HRESULT dummyDeviceCreated = IDirect3D9_CreateDevice(pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDummyDevice);
54-
5554
if (dummyDeviceCreated != S_OK)
5655
{
5756
// may fail in windowed fullscreen mode, trying again with g_windowed mode

src/events.c

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ bool events_HandleKeyboard(void)
127127

128128
if (GetAsyncKeyState(VK_HOME))
129129
{
130+
hack_GodMode(false);
131+
hack_GhostMode(false);
132+
hack_SuperWeapons(false);
133+
hack_DisableAlarms(false);
134+
hack_DisableEnemies(false);
135+
130136
return true;
131137
}
132138

0 commit comments

Comments
 (0)