├── .gitmodules ├── src ├── include │ ├── main.h │ ├── entityutil.h │ ├── util.h │ ├── cvars.h │ ├── mathutil.h │ ├── globals.h │ ├── detour.h │ ├── hooks.h │ └── sdk.h ├── cvars.c ├── features │ ├── features.h │ ├── misc.c │ ├── chams.c │ ├── aim.c │ ├── movement.c │ └── esp.c ├── main.c ├── entityutil.c ├── mathutil.c ├── globals.c ├── detour.c ├── util.c └── hooks.c ├── .gitignore ├── Makefile ├── inject.sh ├── README.org └── LICENSE /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/include/sdk"] 2 | path = src/include/sdk 3 | url = https://github.com/ValveSoftware/halflife.git 4 | -------------------------------------------------------------------------------- /src/include/main.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MAIN_H_ 3 | #define MAIN_H_ 4 | 5 | void load(void); 6 | void unload(void); 7 | void self_unload(void); 8 | 9 | #endif /* MAIN_H_ */ 10 | -------------------------------------------------------------------------------- /src/include/entityutil.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ENTITY_H_ 3 | #define ENTITY_H_ 1 4 | 5 | #include "sdk.h" 6 | 7 | cl_entity_t* get_player(int ent_idx); 8 | bool is_alive(cl_entity_t* ent); 9 | bool valid_player(cl_entity_t* ent); 10 | bool is_friend(cl_entity_t* ent); 11 | bool can_shoot(void); 12 | char* get_name(int ent_idx); 13 | 14 | #endif /* ENTITY_H_ */ 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /src/cvars.c: -------------------------------------------------------------------------------- 1 | 2 | #include "include/cvars.h" 3 | #include "include/sdk.h" 4 | #include "include/globals.h" 5 | 6 | DECL_CVAR(bhop); 7 | DECL_CVAR(autostrafe); 8 | DECL_CVAR(aimbot); 9 | DECL_CVAR(autoshoot); 10 | DECL_CVAR(esp); 11 | DECL_CVAR(chams); 12 | DECL_CVAR(crosshair); 13 | DECL_CVAR(tracers); 14 | DECL_CVAR(clmove); 15 | 16 | bool cvars_init(void) { 17 | REGISTER_CVAR(bhop, 1); 18 | REGISTER_CVAR(autostrafe, 0); 19 | REGISTER_CVAR(aimbot, 0); 20 | REGISTER_CVAR(autoshoot, 0); /* Only works with aimbot enabled */ 21 | REGISTER_CVAR(esp, 3); 22 | REGISTER_CVAR(chams, 1); 23 | REGISTER_CVAR(crosshair, 0); 24 | REGISTER_CVAR(tracers, 0); 25 | REGISTER_CVAR(clmove, 0); 26 | 27 | return true; 28 | } 29 | -------------------------------------------------------------------------------- /src/features/features.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FEATURES_H_ 3 | #define FEATURES_H_ 4 | 5 | #include "../include/sdk.h" 6 | 7 | enum visible_flags { 8 | NONE = 0, 9 | ENEMY_VISIBLE = 1, 10 | ENEMY_NOT_VISIBLE = 2, 11 | FRIEND_VISIBLE = 3, 12 | FRIEND_NOT_VISIBLE = 4, 13 | HANDS = 5, 14 | }; 15 | 16 | /*----------------------------------------------------------------------------*/ 17 | 18 | /* src/features/movement.c */ 19 | void bhop(usercmd_t* cmd); 20 | 21 | /* src/features/esp.c */ 22 | void esp(void); 23 | void correct_movement(usercmd_t* cmd, vec3_t old_angles); 24 | 25 | /* src/features/chams.c */ 26 | extern visible_flags visible_mode; 27 | bool chams(void* this_ptr); 28 | 29 | /* src/features/aim.c */ 30 | void aimbot(usercmd_t* cmd); 31 | 32 | /* src/features/misc.c */ 33 | void custom_crosshair(void); 34 | void bullet_tracers(usercmd_t* cmd); 35 | 36 | #endif /* FEATURES_H_ */ 37 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | # FIXME: Don't use C++ shit, build basic SDK 3 | # FIXME: Remove '-Wno-write-strings', add '-Wpedantic' 4 | CC=g++ 5 | INCLUDES=-Isrc/include/sdk/common -Isrc/include/sdk/public -Isrc/include/sdk/pm_shared -Isrc/include/sdk/engine 6 | CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES) 7 | LDFLAGS=-shared 8 | LDLIBS=-lm 9 | 10 | SRC=main.c util.c mathutil.c entityutil.c globals.c hooks.c cvars.c detour.c \ 11 | features/movement.c features/esp.c features/chams.c features/aim.c features/misc.c 12 | OBJ=$(addprefix obj/, $(addsuffix .o, $(SRC))) 13 | 14 | BIN=libhlcheat.so 15 | 16 | # ------------------------------------------------------------------------------ 17 | 18 | .PHONY: all clean inject 19 | 20 | all: $(BIN) 21 | 22 | clean: 23 | rm -f $(OBJ) 24 | rm -f $(BIN) 25 | 26 | inject: $(BIN) 27 | bash ./inject.sh 28 | 29 | # ------------------------------------------------------------------------------ 30 | 31 | $(BIN): $(OBJ) 32 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 33 | 34 | obj/%.c.o : src/%.c 35 | @mkdir -p $(dir $@) 36 | $(CC) $(CFLAGS) -o $@ -c $< 37 | -------------------------------------------------------------------------------- /src/include/util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef UTIL_H_ 3 | #define UTIL_H_ 1 4 | 5 | #include 6 | #include 7 | 8 | #include "sdk.h" 9 | #include "globals.h" 10 | 11 | typedef struct { 12 | uint8_t r, g, b; 13 | } rgb_t; 14 | 15 | /*----------------------------------------------------------------------------*/ 16 | 17 | #define ERR(...) \ 18 | do { \ 19 | fprintf(stderr, "hl-cheat: %s: ", __func__); \ 20 | fprintf(stderr, __VA_ARGS__); \ 21 | fputc('\n', stderr); \ 22 | } while (0) 23 | 24 | #define gl_drawline_points(p0, p1, w, col) \ 25 | gl_drawline(p0[0], p0[1], p1[0], p1[1], w, col); 26 | 27 | /*----------------------------------------------------------------------------*/ 28 | 29 | game_id get_cur_game(void); 30 | 31 | void engine_draw_text(int x, int y, char* s, rgb_t c); 32 | void draw_tracer(vec3_t start, vec3_t end, rgb_t c, float a, float w, float t); 33 | 34 | void gl_drawbox(int x, int y, int w, int h, rgb_t c); 35 | void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col); 36 | 37 | bool protect_addr(void* ptr, int new_flags); 38 | 39 | #endif /* UTIL_H_ */ 40 | -------------------------------------------------------------------------------- /src/include/cvars.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CVARS_H_ 3 | #define CVARS_H_ 4 | 5 | #include "sdk.h" 6 | #include "globals.h" 7 | 8 | #define CVAR_PREFIX "cv_" 9 | #define CVAR_HACK_ID 0x4000 /* (1<<14) One that is not in use by the game */ 10 | 11 | /* 12 | * DECL_CVAR: Declares cvar variable in source file. 13 | * DECL_CVAR_EXTERN: Same but for headers. 14 | * REGISTER_CVAR: Create the cvar, return cvar_t* 15 | * CVAR_ON: Returns true if the cvar is non-zero 16 | * 17 | * prefix | meaning 18 | * -------+------------------------------- 19 | * cv_* | cvar variable 20 | */ 21 | #define DECL_CVAR(name) cvar_t* cv_##name = NULL; 22 | 23 | #define DECL_CVAR_EXTERN(name) extern cvar_t* cv_##name; 24 | 25 | #define REGISTER_CVAR(name, value) \ 26 | cv_##name = \ 27 | i_engine->pfnRegisterVariable(CVAR_PREFIX #name, #value, CVAR_HACK_ID); 28 | 29 | #define CVAR_ON(name) (cv_##name->value != 0.0f) 30 | 31 | /*----------------------------------------------------------------------------*/ 32 | 33 | DECL_CVAR_EXTERN(bhop); 34 | DECL_CVAR_EXTERN(autostrafe); 35 | DECL_CVAR_EXTERN(aimbot); 36 | DECL_CVAR_EXTERN(autoshoot); 37 | DECL_CVAR_EXTERN(esp); 38 | DECL_CVAR_EXTERN(chams); 39 | DECL_CVAR_EXTERN(crosshair); 40 | DECL_CVAR_EXTERN(tracers); 41 | DECL_CVAR_EXTERN(clmove); 42 | 43 | /*----------------------------------------------------------------------------*/ 44 | 45 | bool cvars_init(void); 46 | 47 | #endif /* CVARS_H_ */ 48 | -------------------------------------------------------------------------------- /src/include/mathutil.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MATHUTIL_H_ 3 | #define MATHUTIL_H_ 1 4 | 5 | #include "sdk.h" 6 | 7 | /* Vector 2 for 2d points */ 8 | typedef float vec2_t[2]; 9 | 10 | /*----------------------------------------------------------------------------*/ 11 | 12 | #define DEG2RAD(n) ((n)*M_PI / 180.0f) 13 | #define RAD2DEG(n) ((n)*180.0f / M_PI) 14 | #define CLAMP(val, min, max) \ 15 | (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) 16 | 17 | /* Use indexes so it works for float[] as well as vec3_t */ 18 | #define vec_copy(dst, src) \ 19 | do { \ 20 | dst[0] = src[0]; \ 21 | dst[1] = src[1]; \ 22 | dst[2] = src[2]; \ 23 | } while (0) 24 | 25 | /*----------------------------------------------------------------------------*/ 26 | 27 | vec3_t vec3(float x, float y, float z); 28 | vec3_t vec_add(vec3_t a, vec3_t b); 29 | vec3_t vec_sub(vec3_t a, vec3_t b); 30 | bool vec_is_zero(vec3_t v); 31 | float vec_len2d(vec3_t v); 32 | void ang_clamp(vec3_t* v); 33 | void vec_norm(vec3_t* v); 34 | float angle_delta_rad(float a, float b); 35 | vec3_t vec_to_ang(vec3_t v); 36 | vec3_t matrix_3x4_origin(matrix_3x4 m); 37 | bool world_to_screen(vec3_t vec, vec2_t screen); 38 | 39 | #endif /* MATHUTIL_H_ */ 40 | -------------------------------------------------------------------------------- /src/include/globals.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GLOBALS_H_ 3 | #define GLOBALS_H_ 4 | 5 | #include "sdk.h" 6 | 7 | enum game_id { 8 | HL = 0, /* Half-Life 1 */ 9 | CS = 1, /* Counter-Strike 1.6 */ 10 | TF = 2, /* Team Fortress Classic */ 11 | DOD = 3, /* Day of Defeat */ 12 | }; 13 | 14 | /*----------------------------------------------------------------------------*/ 15 | 16 | /* 17 | * DECL_INTF: Macro for declaring interfaces and it's originals. 18 | * DECL_INTF_EXTERN: Extern version for the header. 19 | * 20 | * prefix | meaning 21 | * -------+------------------------------- 22 | * h_* | handler ptr (global scope) 23 | * i_* | interface ptr (global scope) 24 | * o_* | original interface (not a ptr) 25 | */ 26 | #define DECL_INTF(type, name) \ 27 | type* i_##name = NULL; \ 28 | type o_##name; 29 | 30 | #define DECL_INTF_EXTERN(type, name) \ 31 | extern type* i_##name; \ 32 | extern type o_##name; 33 | 34 | /*----------------------------------------------------------------------------*/ 35 | 36 | extern void* hw; 37 | 38 | extern game_id this_game_id; 39 | extern vec3_t g_punchAngles; 40 | extern float g_flNextAttack, g_flNextPrimaryAttack; 41 | extern int g_iClip; 42 | 43 | DECL_INTF_EXTERN(cl_enginefunc_t, engine); 44 | DECL_INTF_EXTERN(cl_clientfunc_t, client); 45 | DECL_INTF_EXTERN(playermove_t, pmove); 46 | DECL_INTF_EXTERN(engine_studio_api_t, enginestudio); 47 | DECL_INTF_EXTERN(StudioModelRenderer_t, studiomodelrenderer); 48 | 49 | extern game_t* game_info; 50 | extern void* player_extra_info; 51 | extern cl_entity_t* localplayer; 52 | 53 | /*----------------------------------------------------------------------------*/ 54 | 55 | bool globals_init(void); 56 | void globals_store(void); 57 | void globals_restore(void); 58 | 59 | #endif /* GLOBALS_H_ */ 60 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "include/main.h" 6 | #include "include/sdk.h" 7 | #include "include/globals.h" 8 | #include "include/cvars.h" 9 | #include "include/hooks.h" 10 | #include "include/util.h" 11 | 12 | static bool loaded = false; 13 | 14 | __attribute__((constructor)) /* Entry point when injected */ 15 | void load(void) { 16 | printf("hl-cheat: Injected.\n"); 17 | 18 | /* Initialize globals/interfaces */ 19 | if (!globals_init()) { 20 | ERR("Error loading globals, aborting"); 21 | self_unload(); 22 | return; 23 | } 24 | 25 | /* Create cvars for settings */ 26 | if (!cvars_init()) { 27 | ERR("Error creating cvars, aborting"); 28 | self_unload(); 29 | return; 30 | } 31 | 32 | /* Hook functions */ 33 | if (!hooks_init()) { 34 | ERR("Error hooking functions, aborting"); 35 | self_unload(); 36 | return; 37 | } 38 | 39 | /* Get game version after injecting */ 40 | this_game_id = get_cur_game(); 41 | 42 | i_engine->pfnClientCmd("echo \"hl-cheat loaded successfully!\""); 43 | 44 | loaded = true; 45 | } 46 | 47 | __attribute__((destructor)) /* Entry point when unloaded */ 48 | void unload(void) { 49 | if (loaded) { 50 | /* TODO: Remove our cvars */ 51 | 52 | globals_restore(); 53 | hooks_restore(); 54 | 55 | /* Manually restore OpenGL hooks here */ 56 | GL_UNHOOK(glColor4f); 57 | 58 | /* Close hw.so handler */ 59 | dlclose(hw); 60 | } 61 | 62 | printf("hl-cheat: Unloaded.\n\n"); 63 | } 64 | 65 | void self_unload(void) { 66 | /* 67 | * RTLD_LAZY: If the symbol is never referenced, then it is never resolved. 68 | * RTLD_NOLOAD: Don't load the shared object. 69 | */ 70 | void* self = dlopen("libhlcheat.so", RTLD_LAZY | RTLD_NOLOAD); 71 | 72 | /* Close the call we just made to `dlopen' */ 73 | dlclose(self); 74 | 75 | /* Close the call that our injector made */ 76 | dlclose(self); 77 | } 78 | -------------------------------------------------------------------------------- /src/features/misc.c: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/sdk.h" 3 | #include "../include/util.h" 4 | #include "../include/mathutil.h" 5 | #include "../include/entityutil.h" 6 | #include "../include/globals.h" 7 | #include "../include/cvars.h" 8 | #include "features.h" 9 | 10 | void custom_crosshair(void) { 11 | if (!CVAR_ON(crosshair)) 12 | return; 13 | 14 | /* Get window size, and then the center. */ 15 | int mx = game_info->m_width / 2; 16 | int my = game_info->m_height / 2; 17 | 18 | /* The real length is sqrt(2 * (len^2)) */ 19 | const int len = cv_crosshair->value; 20 | const int gap = 1; 21 | const float w = 1; 22 | const rgb_t col = { 255, 255, 255 }; 23 | 24 | /* 25 | * 1\ /2 26 | * X 27 | * 3/ \4 28 | */ 29 | gl_drawline(mx - gap, my - gap, mx - gap - len, my - gap - len, w, col); 30 | gl_drawline(mx + gap, my - gap, mx + gap + len, my - gap - len, w, col); 31 | gl_drawline(mx - gap, my + gap, mx - gap - len, my + gap + len, w, col); 32 | gl_drawline(mx + gap, my + gap, mx + gap + len, my + gap + len, w, col); 33 | } 34 | 35 | void bullet_tracers(usercmd_t* cmd) { 36 | /* Only draw if we are holding attack and we can shoot */ 37 | if (!CVAR_ON(tracers) || !(cmd->buttons & IN_ATTACK) || !can_shoot() || 38 | !is_alive(localplayer)) 39 | return; 40 | 41 | /* Get player eye pos, start of tracer */ 42 | vec3_t view_height; 43 | i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height); 44 | vec3_t local_eyes = vec_add(localplayer->origin, view_height); 45 | 46 | /* Get forward vector from viewangles */ 47 | vec3_t fwd; 48 | i_engine->pfnAngleVectors(cmd->viewangles, fwd, NULL, NULL); 49 | 50 | const int tracer_len = 3000; 51 | vec3_t end; 52 | end.x = local_eyes.x + fwd.x * tracer_len; 53 | end.y = local_eyes.y + fwd.y * tracer_len; 54 | end.z = local_eyes.z + fwd.z * tracer_len; 55 | 56 | /* NOTE: Change tracer settings here */ 57 | const float w = 0.8; 58 | const float time = 2; 59 | draw_tracer(local_eyes, end, (rgb_t){ 66, 165, 245 }, 1, w, time); 60 | } 61 | -------------------------------------------------------------------------------- /src/features/chams.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../include/util.h" 5 | #include "../include/entityutil.h" 6 | #include "../include/globals.h" 7 | #include "../include/cvars.h" 8 | #include "features.h" 9 | 10 | enum chams_settings { 11 | DISABLED = 0, 12 | PLAYER_CHAMS = 1, 13 | HAND_CHAMS = 2, 14 | /* ALL is 3, but we can OR player and hands */ 15 | }; 16 | visible_flags visible_mode; 17 | 18 | bool chams(void* this_ptr) { 19 | const int setting = cv_chams->value == 5.0f ? 7 : cv_chams->value; 20 | if (setting == DISABLED) 21 | return false; 22 | 23 | cl_entity_t* ent = i_enginestudio->GetCurrentEntity(); 24 | 25 | if (ent->index == localplayer->index && setting & HAND_CHAMS) { 26 | /* If we are rendering hands and setting is on, render them */ 27 | glDisable(GL_TEXTURE_2D); 28 | visible_mode = HANDS; /* Set for this call */ 29 | 30 | i_studiomodelrenderer->StudioRenderFinal(this_ptr); 31 | 32 | visible_mode = NONE; /* Reset for future calls */ 33 | glEnable(GL_TEXTURE_2D); 34 | return true; 35 | } else if (!(setting & PLAYER_CHAMS) || !valid_player(ent) || 36 | !is_alive(ent)) { 37 | /* If we don't want player chams, or this is not a player, stop */ 38 | return false; 39 | } 40 | 41 | const bool friendly = is_friend(ent); 42 | 43 | /* If we got here it means we are rendering a valid player */ 44 | glDisable(GL_TEXTURE_2D); 45 | 46 | glDisable(GL_DEPTH_TEST); /* Ignore depth (walls between target) */ 47 | visible_mode = friendly ? FRIEND_NOT_VISIBLE : ENEMY_NOT_VISIBLE; 48 | i_studiomodelrenderer->StudioRenderFinal(this_ptr); 49 | 50 | glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */ 51 | visible_mode = friendly ? FRIEND_VISIBLE : ENEMY_VISIBLE; 52 | i_studiomodelrenderer->StudioRenderFinal(this_ptr); 53 | 54 | /* Reset for future calls to glColor4f (from here or somewhere else) */ 55 | visible_mode = NONE; 56 | glEnable(GL_TEXTURE_2D); 57 | 58 | /* StudioRenderModel hook doesn't need to call original */ 59 | return true; 60 | } 61 | -------------------------------------------------------------------------------- /src/include/detour.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file detour.h 3 | * @brief Detour hooking library header 4 | * @author 8dcc 5 | * 6 | * https://github.com/8dcc/detour-lib 7 | */ 8 | 9 | #ifndef DETOUR_H_ 10 | #define DETOUR_H_ 11 | 12 | #ifdef __i386__ 13 | typedef uint32_t detour_ptr_t; 14 | #define JMP_SZ_ 7 /* Size of jmp instructions in 32bit */ 15 | #else 16 | typedef uint64_t detour_ptr_t; 17 | #define JMP_SZ_ 12 /* Size of jmp instructions in 64bit */ 18 | #endif 19 | 20 | typedef struct { 21 | bool detoured; 22 | void* orig; 23 | void* hook; 24 | uint8_t jmp_bytes[JMP_SZ_]; 25 | uint8_t saved_bytes[JMP_SZ_]; 26 | } detour_data_t; 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | 30 | void detour_init(detour_data_t* data, void* orig, void* hook); 31 | bool detour_add(detour_data_t* d); 32 | bool detour_del(detour_data_t* d); 33 | 34 | /*----------------------------------------------------------------------------*/ 35 | 36 | /* Declare the type for the original function */ 37 | #define DECL_DETOUR_TYPE(funcRet, newTypeName, ...) \ 38 | typedef funcRet (*newTypeName##_t)(__VA_ARGS__); 39 | 40 | /* Reset original bytes, call original, detour again. 41 | * Keep in mind that: 42 | * - The returned value of the original function is not stored. If the 43 | * function is not void, and you care about the return value, use 44 | * GET_ORIGINAL() instead. 45 | * - detourData is NOT a pointer, it expects the full struct 46 | * - funcType should be the same name passed to DECL_DETOUR_TYPE, without the 47 | * ending added by the macro ("_t") */ 48 | #define CALL_ORIGINAL(detourData, funcType, ...) \ 49 | { \ 50 | detour_del(&detourData); \ 51 | ((funcType##_t)detourData.orig)(__VA_ARGS__); \ 52 | detour_add(&detourData); \ 53 | } 54 | 55 | /* Same as CALL_ORIGINAL, but accepts an extra parameter for storing the 56 | * returned value of the original function */ 57 | #define GET_ORIGINAL(detourData, returnVar, funcType, ...) \ 58 | { \ 59 | detour_del(&detourData); \ 60 | returnVar = ((funcType##_t)detourData.orig)(__VA_ARGS__); \ 61 | detour_add(&detourData); \ 62 | } 63 | 64 | #endif /* DETOUR_H_ */ 65 | -------------------------------------------------------------------------------- /inject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pid=$(pidof "hl_linux") 4 | libpath=$(realpath "libhlcheat.so") 5 | 6 | if [ "$pid" == "" ]; then 7 | echo "inject.sh: process not running." 8 | exit 1 9 | fi 10 | 11 | # Used to echo the command. For debugging. 12 | #set -x 13 | 14 | if [ "$1" == "unload" ]; then 15 | sudo gdb -n -q -batch \ 16 | -ex "attach $pid" \ 17 | -ex "set \$dlopen = (void* (*)(char*, int))dlopen" \ 18 | -ex "set \$dlclose = (int (*)(void*))dlclose" \ 19 | -ex "set \$dlerror = (char* (*)(void))dlerror" \ 20 | \ 21 | -ex "set \$self = \$dlopen(\"$libpath\", 6)" \ 22 | -ex "call \$dlclose(\$self)" \ 23 | -ex "call \$dlclose(\$self)" \ 24 | \ 25 | -ex "call \$dlerror()" \ 26 | -ex "detach" \ 27 | -ex "quit" 28 | 29 | exit 0 30 | fi 31 | 32 | if grep -q "$libpath" "/proc/$pid/maps"; then 33 | echo -e "hl-cheat already loaded. Reloading...\n"; 34 | 35 | # 0x2 -> RTLD_NOW 36 | # 0x6 -> RTLD_LAZY | RTLD_NOLOAD 37 | # For more info on the 3 mid lines, see self_unload() in main.c 38 | sudo gdb -n -q -batch \ 39 | -ex "attach $pid" \ 40 | -ex "set \$dlopen = (void* (*)(char*, int))dlopen" \ 41 | -ex "set \$dlclose = (int (*)(void*))dlclose" \ 42 | -ex "set \$dlerror = (char* (*)(void))dlerror" \ 43 | \ 44 | -ex "set \$self = \$dlopen(\"$libpath\", 6)" \ 45 | -ex "call \$dlclose(\$self)" \ 46 | -ex "call \$dlclose(\$self)" \ 47 | \ 48 | -ex "call \$dlopen(\"$libpath\", 2)" \ 49 | -ex "call \$dlerror()" \ 50 | -ex "detach" \ 51 | -ex "quit" 52 | else 53 | sudo gdb -n -q -batch \ 54 | -ex "attach $pid" \ 55 | -ex "set \$dlopen = (void* (*)(char*, int))dlopen" \ 56 | -ex "set \$dlclose = (int (*)(void*))dlclose" \ 57 | -ex "set \$dlerror = (char* (*)(void))dlerror" \ 58 | -ex "call \$dlopen(\"$libpath\", 2)" \ 59 | -ex "call \$dlerror()" \ 60 | -ex "detach" \ 61 | -ex "quit" 62 | fi 63 | 64 | set +x 65 | echo -e "\nDone." 66 | -------------------------------------------------------------------------------- /src/entityutil.c: -------------------------------------------------------------------------------- 1 | 2 | #include /* dlsym() */ 3 | #include 4 | 5 | #include "include/sdk.h" 6 | #include "include/util.h" 7 | #include "include/entityutil.h" 8 | 9 | cl_entity_t* get_player(int ent_idx) { 10 | if (ent_idx < 0 || ent_idx > 32) 11 | return NULL; 12 | 13 | cl_entity_t* ent = i_engine->GetEntityByIndex(ent_idx); 14 | 15 | if (!valid_player(ent)) 16 | return NULL; 17 | 18 | return ent; 19 | } 20 | 21 | bool is_alive(cl_entity_t* ent) { 22 | return ent && ent->curstate.movetype != 6 && ent->curstate.movetype != 0; 23 | } 24 | 25 | bool valid_player(cl_entity_t* ent) { 26 | return ent && ent->player && ent->index != localplayer->index && 27 | ent->curstate.messagenum >= localplayer->curstate.messagenum; 28 | } 29 | 30 | bool is_friend(cl_entity_t* ent) { 31 | if (!ent) 32 | return false; 33 | 34 | /* Check the current game because this method only works for some games */ 35 | switch (this_game_id) { 36 | case TF: { 37 | extra_player_info_t* info = (extra_player_info_t*)player_extra_info; 38 | 39 | return info[ent->index].teamnumber == 40 | info[localplayer->index].teamnumber; 41 | } 42 | case CS: { 43 | extra_player_info_cs_t* info = 44 | (extra_player_info_cs_t*)player_extra_info; 45 | 46 | return info[ent->index].teamnumber == 47 | info[localplayer->index].teamnumber; 48 | } 49 | case DOD: { 50 | extra_player_info_dod_t* info = 51 | (extra_player_info_dod_t*)player_extra_info; 52 | 53 | return info[ent->index].teamnumber == 54 | info[localplayer->index].teamnumber; 55 | } 56 | case HL: 57 | default: 58 | return false; 59 | } 60 | } 61 | 62 | bool can_shoot(void) { 63 | return g_iClip > 0 && g_flNextAttack <= 0.0f && 64 | g_flNextPrimaryAttack <= 0.0f; 65 | } 66 | 67 | char* get_name(int ent_idx) { 68 | hud_player_info_t info; 69 | i_engine->pfnGetPlayerInfo(ent_idx, &info); 70 | 71 | return info.name; 72 | } 73 | 74 | game_id get_cur_game(void) { 75 | typedef void ( 76 | *COM_ParseDirectoryFromCmd_t)(const char*, char*, int, const char*); 77 | COM_ParseDirectoryFromCmd_t COM_ParseDirectoryFromCmd = 78 | (COM_ParseDirectoryFromCmd_t)dlsym(hw, "COM_ParseDirectoryFromCmd"); 79 | 80 | char game[FILENAME_MAX]; 81 | COM_ParseDirectoryFromCmd("-game", game, sizeof(game), "valve"); 82 | 83 | /* Get the current game we are playing */ 84 | if (game[0] == 'c' && game[1] == 's') /* cstrike */ 85 | return CS; 86 | else if (*game == 'd') /* dod */ 87 | return DOD; 88 | else if (*game == 't') /* tfc */ 89 | return TF; 90 | else 91 | return HL; 92 | } 93 | -------------------------------------------------------------------------------- /src/mathutil.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "include/sdk.h" 5 | #include "include/util.h" 6 | #include "include/mathutil.h" 7 | 8 | vec3_t vec3(float x, float y, float z) { 9 | vec3_t ret; 10 | 11 | ret.x = x; 12 | ret.y = y; 13 | ret.z = z; 14 | 15 | return ret; 16 | } 17 | 18 | vec3_t vec_add(vec3_t a, vec3_t b) { 19 | vec3_t ret; 20 | 21 | ret.x = a.x + b.x; 22 | ret.y = a.y + b.y; 23 | ret.z = a.z + b.z; 24 | 25 | return ret; 26 | } 27 | 28 | vec3_t vec_sub(vec3_t a, vec3_t b) { 29 | vec3_t ret; 30 | 31 | ret.x = a.x - b.x; 32 | ret.y = a.y - b.y; 33 | ret.z = a.z - b.z; 34 | 35 | return ret; 36 | } 37 | 38 | bool vec_is_zero(vec3_t v) { 39 | return v.x == 0.0f && v.y == 0.0f && v.z == 0.0f; 40 | } 41 | 42 | float vec_len2d(vec3_t v) { 43 | return sqrtf(v.x * v.x + v.y * v.y); 44 | } 45 | 46 | void ang_clamp(vec3_t* v) { 47 | v->x = CLAMP(v->x, -89.0f, 89.0f); 48 | v->y = CLAMP(remainderf(v->y, 360.0f), -180.0f, 180.0f); 49 | v->z = CLAMP(v->z, -50.0f, 50.0f); 50 | } 51 | 52 | void vec_norm(vec3_t* v) { 53 | v->x = isfinite(v->x) ? remainderf(v->x, 360.f) : 0.f; 54 | v->y = isfinite(v->y) ? remainderf(v->y, 360.f) : 0.f; 55 | v->z = 0.0f; 56 | } 57 | 58 | float angle_delta_rad(float a, float b) { 59 | float delta = isfinite(a - b) ? remainder(a - b, 360) : 0; 60 | 61 | if (a > b && delta >= M_PI) 62 | delta -= M_PI * 2; 63 | else if (delta <= -M_PI) 64 | delta += M_PI * 2; 65 | 66 | return delta; 67 | } 68 | 69 | vec3_t vec_to_ang(vec3_t v) { 70 | vec3_t ret; 71 | 72 | ret.x = RAD2DEG(atan2(-v.z, hypot(v.x, v.y))); 73 | ret.y = RAD2DEG(atan2(v.y, v.x)); 74 | ret.z = 0.0f; 75 | 76 | return ret; 77 | } 78 | 79 | vec3_t matrix_3x4_origin(matrix_3x4 m) { 80 | vec3_t ret; 81 | 82 | ret.x = m[0][3]; 83 | ret.y = m[1][3]; 84 | ret.z = m[2][3]; 85 | 86 | return ret; 87 | } 88 | 89 | /*----------------------------------------------------------------------------*/ 90 | 91 | bool world_to_screen(vec3_t vec, vec2_t screen) { 92 | if (vec_is_zero(vec)) 93 | return false; 94 | 95 | int engine_w2s = i_engine->pTriAPI->WorldToScreen(vec, screen); 96 | if (engine_w2s) 97 | return false; 98 | 99 | SCREENINFO scr_inf; 100 | scr_inf.iSize = sizeof(SCREENINFO); 101 | i_engine->pfnGetScreenInfo(&scr_inf); 102 | 103 | /* If within bounds, transform to screen scale */ 104 | if (screen[0] < 1 && screen[1] < 1 && screen[0] > -1 && screen[1] > -1) { 105 | screen[0] = screen[0] * (scr_inf.iWidth / 2) + (scr_inf.iWidth / 2); 106 | screen[1] = -screen[1] * (scr_inf.iHeight / 2) + (scr_inf.iHeight / 2); 107 | 108 | return true; 109 | } 110 | 111 | return false; 112 | } 113 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+title: Half-Life cheat 2 | #+options: toc:nil 3 | #+startup: showeverything 4 | #+author: 8dcc 5 | 6 | *Linux cheat for goldsrc games.* 7 | 8 | #+TOC: headlines 2 9 | 10 | * Description 11 | Simple linux cheat for most goldsrc games, made in C. 12 | 13 | Supported games: 14 | - [[https://store.steampowered.com/app/70/HalfLife/][Half-Life 1]] 15 | - [[https://store.steampowered.com/app/10/CounterStrike/][Counter-Strike 1.6]] 16 | - [[https://store.steampowered.com/app/20/Team_Fortress_Classic/][Team Fortress Classic]] 17 | - [[https://store.steampowered.com/app/30/Day_of_Defeat/][Day of Defeat]] 18 | 19 | This project was heavily inspired by [[https://github.com/UnkwUsr/hlhax][UnkwUsr/hlhax]], and would not have been 20 | possible without his help. Make sure to check out his repo too. 21 | 22 | Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ahc]]. 23 | 24 | * Features 25 | 26 | | Feature | Command | Values (0..n) | 27 | |------------+---------------+------------------------| 28 | | Bhop | =cv_bhop= | off/on | 29 | | Autostrafe | =cv_autostrafe= | off/rage/legit | 30 | | Aimbot | =cv_aimbot= | off/fov* | 31 | | Autoshoot | =cv_autoshoot= | off/on* | 32 | | ESP | =cv_esp= | off/3d-box/name/all | 33 | | Chams | =cv_chams= | off/players/hands/all* | 34 | | Crosshair | =cv_crosshair= | off/length | 35 | | Tracers | =cv_tracers= | off/on* | 36 | 37 | 38 | #+begin_quote 39 | *Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies) 40 | #+end_quote 41 | 42 | #+begin_quote 43 | *Note:* If =cv_autoshoot= is enabled, and =cv_aimbot= is enabled, it will stop 44 | attacking if there is no visible target. 45 | #+end_quote 46 | 47 | #+begin_quote 48 | *Note:* Chams color can be changed from the =h_glColor4f()= function inside 49 | [[https://github.com/8dcc/hl-cheat/blob/main/src/hooks.c][src/hooks.c]]. Since this cheat is not hard to compile, I rather have less 50 | console variables than more customization at runtime. 51 | #+end_quote 52 | 53 | #+begin_quote 54 | *Note:* Bullet tracer color, width and time can be changed at the bottom of the 55 | =bullet_tracers()= function inside [[https://github.com/8dcc/hl-cheat/blob/main/src/features/misc.c][src/features/misc.c]]. See previous chams note. 56 | #+end_quote 57 | 58 | * Building 59 | #+begin_src console 60 | $ git clone --recurse-submodules https://github.com/8dcc/hl-cheat 61 | $ cd hl-cheat 62 | $ make 63 | ... 64 | #+end_src 65 | 66 | Note that you will need to clone with =--recurse-submodules= for the sdk. If you 67 | have already cloned it, you can just: 68 | 69 | #+begin_src console 70 | $ cd hl-cheat 71 | $ git submodule update --init --recursive 72 | #+end_src 73 | 74 | * Injecting 75 | Uses the [[https://www.gnu.org/savannah-checkouts/gnu/gdb/index.html][gdb]] debugger for injecting the library. 76 | 77 | #+begin_src console 78 | $ ./injector.sh 79 | [sudo] password for username: 80 | 81 | ... 82 | 83 | hl-cheat loaded! 84 | #+end_src 85 | -------------------------------------------------------------------------------- /src/globals.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include /* PROT_* */ 6 | 7 | #include "include/globals.h" 8 | #include "include/sdk.h" 9 | #include "include/util.h" 10 | 11 | #define GET_PATTERN(VAR, MODULE, SIG) \ 12 | void* VAR = find_sig(MODULE, SIG); \ 13 | if (!VAR) { \ 14 | ERR("Coundn't find pattern for " #SIG); \ 15 | return false; \ 16 | } 17 | 18 | /*----------------------------------------------------------------------------*/ 19 | 20 | /* Handlers used globally */ 21 | void* hw = NULL; 22 | 23 | game_id this_game_id = HL; 24 | vec3_t g_punchAngles = { 0, 0, 0 }; 25 | 26 | /* Weapon info */ 27 | float g_flNextAttack = 0.f, g_flNextPrimaryAttack = 0.f; 28 | int g_iClip = 0; 29 | 30 | DECL_INTF(cl_enginefunc_t, engine); 31 | DECL_INTF(cl_clientfunc_t, client); 32 | DECL_INTF(playermove_t, pmove); 33 | DECL_INTF(engine_studio_api_t, enginestudio); 34 | DECL_INTF(StudioModelRenderer_t, studiomodelrenderer); 35 | 36 | /* Game struct with some useful info */ 37 | game_t* game_info; 38 | 39 | /* Array of extra_player_info's for each player */ 40 | void* player_extra_info; 41 | 42 | /* Updated in CL_CreateMove hook */ 43 | cl_entity_t* localplayer = NULL; 44 | 45 | /*----------------------------------------------------------------------------*/ 46 | 47 | bool globals_init(void) { 48 | /* 49 | * Get handler for hw.so 50 | * RTLD_LAZY: If the symbol is never referenced, then it is never resolved. 51 | * RTLD_NOLOAD: Don't load the shared object. 52 | */ 53 | hw = dlopen("hw.so", RTLD_LAZY | RTLD_NOLOAD); 54 | if (!hw) { 55 | ERR("Can't open hw.so"); 56 | return false; 57 | } 58 | 59 | void* h_client = *(void**)dlsym(hw, "hClientDLL"); 60 | if (!h_client) { 61 | ERR("Can't find hClientDLL"); 62 | return false; 63 | } 64 | 65 | /* Get symbol addresses using dlsym and the handler we just opened */ 66 | i_engine = (cl_enginefunc_t*)dlsym(hw, "cl_enginefuncs"); 67 | i_client = (cl_clientfunc_t*)dlsym(hw, "cl_funcs"); 68 | i_pmove = *(playermove_t**)dlsym(hw, "pmove"); 69 | i_enginestudio = (engine_studio_api_t*)dlsym(hw, "engine_studio_api"); 70 | 71 | const char* SMR_STR = "g_StudioRenderer"; /* For clang-format */ 72 | i_studiomodelrenderer = *(StudioModelRenderer_t**)dlsym(h_client, SMR_STR); 73 | 74 | player_extra_info = dlsym(h_client, "g_PlayerExtraInfo"); 75 | 76 | game_info = *(game_t**)dlsym(hw, "game"); 77 | 78 | if (!i_engine || !i_client || !i_pmove || !i_enginestudio || 79 | !i_studiomodelrenderer || !game_info) { 80 | ERR("Couldn't load some symbols"); 81 | return false; 82 | } 83 | 84 | if (!protect_addr(i_studiomodelrenderer, PROT_READ | PROT_WRITE)) { 85 | ERR("Couldn't unprotect address of SMR"); 86 | return false; 87 | } 88 | 89 | globals_store(); 90 | 91 | return true; 92 | } 93 | 94 | void globals_store(void) { 95 | memcpy(&o_engine, i_engine, sizeof(cl_enginefunc_t)); 96 | memcpy(&o_client, i_client, sizeof(cl_clientfunc_t)); 97 | memcpy(&o_enginestudio, i_enginestudio, sizeof(engine_studio_api_t)); 98 | } 99 | 100 | void globals_restore(void) { 101 | memcpy(i_engine, &o_engine, sizeof(cl_enginefunc_t)); 102 | memcpy(i_client, &o_client, sizeof(cl_clientfunc_t)); 103 | memcpy(i_enginestudio, &o_enginestudio, sizeof(engine_studio_api_t)); 104 | } 105 | -------------------------------------------------------------------------------- /src/detour.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file detour.c 3 | * @brief Detour hooking library source 4 | * @author 8dcc 5 | * 6 | * https://github.com/8dcc/detour-lib 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include /* getpagesize */ 13 | #include /* mprotect */ 14 | 15 | #include "include/detour.h" 16 | 17 | #define PAGE_SIZE getpagesize() 18 | #define PAGE_MASK (~(PAGE_SIZE - 1)) 19 | #define PAGE_ALIGN(x) ((x + PAGE_SIZE - 1) & PAGE_MASK) 20 | #define PAGE_ALIGN_DOWN(x) (PAGE_ALIGN(x) - PAGE_SIZE) 21 | 22 | static bool protect_addr(void* ptr, int new_flags) { 23 | void* p = (void*)PAGE_ALIGN_DOWN((detour_ptr_t)ptr); 24 | int pgsz = getpagesize(); 25 | 26 | if (mprotect(p, pgsz, new_flags) == -1) 27 | return false; 28 | 29 | return true; 30 | } 31 | 32 | /* 33 | * 64 bits: 34 | * 0: 48 b8 45 55 46 84 45 movabs rax,0x454584465545 35 | * 7: 45 00 00 36 | * a: ff e0 jmp rax 37 | * 38 | * 32 bits: 39 | * 0: b8 01 00 00 00 mov eax,0x1 40 | * 5: ff e0 jmp eax 41 | */ 42 | #ifdef __i386__ 43 | static uint8_t def_jmp_bytes[] = { 0xB8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE0 }; 44 | #define JMP_BYTES_PTR 1 /* Offset inside the array where the ptr should go */ 45 | #else 46 | static uint8_t def_jmp_bytes[] = { 0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE0 }; 48 | #define JMP_BYTES_PTR 2 /* Offset inside the array where the ptr should go */ 49 | #endif 50 | 51 | void detour_init(detour_data_t* data, void* orig, void* hook) { 52 | data->detoured = false; 53 | data->orig = orig; 54 | data->hook = hook; 55 | 56 | /* Store the first N bytes of the original function, where N is the size of 57 | * the jmp instructions */ 58 | memcpy(data->saved_bytes, orig, sizeof(data->saved_bytes)); 59 | 60 | /* Default jmp bytes */ 61 | memcpy(data->jmp_bytes, &def_jmp_bytes, sizeof(def_jmp_bytes)); 62 | 63 | /* JMP_BYTES_PTR is defined below def_jmp_bytes, and it changes depending 64 | * on the arch. 65 | * We use "&hook" and not "hook" because we want the address of 66 | * the func, not the first bytes of it like before. */ 67 | memcpy(&data->jmp_bytes[JMP_BYTES_PTR], &hook, sizeof(detour_ptr_t)); 68 | } 69 | 70 | bool detour_add(detour_data_t* d) { 71 | /* Already detoured, nothing to do */ 72 | if (d->detoured) 73 | return true; 74 | 75 | /* See util.c */ 76 | if (!protect_addr(d->orig, PROT_READ | PROT_WRITE | PROT_EXEC)) 77 | return false; 78 | 79 | /* Copy our jmp instruction with our hook address to the orig */ 80 | memcpy(d->orig, d->jmp_bytes, sizeof(d->jmp_bytes)); 81 | 82 | /* Restore old protection */ 83 | if (protect_addr(d->orig, PROT_READ | PROT_EXEC)) { 84 | d->detoured = true; 85 | return true; 86 | } 87 | 88 | return false; 89 | } 90 | 91 | bool detour_del(detour_data_t* d) { 92 | /* Not detoured, nothing to do */ 93 | if (!d->detoured) 94 | return true; 95 | 96 | /* See util.c */ 97 | if (!protect_addr(d->orig, PROT_READ | PROT_WRITE | PROT_EXEC)) 98 | return false; 99 | 100 | /* Restore the bytes that were at the start of orig (we saved on init) */ 101 | memcpy(d->orig, d->saved_bytes, sizeof(d->saved_bytes)); 102 | 103 | /* Restore old protection */ 104 | if (protect_addr(d->orig, PROT_READ | PROT_EXEC)) { 105 | d->detoured = false; 106 | return true; 107 | } 108 | 109 | return false; 110 | } 111 | -------------------------------------------------------------------------------- /src/features/aim.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../include/sdk.h" 5 | #include "../include/util.h" 6 | #include "../include/entityutil.h" 7 | #include "../include/mathutil.h" 8 | #include "../include/cvars.h" 9 | #include "features.h" 10 | 11 | /* Game units to add to the entity origin to get the head */ 12 | #define HEAD_OFFSET 25.f 13 | 14 | /* Scale factor for aim punch */ 15 | #define AIM_PUNCH_MULT 2 16 | 17 | static bool is_visible(vec3_t start, vec3_t end) { 18 | /* Syntax: PM_TraceLine(start, end, flags, usehulll, ignore_pe); */ 19 | pmtrace_t* tr = 20 | i_engine->PM_TraceLine(start, end, PM_TRACELINE_PHYSENTSONLY, 2, -1); 21 | 22 | /* We didn't hit a valid entity */ 23 | if (tr->ent <= 0) 24 | return false; 25 | 26 | /* Get entity index from physents, check if we can't get a valid player */ 27 | const int ent_idx = i_pmove->physents[tr->ent].info; 28 | if (!get_player(ent_idx)) 29 | return false; 30 | 31 | /* We hit a valid player */ 32 | return true; 33 | } 34 | 35 | static vec3_t get_closest_delta(vec3_t viewangles) { 36 | /* Compensate aim punch. We get g_punchAngles from CalcRefdef hook */ 37 | viewangles.x += g_punchAngles.x * AIM_PUNCH_MULT; 38 | viewangles.y += g_punchAngles.y * AIM_PUNCH_MULT; 39 | viewangles.z += g_punchAngles.z * AIM_PUNCH_MULT; 40 | 41 | vec3_t view_height; 42 | i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height); 43 | vec3_t local_eyes = vec_add(localplayer->origin, view_height); 44 | 45 | /* These 2 vars are used to store the best target across iterations. 46 | * NOTE: The default value of best_fov will be the aimbot fov */ 47 | float best_fov = cv_aimbot->value; 48 | vec3_t best_delta = { 0, 0, 0 }; 49 | 50 | for (int i = 1; i <= i_engine->GetMaxClients(); i++) { 51 | cl_entity_t* ent = get_player(i); 52 | 53 | if (!is_alive(ent) || is_friend(ent)) 54 | continue; 55 | 56 | /* TODO: Get bones origin instead of calculating from ent origin */ 57 | vec3_t head_pos = ent->origin; 58 | if (ent->curstate.usehull != 1) /* Get head if not crouched */ 59 | head_pos.z += HEAD_OFFSET; 60 | 61 | if (!is_visible(local_eyes, head_pos)) /* We can't see player */ 62 | continue; 63 | 64 | const vec3_t enemy_angle = vec_to_ang(vec_sub(head_pos, local_eyes)); 65 | 66 | vec3_t delta = vec_sub(enemy_angle, viewangles); 67 | vec_norm(&delta); 68 | ang_clamp(&delta); 69 | 70 | float fov = hypotf(delta.x, delta.y); 71 | if (fov < best_fov) { 72 | best_fov = fov; 73 | vec_copy(best_delta, delta); 74 | } 75 | } 76 | 77 | return best_delta; 78 | } 79 | 80 | void aimbot(usercmd_t* cmd) { 81 | if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK) || !can_shoot()) 82 | return; 83 | 84 | /* Calculate delta with the engine viewangles, not with the cmd ones */ 85 | vec3_t engine_viewangles; 86 | i_engine->GetViewAngles(engine_viewangles); 87 | 88 | /* TODO: Add setting for lowest health */ 89 | vec3_t best_delta = get_closest_delta(engine_viewangles); 90 | if (!vec_is_zero(best_delta)) { 91 | /* NOTE: We can divide the best delta here to add smoothing */ 92 | 93 | engine_viewangles.x += best_delta.x; 94 | engine_viewangles.y += best_delta.y; 95 | engine_viewangles.z += best_delta.z; 96 | } else if (CVAR_ON(autoshoot)) { 97 | /* No valid target and we have autoshoot, don't shoot */ 98 | cmd->buttons &= ~IN_ATTACK; 99 | } 100 | 101 | vec_copy(cmd->viewangles, engine_viewangles); 102 | 103 | /* NOTE: Uncomment to disable silent aim */ 104 | /* i_engine->SetViewAngles(engine_viewangles); */ 105 | } 106 | -------------------------------------------------------------------------------- /src/include/hooks.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HOOKS_H_ 3 | #define HOOKS_H_ 4 | 5 | /*----------------------------------------------------------------------------*/ 6 | 7 | #include "sdk.h" 8 | #include "globals.h" 9 | 10 | #include /* dlsym */ 11 | #include /* GLFloat */ 12 | /* 13 | * Table of prefixes: 14 | * prefix | meaning 15 | * -------+---------------------------- 16 | * *_t | typedef (function type) 17 | * h_* | hook function (ours) 18 | * ho_* | hook original (ptr to orig) 19 | * hp_* | hook pointer (pointer to function pointer) 20 | * 21 | * 22 | * DECL_HOOK_EXTERN: Version for the header. typedef's the function pointer with 23 | * the return type, name and args. Example: 24 | * 25 | * DECL_HOOK_EXTERN(int, test, double, double); 26 | * typedef int (*test_t)(double, double); 27 | * extern test_t ho_test; // Original 28 | * int h_test(double, double); // Our func 29 | * 30 | * 31 | * DECL_HOOK: Macro for declaring the global function pointer for the original 32 | * in the source file. Example: 33 | * 34 | * DECL_HOOK(test); 35 | * test_t ho_test = NULL; // Original 36 | * 37 | * 38 | * HOOK: Macro for storing the original function ptr of an interface and hooking 39 | * our own. Example: 40 | * 41 | * HOOK(gp_client, CL_CreateMove); 42 | * ho_CL_CreateMove = gp_client->CL_CreateMove; // Original 43 | * gp_client->CL_CreateMove = h_CL_CreateMove; // Our func 44 | * 45 | * 46 | * ORIGINAL: Macro for calling the original function. Example: 47 | * 48 | * ORIGINAL(CL_CreateMove, frametime, cmd, active); 49 | * ho_CL_CreateMove(frametime, cmd, active); // Original 50 | * 51 | * 52 | * GL_HOOK: Hooks a OpenGL function. Example: 53 | * 54 | * GL_HOOK(glColor4f); 55 | * void** hp_glColor4f = (void**)dlsym(hw, "qglColor4f"); // Ptr 56 | * ho_glColor4f = (glColor4f_t)(*hp_glColor4f); // Original from ptr 57 | * *hp_glColor4f = (void*)h_glColor4f; // Set ptr to our func 58 | 59 | * Note: ho_glColor4f and h_glColor4f sould be declared with DECL_HOOK_EXTERN 60 | * 61 | * 62 | * GL_UNHOOK: Restores a OpenGL hook created by GL_HOOK. Example: 63 | * 64 | * GL_UNHOOK(glColor4f); 65 | * void** hp_glColor4f = (void**)dlsym(hw, "qglColor4f"); // Ptr 66 | * *hp_glColor4f = (void*)ho_glColor4f; // Set to original 67 | */ 68 | #define DECL_HOOK_EXTERN(TYPE, NAME, ...) \ 69 | typedef TYPE (*NAME##_t)(__VA_ARGS__); \ 70 | extern NAME##_t ho_##NAME; \ 71 | TYPE h_##NAME(__VA_ARGS__); 72 | 73 | #define DECL_HOOK(NAME) NAME##_t ho_##NAME = NULL; 74 | 75 | #define HOOK(INTERFACE, NAME) \ 76 | ho_##NAME = INTERFACE->NAME; \ 77 | INTERFACE->NAME = h_##NAME; 78 | 79 | #define ORIGINAL(NAME, ...) ho_##NAME(__VA_ARGS__); 80 | 81 | #define GL_HOOK(NAME) \ 82 | void** hp_##NAME = (void**)dlsym(hw, "q" #NAME); \ 83 | ho_##NAME = (NAME##_t)(*hp_##NAME); \ 84 | *hp_##NAME = (void*)h_##NAME; 85 | 86 | #define GL_UNHOOK(NAME) \ 87 | void** hp_##NAME = (void**)dlsym(hw, "q" #NAME); \ 88 | *hp_##NAME = (void*)ho_##NAME; 89 | 90 | /*----------------------------------------------------------------------------*/ 91 | 92 | bool hooks_init(void); 93 | void hooks_restore(void); 94 | 95 | /* VMT hooks */ 96 | DECL_HOOK_EXTERN(void, CL_CreateMove, float, usercmd_t*, int); 97 | DECL_HOOK_EXTERN(int, HUD_Redraw, float, int); 98 | DECL_HOOK_EXTERN(void, StudioRenderModel, void*); 99 | DECL_HOOK_EXTERN(void, CalcRefdef, ref_params_t*); 100 | DECL_HOOK_EXTERN(void, HUD_PostRunCmd, struct local_state_s*, 101 | struct local_state_s*, struct usercmd_s*, int, double, 102 | unsigned int); 103 | 104 | /* OpenGL hooks */ 105 | DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat); 106 | 107 | /* Detour hooks */ 108 | DECL_HOOK_EXTERN(void, CL_Move); 109 | 110 | #endif /* HOOKS_H_ */ 111 | -------------------------------------------------------------------------------- /src/features/movement.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "../include/sdk.h" 6 | #include "../include/util.h" 7 | #include "../include/mathutil.h" 8 | #include "../include/globals.h" 9 | #include "../include/cvars.h" 10 | #include "features.h" 11 | 12 | static void autostrafe_legit(usercmd_t* cmd) { 13 | /* Get mouse delta */ 14 | int dx = 0, dy = 0; 15 | i_engine->pfnVguiWrap2_GetMouseDelta(&dx, &dy); 16 | 17 | if (dx < 0) 18 | cmd->sidemove = -450.0f; 19 | else if (dx > 0) 20 | cmd->sidemove = 450.0f; 21 | } 22 | 23 | /* 24 | * See: 25 | * https://github.com/deboogerxyz/ahc/blob/0492646e28dd7234a8cd431d37b152dc18a21b04/ahc.c#L201 26 | * https://github.com/NullHooks/NullHooks/blob/535351569ca599cadd21a286d88098b6dc057a46/src/core/features/movement/bhop.cpp#L73 27 | */ 28 | static void autostrafe_rage(usercmd_t* cmd) { 29 | if (i_pmove->movetype != MOVETYPE_WALK) 30 | return; 31 | 32 | /* TODO: Get at runtime */ 33 | const float sv_airaccelerate = 10.0f; 34 | const float sv_maxspeed = 320.0f; 35 | const float cl_forwardspeed = 425.0f; 36 | const float cl_sidespeed = 400.0f; 37 | 38 | float speed = vec_len2d(i_pmove->velocity); 39 | 40 | /* If low speed, start forward */ 41 | if (speed < 15 && (cmd->buttons & IN_FORWARD)) { 42 | cmd->forwardmove = 450.0f; 43 | return; 44 | } 45 | 46 | float term = sv_airaccelerate / sv_maxspeed * 100.0f / speed; 47 | if (term < -1 || term > 1) 48 | return; 49 | 50 | float best_delta = acosf(term); 51 | 52 | /* Use engine viewangles in case we do something nasty with cmd's angles */ 53 | vec3_t viewangles; 54 | i_engine->GetViewAngles(viewangles); 55 | 56 | /* Get our desired angles and delta */ 57 | float yaw = DEG2RAD(viewangles.y); 58 | float vel_dir = atan2f(i_pmove->velocity.y, i_pmove->velocity.x) - yaw; 59 | float target_ang = atan2f(-cmd->sidemove, cmd->forwardmove); 60 | float delta = angle_delta_rad(vel_dir, target_ang); 61 | 62 | float movedir = delta < 0 ? vel_dir + best_delta : vel_dir - best_delta; 63 | 64 | cmd->forwardmove = cosf(movedir) * cl_forwardspeed; 65 | cmd->sidemove = -sinf(movedir) * cl_sidespeed; 66 | } 67 | 68 | void bhop(usercmd_t* cmd) { 69 | if (!CVAR_ON(bhop) || i_pmove->movetype != MOVETYPE_WALK) 70 | return; 71 | 72 | static bool was_in_air = false; 73 | 74 | /* Used below to check if we should autostrafe before. Store since we might 75 | * change cmd->buttons (autostrafe only when user hold space) */ 76 | bool is_jumping = cmd->buttons & IN_JUMP; 77 | 78 | /* 2 frames in air, release jump */ 79 | if (was_in_air && !(i_pmove->flags & FL_ONGROUND)) 80 | cmd->buttons &= ~IN_JUMP; 81 | 82 | was_in_air = (i_pmove->flags & FL_ONGROUND) == 0; 83 | 84 | /* Autostrafe if enabled. Check if we are in the air and holding space. */ 85 | if (is_jumping) { 86 | switch ((int)cv_autostrafe->value) { 87 | case 1: 88 | autostrafe_rage(cmd); 89 | break; 90 | case 2: 91 | autostrafe_legit(cmd); 92 | break; 93 | case 0: 94 | default: 95 | break; 96 | } 97 | } 98 | } 99 | 100 | /* 101 | * Unfortunately I don't know shit about math, so this is pasted from: 102 | * https://github.com/deboogerxyz/ahc/blob/0492646e28dd7234a8cd431d37b152dc18a21b04/ahc.c#L377 103 | */ 104 | void correct_movement(usercmd_t* cmd, vec3_t old_angles) { 105 | float old_y = old_angles.y + (old_angles.y < 0 ? 360 : 0); 106 | float new_y = cmd->viewangles.y + (cmd->viewangles.y < 0 ? 360 : 0); 107 | float delta = (new_y < old_y) ? fabsf(new_y - old_y) 108 | : 360 - fabsf(new_y - old_y); 109 | 110 | delta = 360 - delta; 111 | 112 | float forward = cmd->forwardmove; 113 | float side = cmd->sidemove; 114 | 115 | cmd->forwardmove = 116 | cos(DEG2RAD(delta)) * forward + cos(DEG2RAD(delta + 90)) * side; 117 | cmd->sidemove = 118 | sin(DEG2RAD(delta)) * forward + sin(DEG2RAD(delta + 90)) * side; 119 | } 120 | -------------------------------------------------------------------------------- /src/util.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include /* dlsym */ 6 | #include /* link_map */ 7 | #include /* getpagesize */ 8 | #include /* mprotect */ 9 | 10 | #include "include/util.h" 11 | #include "include/sdk.h" 12 | #include "include/globals.h" 13 | 14 | /*----------------------------------------------------------------------------*/ 15 | 16 | void engine_draw_text(int x, int y, char* s, rgb_t c) { 17 | /* Convert to 0..1 range */ 18 | float r = c.r / 255.0f; 19 | float g = c.g / 255.0f; 20 | float b = c.b / 255.0f; 21 | 22 | i_engine->pfnDrawSetTextColor(r, g, b); 23 | i_engine->pfnDrawConsoleString(x, y, s); 24 | } 25 | 26 | void draw_tracer(vec3_t start, vec3_t end, rgb_t c, float a, float w, 27 | float time) { 28 | static const char* MDL_STR = "sprites/laserbeam.spr"; 29 | static int beam_idx = i_engine->pEventAPI->EV_FindModelIndex(MDL_STR); 30 | 31 | float r = c.r / 255.f; 32 | float g = c.g / 255.f; 33 | float b = c.b / 255.f; 34 | 35 | i_engine->pEfxAPI 36 | ->R_BeamPoints(start, end, beam_idx, time, w, 0, a, 0, 0, 0, r, g, b); 37 | } 38 | 39 | void gl_drawbox(int x, int y, int w, int h, rgb_t c) { 40 | /* Line width */ 41 | const int lw = 1; 42 | 43 | /* 44 | * 1 45 | * +----+ 46 | * 2 | | 3 47 | * | | 48 | * +----+ 49 | * 4 50 | */ 51 | gl_drawline(x, y, x + w, y, lw, c); 52 | gl_drawline(x, y, x, y + h, lw, c); 53 | gl_drawline(x + w, y, x + w, y + h, lw, c); 54 | gl_drawline(x, y + h, x + w, y + h, lw, c); 55 | } 56 | 57 | void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col) { 58 | const int alpha = 255; 59 | 60 | glDisable(GL_TEXTURE_2D); 61 | glEnable(GL_BLEND); 62 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 63 | glColor4ub(col.r, col.g, col.b, alpha); /* Set colors + alpha */ 64 | glLineWidth(w); /* Set line width */ 65 | glBegin(GL_LINES); /* Interpret vertices as lines */ 66 | glVertex2i(x0, y0); /* Start */ 67 | glVertex2i(x1, y1); /* End */ 68 | glEnd(); /* Stop glBegin, end line mode */ 69 | glEnable(GL_TEXTURE_2D); 70 | glDisable(GL_BLEND); 71 | } 72 | 73 | /*----------------------------------------------------------------------------*/ 74 | 75 | void* find_sig(const char* module, const byte* pattern) { 76 | struct our_link_map { 77 | /* Base from link.h */ 78 | ElfW(Addr) l_addr; 79 | const char* l_name; 80 | ElfW(Dyn) * l_ld; 81 | struct our_link_map* l_next; 82 | struct our_link_map* l_prev; 83 | 84 | /* Added */ 85 | struct our_link_map* real; 86 | long int ns; 87 | struct libname_list* moduleName; 88 | ElfW(Dyn) * info[DT_NUM + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM + 89 | DT_ADDRNUM]; 90 | const ElfW(Phdr) * phdr; 91 | }; 92 | 93 | /* TODO: Remove unnecesary cast after porting C++ SDK to C. */ 94 | struct our_link_map* link = 95 | (struct our_link_map*)dlopen(module, RTLD_NOLOAD | RTLD_NOW); 96 | 97 | if (!link) { 98 | ERR("Can't open module \"%s\"", module); 99 | return NULL; 100 | } 101 | 102 | byte* start = (byte*)link->l_addr; 103 | byte* end = start + link->phdr[0].p_memsz; 104 | 105 | dlclose(link); 106 | 107 | const byte* memPos = start; 108 | const byte* patPos = pattern; 109 | 110 | /* 111 | * Iterate memory area until *patPos is '\0' (we found pattern). 112 | * If we start a pattern match, keep checking all pattern positions until we 113 | * are done or until mismatch. If we find mismatch, reset pattern position 114 | * and continue checking at the memory location where we started +1 115 | */ 116 | while (memPos < end && *patPos != '\0') { 117 | if (*memPos == *patPos || *patPos == '?') { 118 | memPos++; 119 | patPos++; 120 | } else { 121 | start++; 122 | memPos = start; 123 | patPos = pattern; 124 | } 125 | } 126 | 127 | /* We reached end of pattern, we found it */ 128 | if (*patPos == '\0') 129 | return start; 130 | 131 | return NULL; 132 | } 133 | 134 | #define PAGE_MASK (~(PAGE_SZ - 1)) 135 | #define PAGE_ALIGN(x) ((x + PAGE_SZ - 1) & PAGE_MASK) 136 | #define PAGE_ALIGN_DOWN(x) (PAGE_ALIGN(x) - PAGE_SZ) 137 | 138 | bool protect_addr(void* ptr, int new_flags) { 139 | int PAGE_SZ = getpagesize(); 140 | void* p = (void*)PAGE_ALIGN_DOWN((uint32_t)ptr); 141 | 142 | if (mprotect(p, PAGE_SZ, new_flags) == -1) { 143 | ERR("Error protecting %p", ptr); 144 | return false; 145 | } 146 | 147 | return true; 148 | } 149 | -------------------------------------------------------------------------------- /src/features/esp.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "../include/util.h" 5 | #include "../include/mathutil.h" 6 | #include "../include/entityutil.h" 7 | #include "../include/globals.h" 8 | #include "../include/cvars.h" 9 | #include "features.h" 10 | 11 | /* For cv_esp */ 12 | enum esp_values { 13 | ESP_OFF = 0, 14 | ESP_BOX = 1, 15 | ESP_NAME = 2, 16 | /* ESP_ALL should be 3 but we can just OR box and name */ 17 | }; 18 | 19 | bool gl_draw3dbox(vec3_t o, int bh, int bw, int lw) { 20 | /* 21 | * Parameters: 22 | * bw: 3d box width (game units) 23 | * bh: 3d box height (game units) 24 | * lw: Line width 25 | */ 26 | 27 | if (vec_is_zero(o)) 28 | return false; 29 | 30 | const rgb_t col = { 255, 255, 255 }; /* Color */ 31 | 32 | /* 33 | * (Origin would be in the middle of the cube) 34 | * 35 | * 1---2 y(+) 36 | * /| /| / 37 | * 3---4 | *--x(+) 38 | * | 5-|-6 | 39 | * |/ O|/ z(-) 40 | * 7---8 41 | */ 42 | vec3_t p1 = vec3(o.x - bw / 2, o.y + bw / 2, o.z + bh / 2); 43 | vec3_t p2 = vec3(o.x + bw / 2, o.y + bw / 2, o.z + bh / 2); 44 | vec3_t p3 = vec3(o.x - bw / 2, o.y - bw / 2, o.z + bh / 2); 45 | vec3_t p4 = vec3(o.x + bw / 2, o.y - bw / 2, o.z + bh / 2); 46 | vec3_t p5 = vec3(o.x - bw / 2, o.y + bw / 2, o.z - bh / 2); 47 | vec3_t p6 = vec3(o.x + bw / 2, o.y + bw / 2, o.z - bh / 2); 48 | vec3_t p7 = vec3(o.x - bw / 2, o.y - bw / 2, o.z - bh / 2); 49 | vec3_t p8 = vec3(o.x + bw / 2, o.y - bw / 2, o.z - bh / 2); 50 | 51 | vec2_t s1, s2, s3, s4, s5, s6, s7, s8; 52 | if (!world_to_screen(p1, s1) || !world_to_screen(p2, s2) || 53 | !world_to_screen(p3, s3) || !world_to_screen(p4, s4) || 54 | !world_to_screen(p5, s5) || !world_to_screen(p6, s6) || 55 | !world_to_screen(p7, s7) || !world_to_screen(p8, s8)) 56 | return false; 57 | 58 | gl_drawline_points(s1, s2, lw, col); 59 | gl_drawline_points(s1, s3, lw, col); 60 | gl_drawline_points(s1, s5, lw, col); 61 | gl_drawline_points(s2, s4, lw, col); 62 | gl_drawline_points(s2, s6, lw, col); 63 | gl_drawline_points(s3, s4, lw, col); 64 | gl_drawline_points(s3, s7, lw, col); 65 | gl_drawline_points(s4, s8, lw, col); 66 | gl_drawline_points(s5, s6, lw, col); 67 | gl_drawline_points(s5, s7, lw, col); 68 | gl_drawline_points(s6, s8, lw, col); 69 | gl_drawline_points(s7, s8, lw, col); 70 | 71 | return true; 72 | } 73 | 74 | static bool gl_draw2dbox(vec3_t o, int bh) { 75 | /* bh: 3d box height (game units) */ 76 | 77 | if (vec_is_zero(o)) 78 | return false; 79 | 80 | const rgb_t col = { 255, 255, 255 }; /* Color */ 81 | const rgb_t out_col = { 0, 0, 0 }; /* Outline */ 82 | 83 | /* Get top and bottom of player from origin with box height */ 84 | const vec3_t bot = vec3(o.x, o.y, o.z - bh / 2); 85 | const vec3_t top = vec3(o.x, o.y, o.z + bh / 2); 86 | 87 | vec2_t s_bot, s_top; 88 | if (!world_to_screen(bot, s_bot) || !world_to_screen(top, s_top)) 89 | return false; 90 | 91 | const int h = s_bot[1] - s_top[1]; 92 | const int w = bh == 70 ? h * 0.40f : h * 0.75f; 93 | const int y = s_top[1]; 94 | const int x = s_top[0] - w / 2; 95 | 96 | gl_drawbox(x - 1, y - 1, w + 2, h + 2, out_col); /* Outer outline */ 97 | gl_drawbox(x + 1, y + 1, w - 2, h - 2, out_col); /* Inner outline */ 98 | gl_drawbox(x, y, w, h, col); /* Fill */ 99 | 100 | return true; 101 | } 102 | 103 | void esp(void) { 104 | const int setting = (int)cv_esp->value; 105 | if (setting == ESP_OFF) 106 | return; 107 | 108 | /* Iterate all clients */ 109 | for (int i = 1; i <= i_engine->GetMaxClients(); i++) { 110 | cl_entity_t* ent = get_player(i); 111 | 112 | if (!valid_player(ent) || !is_alive(ent) || vec_is_zero(ent->origin)) 113 | continue; 114 | 115 | const int bh = (ent->curstate.usehull == 1) ? 44 : 70; 116 | /* const int bw = 25; */ 117 | 118 | /* If ESP_BOX is enabled, draw it. If it returns false, continue */ 119 | if (setting & ESP_BOX && !gl_draw2dbox(ent->origin, bh)) 120 | continue; 121 | 122 | /* Rest of the loop is for name esp, if var is not enabled, continue */ 123 | if (!(setting & ESP_NAME)) 124 | continue; 125 | 126 | /* Draw name on top of the player. */ 127 | vec3_t top = vec3(ent->origin.x, ent->origin.y, ent->origin.z + bh); 128 | vec2_t s_top; 129 | 130 | if (!world_to_screen(top, s_top)) 131 | continue; 132 | 133 | /* TODO: Instead of -5px, center the player name to the player origin. 134 | * I don't know how to get the text size before rendering. */ 135 | engine_draw_text(s_top[0] - 5, s_top[1] - 2, get_name(ent->index), 136 | (rgb_t){ 255, 255, 255 }); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/hooks.c: -------------------------------------------------------------------------------- 1 | 2 | #include "include/hooks.h" 3 | #include "include/sdk.h" 4 | #include "include/globals.h" 5 | #include "include/util.h" 6 | #include "include/mathutil.h" 7 | #include "include/cvars.h" 8 | #include "include/detour.h" /* 8dcc/detour-lib */ 9 | #include "features/features.h" /* bhop(), esp(), etc. */ 10 | 11 | /* Normal VMT hooks */ 12 | DECL_HOOK(CL_CreateMove); 13 | DECL_HOOK(HUD_Redraw); 14 | DECL_HOOK(StudioRenderModel); 15 | DECL_HOOK(CalcRefdef); 16 | DECL_HOOK(HUD_PostRunCmd); 17 | 18 | /* OpenGL hooks */ 19 | DECL_HOOK(glColor4f); 20 | 21 | /* Detour hooks */ 22 | static detour_data_t detour_data_clmove; 23 | DECL_DETOUR_TYPE(void, clmove_type); 24 | DECL_HOOK(CL_Move); 25 | 26 | /*----------------------------------------------------------------------------*/ 27 | 28 | bool hooks_init(void) { 29 | /* VMT hooking */ 30 | HOOK(i_client, CL_CreateMove); 31 | HOOK(i_client, HUD_Redraw); 32 | HOOK(i_studiomodelrenderer, StudioRenderModel); 33 | HOOK(i_client, CalcRefdef); 34 | HOOK(i_client, HUD_PostRunCmd); 35 | 36 | /* OpenGL hooks */ 37 | GL_HOOK(glColor4f); 38 | 39 | /* Detour hooks */ 40 | void* clmove_ptr = dlsym(hw, "CL_Move"); 41 | if (!clmove_ptr) 42 | return false; 43 | 44 | /* Initialize detour_data_clmove struct for detour, and add the hook */ 45 | detour_init(&detour_data_clmove, clmove_ptr, (void*)h_CL_Move); 46 | detour_add(&detour_data_clmove); 47 | 48 | return true; 49 | } 50 | 51 | void hooks_restore(void) { 52 | detour_del(&detour_data_clmove); 53 | } 54 | 55 | /*----------------------------------------------------------------------------*/ 56 | 57 | void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) { 58 | ORIGINAL(CL_CreateMove, frametime, cmd, active); 59 | 60 | vec3_t old_angles = cmd->viewangles; 61 | 62 | /* Declared in globals.c */ 63 | localplayer = i_engine->GetLocalPlayer(); 64 | 65 | bhop(cmd); 66 | aimbot(cmd); 67 | bullet_tracers(cmd); 68 | 69 | correct_movement(cmd, old_angles); 70 | ang_clamp(&cmd->viewangles); 71 | } 72 | 73 | /*----------------------------------------------------------------------------*/ 74 | 75 | int h_HUD_Redraw(float time, int intermission) { 76 | int ret = ORIGINAL(HUD_Redraw, time, intermission); 77 | 78 | /* Watermark */ 79 | engine_draw_text(5, 5, "8dcc/hl-cheat", (rgb_t){ 255, 255, 255 }); 80 | 81 | esp(); 82 | custom_crosshair(); 83 | 84 | return ret; 85 | } 86 | 87 | /*----------------------------------------------------------------------------*/ 88 | 89 | void h_StudioRenderModel(void* this_ptr) { 90 | if (!chams(this_ptr)) 91 | ORIGINAL(StudioRenderModel, this_ptr); 92 | } 93 | 94 | /*----------------------------------------------------------------------------*/ 95 | 96 | void h_CalcRefdef(ref_params_t* params) { 97 | /* Store punch angles for CreateMove */ 98 | vec_copy(g_punchAngles, params->punchangle); 99 | 100 | ORIGINAL(CalcRefdef, params); 101 | } 102 | 103 | /*----------------------------------------------------------------------------*/ 104 | 105 | void h_HUD_PostRunCmd(struct local_state_s* from, struct local_state_s* to, 106 | struct usercmd_s* cmd, int runfuncs, double time, 107 | unsigned int random_seed) { 108 | ORIGINAL(HUD_PostRunCmd, from, to, cmd, runfuncs, time, random_seed); 109 | 110 | /* Store attack information to check if we can shoot */ 111 | if (runfuncs) { 112 | g_flNextAttack = to->client.m_flNextAttack; 113 | g_flNextPrimaryAttack = 114 | to->weapondata[to->client.m_iId].m_flNextPrimaryAttack; 115 | g_iClip = to->weapondata[to->client.m_iId].m_iClip; 116 | } 117 | } 118 | 119 | /*----------------------------------------------------------------------------*/ 120 | 121 | void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { 122 | /* This visible_mode variable is changed inside the chams() function, which 123 | * is called from the StudioRenderModel hook. 124 | * 125 | * Depending on the type of entity we are trying to render from there, and 126 | * depending on its visibility, we change this visible_mode variable. */ 127 | switch (visible_mode) { 128 | case ENEMY_VISIBLE: 129 | r = 0.40f; 130 | g = 0.73f; 131 | b = 0.41f; 132 | break; 133 | case ENEMY_NOT_VISIBLE: 134 | r = 0.90f; 135 | g = 0.07f; 136 | b = 0.27f; 137 | break; 138 | case FRIEND_VISIBLE: 139 | r = 0.16f; 140 | g = 0.71f; 141 | b = 0.96f; 142 | break; 143 | case FRIEND_NOT_VISIBLE: 144 | r = 0.10f; 145 | g = 0.20f; 146 | b = 0.70f; 147 | break; 148 | case HANDS: 149 | /* Multiply by original func parameters for non-flat chams. 150 | * Credits: @oxiKKK */ 151 | r *= 0.94f; 152 | g *= 0.66f; 153 | b *= 0.94f; 154 | break; 155 | default: 156 | case NONE: 157 | break; 158 | } 159 | 160 | ORIGINAL(glColor4f, r, g, b, a); 161 | } 162 | 163 | /*----------------------------------------------------------------------------*/ 164 | 165 | void h_CL_Move() { 166 | if (cv_clmove->value != 0) { 167 | for (int i = 0; i < (int)cv_clmove->value; i++) 168 | CALL_ORIGINAL(detour_data_clmove, clmove_type); 169 | } 170 | 171 | CALL_ORIGINAL(detour_data_clmove, clmove_type); 172 | } 173 | -------------------------------------------------------------------------------- /src/include/sdk.h: -------------------------------------------------------------------------------- 1 | #ifndef SDK_H_ 2 | #define SDK_H_ 3 | 4 | #include 5 | 6 | /* 7 | * cl_enginefunc_t: 8 | * sdk/cl_dll/cl_dll.h:40 -> sdk/engine/cdll_int.h:164 ---+ 9 | * sdk/engine/APIProxy.h:358-494 <---------------------+ 10 | */ 11 | #include "sdk/cl_dll/wrect.h" 12 | #include "sdk/cl_dll/cl_dll.h" 13 | 14 | /* event_api_s */ 15 | #include "sdk/common/event_api.h" 16 | 17 | /* usercmd_t */ 18 | #include "sdk/common/usercmd.h" 19 | 20 | /* playermove_t */ 21 | #include "sdk/pm_shared/pm_defs.h" 22 | 23 | /* cvar_t */ 24 | #include "sdk/common/cvardef.h" 25 | 26 | /* triangleapi_s */ 27 | #include "sdk/common/triangleapi.h" 28 | 29 | /* mstudioanim_t, mstudioseqdesc_t, mstudiobone_t, etc. */ 30 | #include "sdk/engine/studio.h" 31 | 32 | /* model_t, vec4_t */ 33 | #include "sdk/common/com_model.h" 34 | 35 | /* engine_studio_api_t */ 36 | #include "sdk/common/r_studioint.h" 37 | 38 | typedef float matrix_3x4[3][4]; 39 | typedef matrix_3x4 bone_matrix[128]; 40 | 41 | /* 42 | * Credits: 43 | * https://github.com/UnkwUsr/hlhax/blob/26491984996c8389efec977ed940c5a67a0ecca4/src/sdk.h#L45 44 | */ 45 | typedef struct cl_clientfuncs_s { 46 | int (*Initialize)(cl_enginefunc_t* pEnginefuncs, int iVersion); 47 | void (*HUD_Init)(void); 48 | int (*HUD_VidInit)(void); 49 | int (*HUD_Redraw)(float time, int intermission); 50 | int (*HUD_UpdateClientData)(client_data_t* pcldata, float flTime); 51 | void (*HUD_Reset)(void); 52 | void (*HUD_PlayerMove)(struct playermove_s* ppmove, int server); 53 | void (*HUD_PlayerMoveInit)(struct playermove_s* ppmove); 54 | char (*HUD_PlayerMoveTexture)(char* name); 55 | void (*IN_ActivateMouse)(void); 56 | void (*IN_DeactivateMouse)(void); 57 | void (*IN_MouseEvent)(int mstate); 58 | void (*IN_ClearStates)(void); 59 | void (*IN_Accumulate)(void); 60 | void (*CL_CreateMove)(float frametime, struct usercmd_s* cmd, int active); 61 | int (*CL_IsThirdPerson)(void); 62 | void (*CL_CameraOffset)(float* ofs); 63 | struct kbutton_s* (*KB_Find)(const char* name); 64 | void (*CAM_Think)(void); 65 | void (*CalcRefdef)(struct ref_params_s* pparams); 66 | int (*HUD_AddEntity)(int type, struct cl_entity_s* ent, 67 | const char* modelname); 68 | 69 | void (*HUD_CreateEntities)(void); 70 | void (*HUD_DrawNormalTriangles)(void); 71 | void (*HUD_DrawTransparentTriangles)(void); 72 | void (*HUD_StudioEvent)(const struct mstudioevent_s* event, 73 | const struct cl_entity_s* entity); 74 | 75 | void (*HUD_PostRunCmd)(struct local_state_s* from, struct local_state_s* to, 76 | struct usercmd_s* cmd, int runfuncs, double time, 77 | unsigned int random_seed); 78 | 79 | void (*HUD_Shutdown)(void); 80 | void (*HUD_TxferLocalOverrides)(struct entity_state_s* state, 81 | const struct clientdata_s* client); 82 | 83 | void (*HUD_ProcessPlayerState)(struct entity_state_s* dst, 84 | const struct entity_state_s* src); 85 | 86 | void (*HUD_TxferPredictionData)(struct entity_state_s* ps, 87 | const struct entity_state_s* pps, 88 | struct clientdata_s* pcd, 89 | const struct clientdata_s* ppcd, 90 | struct weapon_data_s* wd, 91 | const struct weapon_data_s* pwd); 92 | 93 | void (*Demo_ReadBuffer)(int size, unsigned char* buffer); 94 | int (*HUD_ConnectionlessPacket)(struct netadr_s* net_from, const char* args, 95 | char* response_buffer, 96 | int* response_buffer_size); 97 | 98 | int (*HUD_GetHullBounds)(int hullnumber, float* mins, float* maxs); 99 | void (*HUD_Frame)(double time); 100 | int (*HUD_Key_Event)(int down, int keynum, const char* pszCurrentBinding); 101 | void (*HUD_TempEntUpdate)( 102 | double frametime, double client_time, double cl_gravity, 103 | struct tempent_s** ppTempEntFree, struct tempent_s** ppTempEntActive, 104 | int (*Callback_AddVisibleEntity)(struct cl_entity_s* pEntity), 105 | void (*Callback_TempEntPlaySound)(struct tempent_s* pTemp, float damp)); 106 | 107 | struct cl_entity_s* (*HUD_GetUserEntity)(int index); 108 | int (*HUD_VoiceStatus)(int entindex, qboolean bTalking); 109 | int (*HUD_DirectorMessage)(unsigned char command, unsigned int firstObject, 110 | unsigned int secondObject, unsigned int flags); 111 | 112 | int (*HUD_GetStudioModelInterface)( 113 | int version, struct r_studio_interface_s** ppinterface, 114 | struct engine_studio_api_s* pstudio); 115 | 116 | void (*HUD_CHATINPUTPOSITION_FUNCTION)(int* x, int* y); 117 | int (*HUD_GETPLAYERTEAM_FUNCTION)(int iplayer); 118 | void (*CLIENTFACTORY)(void); 119 | } cl_clientfunc_t; 120 | 121 | /* 122 | * Credits: 123 | * https://github.com/UnkwUsr/hlhax/blob/26491984996c8389efec977ed940c5a67a0ecca4/src/sdk.h#L93 124 | */ 125 | typedef struct StudioModelRenderer_s { 126 | /* Construction/Destruction */ 127 | void (*CStudioModelRenderer)(void* this_ptr); 128 | void (*_CStudioModelRenderer)(void* this_ptr); 129 | 130 | /* Initialization */ 131 | void (*Init)(void* this_ptr); 132 | 133 | /* Public Interfaces */ 134 | int (*StudioDrawModel)(void* this_ptr, int flags); 135 | int (*StudioDrawPlayer)(void* this_ptr, int flags, 136 | struct entity_state_s* pplayer); 137 | 138 | /* ----- Local interfaces ----- */ 139 | 140 | /* Look up animation data for sequence */ 141 | /* P.S. in other bases i know this have wrong return type: mstudioanim_t 142 | * instead mstudioanim_t* :DD */ 143 | mstudioanim_t* (*StudioGetAnim)(void* this_ptr, model_t* m_pSubModel, 144 | mstudioseqdesc_t* pseqdesc); 145 | 146 | /* Interpolate model position and angles and set up matrices */ 147 | void (*StudioSetUpTransform)(void* this_ptr, int trivial_accept); 148 | 149 | /* Set up model bone positions */ 150 | void (*StudioSetupBones)(void* this_ptr); 151 | 152 | /* Find final attachment points */ 153 | void (*StudioCalcAttachments)(void* this_ptr); 154 | 155 | /* Save bone matrices and names */ 156 | void (*StudioSaveBones)(void* this_ptr); 157 | 158 | /* Merge cached bones with current bones for model */ 159 | void (*StudioMergeBones)(void* this_ptr, model_t* m_pSubModel); 160 | 161 | /* Determine interpolation fraction */ 162 | float (*StudioEstimateInterpolant)(void* this_ptr); 163 | 164 | /* Determine current frame for rendering */ 165 | float (*StudioEstimateFrame)(void* this_ptr, mstudioseqdesc_t* pseqdesc); 166 | 167 | /* Apply special effects to transform matrix */ 168 | void (*StudioFxTransform)(void* this_ptr, cl_entity_t* ent, 169 | float transform[3][4]); 170 | 171 | /* Spherical interpolation of bones */ 172 | void (*StudioSlerpBones)(void* this_ptr, vec4_t q1[], float pos1[][3], 173 | vec4_t q2[], float pos2[][3], float s); 174 | 175 | /* Compute bone adjustments ( bone controllers ) */ 176 | void (*StudioCalcBoneAdj)(void* this_ptr, float dadt, float* adj, 177 | const byte* pcontroller1, 178 | const byte* pcontroller2, byte mouthopen); 179 | 180 | /* Get bone quaternions */ 181 | void (*StudioCalcBoneQuaterion)(void* this_ptr, int frame, float s, 182 | mstudiobone_t* pbone, mstudioanim_t* panim, 183 | float* adj, float* q); 184 | 185 | /* Get bone positions */ 186 | void (*StudioCalcBonePosition)(void* this_ptr, int frame, float s, 187 | mstudiobone_t* pbone, mstudioanim_t* panim, 188 | float* adj, float* pos); 189 | 190 | /* Compute rotations */ 191 | void (*StudioCalcRotations)(void* this_ptr, float pos[][3], vec4_t* q, 192 | mstudioseqdesc_t* pseqdesc, 193 | mstudioanim_t* panim, float f); 194 | 195 | /* Send bones and verts to renderer */ 196 | void (*StudioRenderModel)(void* this_ptr); 197 | 198 | /* Finalize rendering */ 199 | void (*StudioRenderFinal)(void* this_ptr); 200 | 201 | /* GL&D3D vs. Software renderer finishing functions */ 202 | void (*StudioRenderFinal_Software)(void* this_ptr); 203 | void (*StudioRenderFinal_Hardware)(void* this_ptr); 204 | 205 | /* Player specific data */ 206 | /* Determine pitch and blending amounts for players */ 207 | void (*StudioPlayerBlend)(void* this_ptr, mstudioseqdesc_t* pseqdesc, 208 | int* pBlend, float* pPitch); 209 | 210 | /* Estimate gait frame for player */ 211 | void (*StudioEstimateGait)(void* this_ptr, entity_state_t* pplayer); 212 | 213 | /* Process movement of player */ 214 | void (*StudioProcessGait)(void* this_ptr, entity_state_t* pplayer); 215 | 216 | /* 217 | // Client clock 218 | double m_clTime; 219 | // Old Client clock 220 | double m_clOldTime; 221 | 222 | // Do interpolation? 223 | int m_fDoInterp; 224 | // Do gait estimation? 225 | int m_fGaitEstimation; 226 | 227 | // Current render frame # 228 | int m_nFrameCount; 229 | 230 | // Cvars that studio model code needs to reference 231 | // Use high quality models? 232 | cvar_t* m_pCvarHiModels; 233 | // Developer debug output desired? 234 | cvar_t* m_pCvarDeveloper; 235 | // Draw entities bone hit boxes, etc? 236 | cvar_t* m_pCvarDrawEntities; 237 | 238 | // The entity which we are currently rendering. 239 | cl_entity_t* m_pCurrentEntity; 240 | 241 | // The model for the entity being rendered 242 | model_t* m_pRenderModel; 243 | 244 | // Player info for current player, if drawing a player 245 | player_info_t* m_pPlayerInfo; 246 | 247 | // The index of the player being drawn 248 | int m_nPlayerIndex; 249 | 250 | // The player's gait movement 251 | float m_flGaitMovement; 252 | 253 | // Pointer to header block for studio model data 254 | studiohdr_t* m_pStudioHeader; 255 | 256 | // Pointers to current body part and submodel 257 | mstudiobodyparts_t* m_pBodyPart; 258 | mstudiomodel_t* m_pSubModel; 259 | 260 | // Palette substition for top and bottom of model 261 | int m_nTopColor; 262 | int m_nBottomColor; 263 | 264 | // 265 | // Sprite model used for drawing studio model chrome 266 | model_t* m_pChromeSprite; 267 | 268 | // Caching 269 | // Number of bones in bone cache 270 | int m_nCachedBones; 271 | // Names of cached bones 272 | char m_nCachedBoneNames[MAXSTUDIOBONES][32]; 273 | // Cached bone & light transformation matrices 274 | float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4]; 275 | float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4]; 276 | 277 | // Software renderer scale factors 278 | float m_fSoftwareXScale, m_fSoftwareYScale; 279 | 280 | // Current view vectors and render origin 281 | float m_vUp[3]; 282 | float m_vRight[3]; 283 | float m_vNormal[3]; 284 | 285 | float m_vRenderOrigin[3]; 286 | 287 | // Model render counters ( from engine ) 288 | int* m_pStudioModelCount; 289 | int* m_pModelsDrawn; 290 | 291 | // Matrices 292 | // Model to world transformation 293 | float (*m_protationmatrix)[3][4]; 294 | // Model to view transformation 295 | float (*m_paliastransform)[3][4]; 296 | 297 | // Concatenated bone and light transforms 298 | float (*m_pbonetransform)[MAXSTUDIOBONES][3][4]; 299 | float (*m_plighttransform)[MAXSTUDIOBONES][3][4]; 300 | */ 301 | } StudioModelRenderer_t; 302 | 303 | /* Credits: @oxiKKK */ 304 | typedef struct { 305 | void* vtbl; 306 | bool m_bActiveApp; 307 | 308 | void* m_hSDLWindow; /* pmainwindow */ 309 | void* m_hSDLGLContext; 310 | 311 | bool m_bExpectSyntheticMouseMotion; 312 | int m_nMouseTargetX; 313 | int m_nMouseTargetY; 314 | 315 | int m_nWarpDelta; 316 | 317 | bool m_bCursorVisible; 318 | 319 | /* Window pos */ 320 | int m_x; 321 | int m_y; 322 | 323 | /* Window size */ 324 | int m_width; 325 | int m_height; 326 | 327 | bool m_bMultiplayer; 328 | } game_t; 329 | 330 | /* sdk/cl_dll/hud.h */ 331 | typedef struct { 332 | int16_t frags; 333 | int16_t deaths; 334 | int16_t playerclass; 335 | int16_t health; /* UNUSED */ 336 | bool dead; 337 | int16_t teamnumber; 338 | char teamname[16]; 339 | } extra_player_info_t; /* hl1, tfc */ 340 | 341 | typedef struct { 342 | int16_t frags; 343 | int16_t deaths; 344 | int16_t team_id; 345 | int32_t has_c4; 346 | int32_t vip; 347 | vec3_t origin; 348 | int32_t radarflash; 349 | int32_t radarflashon; 350 | int32_t radarflashes; 351 | int16_t playerclass; 352 | int16_t teamnumber; 353 | char teamname[16]; 354 | bool dead; 355 | int32_t showhealth; 356 | int32_t health; 357 | char location[32]; 358 | int32_t sb_health; 359 | int32_t sb_account; 360 | int32_t has_defuse_kit; 361 | } extra_player_info_cs_t; /* cstrike */ 362 | 363 | typedef struct { 364 | int16_t frags; 365 | int16_t objscore; 366 | int16_t deaths; 367 | int16_t playerclass; 368 | int16_t teamnumber; 369 | int32_t status; 370 | char teamname[16]; 371 | int32_t showhealth; 372 | int32_t health; 373 | int32_t teamId; 374 | bool dead; 375 | } extra_player_info_dod_t; /* dod */ 376 | 377 | #endif /* SDK_H_ */ 378 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------