├── .gitattributes
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── nSkinz.sln
├── nSkinz.vcxproj
├── nSkinz.vcxproj.filters
└── src
├── Hooks
├── FireGameEvent.cpp
├── Hooks.hpp
├── PostDataUpdate.cpp
└── Sequence.cpp
├── Imgui_impl_dx9
└── imgui_impl_dx9.cpp
├── SDK.hpp
├── SDK
├── CBaseClientState.hpp
├── CBaseEntity.hpp
├── ClientClass.hpp
├── DataTable.hpp
├── IAppSystem.hpp
├── IBaseClientDLL.hpp
├── IClientEntity.hpp
├── IClientEntityList.hpp
├── IGameEvent.hpp
├── IGameEventManager2.hpp
├── IInputSystem.hpp
├── ILocalize.hpp
├── IVEngineClient.hpp
├── IVModelInfoClient.hpp
├── declarations.hpp
└── interfaces.hpp
├── Utilities
├── Platform.cpp
├── Platform.hpp
├── fnv_hash.hpp
├── netvar_manager.cpp
├── netvar_manager.hpp
└── vmt_smart_hook.hpp
├── config.cpp
├── config.hpp
├── dllmain.cpp
├── gui.cpp
├── item_definitions.cpp
├── item_definitions.hpp
├── kit_parser.cpp
├── kit_parser.hpp
├── nSkinz.cpp
├── nSkinz.hpp
├── recv_proxy_hook.hpp
├── render.cpp
├── render.hpp
├── sticker_changer.cpp
├── sticker_changer.hpp
├── update_check.cpp
└── update_check.hpp
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "deps/imgui"]
2 | path = deps/imgui
3 | url = https://github.com/ocornut/imgui.git
4 | [submodule "deps/json"]
5 | path = deps/json
6 | url = https://github.com/nlohmann/json.git
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) namazso 2018
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # This project is **discontinued**. Please visit [advancedfx's fork](https://github.com/advancedfx/nSkinz) for a more up-to-date version
2 |
--------------------------------------------------------------------------------
/nSkinz.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.16
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nSkinz", "nSkinz.vcxproj", "{D93A638A-0449-48D2-90EB-77571D2C8304}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D93A638A-0449-48D2-90EB-77571D2C8304}.Debug|x86.ActiveCfg = Debug|Win32
15 | {D93A638A-0449-48D2-90EB-77571D2C8304}.Debug|x86.Build.0 = Debug|Win32
16 | {D93A638A-0449-48D2-90EB-77571D2C8304}.Release|x86.ActiveCfg = Release|Win32
17 | {D93A638A-0449-48D2-90EB-77571D2C8304}.Release|x86.Build.0 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {20E550A6-6362-47AB-94C3-670B977ACD50}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/nSkinz.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | {D93A638A-0449-48D2-90EB-77571D2C8304}
66 | Win32Proj
67 | nSkinz
68 | 10.0
69 |
70 |
71 |
72 | DynamicLibrary
73 | true
74 | v142
75 | Unicode
76 |
77 |
78 | DynamicLibrary
79 | false
80 | v142
81 | true
82 | Unicode
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | true
98 | $(ProjectDir)deps\json\include;$(ProjectDir)deps\imgui;$(ProjectDir)deps\imgui\examples\directx9_example;$(IncludePath)
99 |
100 |
101 | false
102 | $(ProjectDir)deps\json\include;$(ProjectDir)deps\imgui;$(ProjectDir)deps\imgui\examples\directx9_example;$(IncludePath)
103 |
104 |
105 |
106 |
107 |
108 | Level4
109 | Disabled
110 | WIN32;_DEBUG;_WINDOWS;_USRDLL;NSKINZ_EXPORTS;%(PreprocessorDefinitions)
111 | true
112 | true
113 | true
114 | stdcpp17
115 | /Zc:threadSafeInit- %(AdditionalOptions)
116 |
117 |
118 | Windows
119 | true
120 |
121 |
122 |
123 |
124 | Level3
125 |
126 |
127 | Full
128 | true
129 | true
130 | WIN32;NDEBUG;_WINDOWS;_USRDLL;NSKINZ_EXPORTS;%(PreprocessorDefinitions)
131 | true
132 | true
133 | Speed
134 | false
135 | Default
136 | stdcpp17
137 | true
138 | ProgramDatabase
139 | false
140 | false
141 | true
142 | Fast
143 | /Zc:threadSafeInit- %(AdditionalOptions)
144 |
145 |
146 | Windows
147 | true
148 | true
149 | true
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/nSkinz.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hooks
6 |
7 |
8 |
9 | Dependency
10 |
11 |
12 | Dependency
13 |
14 |
15 | Utilities
16 |
17 |
18 | Utilities
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Hooks
30 |
31 |
32 | Hooks
33 |
34 |
35 | Dependency
36 |
37 |
38 |
39 |
40 | SDK\Class
41 |
42 |
43 | SDK\Class
44 |
45 |
46 | SDK\Class
47 |
48 |
49 | SDK\Class
50 |
51 |
52 | SDK\Class
53 |
54 |
55 | SDK\Class
56 |
57 |
58 | SDK\Interface
59 |
60 |
61 | SDK\Interface
62 |
63 |
64 | SDK\Interface
65 |
66 |
67 | SDK\Interface
68 |
69 |
70 | SDK\Interface
71 |
72 |
73 | SDK\Interface
74 |
75 |
76 | SDK\Interface
77 |
78 |
79 | SDK
80 |
81 |
82 |
83 | Utilities
84 |
85 |
86 | Utilities
87 |
88 |
89 | SDK
90 |
91 |
92 | Utilities
93 |
94 |
95 | SDK
96 |
97 |
98 | Utilities
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | Hooks
109 |
110 |
111 |
112 |
113 |
114 | {65eccfc5-d06e-4ad9-9c4d-d85d8442d680}
115 |
116 |
117 | {51010c84-be5b-452b-a3a4-2e1d7be8f8b3}
118 |
119 |
120 | {ea773f6e-6f49-4132-8b2f-e1cd313697d0}
121 |
122 |
123 | {4edde6e6-abf1-4097-8ca9-8ac78f0312a6}
124 |
125 |
126 | {dcbb33bc-5f9f-45d0-9c1c-4cca665c10d4}
127 |
128 |
129 | {220d34fa-499b-4bce-9e4f-493421f1b61d}
130 |
131 |
132 |
--------------------------------------------------------------------------------
/src/Hooks/FireGameEvent.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #include "hooks.hpp"
26 | #include "../config.hpp"
27 | #include "../nSkinz.hpp"
28 |
29 | auto __fastcall hooks::SFHudDeathNoticeAndBotStatus_FireGameEvent::hooked(void* thisptr, void*, sdk::IGameEvent* event) -> void
30 | {
31 | // Filter to only the events we're interested in.
32 | if(fnv::hash_runtime(event->GetName()) == FNV("player_death")
33 | && g_engine->GetPlayerForUserID(event->GetInt("attacker")) == g_engine->GetLocalPlayer())
34 | if(const auto icon_override = g_config.get_icon_override(event->GetString("weapon")))
35 | event->SetString("weapon", icon_override);
36 |
37 | m_original(thisptr, nullptr, event);
38 | }
39 |
40 | hooks::SFHudDeathNoticeAndBotStatus_FireGameEvent::Fn* hooks::SFHudDeathNoticeAndBotStatus_FireGameEvent::m_original;
--------------------------------------------------------------------------------
/src/Hooks/Hooks.hpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #pragma once
26 | #include "../SDK.hpp"
27 |
28 | namespace hooks
29 | {
30 | struct CCSPlayer_PostDataUpdate
31 | {
32 | using Fn = void __fastcall(sdk::IClientNetworkable* thisptr, void*, int update_type);
33 | static Fn hooked;
34 | static Fn* m_original;
35 | };
36 |
37 | struct SFHudDeathNoticeAndBotStatus_FireGameEvent
38 | {
39 | using Fn = void __fastcall(void* thisptr, void*, sdk::IGameEvent* event);
40 | static Fn hooked;
41 | static Fn* m_original;
42 | };
43 |
44 | // NetVar Proxies
45 |
46 | extern auto __cdecl sequence_proxy_fn(const sdk::CRecvProxyData* proxy_data_const, void* entity, void* output) -> void;
47 | }
48 |
--------------------------------------------------------------------------------
/src/Hooks/PostDataUpdate.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #include "hooks.hpp"
26 | #include "../item_definitions.hpp"
27 | #include "../nSkinz.hpp"
28 | #include "../config.hpp"
29 | #include "../sticker_changer.hpp"
30 |
31 | static auto erase_override_if_exists_by_index(const int definition_index) -> void
32 | {
33 | // We have info about the item not needed to be overridden
34 | if(const auto original_item = game_data::get_weapon_info(definition_index))
35 | {
36 | auto& icon_override_map = g_config.get_icon_override_map();
37 |
38 | if (!original_item->icon)
39 | return;
40 |
41 | const auto override_entry = icon_override_map.find(original_item->icon);
42 |
43 | // We are overriding its icon when not needed
44 | if(override_entry != end(icon_override_map))
45 | icon_override_map.erase(override_entry); // Remove the leftover override
46 | }
47 | }
48 |
49 | static auto apply_config_on_attributable_item(sdk::C_BaseAttributableItem* item, const item_setting* config,
50 | const unsigned xuid_low) -> void
51 | {
52 | // Force fallback values to be used.
53 | item->GetItemIDHigh() = -1;
54 |
55 | // Set the owner of the weapon to our lower XUID. (fixes StatTrak)
56 | item->GetAccountID() = xuid_low;
57 |
58 | if(config->entity_quality_index)
59 | item->GetEntityQuality() = config->entity_quality_index;
60 |
61 | if(config->custom_name[0])
62 | strcpy_s(item->GetCustomName(), config->custom_name);
63 |
64 | if(config->paint_kit_index)
65 | item->GetFallbackPaintKit() = config->paint_kit_index;
66 |
67 | if(config->seed)
68 | item->GetFallbackSeed() = config->seed;
69 |
70 | if(config->stat_trak)
71 | item->GetFallbackStatTrak() = config->stat_trak;
72 |
73 | item->GetFallbackWear() = config->wear;
74 |
75 | auto& definition_index = item->GetItemDefinitionIndex();
76 |
77 | auto& icon_override_map = g_config.get_icon_override_map();
78 |
79 | if(config->definition_override_index // We need to override defindex
80 | && config->definition_override_index != definition_index) // It is not yet overridden
81 | {
82 | // We have info about what we gonna override it to
83 | if(const auto replacement_item = game_data::get_weapon_info(config->definition_override_index))
84 | {
85 | const auto old_definition_index = definition_index;
86 |
87 | definition_index = short(config->definition_override_index);
88 |
89 | // Set the weapon model index -- required for paint kits to work on replacement items after the 29/11/2016 update.
90 | //item->GetModelIndex() = g_model_info->GetModelIndex(k_weapon_info.at(config->definition_override_index).model);
91 | item->SetModelIndex(g_model_info->GetModelIndex(replacement_item->model));
92 | item->GetClientNetworkable()->PreDataUpdate(0);
93 |
94 | // We didn't override 0, but some actual weapon, that we have data for
95 | if(old_definition_index)
96 | {
97 | if(const auto original_item = game_data::get_weapon_info(old_definition_index))
98 | {
99 | if(original_item->icon && replacement_item->icon)
100 | icon_override_map[original_item->icon] = replacement_item->icon;
101 | }
102 | }
103 | }
104 | }
105 | else
106 | {
107 | erase_override_if_exists_by_index(definition_index);
108 | }
109 |
110 | apply_sticker_changer(item);
111 | }
112 |
113 | static auto get_wearable_create_fn() -> sdk::CreateClientClassFn
114 | {
115 | auto clazz = g_client->GetAllClasses();
116 |
117 | // Please, if you gonna paste it into a cheat use classids here. I use names because they
118 | // won't change in the foreseeable future and i dont need high speed, but chances are
119 | // you already have classids, so use them instead, they are faster.
120 | while(fnv::hash_runtime(clazz->m_pNetworkName) != FNV("CEconWearable"))
121 | clazz = clazz->m_pNext;
122 |
123 | return clazz->m_pCreateFn;
124 | }
125 |
126 | static auto make_glove(int entry, int serial) -> sdk::C_BaseAttributableItem*
127 | {
128 | static auto create_wearable_fn = get_wearable_create_fn();
129 |
130 | create_wearable_fn(entry, serial);
131 |
132 | const auto glove = static_cast(g_entity_list->GetClientEntity(entry));
133 | assert(glove);
134 |
135 | // He he
136 | {
137 | static auto set_abs_origin_addr = platform::find_pattern(get_client_name(), "\x55\x8B\xEC\x83\xE4\xF8\x51\x53\x56\x57\x8B\xF1", "xxxxxxxxxxxx");
138 |
139 | const auto set_abs_origin_fn = reinterpret_cast(set_abs_origin_addr);
140 |
141 | static constexpr sdk::Vector new_pos = { 10000.f, 10000.f, 10000.f };
142 |
143 | set_abs_origin_fn(glove, new_pos);
144 | }
145 |
146 | return glove;
147 | }
148 |
149 | static auto post_data_update_start(sdk::C_BasePlayer* local) -> void
150 | {
151 | const auto local_index = local->GetIndex();
152 |
153 | /*if(auto player_resource = *g_player_resource)
154 | {
155 | player_resource->GetCoins()[local_index] = 890;
156 | player_resource->GetMusicKits()[local_index] = 3;
157 | player_resource->GetRanks()[local_index] = 1;
158 | player_resource->GetWins()[local_index] = 1337;
159 | }*/
160 |
161 | sdk::player_info_t player_info;
162 | if(!g_engine->GetPlayerInfo(local_index, &player_info))
163 | return;
164 |
165 | // Handle glove config
166 | {
167 | const auto wearables = local->GetWearables();
168 |
169 | const auto glove_config = g_config.get_by_definition_index(GLOVE_T_SIDE);
170 |
171 | static auto glove_handle = sdk::CBaseHandle(0);
172 |
173 | auto glove = get_entity_from_handle(wearables[0]);
174 |
175 | if(!glove) // There is no glove
176 | {
177 | // Try to get our last created glove
178 | const auto our_glove = get_entity_from_handle(glove_handle);
179 |
180 | if(our_glove) // Our glove still exists
181 | {
182 | wearables[0] = glove_handle;
183 | glove = our_glove;
184 | }
185 | }
186 |
187 | if(local->GetLifeState() != sdk::LifeState::ALIVE)
188 | {
189 | // We are dead but we have a glove, destroy it
190 | if(glove)
191 | {
192 | glove->GetClientNetworkable()->SetDestroyedOnRecreateEntities();
193 | glove->GetClientNetworkable()->Release();
194 | }
195 |
196 | return;
197 | }
198 |
199 | if(glove_config && glove_config->definition_override_index)
200 | {
201 | // We don't have a glove, but we should
202 | if(!glove)
203 | {
204 | const auto entry = g_entity_list->GetHighestEntityIndex() + 1;
205 | const auto serial = rand() % 0x1000;
206 |
207 | glove = make_glove(entry, serial);
208 |
209 | wearables[0] = entry | serial << 16;
210 |
211 | // Let's store it in case we somehow lose it.
212 | glove_handle = wearables[0];
213 | }
214 |
215 | // Thanks, Beakers
216 | glove->GetIndex() = -1;
217 |
218 | apply_config_on_attributable_item(glove, glove_config, player_info.xuid_low);
219 | }
220 | }
221 |
222 | // Handle weapon configs
223 | {
224 | auto& weapons = local->GetWeapons();
225 |
226 | for(auto weapon_handle : weapons)
227 | {
228 | if(weapon_handle == sdk::INVALID_EHANDLE_INDEX)
229 | break;
230 |
231 | auto weapon = get_entity_from_handle(weapon_handle);
232 |
233 | if(!weapon)
234 | continue;
235 |
236 | auto& definition_index = weapon->GetItemDefinitionIndex();
237 |
238 | // All knives are terrorist knives.
239 | if(const auto active_conf = g_config.get_by_definition_index(is_knife(definition_index) ? WEAPON_KNIFE : definition_index))
240 | apply_config_on_attributable_item(weapon, active_conf, player_info.xuid_low);
241 | else
242 | erase_override_if_exists_by_index(definition_index);
243 | }
244 | }
245 |
246 | const auto view_model = get_entity_from_handle(local->GetViewModel());
247 |
248 | if(!view_model)
249 | return;
250 |
251 | const auto view_model_weapon = get_entity_from_handle(view_model->GetWeapon());
252 |
253 | if(!view_model_weapon)
254 | return;
255 |
256 | const auto override_info = game_data::get_weapon_info(view_model_weapon->GetItemDefinitionIndex());
257 |
258 | if(!override_info)
259 | return;
260 |
261 | const auto override_model_index = g_model_info->GetModelIndex(override_info->model);
262 | view_model->GetModelIndex() = override_model_index;
263 |
264 | const auto world_model = get_entity_from_handle(view_model_weapon->GetWeaponWorldModel());
265 |
266 | if(!world_model)
267 | return;
268 |
269 | world_model->GetModelIndex() = override_model_index + 1;
270 | }
271 |
272 | auto __fastcall hooks::CCSPlayer_PostDataUpdate::hooked(sdk::IClientNetworkable* thisptr, void*, int update_type) -> void
273 | {
274 | post_data_update_start(static_cast(thisptr));
275 |
276 | return m_original(thisptr, nullptr, update_type);
277 | }
278 |
279 | hooks::CCSPlayer_PostDataUpdate::Fn* hooks::CCSPlayer_PostDataUpdate::m_original;
--------------------------------------------------------------------------------
/src/Hooks/Sequence.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #include "hooks.hpp"
26 | #include "../nSkinz.hpp"
27 | #include "../config.hpp"
28 |
29 | static auto random_sequence(const int low, const int high) -> int
30 | {
31 | return rand() % (high - low + 1) + low;
32 | }
33 |
34 | // This only fixes if the original knife was a default knife.
35 | // The best would be having a function that converts original knife's sequence
36 | // into some generic enum, then another function that generates a sequence
37 | // from the sequences of the new knife. I won't write that.
38 | static auto get_new_animation(const fnv::hash model, const int sequence) -> int
39 | {
40 | enum ESequence
41 | {
42 | SEQUENCE_DEFAULT_DRAW = 0,
43 | SEQUENCE_DEFAULT_IDLE1 = 1,
44 | SEQUENCE_DEFAULT_IDLE2 = 2,
45 | SEQUENCE_DEFAULT_LIGHT_MISS1 = 3,
46 | SEQUENCE_DEFAULT_LIGHT_MISS2 = 4,
47 | SEQUENCE_DEFAULT_HEAVY_MISS1 = 9,
48 | SEQUENCE_DEFAULT_HEAVY_HIT1 = 10,
49 | SEQUENCE_DEFAULT_HEAVY_BACKSTAB = 11,
50 | SEQUENCE_DEFAULT_LOOKAT01 = 12,
51 |
52 | SEQUENCE_BUTTERFLY_DRAW = 0,
53 | SEQUENCE_BUTTERFLY_DRAW2 = 1,
54 | SEQUENCE_BUTTERFLY_LOOKAT01 = 13,
55 | SEQUENCE_BUTTERFLY_LOOKAT03 = 15,
56 |
57 | SEQUENCE_FALCHION_IDLE1 = 1,
58 | SEQUENCE_FALCHION_HEAVY_MISS1 = 8,
59 | SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP = 9,
60 | SEQUENCE_FALCHION_LOOKAT01 = 12,
61 | SEQUENCE_FALCHION_LOOKAT02 = 13,
62 |
63 | SEQUENCE_CSS_LOOKAT01 = 14,
64 | SEQUENCE_CSS_LOOKAT02 = 15,
65 |
66 | SEQUENCE_DAGGERS_IDLE1 = 1,
67 | SEQUENCE_DAGGERS_LIGHT_MISS1 = 2,
68 | SEQUENCE_DAGGERS_LIGHT_MISS5 = 6,
69 | SEQUENCE_DAGGERS_HEAVY_MISS2 = 11,
70 | SEQUENCE_DAGGERS_HEAVY_MISS1 = 12,
71 |
72 | SEQUENCE_BOWIE_IDLE1 = 1,
73 | };
74 |
75 | // Hashes for best performance.
76 | switch(model)
77 | {
78 | case FNV("models/weapons/v_knife_butterfly.mdl"):
79 | {
80 | switch(sequence)
81 | {
82 | case SEQUENCE_DEFAULT_DRAW:
83 | return random_sequence(SEQUENCE_BUTTERFLY_DRAW, SEQUENCE_BUTTERFLY_DRAW2);
84 | case SEQUENCE_DEFAULT_LOOKAT01:
85 | return random_sequence(SEQUENCE_BUTTERFLY_LOOKAT01, SEQUENCE_BUTTERFLY_LOOKAT03);
86 | default:
87 | return sequence + 1;
88 | }
89 | }
90 | case FNV("models/weapons/v_knife_falchion_advanced.mdl"):
91 | {
92 | switch(sequence)
93 | {
94 | case SEQUENCE_DEFAULT_IDLE2:
95 | return SEQUENCE_FALCHION_IDLE1;
96 | case SEQUENCE_DEFAULT_HEAVY_MISS1:
97 | return random_sequence(SEQUENCE_FALCHION_HEAVY_MISS1, SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP);
98 | case SEQUENCE_DEFAULT_LOOKAT01:
99 | return random_sequence(SEQUENCE_FALCHION_LOOKAT01, SEQUENCE_FALCHION_LOOKAT02);
100 | case SEQUENCE_DEFAULT_DRAW:
101 | case SEQUENCE_DEFAULT_IDLE1:
102 | return sequence;
103 | default:
104 | return sequence - 1;
105 | }
106 | }
107 | case FNV("models/weapons/v_knife_css.mdl"):
108 | {
109 | switch (sequence)
110 | {
111 | case SEQUENCE_DEFAULT_LOOKAT01:
112 | return random_sequence(SEQUENCE_CSS_LOOKAT01, SEQUENCE_CSS_LOOKAT02);
113 | default:
114 | return sequence;
115 | }
116 | }
117 | case FNV("models/weapons/v_knife_push.mdl"):
118 | {
119 | switch(sequence)
120 | {
121 | case SEQUENCE_DEFAULT_IDLE2:
122 | return SEQUENCE_DAGGERS_IDLE1;
123 | case SEQUENCE_DEFAULT_LIGHT_MISS1:
124 | case SEQUENCE_DEFAULT_LIGHT_MISS2:
125 | return random_sequence(SEQUENCE_DAGGERS_LIGHT_MISS1, SEQUENCE_DAGGERS_LIGHT_MISS5);
126 | case SEQUENCE_DEFAULT_HEAVY_MISS1:
127 | return random_sequence(SEQUENCE_DAGGERS_HEAVY_MISS2, SEQUENCE_DAGGERS_HEAVY_MISS1);
128 | case SEQUENCE_DEFAULT_HEAVY_HIT1:
129 | case SEQUENCE_DEFAULT_HEAVY_BACKSTAB:
130 | case SEQUENCE_DEFAULT_LOOKAT01:
131 | return sequence + 3;
132 | case SEQUENCE_DEFAULT_DRAW:
133 | case SEQUENCE_DEFAULT_IDLE1:
134 | return sequence;
135 | default:
136 | return sequence + 2;
137 | }
138 | }
139 | case FNV("models/weapons/v_knife_survival_bowie.mdl"):
140 | {
141 | switch(sequence)
142 | {
143 | case SEQUENCE_DEFAULT_DRAW:
144 | case SEQUENCE_DEFAULT_IDLE1:
145 | return sequence;
146 | case SEQUENCE_DEFAULT_IDLE2:
147 | return SEQUENCE_BOWIE_IDLE1;
148 | default:
149 | return sequence - 1;
150 | }
151 | }
152 | case FNV("models/weapons/v_knife_ursus.mdl"):
153 | case FNV("models/weapons/v_knife_cord.mdl"):
154 | case FNV("models/weapons/v_knife_canis.mdl"):
155 | case FNV("models/weapons/v_knife_outdoor.mdl"):
156 | case FNV("models/weapons/v_knife_skeleton.mdl"):
157 | {
158 | switch (sequence)
159 | {
160 | case SEQUENCE_DEFAULT_DRAW:
161 | return random_sequence(SEQUENCE_BUTTERFLY_DRAW, SEQUENCE_BUTTERFLY_DRAW2);
162 | case SEQUENCE_DEFAULT_LOOKAT01:
163 | return random_sequence(SEQUENCE_BUTTERFLY_LOOKAT01, 14);
164 | default:
165 | return sequence + 1;
166 | }
167 | }
168 | case FNV("models/weapons/v_knife_stiletto.mdl"):
169 | {
170 | switch (sequence)
171 | {
172 | case SEQUENCE_DEFAULT_LOOKAT01:
173 | return random_sequence(12, 13);
174 | default:
175 | return sequence;
176 | }
177 | }
178 | case FNV("models/weapons/v_knife_widowmaker.mdl"):
179 | {
180 | switch (sequence)
181 | {
182 | case SEQUENCE_DEFAULT_LOOKAT01:
183 | return random_sequence(14, 15);
184 | default:
185 | return sequence;
186 | }
187 | }
188 | default:
189 | return sequence;
190 | }
191 | }
192 |
193 | static auto do_sequence_remapping(sdk::CRecvProxyData* data, sdk::C_BaseViewModel* entity) -> void
194 | {
195 | const auto local = static_cast(g_entity_list->GetClientEntity(g_engine->GetLocalPlayer()));
196 |
197 | if(!local)
198 | return;
199 |
200 | if(local->GetLifeState() != sdk::LifeState::ALIVE)
201 | return;
202 |
203 | const auto owner = get_entity_from_handle(entity->GetOwner());
204 |
205 | if(owner != local)
206 | return;
207 |
208 | const auto view_model_weapon = get_entity_from_handle(entity->GetWeapon());
209 |
210 | if(!view_model_weapon)
211 | return;
212 |
213 | const auto weapon_info = game_data::get_weapon_info(view_model_weapon->GetItemDefinitionIndex());
214 |
215 | if(!weapon_info)
216 | return;
217 |
218 | const auto override_model = weapon_info->model;
219 |
220 | auto& sequence = data->m_Value.m_Int;
221 | sequence = get_new_animation(fnv::hash_runtime(override_model), sequence);
222 | }
223 |
224 | // Replacement function that will be called when the view model animation sequence changes.
225 | auto __cdecl hooks::sequence_proxy_fn(const sdk::CRecvProxyData* proxy_data_const, void* entity, void* output) -> void
226 | {
227 | // Ensure our other dynamic object hooks are in place.
228 | // Must do this from a game thread.
229 | ensure_dynamic_hooks();
230 |
231 | static auto original_fn = g_sequence_hook->get_original_function();
232 |
233 | // Remove the constness from the proxy data allowing us to make changes.
234 | const auto proxy_data = const_cast(proxy_data_const);
235 |
236 | const auto view_model = static_cast(entity);
237 |
238 | do_sequence_remapping(proxy_data, view_model);
239 |
240 | // Call the original function with our edited data.
241 | original_fn(proxy_data_const, entity, output);
242 | }
243 |
--------------------------------------------------------------------------------
/src/Imgui_impl_dx9/imgui_impl_dx9.cpp:
--------------------------------------------------------------------------------
1 | // ImGui Win32 + DirectX9 binding
2 | // In this binding, ImTextureID is used to store a 'LPDIRECT3DTEXTURE9' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
3 |
4 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
5 | // If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
6 | // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
7 | // https://github.com/ocornut/imgui
8 |
9 | #include
10 | #include "imgui_impl_dx9.h"
11 |
12 | // DirectX
13 | #include
14 | #define DIRECTINPUT_VERSION 0x0800
15 | #include
16 |
17 | // Data
18 | static HWND g_hWnd = 0;
19 | static INT64 g_Time = 0;
20 | static INT64 g_TicksPerSecond = 0;
21 | static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
22 | static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
23 | static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
24 | static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
25 | static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
26 |
27 | struct CUSTOMVERTEX
28 | {
29 | float pos[3];
30 | D3DCOLOR col;
31 | float uv[2];
32 | };
33 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
34 |
35 | // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
36 | // If text or lines are blurry when integrating ImGui in your engine:
37 | // - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
38 | void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
39 | {
40 | // Avoid rendering when minimized
41 | ImGuiIO& io = ImGui::GetIO();
42 | if (io.DisplaySize.x <= 0.0f || io.DisplaySize.y <= 0.0f)
43 | return;
44 |
45 | // Create and grow buffers if needed
46 | if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
47 | {
48 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
49 | g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
50 | if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
51 | return;
52 | }
53 | if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
54 | {
55 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
56 | g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
57 | if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
58 | return;
59 | }
60 |
61 | // Backup the DX9 state
62 | IDirect3DStateBlock9* d3d9_state_block = NULL;
63 | if (g_pd3dDevice->CreateStateBlock(D3DSBT_PIXELSTATE, &d3d9_state_block) < 0)
64 | return;
65 |
66 | // Copy and convert all vertices into a single contiguous buffer
67 | CUSTOMVERTEX* vtx_dst;
68 | ImDrawIdx* idx_dst;
69 | if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
70 | return;
71 | if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
72 | return;
73 | for (int n = 0; n < draw_data->CmdListsCount; n++)
74 | {
75 | const ImDrawList* cmd_list = draw_data->CmdLists[n];
76 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
77 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
78 | {
79 | vtx_dst->pos[0] = vtx_src->pos.x;
80 | vtx_dst->pos[1] = vtx_src->pos.y;
81 | vtx_dst->pos[2] = 0.0f;
82 | vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000)>>16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9
83 | vtx_dst->uv[0] = vtx_src->uv.x;
84 | vtx_dst->uv[1] = vtx_src->uv.y;
85 | vtx_dst++;
86 | vtx_src++;
87 | }
88 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
89 | idx_dst += cmd_list->IdxBuffer.Size;
90 | }
91 | g_pVB->Unlock();
92 | g_pIB->Unlock();
93 | g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
94 | g_pd3dDevice->SetIndices(g_pIB);
95 | g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
96 |
97 | // Setup viewport
98 | D3DVIEWPORT9 vp;
99 | vp.X = vp.Y = 0;
100 | vp.Width = (DWORD)io.DisplaySize.x;
101 | vp.Height = (DWORD)io.DisplaySize.y;
102 | vp.MinZ = 0.0f;
103 | vp.MaxZ = 1.0f;
104 | g_pd3dDevice->SetViewport(&vp);
105 |
106 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing
107 | g_pd3dDevice->SetPixelShader(NULL);
108 | g_pd3dDevice->SetVertexShader(NULL);
109 | g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
110 | g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
111 | g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
112 | g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
113 | g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
114 | g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
115 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
116 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
117 | g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true);
118 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
119 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
120 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
121 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
122 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
123 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
124 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
125 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
126 |
127 | // Setup orthographic projection matrix
128 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH()
129 | {
130 | const float L = 0.5f, R = io.DisplaySize.x+0.5f, T = 0.5f, B = io.DisplaySize.y+0.5f;
131 | D3DMATRIX mat_identity = { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } };
132 | D3DMATRIX mat_projection =
133 | {
134 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f,
135 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f,
136 | 0.0f, 0.0f, 0.5f, 0.0f,
137 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f,
138 | };
139 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
140 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
141 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
142 | }
143 |
144 | // Render command lists
145 | int vtx_offset = 0;
146 | int idx_offset = 0;
147 | for (int n = 0; n < draw_data->CmdListsCount; n++)
148 | {
149 | const ImDrawList* cmd_list = draw_data->CmdLists[n];
150 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
151 | {
152 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
153 | if (pcmd->UserCallback)
154 | {
155 | pcmd->UserCallback(cmd_list, pcmd);
156 | }
157 | else
158 | {
159 | const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
160 | g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
161 | g_pd3dDevice->SetScissorRect(&r);
162 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
163 | }
164 | idx_offset += pcmd->ElemCount;
165 | }
166 | vtx_offset += cmd_list->VtxBuffer.Size;
167 | }
168 |
169 | // Restore the DX9 state
170 | d3d9_state_block->Apply();
171 | d3d9_state_block->Release();
172 | }
173 |
174 | static bool IsAnyMouseButtonDown()
175 | {
176 | ImGuiIO& io = ImGui::GetIO();
177 | for (int n = 0; n < ARRAYSIZE(io.MouseDown); n++)
178 | if (io.MouseDown[n])
179 | return true;
180 | return false;
181 | }
182 |
183 | // We use the Win32 capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
184 | IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
185 | {
186 | ImGuiIO& io = ImGui::GetIO();
187 | switch (msg)
188 | {
189 | case WM_LBUTTONDOWN:
190 | case WM_RBUTTONDOWN:
191 | case WM_MBUTTONDOWN:
192 | {
193 | int button = 0;
194 | if (msg == WM_LBUTTONDOWN) button = 0;
195 | if (msg == WM_RBUTTONDOWN) button = 1;
196 | if (msg == WM_MBUTTONDOWN) button = 2;
197 | if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
198 | SetCapture(hwnd);
199 | io.MouseDown[button] = true;
200 | return 0;
201 | }
202 | case WM_LBUTTONUP:
203 | case WM_RBUTTONUP:
204 | case WM_MBUTTONUP:
205 | {
206 | int button = 0;
207 | if (msg == WM_LBUTTONUP) button = 0;
208 | if (msg == WM_RBUTTONUP) button = 1;
209 | if (msg == WM_MBUTTONUP) button = 2;
210 | io.MouseDown[button] = false;
211 | if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
212 | ReleaseCapture();
213 | return 0;
214 | }
215 | case WM_MOUSEWHEEL:
216 | io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
217 | return 0;
218 | case WM_MOUSEMOVE:
219 | io.MousePos.x = (signed short)(lParam);
220 | io.MousePos.y = (signed short)(lParam >> 16);
221 | return 0;
222 | case WM_KEYDOWN:
223 | case WM_SYSKEYDOWN:
224 | if (wParam < 256)
225 | io.KeysDown[wParam] = 1;
226 | return 0;
227 | case WM_KEYUP:
228 | case WM_SYSKEYUP:
229 | if (wParam < 256)
230 | io.KeysDown[wParam] = 0;
231 | return 0;
232 | case WM_CHAR:
233 | // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
234 | if (wParam > 0 && wParam < 0x10000)
235 | io.AddInputCharacter((unsigned short)wParam);
236 | return 0;
237 | }
238 | return 0;
239 | }
240 |
241 | bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device)
242 | {
243 | g_hWnd = (HWND)hwnd;
244 | g_pd3dDevice = device;
245 |
246 | if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
247 | return false;
248 | if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
249 | return false;
250 |
251 | ImGuiIO& io = ImGui::GetIO();
252 | io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
253 | io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
254 | io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
255 | io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
256 | io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
257 | io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
258 | io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
259 | io.KeyMap[ImGuiKey_Home] = VK_HOME;
260 | io.KeyMap[ImGuiKey_End] = VK_END;
261 | io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
262 | io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
263 | io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
264 | io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
265 | io.KeyMap[ImGuiKey_A] = 'A';
266 | io.KeyMap[ImGuiKey_C] = 'C';
267 | io.KeyMap[ImGuiKey_V] = 'V';
268 | io.KeyMap[ImGuiKey_X] = 'X';
269 | io.KeyMap[ImGuiKey_Y] = 'Y';
270 | io.KeyMap[ImGuiKey_Z] = 'Z';
271 |
272 | io.RenderDrawListsFn = ImGui_ImplDX9_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
273 | io.ImeWindowHandle = g_hWnd;
274 |
275 | return true;
276 | }
277 |
278 | void ImGui_ImplDX9_Shutdown()
279 | {
280 | ImGui_ImplDX9_InvalidateDeviceObjects();
281 | ImGui::Shutdown();
282 | g_pd3dDevice = NULL;
283 | g_hWnd = 0;
284 | }
285 |
286 | static bool ImGui_ImplDX9_CreateFontsTexture()
287 | {
288 | // Build texture atlas
289 | ImGuiIO& io = ImGui::GetIO();
290 | unsigned char* pixels;
291 | int width, height, bytes_per_pixel;
292 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
293 |
294 | // Upload texture to graphics system
295 | g_FontTexture = NULL;
296 | if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
297 | return false;
298 | D3DLOCKED_RECT tex_locked_rect;
299 | if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
300 | return false;
301 | for (int y = 0; y < height; y++)
302 | memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
303 | g_FontTexture->UnlockRect(0);
304 |
305 | // Store our identifier
306 | io.Fonts->TexID = (void *)g_FontTexture;
307 |
308 | return true;
309 | }
310 |
311 | bool ImGui_ImplDX9_CreateDeviceObjects()
312 | {
313 | if (!g_pd3dDevice)
314 | return false;
315 | if (!ImGui_ImplDX9_CreateFontsTexture())
316 | return false;
317 | return true;
318 | }
319 |
320 | void ImGui_ImplDX9_InvalidateDeviceObjects()
321 | {
322 | if (!g_pd3dDevice)
323 | return;
324 | if (g_pVB)
325 | {
326 | g_pVB->Release();
327 | g_pVB = NULL;
328 | }
329 | if (g_pIB)
330 | {
331 | g_pIB->Release();
332 | g_pIB = NULL;
333 | }
334 |
335 | // At this point note that we set ImGui::GetIO().Fonts->TexID to be == g_FontTexture, so clear both.
336 | ImGuiIO& io = ImGui::GetIO();
337 | IM_ASSERT(g_FontTexture == io.Fonts->TexID);
338 | if (g_FontTexture)
339 | g_FontTexture->Release();
340 | g_FontTexture = NULL;
341 | io.Fonts->TexID = NULL;
342 | }
343 |
344 | void ImGui_ImplDX9_NewFrame()
345 | {
346 | if (!g_FontTexture)
347 | ImGui_ImplDX9_CreateDeviceObjects();
348 |
349 | ImGuiIO& io = ImGui::GetIO();
350 |
351 | // Setup display size (every frame to accommodate for window resizing)
352 | RECT rect;
353 | GetClientRect(g_hWnd, &rect);
354 | io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
355 |
356 | // Setup time step
357 | INT64 current_time;
358 | QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
359 | io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
360 | g_Time = current_time;
361 |
362 | // Read keyboard modifiers inputs
363 | io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
364 | io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
365 | io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
366 | io.KeySuper = false;
367 | // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
368 | // io.MousePos : filled by WM_MOUSEMOVE events
369 | // io.MouseDown : filled by WM_*BUTTON* events
370 | // io.MouseWheel : filled by WM_MOUSEWHEEL events
371 |
372 | // Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
373 | if (io.WantMoveMouse)
374 | {
375 | POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
376 | ClientToScreen(g_hWnd, &pos);
377 | SetCursorPos(pos.x, pos.y);
378 | }
379 |
380 | // Hide OS mouse cursor if ImGui is drawing it
381 | if (io.MouseDrawCursor)
382 | SetCursor(NULL);
383 |
384 | // Start the frame
385 | ImGui::NewFrame();
386 | }
387 |
--------------------------------------------------------------------------------
/src/SDK.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "SDK/declarations.hpp"
3 | #include "SDK/DataTable.hpp"
4 | #include "SDK/CBaseClientState.hpp"
5 | #include "SDK/ClientClass.hpp"
6 | #include "SDK/IGameEvent.hpp"
7 | #include "SDK/IClientEntity.hpp"
8 | #include "SDK/CBaseEntity.hpp"
9 |
10 | #include "SDK/IBaseClientDLL.hpp"
11 | #include "SDK/IClientEntityList.hpp"
12 | #include "SDK/IGameEventManager2.hpp"
13 | #include "SDK/IVEngineClient.hpp"
14 | #include "SDK/IVModelInfoClient.hpp"
15 | #include "SDK/ILocalize.hpp"
16 | #include "SDK/IInputSystem.hpp"
17 |
18 | #include "SDK/interfaces.hpp"
19 |
20 | #include "Utilities/vmt_smart_hook.hpp"
21 | #include "Utilities/platform.hpp"
22 | #include "Utilities/netvar_manager.hpp"
23 |
--------------------------------------------------------------------------------
/src/SDK/CBaseClientState.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace sdk
5 | {
6 | class CBaseClientState
7 | {
8 | public:
9 | void ForceFullUpdate()
10 | {
11 | *reinterpret_cast(std::uintptr_t(this) + 0x174) = -1;
12 | };
13 | };
14 | }
--------------------------------------------------------------------------------
/src/SDK/CBaseEntity.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "declarations.hpp"
3 | #include "IClientEntity.hpp"
4 | #include "../Utilities/netvar_manager.hpp"
5 |
6 | namespace sdk
7 | {
8 | class C_BaseEntity : public IClientEntity
9 | {
10 | public:
11 | NETVAR_OFFSET(GetIndex, "CBaseEntity", "m_bIsAutoaimTarget", +0x4, int);
12 | NETVAR(GetModelIndex, "CBaseEntity", "m_nModelIndex", unsigned);
13 |
14 | void SetModelIndex(const int index)
15 | {
16 | get_vfunc(this, 75)(this, index);
17 | }
18 | };
19 |
20 | class C_BaseCombatCharacter : public C_BaseEntity
21 | {
22 | public:
23 | NETVAR(GetWeapons, "CBaseCombatCharacter", "m_hMyWeapons", std::array);
24 | PNETVAR(GetWearables, "CBaseCombatCharacter", "m_hMyWearables", CBaseHandle);
25 | };
26 |
27 | class C_BasePlayer : public C_BaseCombatCharacter
28 | {
29 | public:
30 | NETVAR(GetLifeState, "CBasePlayer", "m_lifeState", LifeState);
31 | NETVAR(GetViewModel, "CBasePlayer", "m_hViewModel[0]", CBaseHandle);
32 | };
33 |
34 | class C_BaseCombatWeapon : public C_BaseEntity
35 | {
36 | public:
37 | NETVAR(GetViewModelIndex, "CBaseCombatWeapon", "m_iViewModelIndex", int);
38 | NETVAR(GetWorldModelIndex, "CBaseCombatWeapon", "m_iWorldModelIndex", int);
39 | NETVAR(GetWorldDroppedModelIndex, "CBaseCombatWeapon", "m_iWorldDroppedModelIndex", int);
40 | NETVAR(GetWeaponWorldModel, "CBaseCombatWeapon", "m_hWeaponWorldModel", CBaseHandle);
41 | };
42 |
43 | class C_BaseAttributableItem : public C_BaseCombatWeapon
44 | {
45 | public:
46 | NETVAR(GetAccountID, "CBaseAttributableItem", "m_iAccountID", int);
47 | NETVAR(GetItemDefinitionIndex, "CBaseAttributableItem", "m_iItemDefinitionIndex", short);
48 | NETVAR(GetItemIDHigh, "CBaseAttributableItem", "m_iItemIDHigh", int);
49 | NETVAR(GetEntityQuality, "CBaseAttributableItem", "m_iEntityQuality", int);
50 | NETVAR(GetCustomName, "CBaseAttributableItem", "m_szCustomName", char[32]);
51 | NETVAR(GetFallbackPaintKit, "CBaseAttributableItem", "m_nFallbackPaintKit", unsigned);
52 | NETVAR(GetFallbackSeed, "CBaseAttributableItem", "m_nFallbackSeed", unsigned);
53 | NETVAR(GetFallbackWear, "CBaseAttributableItem", "m_flFallbackWear", float);
54 | NETVAR(GetFallbackStatTrak, "CBaseAttributableItem", "m_nFallbackStatTrak", unsigned);
55 | };
56 |
57 | class C_BaseViewModel : public C_BaseEntity
58 | {
59 | public:
60 | NETVAR(GetOwner, "CBaseViewModel", "m_hOwner", CBaseHandle);
61 | NETVAR(GetWeapon, "CBaseViewModel", "m_hWeapon", CBaseHandle);
62 | NETPROP(GetSequenceProp, "CBaseViewModel", "m_nSequence");
63 | };
64 |
65 | class C_PlayerResource
66 | {
67 | public:
68 | NETPROP(GetTeamProp, "CPlayerResource", "m_iTeam");
69 | };
70 |
71 | class C_CS_PlayerResource : public C_PlayerResource
72 | {
73 | public:
74 | NETVAR(GetRanks, "CCSPlayerResource", "m_iCompetitiveRanking", int[MAX_PLAYERS]);
75 | NETVAR(GetWins, "CCSPlayerResource", "m_iCompetitiveWins", int[MAX_PLAYERS]);
76 | NETVAR(GetClanTags, "CCSPlayerResource", "m_szClan", char[MAX_PLAYERS][32]);
77 | NETVAR(GetCoins, "CCSPlayerResource", "m_nActiveCoinRank", unsigned[MAX_PLAYERS]);
78 | NETVAR(GetMusicKits, "CCSPlayerResource", "m_nMusicID", unsigned[MAX_PLAYERS]);
79 | };
80 |
81 | class CBaseWeaponWorldModel : public C_BaseEntity
82 | {
83 | };
84 | }
--------------------------------------------------------------------------------
/src/SDK/ClientClass.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "declarations.hpp"
3 |
4 | namespace sdk
5 | {
6 | class ClientClass
7 | {
8 | public:
9 | CreateClientClassFn m_pCreateFn;
10 | CreateEventFn m_pCreateEventFn;
11 | const char* m_pNetworkName;
12 | RecvTable* m_pRecvTable;
13 | ClientClass* m_pNext;
14 | int m_ClassID;
15 | };
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/SDK/DataTable.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "declarations.hpp"
3 | #include
4 |
5 | namespace sdk
6 | {
7 | struct DVariant
8 | {
9 | union
10 | {
11 | float m_Float;
12 | long m_Int;
13 | char* m_pString;
14 | void* m_pData;
15 | Vector m_Vector;
16 | int64_t m_Int64;
17 | };
18 |
19 | int m_Type;
20 | };
21 |
22 | struct CRecvProxyData
23 | {
24 | const RecvProp* m_pRecvProp;
25 | DVariant m_Value;
26 | int m_iElement;
27 | int m_ObjectID;
28 | };
29 |
30 | enum SendPropType : int
31 | {
32 | DPT_Int = 0,
33 | DPT_Float,
34 | DPT_Vector,
35 | DPT_VectorXY,
36 | DPT_String,
37 | DPT_Array,
38 | DPT_DataTable,
39 | DPT_Int64,
40 | DPT_NUMSendPropTypes
41 | };
42 |
43 | class RecvProp
44 | {
45 | public:
46 | char* m_pVarName;
47 | SendPropType m_RecvType;
48 | int m_Flags;
49 | int m_StringBufferSize;
50 | bool m_bInsideArray;
51 | const void* m_pExtraData;
52 | RecvProp* m_pArrayProp;
53 | void* m_ArrayLengthProxy;
54 | RecvVarProxyFn m_ProxyFn;
55 | void* m_DataTableProxyFn;
56 | RecvTable* m_pDataTable;
57 | int m_Offset;
58 | int m_ElementStride;
59 | int m_nElements;
60 | const char* m_pParentArrayPropName;
61 | };
62 |
63 | class RecvTable
64 | {
65 | public:
66 | RecvProp* m_pProps;
67 | int m_nProps;
68 | void* m_pDecoder;
69 | char* m_pNetTableName;
70 | bool m_bInitialized;
71 | bool m_bInMainList;
72 | };
73 | }
74 |
--------------------------------------------------------------------------------
/src/SDK/IAppSystem.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | enum InitReturnVal_t
6 | {
7 | INIT_FAILED = 0,
8 | INIT_OK,
9 |
10 | INIT_LAST_VAL,
11 | };
12 |
13 | enum AppSystemTier_t
14 | {
15 | APP_SYSTEM_TIER0 = 0,
16 | APP_SYSTEM_TIER1,
17 | APP_SYSTEM_TIER2,
18 | APP_SYSTEM_TIER3,
19 |
20 | APP_SYSTEM_TIER_OTHER,
21 | };
22 |
23 | class IAppSystem
24 | {
25 | public:
26 | virtual bool Connect(CreateInterfaceFn factory) = 0;
27 | virtual void Disconnect() = 0;
28 | virtual void* QueryInterface(const char* pInterfaceName) = 0;
29 | virtual InitReturnVal_t Init() = 0;
30 | virtual void Shutdown() = 0;
31 | virtual const AppSystemInfo_t* GetDependencies() = 0;
32 | virtual AppSystemTier_t GetTier() = 0;
33 | virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) = 0;
34 | virtual bool IsSingleton() = 0;
35 | };
36 | }
--------------------------------------------------------------------------------
/src/SDK/IBaseClientDLL.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | enum ClientFrameStage_t : int
6 | {
7 | FRAME_UNDEFINED = -1,
8 | FRAME_START,
9 | FRAME_NET_UPDATE_START,
10 | FRAME_NET_UPDATE_POSTDATAUPDATE_START,
11 | FRAME_NET_UPDATE_POSTDATAUPDATE_END,
12 | FRAME_NET_UPDATE_END,
13 | FRAME_RENDER_START,
14 | FRAME_RENDER_END
15 | };
16 |
17 | class IBaseClientDLL
18 | {
19 | public:
20 | ClientClass* GetAllClasses()
21 | {
22 | return get_vfunc(this, 8)(this);
23 | }
24 | };
25 |
26 | }
--------------------------------------------------------------------------------
/src/SDK/IClientEntity.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | class IHandleEntity
6 | {
7 | public:
8 | virtual ~IHandleEntity() {}
9 | virtual void SetRefEHandle(const CBaseHandle& handle) = 0;
10 | virtual const CBaseHandle& GetRefEHandle() const = 0;
11 | };
12 |
13 | class IClientUnknown : public IHandleEntity
14 | {
15 | public:
16 | virtual ICollideable* GetCollideable() = 0;
17 | virtual IClientNetworkable* GetClientNetworkable() = 0;
18 | virtual IClientRenderable* GetClientRenderable() = 0;
19 | virtual IClientEntity* GetIClientEntity() = 0;
20 | virtual C_BaseEntity* GetBaseEntity() = 0;
21 | virtual IClientThinkable* GetClientThinkable() = 0;
22 | //virtual IClientModelRenderable* GetClientModelRenderable() = 0;
23 | virtual IClientAlphaProperty* GetClientAlphaProperty() = 0;
24 | };
25 |
26 | class IClientThinkable
27 | {
28 | public:
29 | virtual ~IClientThinkable() {};
30 | };
31 |
32 | class IClientRenderable
33 | {
34 | public:
35 | virtual ~IClientRenderable() {};
36 | };
37 |
38 | class IClientNetworkable
39 | {
40 | public:
41 | virtual IClientUnknown* GetIClientUnknown() = 0;
42 | virtual void Release() = 0;
43 | virtual ClientClass* GetClientClass() = 0;
44 | virtual void NotifyShouldTransmit(int state) = 0;
45 | virtual void OnPreDataChanged(int updateType) = 0;
46 | virtual void OnDataChanged(int updateType) = 0;
47 | virtual void PreDataUpdate(int updateType) = 0;
48 | virtual void PostDataUpdate(int updateType) = 0;
49 | virtual void OnDataUnchangedInPVS() = 0;
50 | virtual bool IsDormant() = 0;
51 | virtual int EntIndex() const = 0;
52 | virtual void ReceiveMessage(int classID, bf_read& msg) = 0;
53 | virtual void* GetDataTableBasePtr() = 0;
54 | virtual void SetDestroyedOnRecreateEntities() = 0;
55 | };
56 |
57 | class IClientEntity : public IClientUnknown, public IClientRenderable, public IClientNetworkable, public IClientThinkable
58 | {
59 | public:
60 | virtual ~IClientEntity() {};
61 | };
62 | }
--------------------------------------------------------------------------------
/src/SDK/IClientEntityList.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | class IClientEntityList
6 | {
7 | public:
8 | virtual IClientNetworkable* GetClientNetworkable(int iEnt) = 0;
9 | virtual IClientNetworkable* GetClientNetworkableFromHandle(CBaseHandle hEnt) = 0;
10 | virtual IClientUnknown* GetClientUnknownFromHandle(CBaseHandle hEnt) = 0;
11 | virtual IClientEntity* GetClientEntity(int iEnt) = 0;
12 | virtual IClientEntity* GetClientEntityFromHandle(CBaseHandle hEnt) = 0;
13 | virtual int NumberOfEntities(bool bIncludeNonNetworkable) = 0;
14 | virtual int GetHighestEntityIndex() = 0;
15 | virtual void SetMaxEntities(int iMax) = 0;
16 | virtual int GetMaxEntities() = 0;
17 | };
18 | }
--------------------------------------------------------------------------------
/src/SDK/IGameEvent.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace sdk
5 | {
6 | class IGameEvent
7 | {
8 | public:
9 | virtual ~IGameEvent() {};
10 | virtual const char* GetName() const = 0;
11 |
12 | virtual bool IsReliable() const = 0;
13 | virtual bool IsLocal() const = 0;
14 | virtual bool IsEmpty(const char* keyname = nullptr) = 0;
15 |
16 | virtual bool GetBool(const char* keyname = nullptr, bool default_value = false) = 0;
17 | virtual int GetInt(const char* keyname = nullptr, int default_value = 0) = 0;
18 | virtual uint64_t GetUint64(const char* keyname = nullptr, uint64_t default_value = 0) = 0;
19 | virtual float GetFloat(const char* keyname = nullptr, float default_value = 0.0f) = 0;
20 | virtual const char* GetString(const char* keyname = nullptr, const char* default_value = "") = 0;
21 | virtual const wchar_t* GetWString(const char* keyname = nullptr, const wchar_t* default_value = L"") = 0;
22 | virtual const void* GetPtr(const char* keyname = nullptr, const void* default_values = nullptr) = 0;
23 |
24 | virtual void SetBool(const char* keyname, bool value) = 0;
25 | virtual void SetInt(const char* keyname, int value) = 0;
26 | virtual void SetUint64(const char* keyname, uint64_t value) = 0;
27 | virtual void SetFloat(const char* keyname, float value) = 0;
28 | virtual void SetString(const char* keyname, const char* value) = 0;
29 | virtual void SetWString(const char* keyname, const wchar_t* value) = 0;
30 | virtual void SetPtr(const char* keyname, const void* value) = 0;
31 | };
32 |
33 | }
--------------------------------------------------------------------------------
/src/SDK/IGameEventManager2.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | class IGameEventListener2
6 | {
7 | public:
8 | virtual ~IGameEventListener2() {};
9 | virtual void FireGameEvent(IGameEvent* event) = 0;
10 | virtual int GetEventDebugID() = 0;
11 | };
12 |
13 | class IGameEventManager2
14 | {
15 | public:
16 | virtual ~IGameEventManager2() {};
17 | virtual int LoadEventsFromFile(const char* filename) = 0;
18 | virtual void Reset() = 0;
19 | virtual bool AddListener(IGameEventListener2* listener, const char* name, bool serverside) = 0;
20 | virtual bool FindListener(IGameEventListener2* listener, const char* name) = 0;
21 | virtual void RemoveListener(IGameEventListener2* listener) = 0;
22 | virtual void AddListenerGlobal(IGameEventListener2* listener, bool serverside) = 0;
23 | virtual IGameEvent* CreateEvent(const char* name, bool force = false, int* cookie = nullptr) = 0;
24 | virtual bool FireEvent(IGameEvent* event, bool bDontBroadcast = false) = 0;
25 | virtual bool FireEventClientSide(IGameEvent* event) = 0;
26 | virtual IGameEvent* DuplicateEvent(IGameEvent* event) = 0;
27 | virtual void FreeEvent(IGameEvent* event) = 0;
28 | virtual bool SerializeEvent(IGameEvent* event, bf_write* buffer) = 0;
29 | virtual IGameEvent* UnserializeEvent(bf_read* buffer) = 0;
30 | virtual KeyValues* GetEventDataTypes(IGameEvent* event) = 0;
31 | };
32 | }
--------------------------------------------------------------------------------
/src/SDK/IInputSystem.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | class IInputSystem
6 | {
7 | public:
8 | void EnableInput(bool bEnable)
9 | {
10 | return get_vfunc(this, 11)(this, bEnable);
11 | }
12 |
13 | void*& get_window()
14 | {
15 | static uint32_t offset = 0;
16 | if (!offset)
17 | offset = *(uint32_t*)((*(char***)this)[10] + 5);
18 | return *(void**)((char*)this + offset);
19 | }
20 | };
21 |
22 | }
--------------------------------------------------------------------------------
/src/SDK/ILocalize.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "IAppSystem.hpp"
3 |
4 | namespace sdk
5 | {
6 | class ILocalizeTextQuery
7 | {
8 | public:
9 | virtual int ComputeTextWidth(const wchar_t* pString) = 0;
10 | };
11 |
12 | class ILocalizationChangeCallback
13 | {
14 | public:
15 | virtual void OnLocalizationChanged() = 0;
16 | };
17 |
18 | class ILocalize : public IAppSystem
19 | {
20 | public:
21 | virtual bool AddFile(const char* fileName, const char* pPathID = nullptr, bool bIncludeFallbackSearchPaths = false) = 0;
22 | virtual void RemoveAll() = 0;
23 | virtual wchar_t* Find(const char* tokenName) = 0;
24 | virtual const wchar_t* FindSafe(const char* tokenName) = 0;
25 | virtual int ConvertANSIToUnicode(const char* ansi, wchar_t* unicode, int unicodeBufferSizeInBytes) = 0;
26 | virtual int ConvertUnicodeToANSI(const wchar_t* unicode, char* ansi, int ansiBufferSize) = 0;
27 | virtual LocalizeStringIndex_t FindIndex(const char* tokenName) = 0;
28 | virtual void ConstructString(wchar_t* unicodeOuput, int unicodeBufferSizeInBytes, const wchar_t* formatString, int numFormatParameters, ...) = 0;
29 | virtual const char* GetNameByIndex(LocalizeStringIndex_t index) = 0;
30 | virtual wchar_t* GetValueByIndex(LocalizeStringIndex_t index) = 0;
31 | };
32 | }
--------------------------------------------------------------------------------
/src/SDK/IVEngineClient.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "declarations.hpp"
3 |
4 | namespace sdk
5 | {
6 | typedef struct player_info_s
7 | {
8 | private:
9 | int64_t unknown;
10 | public:
11 | union
12 | {
13 | int64_t xuid;
14 |
15 | struct
16 | {
17 | int xuid_low;
18 | int xuid_high;
19 | };
20 | };
21 |
22 | char name[MAX_PLAYER_NAME_LENGTH];
23 | int userid;
24 | int m_nUserID;
25 | char guid[SIGNED_GUID_LEN + 1];
26 | unsigned int friendsid;
27 | char friendsname[MAX_PLAYER_NAME_LENGTH];
28 | bool fakeplayer;
29 | bool ishltv;
30 | unsigned int customfiles[4];
31 | unsigned char filesdownloaded;
32 | } player_info_t;
33 |
34 | class IVEngineClient
35 | {
36 | public:
37 | bool GetPlayerInfo(const int index, player_info_t* player_info)
38 | {
39 | return get_vfunc(this, 8)(this, index, player_info);
40 | }
41 |
42 | int GetPlayerForUserID(const int userid)
43 | {
44 | return get_vfunc(this, 9)(this, userid);
45 | }
46 |
47 | int GetLocalPlayer()
48 | {
49 | return get_vfunc(this, 12)(this);
50 | }
51 |
52 | bool IsInGame()
53 | {
54 | return get_vfunc(this, 26)(this);
55 | }
56 |
57 | bool IsConnected()
58 | {
59 | return get_vfunc(this, 27)(this);
60 | }
61 |
62 | void ClientCmd_Unrestricted(const char* command, const bool delayed = false)
63 | {
64 | return get_vfunc(this, 114)(this, command, delayed);
65 | }
66 | };
67 |
68 | }
--------------------------------------------------------------------------------
/src/SDK/IVModelInfoClient.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace sdk
4 | {
5 | class IVModelInfoClient
6 | {
7 | public:
8 | virtual ~IVModelInfoClient() {};
9 | virtual const model_t* GetModel(int modelindex) const = 0;
10 | virtual int GetModelIndex(const char* name) const = 0;
11 | virtual const char* GetModelName(const model_t* model) const = 0;
12 | };
13 | }
--------------------------------------------------------------------------------
/src/SDK/declarations.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | template
6 | Fn get_vfunc(void* class_base, const std::size_t index)
7 | {
8 | return (*reinterpret_cast(class_base))[index];
9 | }
10 |
11 | namespace sdk
12 | {
13 | class C_BaseEntity;
14 | class ClientClass;
15 | class ClientClass;
16 | class IClientAlphaProperty;
17 | class IClientEntity;
18 | class IClientEntity;
19 | class IClientNetworkable;
20 | class IClientNetworkable;
21 | class IClientRenderable;
22 | class IClientThinkable;
23 | class IClientUnknown;
24 | class ICollideable;
25 | class IGameEvent;
26 | class KeyValues;
27 | class RecvProp;
28 | class RecvTable;
29 |
30 | struct AppSystemInfo_t;
31 | struct CRecvProxyData;
32 | struct bf_read;
33 | struct bf_read;
34 | struct bf_write;
35 | struct model_t;
36 |
37 | using CBaseHandle = unsigned long;
38 | using CreateClientClassFn = IClientNetworkable* (*)(int, int);
39 | using CreateEventFn = IClientNetworkable* (*)();
40 | using CreateInterfaceFn = void* (*)(const char*, int*);
41 | using LocalizeStringIndex_t = unsigned;
42 | using RecvVarProxyFn = void(__cdecl *)(const CRecvProxyData*, void*, void*);
43 | using Vector = std::array;
44 |
45 | constexpr static auto INVALID_EHANDLE_INDEX = 0xFFFFFFFF;
46 | constexpr static auto MAX_PLAYER_NAME_LENGTH = 128;
47 | constexpr static auto SIGNED_GUID_LEN = 32;
48 | constexpr static auto MAX_WEAPONS = 48;
49 | constexpr static auto MAX_PLAYERS = 65; // Only cstrike and csgo
50 |
51 | enum class LifeState
52 | {
53 | ALIVE = 0,
54 | DYING,
55 | DEAD,
56 | RESPAWNABLE,
57 | DISCARDBODY,
58 | };
59 | }
--------------------------------------------------------------------------------
/src/SDK/interfaces.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "CBaseClientState.hpp"
3 | #include "IBaseClientDLL.hpp"
4 | #include "IClientEntityList.hpp"
5 | #include "IGameEventManager2.hpp"
6 | #include "ILocalize.hpp"
7 | #include "IVEngineClient.hpp"
8 | #include "IVModelInfoClient.hpp"
9 |
10 | #define CLIENT_DLL_INTERFACE_VERSION "VClient018"
11 | extern sdk::IBaseClientDLL* g_client;
12 |
13 | #define VCLIENTENTITYLIST_INTERFACE_VERSION "VClientEntityList003"
14 | extern sdk::IClientEntityList* g_entity_list;
15 |
16 | #define VENGINE_CLIENT_INTERFACE_VERSION "VEngineClient014"
17 | extern sdk::IVEngineClient* g_engine;
18 |
19 | #define VMODELINFO_CLIENT_INTERFACE_VERSION "VModelInfoClient004"
20 | extern sdk::IVModelInfoClient* g_model_info;
21 |
22 | #define INTERFACEVERSION_GAMEEVENTSMANAGER2 "GAMEEVENTSMANAGER002"
23 | extern sdk::IGameEventManager2* g_game_event_manager;
24 |
25 | #define ILOCALIZE_CLIENT_INTERFACE_VERSION "Localize_001"
26 | extern sdk::ILocalize* g_localize;
27 |
28 | #define INPUTSYSTEM_INTERFACE_VERSION "InputSystemVersion001"
29 | extern sdk::IInputSystem* g_input_system;
30 |
31 | extern sdk::CBaseClientState** g_client_state;
32 | extern sdk::C_CS_PlayerResource** g_player_resource;
--------------------------------------------------------------------------------
/src/Utilities/Platform.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #include "../SDK.hpp"
26 | #include "platform.hpp"
27 | #include
28 | #include
29 |
30 | // Platform tools for windows. Maybe I'll make linux ones too
31 |
32 | #include
33 | #include
34 |
35 | auto platform::get_export(const char* module_name, const char* export_name) -> void*
36 | {
37 | HMODULE mod;
38 | while(!((mod = GetModuleHandleA(module_name))))
39 | Sleep(100);
40 |
41 | return reinterpret_cast(GetProcAddress(mod, export_name));
42 | }
43 |
44 | auto platform::get_interface(const char* module_name, const char* interface_name) -> void*
45 | {
46 | const auto addr = get_export(module_name, "CreateInterface");
47 | const auto create_interface_fn = reinterpret_cast(addr);
48 |
49 | return create_interface_fn(interface_name, nullptr);
50 | }
51 |
52 | auto platform::get_module_info(const char* module_name) -> std::pair
53 | {
54 | const auto module = GetModuleHandleA(module_name);
55 | if (!module)
56 | return { 0, 0 };
57 | MODULEINFO module_info;
58 | K32GetModuleInformation(GetCurrentProcess(), module, &module_info, sizeof(MODULEINFO));
59 | return { std::uintptr_t(module_info.lpBaseOfDll), module_info.SizeOfImage };
60 | }
61 |
62 | /*auto platform::find_pattern(const char* module_name, const char* pattern, const char* mask) -> std::uintptr_t
63 | {
64 | MODULEINFO module_info = {};
65 | K32GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(module_name), &module_info, sizeof(MODULEINFO));
66 |
67 | const auto address = reinterpret_cast(module_info.lpBaseOfDll);
68 | const auto size = module_info.SizeOfImage;
69 |
70 | std::vector> signature;
71 |
72 | for (auto i = 0u; mask[i]; i++)
73 | signature.push_back(std::make_pair(pattern[i], mask[i] == 'x'));
74 |
75 | auto ret = std::search(address, address + size, signature.begin(), signature.end(),
76 | [](std::uint8_t curr, std::pair curr_pattern)
77 | {
78 | return (!curr_pattern.second) || curr == curr_pattern.first;
79 | });
80 |
81 | return ret == address + size ? 0 : std::uintptr_t(ret);
82 | }*/
83 |
84 | auto platform::is_code_ptr(void* ptr) -> bool
85 | {
86 | constexpr const DWORD protect_flags = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY;
87 |
88 | MEMORY_BASIC_INFORMATION out;
89 | VirtualQuery(ptr, &out, sizeof out);
90 |
91 | return out.Type
92 | && !(out.Protect & (PAGE_GUARD | PAGE_NOACCESS))
93 | && out.Protect & protect_flags;
94 | }
95 |
--------------------------------------------------------------------------------
/src/Utilities/Platform.hpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #pragma once
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | namespace platform
32 | {
33 | namespace detail
34 | {
35 | constexpr auto process_pattern_byte(const std::pair pair) -> std::pair
36 | {
37 | return { std::uint8_t(pair.first), pair.second == 'x' };
38 | }
39 |
40 | template
41 | constexpr auto select_pattern_byte(const char(&pattern)[N], const char(&mask)[N], std::size_t n) -> std::pair
42 | {
43 | return { pattern[n], mask[n] };
44 | }
45 |
46 | template
47 | struct sig_processor {};
48 |
49 | template
50 | struct sig_processor>
51 | {
52 | template
53 | static constexpr auto process(const char(&pattern)[N], const char(&mask)[N]) -> std::array, N>
54 | {
55 | return { process_pattern_byte(select_pattern_byte(pattern, mask, Indices))... };
56 | }
57 | };
58 | }
59 |
60 | auto get_interface(const char* module_name, const char* interface_name) -> void*;
61 | auto get_module_info(const char* module_name) -> std::pair;
62 | //auto find_pattern(const char* module_name, const char* pattern, const char* mask) -> std::uintptr_t;
63 | auto is_code_ptr(void* ptr) -> bool;
64 | auto get_export(const char* module_name, const char* export_name) -> void*;
65 |
66 | template
67 | auto find_pattern(const char* module_name, const char(&pattern)[N], const char(&mask)[N]) -> std::uintptr_t
68 | {
69 | const std::array, N> signature = detail::sig_processor>::process(pattern, mask);
70 |
71 | const auto info = get_module_info(module_name);
72 | const auto address = reinterpret_cast(info.first);
73 | const auto size = info.second;
74 |
75 | const auto ret = std::search(address, address + size, signature.begin(), signature.end(),
76 | [](std::uint8_t curr, std::pair curr_pattern)
77 | {
78 | return (!curr_pattern.second) || curr == curr_pattern.first;
79 | });
80 |
81 | return ret == address + size ? 0 : std::uintptr_t(ret);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/Utilities/fnv_hash.hpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #pragma once
26 | #include
27 |
28 | namespace detail
29 | {
30 | template
31 | struct size_dependant_data
32 | {
33 | using type = Type;
34 | constexpr static auto k_offset_basis = OffsetBasis;
35 | constexpr static auto k_prime = Prime;
36 | };
37 |
38 | template
39 | struct size_selector;
40 |
41 | template <>
42 | struct size_selector<32>
43 | {
44 | using type = size_dependant_data;
45 | };
46 |
47 | template <>
48 | struct size_selector<64>
49 | {
50 | using type = size_dependant_data;
51 | };
52 |
53 | // Implements FNV-1a hash algorithm
54 | template
55 | class fnv_hash
56 | {
57 | private:
58 | using data_t = typename size_selector::type;
59 |
60 | public:
61 | using hash = typename data_t::type;
62 |
63 | private:
64 | constexpr static auto k_offset_basis = data_t::k_offset_basis;
65 | constexpr static auto k_prime = data_t::k_prime;
66 |
67 | public:
68 | template
69 | static __forceinline constexpr auto hash_constexpr(const char(&str)[N], const std::size_t size = N) -> hash
70 | {
71 | return static_cast(1ull * (size == 1
72 | ? (k_offset_basis ^ str[0])
73 | : (hash_constexpr(str, size - 1) ^ str[size - 1])) * k_prime);
74 | }
75 |
76 | static auto __forceinline hash_runtime(const char* str) -> hash
77 | {
78 | auto result = k_offset_basis;
79 | do
80 | {
81 | result ^= *str++;
82 | result *= k_prime;
83 | } while(*(str - 1) != '\0');
84 |
85 | return result;
86 | }
87 | };
88 | }
89 |
90 | using fnv = ::detail::fnv_hash;
91 |
92 | #define FNV(str) (std::integral_constant::value)
--------------------------------------------------------------------------------
/src/Utilities/netvar_manager.cpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #include "netvar_manager.hpp"
26 | #include "../SDK.hpp"
27 | #include
28 |
29 | //#define DUMP_NETVARS
30 |
31 | #ifdef DUMP_NETVARS
32 | #define IF_DUMPING(...) __VA_ARGS__
33 | #else
34 | #define IF_DUMPING(...)
35 | #endif
36 |
37 | IF_DUMPING(static FILE* s_fp;)
38 |
39 | netvar_manager::netvar_manager()
40 | {
41 | IF_DUMPING(fopen_s(&s_fp, "netvar_dump.txt", "w");)
42 | for (auto clazz = g_client->GetAllClasses(); clazz; clazz = clazz->m_pNext)
43 | if (clazz->m_pRecvTable)
44 | dump_recursive(clazz->m_pNetworkName, clazz->m_pRecvTable, 0);
45 | IF_DUMPING(fclose(s_fp);)
46 | }
47 |
48 | auto netvar_manager::dump_recursive(const char* base_class, sdk::RecvTable* table, const std::uint16_t offset) -> void
49 | {
50 | for (auto i = 0; i < table->m_nProps; ++i)
51 | {
52 | const auto prop_ptr = &table->m_pProps[i];
53 |
54 | //Skip trash array items
55 | if (!prop_ptr || isdigit(prop_ptr->m_pVarName[0]))
56 | continue;
57 |
58 | //We dont care about the base class, we already know that
59 | if (fnv::hash_runtime(prop_ptr->m_pVarName) == FNV("baseclass"))
60 | continue;
61 |
62 | if (prop_ptr->m_RecvType == sdk::DPT_DataTable &&
63 | prop_ptr->m_pDataTable != nullptr &&
64 | prop_ptr->m_pDataTable->m_pNetTableName[0] == 'D') // Skip shitty tables
65 | {
66 | dump_recursive(base_class, prop_ptr->m_pDataTable, std::uint16_t(offset + prop_ptr->m_Offset));
67 | }
68 |
69 | char hash_name[256];
70 |
71 | strcpy_s(hash_name, base_class);
72 | strcat_s(hash_name, "->");
73 | strcat_s(hash_name, prop_ptr->m_pVarName);
74 |
75 | const auto hash = fnv::hash_runtime(hash_name);
76 | const auto total_offset = std::uint16_t(offset + prop_ptr->m_Offset);
77 |
78 | IF_DUMPING(fprintf(s_fp, "%s\t0x%04X\t%s\n", base_class, total_offset, prop_ptr->m_pVarName);)
79 |
80 | m_props[hash] =
81 | {
82 | prop_ptr,
83 | total_offset
84 | };
85 | }
86 | }
--------------------------------------------------------------------------------
/src/Utilities/netvar_manager.hpp:
--------------------------------------------------------------------------------
1 | /* This file is part of nSkinz by namazso, licensed under the MIT license:
2 | *
3 | * MIT License
4 | *
5 | * Copyright (c) namazso 2018
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 | #pragma once
26 | #include "../SDK/DataTable.hpp"
27 | #include "fnv_hash.hpp"
28 | #include