├── .gitignore
├── .gitmodules
├── LICENSE
├── OpenSource2-SDK
├── .editorconfig
├── OpenSource2-SDK.sln
├── OpenSource2-SDK.vcxproj
├── OpenSource2-SDK.vcxproj.filters
├── OpenSource2-SDK.vcxproj.user
├── cpp.hint
├── dependencies
│ └── funchook
│ │ ├── include
│ │ ├── distorm.h
│ │ ├── distormx.lib
│ │ └── mnemonics.h
│ │ └── src
│ │ ├── config.h
│ │ ├── decoder.c
│ │ ├── decoder.h
│ │ ├── disasm.h
│ │ ├── disasm_distorm.c
│ │ ├── distorm.c
│ │ ├── funchook.c
│ │ ├── funchook.h
│ │ ├── funchook_internal.h
│ │ ├── funchook_windows.c
│ │ ├── funchook_x86.c
│ │ ├── funchook_x86.h
│ │ ├── instructions.c
│ │ ├── instructions.h
│ │ ├── insts.c
│ │ ├── insts.h
│ │ ├── mnemonics.c
│ │ ├── operands.c
│ │ ├── operands.h
│ │ ├── prefix.c
│ │ ├── prefix.h
│ │ ├── textdefs.c
│ │ ├── textdefs.h
│ │ ├── wstring.h
│ │ └── x86defs.h
├── resources
│ └── fonts
│ │ ├── cartograph_font.hpp
│ │ ├── icons
│ │ ├── IconsMaterialDesignIcons.h
│ │ └── mdi_font.hpp
│ │ ├── libertad_font.hpp
│ │ └── red_hat_display.hpp
└── src
│ ├── entrypoint
│ ├── OpenSource2SDK.cpp
│ ├── OpenSource2SDK.hpp
│ └── dllmain.cpp
│ ├── features
│ ├── aim_enhancement
│ │ ├── aimbot.cpp
│ │ ├── aimbot.hpp
│ │ ├── recoil_control.cpp
│ │ └── recoil_control.hpp
│ ├── drawing
│ │ ├── drawing.cpp
│ │ └── drawing.hpp
│ ├── esp
│ │ ├── esp.cpp
│ │ └── esp.hpp
│ ├── feature.hpp
│ ├── features.cpp
│ ├── features.hpp
│ ├── fov_changer
│ │ ├── fov_changer.cpp
│ │ └── fov_changer.hpp
│ ├── game_hooks
│ │ ├── game_hooks.cpp
│ │ └── game_hooks.hpp
│ ├── helpers
│ │ ├── draw_utilities.cpp
│ │ ├── draw_utilities.hpp
│ │ ├── post_processing.cpp
│ │ └── post_processing.hpp
│ ├── movement
│ │ ├── bunnyhop.cpp
│ │ └── bunnyhop.hpp
│ └── triggerbot
│ │ ├── triggerbot.cpp
│ │ └── triggerbot.hpp
│ ├── game
│ ├── renderer.cpp
│ └── state.hpp
│ ├── gamedata
│ ├── gamedata.cpp
│ └── gamedata.hpp
│ ├── menu
│ ├── components
│ │ └── TopBar.cpp
│ ├── gui
│ │ ├── gui.cpp
│ │ └── gui.hpp
│ ├── menu.cpp
│ ├── menu.hpp
│ └── state.hpp
│ └── sdk
│ ├── api.hpp
│ ├── fnv1a
│ └── hash_fnv1a_constexpr.hpp
│ ├── framework.hpp
│ ├── hooks
│ ├── directx11
│ │ ├── directx11_hook.cpp
│ │ └── directx11_hook.hpp
│ ├── hook.hpp
│ ├── hooks.cpp
│ ├── hooks.hpp
│ └── wndproc
│ │ ├── wndproc_hook.cpp
│ │ └── wndproc_hook.hpp
│ ├── interface
│ └── interface.hpp
│ ├── interfaces
│ ├── interfaces.cpp
│ └── interfaces.hpp
│ ├── math
│ ├── classes
│ │ ├── transform.cpp
│ │ ├── transform.hpp
│ │ ├── vector.hpp
│ │ └── vmatrix.hpp
│ ├── math.cpp
│ ├── math.hpp
│ └── types
│ │ ├── bbox_t.hpp
│ │ └── quaternion.hpp
│ ├── memory
│ ├── memory.cpp
│ └── memory.hpp
│ ├── module
│ └── module.hpp
│ ├── schema
│ ├── schema.cpp
│ └── schema.hpp
│ ├── shaders
│ ├── CopyPS.hlsl
│ ├── build
│ │ └── gaussian_blur.hpp
│ ├── gaussian_blur_x.hlsl
│ └── gaussian_blur_y.hlsl
│ ├── source-sdk
│ ├── classes
│ │ ├── bitflag.hpp
│ │ ├── c_attributecontainer.hpp
│ │ ├── c_baseplayerweapon.hpp
│ │ ├── ccsgoinput.hpp
│ │ ├── cgameentitysystem.cpp
│ │ ├── cgameentitysystem.hpp
│ │ ├── cgameevent.hpp
│ │ ├── cgameeventmanager.hpp
│ │ ├── chandle.cpp
│ │ ├── chandle.hpp
│ │ ├── cheapmemalloc.hpp
│ │ ├── cmaterial2.hpp
│ │ ├── cnetworkutlvectorbase.hpp
│ │ ├── cstronghandle.hpp
│ │ ├── cutlmap.hpp
│ │ ├── cutlsymbollarge.hpp
│ │ ├── cutlvector.hpp
│ │ ├── econ
│ │ │ ├── c_econentity.hpp
│ │ │ ├── c_econitemview.cpp
│ │ │ ├── c_econitemview.hpp
│ │ │ ├── ceconitem.cpp
│ │ │ ├── ceconitem.hpp
│ │ │ ├── ceconitemdefinition.cpp
│ │ │ ├── ceconitemdefinition.hpp
│ │ │ ├── ceconitemschema.cpp
│ │ │ ├── ceconitemschema.hpp
│ │ │ └── ceconitemsystem.hpp
│ │ ├── entity
│ │ │ ├── bones
│ │ │ │ ├── cbonesystem.cpp
│ │ │ │ └── cbonesystem.hpp
│ │ │ ├── c_baseentity.cpp
│ │ │ ├── c_baseentity.hpp
│ │ │ ├── c_basemodelentity.cpp
│ │ │ ├── c_basemodelentity.hpp
│ │ │ ├── c_baseplayerpawn.hpp
│ │ │ ├── c_baseplayerweapon.hpp
│ │ │ ├── c_baseviewmodel.hpp
│ │ │ ├── c_chicken.hpp
│ │ │ ├── c_csplayerpawn.cpp
│ │ │ ├── c_csplayerpawn.hpp
│ │ │ ├── c_csplayerpawnbase.hpp
│ │ │ ├── c_csweaponbase.cpp
│ │ │ ├── c_csweaponbase.hpp
│ │ │ ├── c_plantedc4.hpp
│ │ │ ├── c_pointcamera.hpp
│ │ │ ├── cbaseplayercontroller.hpp
│ │ │ ├── ccollisionproperty.hpp
│ │ │ ├── ccsplayer_viewmodelservices.hpp
│ │ │ ├── ccsplayercontroller.hpp
│ │ │ ├── centityidentity.hpp
│ │ │ ├── centityinstance.hpp
│ │ │ ├── cgamescenenode.cpp
│ │ │ ├── cgamescenenode.hpp
│ │ │ ├── cplayer_cameraservices.hpp
│ │ │ ├── cplayer_weaponservices.hpp
│ │ │ └── hitbox
│ │ │ │ └── hitbox.hpp
│ │ ├── gcsdk
│ │ │ ├── cgcclient.cpp
│ │ │ ├── cgcclient.hpp
│ │ │ ├── cgcclientsystem.cpp
│ │ │ └── cgcclientsystem.hpp
│ │ ├── material_system
│ │ │ └── material_system.hpp
│ │ └── types
│ │ │ ├── c_sounddata.hpp
│ │ │ ├── c_trace.cpp
│ │ │ ├── c_trace.hpp
│ │ │ └── cglobalvarsbase.hpp
│ ├── interfaces
│ │ ├── ccvar.hpp
│ │ ├── cengineclient.hpp
│ │ ├── cgameeventmanager.hpp
│ │ ├── cgameresourceserviceclient.hpp
│ │ ├── cinputsystem.hpp
│ │ ├── clocalize.hpp
│ │ ├── cmaterialsystem2.hpp
│ │ ├── cschemasystem.hpp
│ │ ├── csource2client.hpp
│ │ └── iscenelayer.hpp
│ └── source-sdk.hpp
│ ├── utilities
│ └── static_string.hpp
│ └── virtual
│ └── virtual.hpp
├── README.md
└── media
├── gui-v0.2.0.png
├── gui-v0.3.0.png
├── gui-v0.4.0.png
├── gui-v0.5.0-1.png
└── gui-v0.5.0-2.png
/.gitignore:
--------------------------------------------------------------------------------
1 | x64/
2 | .vs/
3 | !.vs/settings.json
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "OpenSource2-SDK/dependencies/imgui"]
2 | path = OpenSource2-SDK/dependencies/imgui
3 | url = https://github.com/ocornut/imgui.git
4 | [submodule "OpenSource2-SDK/dependencies/stb"]
5 | path = OpenSource2-SDK/dependencies/stb
6 | url = https://github.com/cristeigabriel/STB.git
7 | [submodule "OpenSource2-SDK/dependencies/implot"]
8 | path = OpenSource2-SDK/dependencies/implot
9 | url = https://github.com/epezent/implot.git
10 | [submodule "OpenSource2-SDK/dependencies/glm"]
11 | path = OpenSource2-SDK/dependencies/glm
12 | url = https://github.com/g-truc/glm.git
13 | [submodule "OpenSource2-SDK/dependencies/nlohmann"]
14 | path = OpenSource2-SDK/dependencies/nlohmann
15 | url = https://github.com/nlohmann/json.git
16 | branch = develop
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 alza54 (18yo)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 | end_of_line = lf
10 |
11 | [Makefile]
12 | indent_style = tab
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/OpenSource2-SDK/OpenSource2-SDK.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33424.131
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenSource2-SDK", "OpenSource2-SDK.vcxproj", "{00E72344-CA6E-47D4-B151-486E3E586950}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {00E72344-CA6E-47D4-B151-486E3E586950}.Debug|x64.ActiveCfg = Debug|x64
15 | {00E72344-CA6E-47D4-B151-486E3E586950}.Debug|x64.Build.0 = Debug|x64
16 | {00E72344-CA6E-47D4-B151-486E3E586950}.Release|x64.ActiveCfg = Release|x64
17 | {00E72344-CA6E-47D4-B151-486E3E586950}.Release|x64.Build.0 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DEC8475C-586D-4369-B6D3-0EA29A48154D}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/OpenSource2-SDK.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/cpp.hint:
--------------------------------------------------------------------------------
1 | // Hint files help the Visual Studio IDE interpret Visual C++ identifiers
2 | // such as names of functions and macros.
3 | // For more information see https://go.microsoft.com/fwlink/?linkid=865984
4 | #define CONFIG_GETTER(TYPE, NAME) TYPE#NAME() { return config_.NAME; }
5 | #define CONSTRUCT_FEATURE(FEATURE_NAME) FEATURE_NAME(Features* pFeatures_) : Feature(#FEATURE_NAME, pFeatures_)
6 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/include/distormx.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alza54/opensource2/ff7c27a072f059597277b2eeacaf012683d4ff74/OpenSource2-SDK/dependencies/funchook/include/distormx.lib
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/config.h:
--------------------------------------------------------------------------------
1 | /*
2 | config.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef CONFIG_H
12 | #define CONFIG_H
13 |
14 | /* diStorm version number. */
15 | #define __DISTORMV__ 0x030503
16 |
17 | #include /* memset, memcpy - can be easily self implemented for libc independency. */
18 |
19 | #include "../include/distorm.h"
20 |
21 | /*
22 | * 64 bit offsets support:
23 | * This macro should be defined from compiler command line flags, e.g:
24 | * -DSUPPORT_64BIT_OFFSET Note: make sure that the caller (library user) defines
25 | * it too!
26 | */
27 | /* #define SUPPORT_64BIT_OFFSET */
28 |
29 | /*
30 | * If you compile diStorm as a dynamic library (.dll or .so) file, make sure you
31 | * uncomment the next line. So the interface functions will be exported,
32 | * otherwise they are useable only for static library. For example, this macro
33 | * is being set for compiling diStorm as a .dll for Python with CTypes.
34 | */
35 | /* #define DISTORM_DYNAMIC */
36 |
37 | /*
38 | * If DISTORM_LIGHT is defined, everything involved in formatting the
39 | * instructions as text will be excluded from compilation. distorm_decode(..)
40 | * and distorm_format(..) will not be available. This will decrease the size of
41 | * the executable and leave you with decomposition functionality only.
42 | *
43 | * Note: it should be either set in the preprocessor definitions manually or in
44 | * command line -D switch. #define DISTORM_LIGHT
45 | */
46 |
47 | /*
48 | * diStorm now supports little/big endian CPU's.
49 | * It should detect the endianness according to predefined macro's of the
50 | * compiler. If you don't use GCC/MSVC you will have to define it on your own.
51 | */
52 |
53 | /* These macros are used in order to make the code portable. */
54 | #ifdef __GNUC__
55 |
56 | #include
57 |
58 | #define _DLLEXPORT_
59 | #define _FASTCALL_
60 | /* Keep inline as static (arrrrg) as it would break linux on some flavors
61 | * otherwise. */
62 | #define _INLINE_ static
63 | /* GCC ignores this directive... */
64 | /*#define _FASTCALL_ __attribute__((__fastcall__))*/
65 |
66 | /* Set endianity (supposed to be LE though): */
67 | #ifdef __BIG_ENDIAN__
68 | #define BE_SYSTEM
69 | #endif
70 |
71 | /* End of __GCC__ */
72 |
73 | #elif __WATCOMC__
74 |
75 | #include
76 |
77 | #define _DLLEXPORT_
78 | #define _FASTCALL_
79 | #define _INLINE_ __inline
80 |
81 | /* End of __WATCOMC__ */
82 |
83 | #elif __DMC__
84 |
85 | #include
86 |
87 | #define _DLLEXPORT_
88 | #define _FASTCALL_
89 | #define _INLINE_ __inline
90 |
91 | /* End of __DMC__ */
92 |
93 | #elif __TINYC__
94 |
95 | #include
96 |
97 | #define _DLLEXPORT_
98 | #define _FASTCALL_
99 | #define _INLINE_ static
100 |
101 | /* End of __TINYC__ */
102 |
103 | #elif _MSC_VER
104 |
105 | /* stdint alternative is defined in distorm.h */
106 |
107 | #define _DLLEXPORT_ __declspec(dllexport)
108 | #define _FASTCALL_ __fastcall
109 | #define _INLINE_ __inline
110 |
111 | /* Set endianity (supposed to be LE though): */
112 | #if !defined(_M_IX86) && !defined(_M_X64)
113 | #define BE_SYSTEM
114 | #endif
115 |
116 | #endif /* #elif _MSC_VER */
117 |
118 | /* If the library isn't compiled as a dynamic library don't export any
119 | * functions. */
120 | #ifndef DISTORM_DYNAMIC
121 | #undef _DLLEXPORT_
122 | #define _DLLEXPORT_
123 | #endif
124 |
125 | #ifndef FALSE
126 | #define FALSE 0
127 | #endif
128 | #ifndef TRUE
129 | #define TRUE 1
130 | #endif
131 |
132 | /* Define stream read functions for big endian systems. */
133 | #ifdef BE_SYSTEM
134 |
135 | /* Avoid defining 'static static' for GCC. */
136 | #ifndef __GNUC__
137 | #define STATIC_INLINE static _INLINE_
138 | #else
139 | #define STATIC_INLINE static
140 | #endif
141 |
142 | /*
143 | * Assumption: These functions can read from the stream safely!
144 | * Swap endianity of input to little endian.
145 | */
146 | STATIC_INLINE int16_t RSHORT(const uint8_t *s) { return s[0] | (s[1] << 8); }
147 | STATIC_INLINE uint16_t RUSHORT(const uint8_t *s) { return s[0] | (s[1] << 8); }
148 | STATIC_INLINE int32_t RLONG(const uint8_t *s) {
149 | return s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
150 | }
151 | STATIC_INLINE uint32_t RULONG(const uint8_t *s) {
152 | return s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
153 | }
154 | STATIC_INLINE int64_t RLLONG(const uint8_t *s) {
155 | return s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24) |
156 | ((uint64_t)s[4] << 32) | ((uint64_t)s[5] << 40) |
157 | ((uint64_t)s[6] << 48) | ((uint64_t)s[7] << 56);
158 | }
159 | STATIC_INLINE uint64_t RULLONG(const uint8_t *s) {
160 | return s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24) |
161 | ((uint64_t)s[4] << 32) | ((uint64_t)s[5] << 40) |
162 | ((uint64_t)s[6] << 48) | ((uint64_t)s[7] << 56);
163 | }
164 |
165 | #undef STATIC_INLINE
166 |
167 | #else
168 | /* Little endian macro's will just make the cast. */
169 | #define RSHORT(x) *(int16_t *)x
170 | #define RUSHORT(x) *(uint16_t *)x
171 | #define RLONG(x) *(int32_t *)x
172 | #define RULONG(x) *(uint32_t *)x
173 | #define RLLONG(x) *(int64_t *)x
174 | #define RULLONG(x) *(uint64_t *)x
175 | #endif
176 |
177 | #endif /* CONFIG_H */
178 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/decoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | decoder.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef DECODER_H
12 | #define DECODER_H
13 |
14 | #include "config.h"
15 |
16 | typedef unsigned int _iflags;
17 |
18 | _DecodeResult decode_internal(_CodeInfo* _ci, int supportOldIntr,
19 | _DInst result[], unsigned int maxResultCount,
20 | unsigned int* usedInstructionsCount);
21 |
22 | #endif /* DECODER_H */
23 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/disasm.h:
--------------------------------------------------------------------------------
1 | /* -*- indent-tabs-mode: nil -*-
2 | *
3 | * This file is part of Funchook.
4 | * https://github.com/kubo/funchook
5 | *
6 | * Funchook is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * As a special exception, the copyright holders of this library give you
12 | * permission to link this library with independent modules to produce an
13 | * executable, regardless of the license terms of these independent
14 | * modules, and to copy and distribute the resulting executable under
15 | * terms of your choice, provided that you also meet, for each linked
16 | * independent module, the terms and conditions of the license of that
17 | * module. An independent module is a module which is not derived from or
18 | * based on this library. If you modify this library, you may extend this
19 | * exception to your version of the library, but you are not obliged to
20 | * do so. If you do not wish to do so, delete this exception statement
21 | * from your version.
22 | *
23 | * Funchook is distributed in the hope that it will be useful, but WITHOUT
24 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 | * for more details.
27 | *
28 | * You should have received a copy of the GNU General Public License
29 | * along with Funchook. If not, see .
30 | */
31 | #ifndef DISASM_H
32 | #define DISASM_H 1
33 |
34 | #ifdef DISASM_DISTORM
35 | #include
36 | #include
37 |
38 | typedef struct funchook_disasm {
39 | funchook_t *funchook;
40 | _CodeInfo ci;
41 | unsigned int idx;
42 | unsigned int cnt;
43 | _DInst dis[MAX_INSN_CHECK_SIZE];
44 | } funchook_disasm_t;
45 | typedef _DInst funchook_insn_t;
46 |
47 | #define funchook_insn_size(insn) ((insn)->size)
48 | #define funchook_insn_address(insn) ((size_t)(insn)->addr)
49 | #define funchook_insn_branch_address(insn) ((size_t)INSTRUCTION_GET_TARGET(insn))
50 |
51 | #endif
52 |
53 | #ifdef DISASM_CAPSTONE
54 | #include
55 |
56 | typedef struct funchook_disasm {
57 | funchook_t *funchook;
58 | csh handle;
59 | cs_insn *insns;
60 | size_t index;
61 | size_t count;
62 | } funchook_disasm_t;
63 |
64 | typedef cs_insn funchook_insn_t;
65 |
66 | #define funchook_insn_size(insn) ((insn)->size / sizeof(insn_t))
67 | #define funchook_insn_address(insn) ((size_t)(insn)->address)
68 | #define funchook_insn_branch_address(insn) ((size_t)(insn)->detail->x86.operands[0].imm)
69 | #endif
70 |
71 | #ifdef DISASM_ZYDIS
72 | #include
73 |
74 | typedef struct {
75 | ZydisDecodedInstruction insn;
76 | size_t next_address;
77 | } funchook_insn_t;
78 |
79 | typedef struct funchook_disasm {
80 | funchook_t *funchook;
81 | ZydisDecoder decoder;
82 | ZydisFormatter formatter;
83 | funchook_insn_t insn;
84 | const uint8_t *code;
85 | const uint8_t *code_end;
86 | } funchook_disasm_t;
87 |
88 | #define funchook_insn_size(insn) ((insn)->insn.length)
89 | #define funchook_insn_address(insn) ((insn)->next_address - (insn)->insn.length)
90 | #define funchook_insn_branch_address(insn) ((insn)->next_address + (intptr_t)(insn)->insn.raw.imm[0].value.s)
91 |
92 | #endif
93 |
94 | #define FUNCHOOK_ERROR_END_OF_INSTRUCTION -2
95 |
96 | int funchook_disasm_init(funchook_disasm_t *disasm, funchook_t *funchook, const insn_t *code, size_t code_size, size_t address);
97 | void funchook_disasm_cleanup(funchook_disasm_t *disasm);
98 | int funchook_disasm_next(funchook_disasm_t *disasm, const funchook_insn_t **next_insn);
99 | void funchook_disasm_log_instruction(funchook_disasm_t *disasm, const funchook_insn_t *insn);
100 |
101 | #if defined(CPU_ARM64)
102 | funchook_insn_info_t funchook_disasm_arm64_insn_info(funchook_disasm_t *disasm, const funchook_insn_t *insn);
103 | #endif
104 |
105 | #if defined(CPU_X86) || defined(CPU_X86_64)
106 | /* RIP-relative address information */
107 | typedef struct {
108 | insn_t *addr; /* absolute address */
109 | intptr_t raddr; /* relative address */
110 | int offset;
111 | int size;
112 | } rip_relative_t;
113 |
114 | void funchook_disasm_x86_rip_relative(funchook_disasm_t *disasm, const funchook_insn_t *insn, rip_relative_t *rel_disp, rip_relative_t *rel_imm);
115 | #endif
116 |
117 | #endif
118 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/funchook.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Funchook.
3 | * https://github.com/kubo/funchook
4 | *
5 | * Funchook is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the
7 | * Free Software Foundation, either version 2 of the License, or (at your
8 | * option) any later version.
9 | *
10 | * As a special exception, the copyright holders of this library give you
11 | * permission to link this library with independent modules to produce an
12 | * executable, regardless of the license terms of these independent
13 | * modules, and to copy and distribute the resulting executable under
14 | * terms of your choice, provided that you also meet, for each linked
15 | * independent module, the terms and conditions of the license of that
16 | * module. An independent module is a module which is not derived from or
17 | * based on this library. If you modify this library, you may extend this
18 | * exception to your version of the library, but you are not obliged to
19 | * do so. If you do not wish to do so, delete this exception statement
20 | * from your version.
21 | *
22 | * Funchook is distributed in the hope that it will be useful, but WITHOUT
23 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 | * for more details.
26 | *
27 | * You should have received a copy of the GNU General Public License
28 | * along with Funchook. If not, see .
29 | */
30 | #ifndef FUNCHOOK_H
31 | #define FUNCHOOK_H 1
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /*
38 | * Only functions with FUNCHOOK_EXPORT are visible from outside of funchook.dll
39 | * or libfunchook.so. Others are invisible.
40 | */
41 | #ifdef FUNCHOOK_EXPORTS
42 | #if defined(_WIN32)
43 | #define FUNCHOOK_EXPORT __declspec(dllexport)
44 | #elif defined(__GNUC__)
45 | #define FUNCHOOK_EXPORT __attribute__((visibility("default")))
46 | #endif
47 | #endif /* FUNCHOOK_EXPORTS */
48 | #ifndef FUNCHOOK_EXPORT
49 | #define FUNCHOOK_EXPORT
50 | #endif
51 |
52 | typedef struct funchook funchook_t;
53 |
54 | #define FUNCHOOK_ERROR_INTERNAL_ERROR -1
55 | #define FUNCHOOK_ERROR_SUCCESS 0
56 | #define FUNCHOOK_ERROR_OUT_OF_MEMORY 1
57 | #define FUNCHOOK_ERROR_ALREADY_INSTALLED 2
58 | #define FUNCHOOK_ERROR_DISASSEMBLY 3
59 | #define FUNCHOOK_ERROR_IP_RELATIVE_OFFSET 4
60 | #define FUNCHOOK_ERROR_CANNOT_FIX_IP_RELATIVE 5
61 | #define FUNCHOOK_ERROR_FOUND_BACK_JUMP 6
62 | #define FUNCHOOK_ERROR_TOO_SHORT_INSTRUCTIONS 7
63 | #define FUNCHOOK_ERROR_MEMORY_ALLOCATION 8 /* memory allocation error */
64 | #define FUNCHOOK_ERROR_MEMORY_FUNCTION 9 /* other memory function errors */
65 | #define FUNCHOOK_ERROR_NOT_INSTALLED 10
66 | #define FUNCHOOK_ERROR_NO_AVAILABLE_REGISTERS 11
67 |
68 | /**
69 | * Create a funchook handle
70 | *
71 | * @return allocated funchook handle. NULL when out-of-memory.
72 | */
73 | FUNCHOOK_EXPORT funchook_t *funchook_create(void);
74 |
75 | /**
76 | * Prepare hooking
77 | *
78 | * @param funchook a funchook handle created by funchook_create()
79 | * @param target_func function pointer to be intercepted. The pointer to trampoline function is set on success.
80 | * @param hook_func function pointer which is called istead of target_func
81 | * @return error code. one of FUNCHOOK_ERROR_*.
82 | */
83 | FUNCHOOK_EXPORT int funchook_prepare(funchook_t *funchook, void **target_func, void *hook_func);
84 |
85 | /**
86 | * Install hooks prepared by funchook_prepare().
87 | *
88 | * @param funchook a funchook handle created by funchook_create()
89 | * @param flags reserved. Set zero.
90 | * @return error code. one of FUNCHOOK_ERROR_*.
91 | */
92 | FUNCHOOK_EXPORT int funchook_install(funchook_t *funchook, int flags);
93 |
94 | /**
95 | * Uninstall hooks installed by funchook_install().
96 | *
97 | * @param funchook a funchook handle created by funchook_create()
98 | * @param flags reserved. Set zero.
99 | * @return error code. one of FUNCHOOK_ERROR_*.
100 | */
101 | FUNCHOOK_EXPORT int funchook_uninstall(funchook_t *funchook, int flags);
102 |
103 | /**
104 | * Destroy a funchook handle
105 | *
106 | * @param funchook a funchook handle created by funchook_create()
107 | * @return error code. one of FUNCHOOK_ERROR_*.
108 | */
109 | FUNCHOOK_EXPORT int funchook_destroy(funchook_t *funchook);
110 |
111 | /**
112 | * Get error message
113 | *
114 | * @param funchook a funchook handle created by funchook_create()
115 | * @return pointer to buffer containing error message
116 | */
117 | FUNCHOOK_EXPORT const char *funchook_error_message(const funchook_t *funchook);
118 |
119 | /**
120 | * Set log file name to debug funchook itself.
121 | *
122 | * @param name log file name
123 | * @return error code. one of FUNCHOOK_ERROR_*.
124 | */
125 | FUNCHOOK_EXPORT int funchook_set_debug_file(const char *name);
126 |
127 | #ifdef __cplusplus
128 | } // extern "C"
129 | #endif
130 |
131 | #endif
132 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/funchook_x86.h:
--------------------------------------------------------------------------------
1 | /* -*- indent-tabs-mode: nil -*-
2 | *
3 | * This file is part of Funchook.
4 | * https://github.com/kubo/funchook
5 | *
6 | * Funchook is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * As a special exception, the copyright holders of this library give you
12 | * permission to link this library with independent modules to produce an
13 | * executable, regardless of the license terms of these independent
14 | * modules, and to copy and distribute the resulting executable under
15 | * terms of your choice, provided that you also meet, for each linked
16 | * independent module, the terms and conditions of the license of that
17 | * module. An independent module is a module which is not derived from or
18 | * based on this library. If you modify this library, you may extend this
19 | * exception to your version of the library, but you are not obliged to
20 | * do so. If you do not wish to do so, delete this exception statement
21 | * from your version.
22 | *
23 | * Funchook is distributed in the hope that it will be useful, but WITHOUT
24 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 | * for more details.
27 | *
28 | * You should have received a copy of the GNU General Public License
29 | * along with Funchook. If not, see .
30 | */
31 | #ifndef FUNCHOOK_X86_H
32 | #define FUNCHOOK_X86_H 1
33 |
34 | #define MAX_INSN_LEN 16
35 | #define MAX_INSN_CHECK_SIZE 256
36 |
37 | #define JUMP32_SIZE 5
38 | #ifdef CPU_X86_64
39 | #define JUMP64_SIZE 14
40 | #endif
41 |
42 | #define TRAMPOLINE_SIZE (JUMP32_SIZE + (MAX_INSN_LEN - 1) + JUMP32_SIZE)
43 |
44 | typedef uint8_t insn_t;
45 |
46 | typedef struct funchook_entry {
47 | void *target_func;
48 | void *hook_func;
49 | uint8_t trampoline[TRAMPOLINE_SIZE];
50 | uint8_t old_code[JUMP32_SIZE];
51 | uint8_t new_code[JUMP32_SIZE];
52 | #ifdef CPU_X86_64
53 | uint8_t transit[JUMP64_SIZE];
54 | #endif
55 | } funchook_entry_t;
56 |
57 | typedef struct {
58 | const insn_t *dst_addr;
59 | intptr_t src_addr_offset;
60 | intptr_t pos_offset;
61 | } ip_displacement_entry_t;
62 |
63 | typedef struct {
64 | ip_displacement_entry_t disp[2];
65 | } ip_displacement_t;
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/insts.c:
--------------------------------------------------------------------------------
1 | /*
2 | insts.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef INSTS_H
12 | #define INSTS_H
13 |
14 | #include "instructions.h"
15 |
16 | /* Flags Table */
17 | extern _iflags FlagsTable[];
18 |
19 | /* Root Trie DB */
20 | extern _InstSharedInfo InstSharedInfoTable[];
21 | extern _InstInfo InstInfos[];
22 | extern _InstInfoEx InstInfosEx[];
23 | extern _InstNode InstructionsTree[];
24 |
25 | /* 3DNow! Trie DB */
26 | extern _InstNode Table_0F_0F;
27 | /* AVX related: */
28 | extern _InstNode Table_0F, Table_0F_38, Table_0F_3A;
29 |
30 | /*
31 | * The inst_lookup will return on of these two instructions according to the
32 | * specified decoding mode. ARPL or MOVSXD on 64 bits is one byte instruction at
33 | * index 0x63.
34 | */
35 | extern _InstInfo II_MOVSXD;
36 |
37 | /*
38 | * The NOP instruction can be prefixed by REX in 64bits, therefore we have to
39 | * decide in runtime whether it's an XCHG or NOP instruction. If 0x90 is
40 | * prefixed by a usable REX it will become XCHG, otherwise it will become a NOP.
41 | * Also note that if it's prefixed by 0xf3, it becomes a Pause.
42 | */
43 | extern _InstInfo II_NOP;
44 | extern _InstInfo II_PAUSE;
45 |
46 | /*
47 | * RDRAND and VMPTRLD share same 2.3 bytes opcode, and then alternates on the
48 | * MOD bits, RDRAND is OT_FULL_REG while VMPTRLD is OT_MEM, and there's no such
49 | * mixed type. So a hack into the inst_lookup was added for this decision, the
50 | * DB isn't flexible enough. :(
51 | */
52 | extern _InstInfo II_RDRAND;
53 |
54 | /*
55 | * Used for letting the extract operand know the type of operands without
56 | * knowing the instruction itself yet, because of the way those instructions
57 | * work. See function instructions.c!inst_lookup_3dnow.
58 | */
59 | extern _InstInfo II_3DNOW;
60 |
61 | /* Helper tables for pseudo compare mnemonics. */
62 | extern uint16_t CmpMnemonicOffsets[8]; /* SSE */
63 | extern uint16_t VCmpMnemonicOffsets[32]; /* AVX */
64 |
65 | #endif /* INSTS_H */
66 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/insts.h:
--------------------------------------------------------------------------------
1 | /*
2 | insts.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef INSTS_H
12 | #define INSTS_H
13 |
14 | #include "instructions.h"
15 |
16 | /* Flags Table */
17 | extern _iflags FlagsTable[];
18 |
19 | /* Root Trie DB */
20 | extern _InstSharedInfo InstSharedInfoTable[];
21 | extern _InstInfo InstInfos[];
22 | extern _InstInfoEx InstInfosEx[];
23 | extern _InstNode InstructionsTree[];
24 |
25 | /* 3DNow! Trie DB */
26 | extern _InstNode Table_0F_0F;
27 | /* AVX related: */
28 | extern _InstNode Table_0F, Table_0F_38, Table_0F_3A;
29 |
30 | /*
31 | * The inst_lookup will return on of these two instructions according to the
32 | * specified decoding mode. ARPL or MOVSXD on 64 bits is one byte instruction at
33 | * index 0x63.
34 | */
35 | extern _InstInfo II_MOVSXD;
36 |
37 | /*
38 | * The NOP instruction can be prefixed by REX in 64bits, therefore we have to
39 | * decide in runtime whether it's an XCHG or NOP instruction. If 0x90 is
40 | * prefixed by a usable REX it will become XCHG, otherwise it will become a NOP.
41 | * Also note that if it's prefixed by 0xf3, it becomes a Pause.
42 | */
43 | extern _InstInfo II_NOP;
44 | extern _InstInfo II_PAUSE;
45 |
46 | /*
47 | * RDRAND and VMPTRLD share same 2.3 bytes opcode, and then alternates on the
48 | * MOD bits, RDRAND is OT_FULL_REG while VMPTRLD is OT_MEM, and there's no such
49 | * mixed type. So a hack into the inst_lookup was added for this decision, the
50 | * DB isn't flexible enough. :(
51 | */
52 | extern _InstInfo II_RDRAND;
53 |
54 | /*
55 | * Used for letting the extract operand know the type of operands without
56 | * knowing the instruction itself yet, because of the way those instructions
57 | * work. See function instructions.c!inst_lookup_3dnow.
58 | */
59 | extern _InstInfo II_3DNOW;
60 |
61 | /* Helper tables for pseudo compare mnemonics. */
62 | extern uint16_t CmpMnemonicOffsets[8]; /* SSE */
63 | extern uint16_t VCmpMnemonicOffsets[32]; /* AVX */
64 |
65 | #endif /* INSTS_H */
66 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/operands.h:
--------------------------------------------------------------------------------
1 | /*
2 | operands.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef OPERANDS_H
12 | #define OPERANDS_H
13 |
14 | #include "config.h"
15 | #include "decoder.h"
16 | #include "instructions.h"
17 | #include "prefix.h"
18 |
19 | int operands_extract(_CodeInfo* ci, _DInst* di, _InstInfo* ii,
20 | _iflags instFlags, _OpType type, unsigned int modrm,
21 | _PrefixState* ps, _DecodeType effOpSz,
22 | _DecodeType effAdrSz, _Operand* op);
23 |
24 | #endif /* OPERANDS_H */
25 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/prefix.h:
--------------------------------------------------------------------------------
1 | /*
2 | prefix.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef PREFIX_H
12 | #define PREFIX_H
13 |
14 | #include "config.h"
15 | #include "decoder.h"
16 |
17 | /* Specifies the type of the extension prefix, such as: REX, 2 bytes VEX, 3
18 | * bytes VEX. */
19 | typedef enum {
20 | PET_NONE = 0,
21 | PET_REX,
22 | PET_VEX2BYTES,
23 | PET_VEX3BYTES
24 | } _PrefixExtType;
25 |
26 | /* Specifies an index into a table of prefixes by their type. */
27 | typedef enum {
28 | PFXIDX_NONE = -1,
29 | PFXIDX_REX,
30 | PFXIDX_LOREP,
31 | PFXIDX_SEG,
32 | PFXIDX_OP_SIZE,
33 | PFXIDX_ADRS,
34 | PFXIDX_MAX
35 | } _PrefixIndexer;
36 |
37 | /*
38 | * This holds the prefixes state for the current instruction we decode.
39 | * decodedPrefixes includes all specific prefixes that the instruction got.
40 | * start is a pointer to the first prefix to take into account.
41 | * last is a pointer to the last byte we scanned.
42 | * Other pointers are used to keep track of prefixes positions and help us know
43 | * if they appeared already and where.
44 | */
45 | typedef struct {
46 | _iflags decodedPrefixes, usedPrefixes;
47 | /* Number of prefixes scanned for current instruction, including VEX! */
48 | unsigned int count;
49 | uint16_t unusedPrefixesMask;
50 | /* Holds the offset to the prefix byte by its type. */
51 | uint16_t pfxIndexer[PFXIDX_MAX];
52 | _PrefixExtType prefixExtType;
53 | /* Indicates whether the operand size prefix (0x66) was used as a mandatory
54 | * prefix. */
55 | int isOpSizeMandatory;
56 | /* If VEX prefix is used, store the VEX.vvvv field. */
57 | unsigned int vexV;
58 | /* The fields B/X/R/W/L of REX and VEX are stored together in this byte. */
59 | unsigned int vrex;
60 | const uint8_t* vexPos;
61 | } _PrefixState;
62 |
63 | /*
64 | * Intel supports 6 types of prefixes, whereas AMD supports 5 types (lock is
65 | * seperated from rep/nz). REX is the fifth prefix type, this time I'm based on
66 | * AMD64. VEX is the 6th, though it can't be repeated.
67 | */
68 | #define MAX_PREFIXES (5)
69 |
70 | extern int PrefixTables[256 * 2];
71 |
72 | _INLINE_ int prefixes_is_valid(unsigned char ch, _DecodeType dt) {
73 | /* The predicate selects (branchlessly) second half table for 64 bits
74 | * otherwise selects first half. */
75 | return PrefixTables[ch + ((dt >> 1) << 8)];
76 | }
77 |
78 | /* Ignore a specific prefix type. */
79 | _INLINE_ void prefixes_ignore(_PrefixState* ps, _PrefixIndexer pi) {
80 | /*
81 | * If that type of prefix appeared already, set the bit of that *former*
82 | * prefix. Anyway, set the new index of that prefix type to the current index,
83 | * so next time we know its position.
84 | */
85 | ps->unusedPrefixesMask |= ps->pfxIndexer[pi];
86 | }
87 |
88 | void prefixes_ignore_all(_PrefixState* ps);
89 | uint16_t prefixes_set_unused_mask(_PrefixState* ps);
90 | void prefixes_decode(_CodeInfo* ci, _PrefixState* ps);
91 | void prefixes_use_segment(_iflags defaultSeg, _PrefixState* ps, _DecodeType dt,
92 | _DInst* di);
93 |
94 | #endif /* PREFIX_H */
95 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/textdefs.c:
--------------------------------------------------------------------------------
1 | /*
2 | textdefs.c
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #include "textdefs.h"
12 |
13 | #ifndef DISTORM_LIGHT
14 |
15 | static uint8_t Nibble2ChrTable[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
16 | '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
17 | #define NIBBLE_TO_CHR Nibble2ChrTable[t]
18 |
19 | void str_hex(_WString* s, const uint8_t* buf, unsigned int len) {
20 | /* 256 * 2 : 2 chars per byte value. */
21 | static const char* TextBTable =
22 | "000102030405060708090a0b0c0d0e0f"
23 | "101112131415161718191a1b1c1d1e1f"
24 | "202122232425262728292a2b2c2d2e2f"
25 | "303132333435363738393a3b3c3d3e3f"
26 | "404142434445464748494a4b4c4d4e4f"
27 | "505152535455565758595a5b5c5d5e5f"
28 | "606162636465666768696a6b6c6d6e6f"
29 | "707172737475767778797a7b7c7d7e7f"
30 | "808182838485868788898a8b8c8d8e8f"
31 | "909192939495969798999a9b9c9d9e9f"
32 | "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
33 | "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
34 | "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
35 | "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
36 | "e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
37 | "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
38 |
39 | unsigned int i = 0;
40 | /* Length is at least 1, enter loop. */
41 | s->length = len * 2;
42 | s->p[len * 2] = 0;
43 | do {
44 | RSHORT(&s->p[i]) = RSHORT(&TextBTable[(*buf) * 2]);
45 | buf++;
46 | i += 2;
47 | } while (i < len * 2);
48 | }
49 |
50 | #ifdef SUPPORT_64BIT_OFFSET
51 |
52 | void str_int_impl(unsigned char** s, uint64_t x) {
53 | int8_t* buf;
54 | int shift = 0;
55 | OFFSET_INTEGER t = x;
56 |
57 | buf = (int8_t*)*s;
58 |
59 | *buf++ = '0';
60 | *buf++ = 'x';
61 |
62 | if (x == 0) {
63 | *buf = '0';
64 | *s += 3;
65 | return;
66 | }
67 |
68 | do {
69 | t >>= 4;
70 | shift += 4;
71 | } while (t);
72 |
73 | do {
74 | shift -= 4;
75 | t = (x >> shift) & 0xf;
76 | *buf++ = NIBBLE_TO_CHR;
77 | } while (shift > 0);
78 |
79 | *s = (unsigned char*)buf;
80 | }
81 |
82 | #else
83 |
84 | void str_int_impl(unsigned char** s, uint8_t src[8]) {
85 | int8_t* buf;
86 | int i = 0, shift = 0;
87 | uint32_t x = RULONG(&src[sizeof(int32_t)]);
88 | int t;
89 |
90 | buf = (int8_t*)*s;
91 | buf[0] = '0';
92 | buf[1] = 'x';
93 | buf += 2;
94 |
95 | for (shift = 28; shift != -4; shift -= 4) {
96 | t = (x >> shift) & 0xf;
97 | if (i | t) buf[i++] = NIBBLE_TO_CHR;
98 | }
99 |
100 | x = RULONG(src);
101 | for (shift = 28; shift != 0; shift -= 4) {
102 | t = (x >> shift) & 0xf;
103 | if (i | t) buf[i++] = NIBBLE_TO_CHR;
104 | }
105 | t = x & 0xf;
106 | buf[i++] = NIBBLE_TO_CHR;
107 |
108 | *s += (size_t)(i + 2);
109 | }
110 |
111 | #endif /* SUPPORT_64BIT_OFFSET */
112 |
113 | #endif /* DISTORM_LIGHT */
114 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/textdefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | textdefs.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef TEXTDEFS_H
12 | #define TEXTDEFS_H
13 |
14 | #include "config.h"
15 | #include "wstring.h"
16 |
17 | #ifndef DISTORM_LIGHT
18 |
19 | #define PLUS_DISP_CHR '+'
20 | #define MINUS_DISP_CHR '-'
21 | #define OPEN_CHR '['
22 | #define CLOSE_CHR ']'
23 | #define SP_CHR ' '
24 | #define SEG_OFF_CHR ':'
25 |
26 | /*
27 | Naming Convention:
28 |
29 | * get - returns a pointer to a string.
30 | * str - concatenates to string.
31 |
32 | * hex - means the function is used for hex dump (number is padded to required
33 | size) - Little Endian output.
34 | * code - means the function is used for disassembled instruction - Big Endian
35 | output.
36 | * off - means the function is used for 64bit offset - Big Endian output.
37 |
38 | * h - '0x' in front of the string.
39 |
40 | * b - byte
41 | * dw - double word (can be used for word also)
42 | * qw - quad word
43 |
44 | * all numbers are in HEX.
45 | */
46 |
47 | void str_hex(_WString* s, const uint8_t* buf, unsigned int len);
48 |
49 | #ifdef SUPPORT_64BIT_OFFSET
50 | #define str_int(s, x) str_int_impl((s), (x))
51 | void str_int_impl(unsigned char** s, uint64_t x);
52 | #else
53 | #define str_int(s, x) str_int_impl((s), (uint8_t*)&(x))
54 | void str_int_impl(unsigned char** s, uint8_t src[8]);
55 | #endif
56 |
57 | #endif /* DISTORM_LIGHT */
58 |
59 | #endif /* TEXTDEFS_H */
60 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/wstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | wstring.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef WSTRING_H
12 | #define WSTRING_H
13 |
14 | #include "../include/mnemonics.h"
15 | #include "config.h"
16 |
17 | #ifndef DISTORM_LIGHT
18 |
19 | _INLINE_ void strcat_WSR(unsigned char** str, const _WRegister* reg) {
20 | /*
21 | * Longest register name is YMM15 - 5 characters,
22 | * Copy 8 so compiler can do a QWORD move.
23 | * We copy nul termination and fix the length, so it's okay to copy more to
24 | * the output buffer. There's a sentinel register to make sure we don't read
25 | * past the end of the registers table.
26 | */
27 | memcpy((int8_t*)*str, (const int8_t*)reg->p, 8);
28 | *str += reg->length;
29 | }
30 |
31 | #define strfinalize_WS(s, end) \
32 | do { \
33 | *end = 0; \
34 | s.length = (unsigned int)((size_t)end - (size_t)s.p); \
35 | } while (0)
36 | #define chrcat_WS(s, ch) \
37 | do { \
38 | *s = ch; \
39 | s += 1; \
40 | } while (0)
41 | #define strcat_WS(s, buf, copylen, advancelen) \
42 | do { \
43 | memcpy((int8_t*)s, buf, copylen); \
44 | s += advancelen; \
45 | } while (0)
46 |
47 | #endif /* DISTORM_LIGHT */
48 |
49 | #endif /* WSTRING_H */
50 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/dependencies/funchook/src/x86defs.h:
--------------------------------------------------------------------------------
1 | /*
2 | x86defs.h
3 |
4 | diStorm3 - Powerful disassembler for X86/AMD64
5 | http://ragestorm.net/distorm/
6 | distorm at gmail dot com
7 | Copyright (C) 2003-2021 Gil Dabah
8 | This library is licensed under the BSD license. See the file COPYING.
9 | */
10 |
11 | #ifndef X86DEFS_H
12 | #define X86DEFS_H
13 |
14 | #define SEG_REGS_MAX (6)
15 | #define CREGS_MAX (9)
16 | #define DREGS_MAX (8)
17 |
18 | /* Maximum instruction size, including prefixes */
19 | #define INST_MAXIMUM_SIZE (15)
20 |
21 | /* Maximum range of imm8 (comparison type) of special SSE CMP instructions. */
22 | #define INST_CMP_MAX_RANGE (8)
23 |
24 | /* Maximum range of imm8 (comparison type) of special AVX VCMP instructions. */
25 | #define INST_VCMP_MAX_RANGE (32)
26 |
27 | /* Wait instruction byte code. */
28 | #define INST_WAIT_INDEX (0x9b)
29 |
30 | /* Lea instruction byte code. */
31 | #define INST_LEA_INDEX (0x8d)
32 |
33 | /* NOP/XCHG instruction byte code. */
34 | #define INST_NOP_INDEX (0x90)
35 |
36 | /* ARPL/MOVSXD instruction byte code. */
37 | #define INST_ARPL_INDEX (0x63)
38 |
39 | /*
40 | * Minimal MODR/M value of divided instructions.
41 | * It's 0xc0, two MSBs set, which indicates a general purpose register is used
42 | * too.
43 | */
44 | #define INST_DIVIDED_MODRM (0xc0)
45 |
46 | /* This is the escape byte value used for 3DNow! instructions. */
47 | #define _3DNOW_ESCAPE_BYTE (0x0f)
48 |
49 | #define PREFIX_LOCK (0xf0)
50 | #define PREFIX_REPNZ (0xf2)
51 | #define PREFIX_REP (0xf3)
52 | #define PREFIX_CS (0x2e)
53 | #define PREFIX_SS (0x36)
54 | #define PREFIX_DS (0x3e)
55 | #define PREFIX_ES (0x26)
56 | #define PREFIX_FS (0x64)
57 | #define PREFIX_GS (0x65)
58 | #define PREFIX_OP_SIZE (0x66)
59 | #define PREFIX_ADDR_SIZE (0x67)
60 | #define PREFIX_VEX2b (0xc5)
61 | #define PREFIX_VEX3b (0xc4)
62 |
63 | /* REX prefix value range, 64 bits mode decoding only. */
64 | #define PREFIX_REX_LOW (0x40)
65 | #define PREFIX_REX_HI (0x4f)
66 | /* In order to use the extended GPR's we have to add 8 to the Modr/M info
67 | * values. */
68 | #define EX_GPR_BASE (8)
69 |
70 | /* Mask for REX and VEX features: */
71 | /* Base */
72 | #define PREFIX_EX_B (1)
73 | /* Index */
74 | #define PREFIX_EX_X (2)
75 | /* Register */
76 | #define PREFIX_EX_R (4)
77 | /* Operand Width */
78 | #define PREFIX_EX_W (8)
79 | /* Vector Lengh */
80 | #define PREFIX_EX_L (0x10)
81 |
82 | #endif /* X86DEFS_H */
83 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/src/entrypoint/OpenSource2SDK.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "OpenSource2SDK.hpp"
6 |
7 | EXTERN_C IMAGE_DOS_HEADER __ImageBase;
8 | #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
9 |
10 | std::chrono::duration time_since(std::chrono::system_clock::time_point time) {
11 | return std::chrono::system_clock::now().time_since_epoch() -
12 | time.time_since_epoch();
13 | }
14 |
15 | WaitUntilModulesLoaded_t os2::entrypoint::WaitUntilModulesLoaded(
16 | std::chrono::duration timeout,
17 | std::chrono::duration pool_rate) {
18 | const auto start_timestamp = std::chrono::system_clock::now();
19 |
20 | HANDLE hProcess = GetCurrentProcess();
21 |
22 | if (hProcess == NULL) {
23 | std::this_thread::sleep_for(timeout);
24 | return std::make_pair(std::string(), timeout);
25 | }
26 |
27 | HMODULE hModules[1024];
28 | DWORD cbNeeded;
29 |
30 | std::set modulesSet = {};
31 |
32 | auto load_timestamp = std::chrono::system_clock::now();
33 |
34 | std::string last_module_name = "";
35 |
36 | while (true) {
37 | const auto time_since_last_module = time_since(load_timestamp);
38 |
39 | if (time_since_last_module >= timeout) {
40 | return std::make_pair(last_module_name, time_since(start_timestamp));
41 | }
42 |
43 | if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded)) {
44 | unsigned int i;
45 | for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
46 | char szModName[MAX_PATH];
47 |
48 | if (GetModuleFileNameExA(hProcess, hModules[i], szModName,
49 | sizeof(szModName) / sizeof(TCHAR))) {
50 | std::string moduleName = std::string(szModName);
51 |
52 | if (moduleName.find(os2::entrypoint::game_path_part) != std::string::npos) {
53 | auto insertStatus = modulesSet.insert(moduleName);
54 |
55 | const bool didInsert = insertStatus.second;
56 |
57 | // Actually inserted value into the set (it is a new value)
58 | if (didInsert) {
59 | load_timestamp = std::chrono::system_clock::now();
60 | last_module_name = moduleName.substr(moduleName.rfind('\\') + 1);
61 | }
62 | }
63 | }
64 | }
65 | }
66 |
67 | std::this_thread::sleep_for(pool_rate);
68 | }
69 | }
70 |
71 | void os2::entrypoint::BeginUnloadProcedure() noexcept {
72 | HANDLE hThread = CreateThread(
73 | nullptr, NULL,
74 | [](LPVOID pData) -> DWORD {
75 | FreeLibraryAndExitThread((HMODULE)(pData), EXIT_SUCCESS);
76 | },
77 | HINST_THISCOMPONENT, NULL, nullptr);
78 |
79 | if (hThread != NULL) {
80 | CloseHandle(hThread);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/src/entrypoint/OpenSource2SDK.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../sdk/utilities/static_string.hpp"
9 |
10 | typedef std::pair>
11 | WaitUntilModulesLoaded_t;
12 |
13 | #define DEBUG_PREFIX os2::entrypoint::debug_console_prefix
14 |
15 | namespace os2::entrypoint {
16 | const std::string game_path_part = os2_string(
17 | "Steam\\steamapps\\common\\Counter-Strike Global "
18 | "Offensive\\game");
19 |
20 | const std::string debug_console_title = os2_string("OpenSource2 SDK");
21 |
22 | const std::string debug_console_prefix = os2_string("[OpenSource2 SDK] ");
23 |
24 | namespace debug {
25 | /**
26 | * @brief "Loaded all modules, last: %s. Took %.2f s\n"
27 | */
28 | const std::string modules_loaded =
29 | os2_string("Loaded all modules, last: %s. Took %.2f s\n");
30 | } // namespace debug
31 |
32 | /**
33 | * @brief Waits till the game loads all modules. Does not hardcode module names.
34 | * @param timeout Time after function considers the module loading ends
35 | * @param pool_rate Thread sleep time duration between enumerating modules
36 | * @return
37 | */
38 | WaitUntilModulesLoaded_t WaitUntilModulesLoaded(
39 | std::chrono::duration timeout = std::chrono::milliseconds(1500),
40 | std::chrono::duration pool_rate = std::chrono::milliseconds(15));
41 |
42 | void BeginUnloadProcedure() noexcept;
43 | }; // namespace os2::entrypoint
44 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/src/entrypoint/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #define LOAD_SDK_FILES
3 | #include "OpenSource2SDK.hpp"
4 | #include "../sdk/framework.hpp"
5 | #include "../features/features.hpp"
6 |
7 | #include
8 | #include
9 |
10 | // static Config* g_Config = Config::GetInstance("CONFIG");
11 |
12 | EXTERN_C IMAGE_DOS_HEADER __ImageBase;
13 | #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
14 |
15 | #if OPENSOURCE2_ENABLE_LOGGING
16 | void InitialiseConsole() {
17 | AllocConsole();
18 |
19 | SetConsoleTitleA(os2::entrypoint::debug_console_title.c_str());
20 |
21 | // Enable I/O
22 | freopen_s(reinterpret_cast stdin, "CONIN$", "r", stdin);
23 | freopen_s(reinterpret_cast stdout, "CONOUT$", "w", stdout);
24 | }
25 | #endif
26 |
27 | void InitialiseSDK() {
28 | std::setlocale(LC_ALL, ".utf8");
29 |
30 | #if OPENSOURCE2_ENABLE_LOGGING
31 | InitialiseConsole();
32 | #endif
33 |
34 | [[maybe_unused]] const auto moduleInfo = os2::entrypoint::WaitUntilModulesLoaded();
35 |
36 | LOG(os2::entrypoint::debug::modules_loaded.c_str(), moduleInfo.first.c_str(),
37 | moduleInfo.second.count());
38 |
39 | gameFeatures.emplace();
40 |
41 | os2::iface::initialise();
42 | os2::memory::initialise();
43 | os2::hooks::initialise();
44 | }
45 |
46 | void UnloadSDK() {
47 | os2::hooks::shutdown();
48 | os2::memory::shutdown();
49 | os2::iface::shutdown();
50 |
51 | if (gameFeatures.has_value()) gameFeatures.reset();
52 |
53 | #if OPENSOURCE2_ENABLE_LOGGING
54 | fclose(stdin);
55 | fclose(stdout);
56 | FreeConsole();
57 | #endif
58 | }
59 |
60 | BOOL WINAPI DllMain( HMODULE hModule, DWORD fdwReason, LPVOID lpvReserved)
61 | {
62 | if (fdwReason == DLL_PROCESS_ATTACH) {
63 | DisableThreadLibraryCalls(hModule);
64 |
65 | HANDLE hThread = CreateThread(
66 | nullptr, NULL, reinterpret_cast(InitialiseSDK),
67 | NULL, NULL, nullptr);
68 |
69 | if (hThread != NULL) {
70 | CloseHandle(hThread);
71 | }
72 | } else if (fdwReason == DLL_PROCESS_DETACH && !lpvReserved) {
73 | UnloadSDK();
74 | }
75 |
76 | return TRUE;
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/OpenSource2-SDK/src/features/aim_enhancement/aimbot.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include