├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── build
└── .gitkeep
├── src
├── SDK
│ ├── classes
│ │ ├── cEntity.h
│ │ └── cUserCmd.h
│ ├── helpers
│ │ ├── definitions.h
│ │ ├── fnv.h
│ │ ├── misc.h
│ │ └── vector.h
│ ├── interfaces
│ │ ├── files
│ │ │ ├── iBaseClientDLL.h
│ │ │ ├── iClientEntityList.h
│ │ │ ├── iClientMode.h
│ │ │ ├── ivEngineClient.h
│ │ │ └── ivModelRenderer.h
│ │ ├── getInterface.h
│ │ ├── interfaces.cpp
│ │ └── interfaces.h
│ ├── netvarManager.cpp
│ ├── netvarManager.h
│ └── sdk.h
├── hooks
│ ├── files
│ │ ├── createMove.cpp
│ │ ├── sdlHooks.cpp
│ │ └── vmtHook.cpp
│ ├── hooks.cpp
│ └── hooks.h
├── main.cpp
├── main.h
├── menu
│ ├── ImGUI
│ │ ├── GL
│ │ │ ├── gl3w.c
│ │ │ ├── gl3w.h
│ │ │ └── glcorearb.h
│ │ ├── LICENSE.txt
│ │ ├── imconfig.h
│ │ ├── imgui.cpp
│ │ ├── imgui.h
│ │ ├── imgui_demo.cpp
│ │ ├── imgui_draw.cpp
│ │ ├── imgui_impl_opengl3.cpp
│ │ ├── imgui_impl_opengl3.h
│ │ ├── imgui_impl_sdl.cpp
│ │ ├── imgui_impl_sdl.h
│ │ ├── imgui_internal.h
│ │ ├── imgui_widgets.cpp
│ │ ├── imstb_rectpack.h
│ │ ├── imstb_textedit.h
│ │ └── imstb_truetype.h
│ ├── config.h
│ ├── menu.cpp
│ ├── menu.h
│ └── pages
│ │ ├── aimbotPage.cpp
│ │ ├── infoPage.cpp
│ │ ├── miscPage.cpp
│ │ └── visualsPage.cpp
└── modules
│ ├── misc
│ ├── bhop.cpp
│ └── radar.cpp
│ ├── modules.h
│ └── visuals
│ └── esp.cpp
└── tools
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | csgo-simple-linux-cheat.code-workspace
3 | build/*
4 | !build/.gitkeep
5 | gdb.txt
6 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.11.0)
2 | project(csgo-simple-linux-cheat)
3 |
4 | set(CMAKE_CXX_STANDARD 20)
5 |
6 | set(CMAKE_C_COMPILER "/usr/bin/gcc")
7 | set(CMAKE_CXX_COMPILER "/usr/bin/g++")
8 |
9 | set(CMAKE_C_FLAGS_RELEASE "-W -Wall -Wextra -O3 -march=native -mtune=native -s -Wno-unused-variable -fvisibility=hidden -flto -fwhole-program -Wl,--strip-all")
10 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} --no-gnu-unique -fno-rtti -std=c++2a")
11 |
12 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
13 |
14 | file(GLOB_RECURSE SOURCE_FILES "${CMAKE_SOURCE_DIR}/src/*.cpp")
15 | list(APPEND SOURCE_FILES "${CMAKE_SOURCE_DIR}/src/menu/ImGUI/GL/gl3w.c")
16 |
17 | include_directories("${CMAKE_SOURCE_DIR}/src/")
18 |
19 | add_library(csgo-simple-linux-cheat SHARED ${SOURCE_FILES})
20 | target_link_libraries(csgo-simple-linux-cheat dl pthread SDL2 GL)
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # csgo-simple-linux-cheat
2 |
3 | This is a simple CS:GO cheat for Linux
4 | It is not meant to be used as is and is rather a WIP project for educational purposes
5 |
6 | ## Building
7 |
8 | Make sure included `tools` script is executable:
9 | `chmod +x ./tools`
10 |
11 | Build cheat once using `tools` script:
12 | `./tools -b`
13 |
14 | ## Loading/Injecting:
15 |
16 | Make sure csgo is running before trying to inject
17 |
18 | Inject using `tools` script:
19 | `./tools -l`
20 |
21 | ## Unload:
22 |
23 | **Currently broken, idk why**
24 |
25 | Unload using `tools` script:
26 | `./tools -u`
27 |
28 |
29 |
30 |
31 | ## Credit:
32 |
33 | Thank you so much to these sources, without them I would have had no idea how to build this thing:
34 | https://github.com/seksea/gamesneeze
35 | https://github.com/ArnoldasMk/Kali
36 | https://www.youtube.com/channel/UC9iIZaEy1r_q6CRAiXBqXOA
--------------------------------------------------------------------------------
/build/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/3urobeat/csgo-simple-linux-cheat/79e518b57baa178065cefc9143b75e3f7d49f024/build/.gitkeep
--------------------------------------------------------------------------------
/src/SDK/classes/cEntity.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: cEntity.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 16.02.2023 21:41:39
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 21:04:19
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../interfaces/files/ivModelRenderer.h"
22 | #include "../netvarManager.h"
23 | #include "../helpers/vector.h"
24 |
25 |
26 | class ICollideable {
27 | public:
28 | virtual void pad0();
29 | virtual const Vector& OBBMins() const;
30 | virtual const Vector& OBBMaxs() const;
31 | };
32 |
33 |
34 | class CEntity {
35 | public:
36 | // Note because I might be stupid: This works, don't change it
37 | virtual void *networkable() = 0;
38 | virtual void *renderable() = 0;
39 | virtual ClientClass *clientClass() = 0;
40 | virtual bool dormant() = 0;
41 | virtual int index() = 0;
42 | virtual model_t* model() = 0;
43 | virtual bool setupBones(matrix3x4_t* pBoneMatrix, int nMaxBones, int nBoneMask, float flCurTime = 0) = 0;
44 | virtual bool shouldDraw() = 0;
45 | virtual const Vector& origin() = 0;
46 | virtual bool isPlayer() = 0;
47 |
48 | NETVAR(collideable, "CBaseEntity->m_Collision", ICollideable);
49 | NETVAR(team, "CBaseEntity->m_iTeamNum", int);
50 | NETVAR(spotted, "CBaseEntity->m_bSpotted", bool);
51 | };
52 |
53 |
54 | // CPlayer inherits from CEntity
55 | class CPlayer : public CEntity {
56 | public:
57 |
58 | };
--------------------------------------------------------------------------------
/src/SDK/classes/cUserCmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: cUserCmd.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 04.04.2022 14:46:32
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 11:02:02
8 | * Modified By: 3urobeat
9 | *
10 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
13 | */
14 |
15 |
16 | #pragma once
17 |
18 |
19 | #include "../helpers/vector.h"
20 |
21 |
22 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/shared/usercmd.h
23 |
24 | struct CUserCmd {
25 | virtual ~CUserCmd() {}; // Destructor
26 |
27 | int command_number;
28 | int tick_count;
29 | Vector viewPoint;
30 | Vector aimDirection;
31 | float forwardmove;
32 | float sidemove;
33 | float upmove;
34 | int buttons;
35 | char impulse;
36 | int weaponselect;
37 | int weaponsubtype;
38 | int random_seed;
39 | short mousedx;
40 | short mousedy;
41 | bool hasbeenpredicted;
42 | Vector headAngles;
43 | Vector headOffset;
44 | };
45 |
46 |
47 | enum CommandButtons : int {
48 | IN_ATTACK = (1 << 0),
49 | IN_JUMP = (1 << 1),
50 | IN_DUCK = (1 << 2),
51 | IN_FORWARD = (1 << 3),
52 | IN_BACK = (1 << 4),
53 | IN_USE = (1 << 5),
54 | IN_CANCEL = (1 << 6),
55 | IN_LEFT = (1 << 7),
56 | IN_RIGHT = (1 << 8),
57 | IN_MOVELEFT = (1 << 9),
58 | IN_MOVERIGHT = (1 << 10),
59 | IN_SECOND_ATTACK = (1 << 11),
60 | IN_RUN = (1 << 12),
61 | IN_RELOAD = (1 << 13),
62 | IN_LEFT_ALT = (1 << 14),
63 | IN_RIGHT_ALT = (1 << 15),
64 | IN_SCORE = (1 << 16),
65 | IN_SPEED = (1 << 17),
66 | IN_WALK = (1 << 18),
67 | IN_ZOOM = (1 << 19),
68 | IN_FIRST_WEAPON = (1 << 20),
69 | IN_SECOND_WEAPON = (1 << 21),
70 | IN_BULLRUSH = (1 << 22),
71 | IN_FIRST_GRENADE = (1 << 23),
72 | IN_SECOND_GRENADE = (1 << 24),
73 | IN_MIDDLE_ATTACK = (1 << 25)
74 | };
--------------------------------------------------------------------------------
/src/SDK/helpers/definitions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: definitions.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 04.04.2022 20:25:38
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 16.02.2023 19:20:52
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | // I wasn't able to find this (I guess it would be in the SDK?) but the other cheats are using exactly this list sooo
22 | enum EClassIds {
23 | CAI_BaseNPC = 0,
24 | CAK47,
25 | CBaseAnimating,
26 | CBaseAnimatingOverlay,
27 | CBaseAttributableItem,
28 | CBaseButton,
29 | CBaseCombatCharacter,
30 | CBaseCombatWeapon,
31 | CBaseCSGrenade,
32 | CBaseCSGrenadeProjectile,
33 | CBaseDoor,
34 | CBaseEntity,
35 | CBaseFlex,
36 | CBaseGrenade,
37 | CBaseParticleEntity,
38 | CBasePlayer,
39 | CBasePropDoor,
40 | CBaseTeamObjectiveResource,
41 | CBaseTempEntity,
42 | CBaseToggle,
43 | CBaseTrigger,
44 | CBaseViewModel,
45 | CBaseVPhysicsTrigger,
46 | CBaseWeaponWorldModel,
47 | CBeam,
48 | CBeamSpotlight,
49 | CBoneFollower,
50 | CBRC4Target,
51 | CBreachCharge,
52 | CBreachChargeProjectile,
53 | CBreakableProp,
54 | CBreakableSurface,
55 | CBumpMine,
56 | CBumpMineProjectile,
57 | CC4,
58 | CCascadeLight,
59 | CChicken,
60 | CColorCorrection,
61 | CColorCorrectionVolume,
62 | CCSGameRulesProxy,
63 | CCSPlayer,
64 | CCSPlayerResource,
65 | CCSRagdoll,
66 | CCSTeam,
67 | CDangerZone,
68 | CDangerZoneController,
69 | CDEagle,
70 | CDecoyGrenade,
71 | CDecoyProjectile,
72 | CDrone,
73 | CDronegun,
74 | CDynamicLight,
75 | CDynamicProp,
76 | CEconEntity,
77 | CEconWearable,
78 | CEmbers,
79 | CEntityDissolve,
80 | CEntityFlame,
81 | CEntityFreezing,
82 | CEntityParticleTrail,
83 | CEnvAmbientLight,
84 | CEnvDetailController,
85 | CEnvDOFController,
86 | CEnvGasCanister,
87 | CEnvParticleScript,
88 | CEnvProjectedTexture,
89 | CEnvQuadraticBeam,
90 | CEnvScreenEffect,
91 | CEnvScreenOverlay,
92 | CEnvTonemapController,
93 | CEnvWind,
94 | CFEPlayerDecal,
95 | CFireCrackerBlast,
96 | CFireSmoke,
97 | CFireTrail,
98 | CFish,
99 | CFists,
100 | CFlashbang,
101 | CFogController,
102 | CFootstepControl,
103 | CFunc_Dust,
104 | CFunc_LOD,
105 | CFuncAreaPortalWindow,
106 | CFuncBrush,
107 | CFuncConveyor,
108 | CFuncLadder,
109 | CFuncMonitor,
110 | CFuncMoveLinear,
111 | CFuncOccluder,
112 | CFuncReflectiveGlass,
113 | CFuncRotating,
114 | CFuncSmokeVolume,
115 | CFuncTrackTrain,
116 | CGameRulesProxy,
117 | CGrassBurn,
118 | CHandleTest,
119 | CHEGrenade,
120 | CHostage,
121 | CHostageCarriableProp,
122 | CIncendiaryGrenade,
123 | CInferno,
124 | CInfoLadderDismount,
125 | CInfoMapRegion,
126 | CInfoOverlayAccessor,
127 | CItem_Healthshot,
128 | CItemCash,
129 | CItemDogtags,
130 | CKnife,
131 | CKnifeGG,
132 | CLightGlow,
133 | CMapVetoPickController,
134 | CMaterialModifyControl,
135 | CMelee,
136 | CMolotovGrenade,
137 | CMolotovProjectile,
138 | CMovieDisplay,
139 | CParadropChopper,
140 | CParticleFire,
141 | CParticlePerformanceMonitor,
142 | CParticleSystem,
143 | CPhysBox,
144 | CPhysBoxMultiplayer,
145 | CPhysicsProp,
146 | CPhysicsPropMultiplayer,
147 | CPhysMagnet,
148 | CPhysPropAmmoBox,
149 | CPhysPropLootCrate,
150 | CPhysPropRadarJammer,
151 | CPhysPropWeaponUpgrade,
152 | CPlantedC4,
153 | CPlasma,
154 | CPlayerPing,
155 | CPlayerResource,
156 | CPointCamera,
157 | CPointCommentaryNode,
158 | CPointWorldText,
159 | CPoseController,
160 | CPostProcessController,
161 | CPrecipitation,
162 | CPrecipitationBlocker,
163 | CPredictedViewModel,
164 | CProp_Hallucination,
165 | CPropCounter,
166 | CPropDoorRotating,
167 | CPropJeep,
168 | CPropVehicleDriveable,
169 | CRagdollManager,
170 | CRagdollProp,
171 | CRagdollPropAttached,
172 | CRopeKeyframe,
173 | CSCAR17,
174 | CSceneEntity,
175 | CSensorGrenade,
176 | CSensorGrenadeProjectile,
177 | CShadowControl,
178 | CSlideshowDisplay,
179 | CSmokeGrenade,
180 | CSmokeGrenadeProjectile,
181 | CSmokeStack,
182 | CSnowball,
183 | CSnowballPile,
184 | CSnowballProjectile,
185 | CSpatialEntity,
186 | CSpotlightEnd,
187 | CSprite,
188 | CSpriteOriented,
189 | CSpriteTrail,
190 | CStatueProp,
191 | CSteamJet,
192 | CSun,
193 | CSunlightShadowControl,
194 | CSurvivalSpawnChopper,
195 | CTablet,
196 | CTeam,
197 | CTeamplayRoundBasedRulesProxy,
198 | CTEArmorRicochet,
199 | CTEBaseBeam,
200 | CTEBeamEntPoint,
201 | CTEBeamEnts,
202 | CTEBeamFollow,
203 | CTEBeamLaser,
204 | CTEBeamPoints,
205 | CTEBeamRing,
206 | CTEBeamRingPoint,
207 | CTEBeamSpline,
208 | CTEBloodSprite,
209 | CTEBloodStream,
210 | CTEBreakModel,
211 | CTEBSPDecal,
212 | CTEBubbles,
213 | CTEBubbleTrail,
214 | CTEClientProjectile,
215 | CTEDecal,
216 | CTEDust,
217 | CTEDynamicLight,
218 | CTEEffectDispatch,
219 | CTEEnergySplash,
220 | CTEExplosion,
221 | CTEFireBullets,
222 | CTEFizz,
223 | CTEFootprintDecal,
224 | CTEFoundryHelpers,
225 | CTEGaussExplosion,
226 | CTEGlowSprite,
227 | CTEImpact,
228 | CTEKillPlayerAttachments,
229 | CTELargeFunnel,
230 | CTEMetalSparks,
231 | CTEMuzzleFlash,
232 | CTEParticleSystem,
233 | CTEPhysicsProp,
234 | CTEPlantBomb,
235 | CTEPlayerAnimEvent,
236 | CTEPlayerDecal,
237 | CTEProjectedDecal,
238 | CTERadioIcon,
239 | CTEShatterSurface,
240 | CTEShowLine,
241 | CTesla,
242 | CTESmoke,
243 | CTESparks,
244 | CTESprite,
245 | CTESpriteSpray,
246 | CTest_ProxyToggle_Networkable,
247 | CTestTraceline,
248 | CTEWorldDecal,
249 | CTriggerPlayerMovement,
250 | CTriggerSoundOperator,
251 | CVGuiScreen,
252 | CVoteController,
253 | CWaterBullet,
254 | CWaterLODControl,
255 | CWeaponAug,
256 | CWeaponAWP,
257 | CWeaponBaseItem,
258 | CWeaponBizon,
259 | CWeaponCSBase,
260 | CWeaponCSBaseGun,
261 | CWeaponCycler,
262 | CWeaponElite,
263 | CWeaponFamas,
264 | CWeaponFiveSeven,
265 | CWeaponG3SG1,
266 | CWeaponGalil,
267 | CWeaponGalilAR,
268 | CWeaponGlock,
269 | CWeaponHKP2000,
270 | CWeaponM249,
271 | CWeaponM3,
272 | CWeaponM4A1,
273 | CWeaponMAC10,
274 | CWeaponMag7,
275 | CWeaponMP5Navy,
276 | CWeaponMP7,
277 | CWeaponMP9,
278 | CWeaponNegev,
279 | CWeaponNOVA,
280 | CWeaponP228,
281 | CWeaponP250,
282 | CWeaponP90,
283 | CWeaponSawedoff,
284 | CWeaponSCAR20,
285 | CWeaponScout,
286 | CWeaponSG550,
287 | CWeaponSG552,
288 | CWeaponSG556,
289 | CWeaponShield,
290 | CWeaponSSG08,
291 | CWeaponTaser,
292 | CWeaponTec9,
293 | CWeaponTMP,
294 | CWeaponUMP45,
295 | CWeaponUSP,
296 | CWeaponXM1014,
297 | CWeaponZoneRepulsor,
298 | CWorld,
299 | CWorldVguiText,
300 | DustTrail,
301 | MovieExplosion,
302 | ParticleSmokeGrenade,
303 | RocketTrail,
304 | SmokeTrail,
305 | SporeExplosion,
306 | SporeTrail,
307 | };
--------------------------------------------------------------------------------
/src/SDK/helpers/fnv.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: fnv.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 16.02.2023 18:15:25
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 16.02.2023 19:17:55
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include
22 | #include
23 |
24 |
25 | // Helper for hashing strings to improve performance (at least thats what he said xd: https://youtu.be/VCsNZ0GRVzo?t=448)
26 | namespace fnv {
27 | inline constexpr uint32_t base = 0x811C9DC5;
28 | inline constexpr uint32_t prime = 0x1000193;
29 |
30 | // Compiletime hash
31 | constexpr uint32_t hashConst(const char* data, const uint32_t value = base) noexcept {
32 | return (data[0] == '\0') ? value : hashConst(&data[1], (value ^ uint32_t(data[0])) * prime);
33 | }
34 |
35 | // Runtime hash
36 | inline uint32_t hash(const char* data) noexcept {
37 | uint32_t hashed = base;
38 |
39 | for (size_t i = 0U; i < strlen(data); ++i) {
40 | hashed ^= data[i];
41 | hashed *= prime;
42 | }
43 |
44 | return hashed;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/SDK/helpers/misc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: misc.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 04.04.2022 22:30:35
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 13.02.2023 21:39:43
8 | * Modified By: 3urobeat
9 | */
10 |
11 | // Credit: https://github.com/seksea/gamesneeze/blob/master/src/utils/utils.hpp
12 | // I'm currently not sure how this works completely
13 |
14 | #pragma once
15 |
16 |
17 | // TODO: Add function docs
18 |
19 |
20 | inline uintptr_t getAbsoluteAddress(uintptr_t pointer, int offset, int size) {
21 | return pointer + *reinterpret_cast(pointer + offset) + size;
22 | }
23 |
24 |
25 | inline void**& getVTable(void *c, size_t offset = 0) {
26 | return *reinterpret_cast((size_t) c + offset);
27 | }
28 |
29 |
30 | template
31 | inline T getVirtualFunc(void *c, size_t i, size_t offset = 0) {
32 | return reinterpret_cast(getVTable(c, offset)[i]);
33 | }
--------------------------------------------------------------------------------
/src/SDK/interfaces/files/iBaseClientDLL.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: iBaseClientDLL.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 04.04.2022 20:04:28
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 14:39:00
8 | * Modified By: 3urobeat
9 | */
10 |
11 |
12 | #pragma once
13 |
14 |
15 | #include
16 |
17 | #include "../../helpers/definitions.h"
18 |
19 |
20 | struct RecvProp;
21 |
22 |
23 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/dt_recv.h#L172
24 | struct RecvTable {
25 | RecvProp *m_pProps;
26 | int m_nProps;
27 | void *m_pDecoder;
28 | char *m_pNetTableName;
29 | bool m_bInitialized;
30 | bool m_bInMainList;
31 | };
32 |
33 |
34 | struct DVariant {
35 | union {
36 | float m_Float;
37 | long m_Int;
38 | char *m_pString;
39 | void *m_pData;
40 | float m_Vector[3];
41 | int64_t m_Int64;
42 | };
43 |
44 | int m_Type;
45 | };
46 |
47 |
48 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/dt_recv.h#L28
49 | struct CRecvProxyData {
50 | const RecvProp* m_pRecvProp;
51 | DVariant m_Value;
52 | int m_iElement;
53 | int m_ObjectID;
54 | };
55 |
56 |
57 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/dt_recv.h#L41
58 | typedef void (*RecvVarProxyFn) (const CRecvProxyData *pData, void *pStruct, void *pOut);
59 |
60 |
61 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/dt_recv.h#L87
62 | struct RecvProp {
63 | char *m_pVarName;
64 | int m_RecvType;
65 | int m_Flags;
66 | int m_StringBufferSize;
67 | bool m_bInsideArray;
68 | const void *m_pExtraData;
69 | RecvProp *m_pArrayProp;
70 | void *m_ArrayLengthProxy;
71 | RecvVarProxyFn m_ProxyFn;
72 | void *m_DataTableProxyFn;
73 | RecvTable *m_pDataTable;
74 | int m_Offset;
75 | int m_ElementStride;
76 | int m_nElements;
77 | const char *m_pParentArrayPropName;
78 | };
79 |
80 |
81 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/client_class.h#L38
82 | class IClientNetworkable;
83 | typedef IClientNetworkable* (*CreateClientClassFn)(int entnum, int serialNum);
84 | typedef IClientNetworkable* (*CreateEventFn)();
85 |
86 |
87 | class ClientClass {
88 | public:
89 | CreateClientClassFn m_pCreateFn;
90 | CreateEventFn *m_pCreateEventFn;
91 | char* m_pNetworkName;
92 | RecvTable *m_pRecvTable;
93 | ClientClass* m_pNext;
94 | EClassIds m_ClassID;
95 | };
96 |
97 |
98 | class IBaseClientDLL {
99 | public:
100 | ClientClass* GetAllClasses() {
101 | typedef ClientClass* (* Fn)(void *);
102 | return getVirtualFunc(this, 8)(this);
103 | }
104 | };
--------------------------------------------------------------------------------
/src/SDK/interfaces/files/iClientEntityList.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: iClientEntityList.h
3 | * Project: files
4 | * Created Date: 16.02.2023 21:45:21
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 15:37:49
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../../classes/cEntity.h"
22 |
23 |
24 | // https://gitlab.com/KittenPopo/csgo-2018-source/-/blob/main/game/server/entitylist.h#L374
25 | class IEntityList {
26 | public:
27 | virtual CEntity *GetClientEntity(int index) = 0;
28 | };
--------------------------------------------------------------------------------
/src/SDK/interfaces/files/iClientMode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: iClientMode.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 04.04.2022 14:49:05
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 18:13:27
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | class IClientMode {
22 |
23 | };
--------------------------------------------------------------------------------
/src/SDK/interfaces/files/ivEngineClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ivEngineClient.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 19.02.2023 19:46:56
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 20:09:58
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../interfaces.h"
22 |
23 |
24 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/cdll_int.h#L194
25 | class IVEngineClient {
26 | public:
27 | typedef struct player_info_s {
28 | int64_t __pad0;
29 | union {
30 | int64_t xuid;
31 | struct {
32 | int xuidlow;
33 | int xuidhigh;
34 | };
35 | };
36 | char name[128];
37 | int userid;
38 | char guid[33];
39 | unsigned int friendsid;
40 | char friendsname[128];
41 | bool fakeplayer;
42 | bool ishltv;
43 | unsigned int customfiles[4];
44 | unsigned char filesdownloaded;
45 | } player_info_t;
46 |
47 | void GetScreenSize(int &width, int &height) {
48 | typedef void (* oGetScreenSize)(void *, int &, int &);
49 | return getVirtualFunc(this, 5)(this, width, height);
50 | }
51 |
52 | bool GetPlayerInfo(int iIndex, player_info_t *pInfo) {
53 | typedef bool (* oGetPlayerInfo)(void *, int, player_info_t *);
54 | return getVirtualFunc(this, 8)(this, iIndex, pInfo);
55 | }
56 |
57 | int GetPlayerForUserID(int UserID) {
58 | typedef int (* oGetPlayerForUserID)(void *, int);
59 | return getVirtualFunc(this, 9)(this, UserID);
60 | }
61 |
62 | int GetLocalPlayer() {
63 | typedef int (* oGetLocalPlayer)(void *);
64 | return getVirtualFunc(this, 12)(this);
65 | }
66 |
67 | void GetViewAngles(QAngle& angle) {
68 | typedef void (* oGetViewAngles)(void *, QAngle &);
69 | return getVirtualFunc(this, 18)(this, angle);
70 | }
71 |
72 | void SetViewAngles(QAngle& angle) {
73 | typedef void (* oSetViewAngles)(void *, QAngle &);
74 | return getVirtualFunc(this, 19)(this, angle);
75 | }
76 |
77 | int GetMaxClients() {
78 | typedef int (* oGetMaxClients)(void *);
79 | return getVirtualFunc(this, 20)(this);
80 | }
81 |
82 | bool IsInGame() {
83 | typedef bool (* oIsInGame)(void *);
84 | return getVirtualFunc(this, 26)(this);
85 | }
86 |
87 | const VMatrix &WorldToScreenMatrix() {
88 | typedef VMatrix &(* oWorldToScreenMatrix)(void *);
89 | return getVirtualFunc( this, 37 )( this );
90 | }
91 |
92 | bool IsTakingScreenshot() {
93 | typedef bool (* oIsTakingScreenshot)(void *);
94 | return getVirtualFunc(this, 92)(this);
95 | }
96 |
97 | void ExecuteClientCmd(const char *szCmdString) {
98 | typedef void (* oExecuteClientCmd)(void *, const char *);
99 | return getVirtualFunc(this, 108)(this, szCmdString);
100 | }
101 |
102 | void ClientCmd_Unrestricted(const char *szCmdString) {
103 | typedef void (* oClientCmd_Unrestricted)(void *, const char *);
104 | return getVirtualFunc(this, 113)(this, szCmdString);
105 | }
106 |
107 | bool IsVoiceRecording() {
108 | typedef bool (* Fn)(void *);
109 | return getVirtualFunc(this, 225)(this);
110 | }
111 | };
--------------------------------------------------------------------------------
/src/SDK/interfaces/files/ivModelRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ivModelRenderer.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 19.02.2023 21:02:00
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 21:02:22
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | struct model_t
22 | {
23 | char name[255];
24 | };
--------------------------------------------------------------------------------
/src/SDK/interfaces/getInterface.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: getInterface.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 03.04.2022 15:38:59
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 14:40:03
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../../main.h"
22 |
23 |
24 | // https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/tier1/interface.h#L69
25 | typedef void* (*InstantiateInterfaceFn)();
26 |
27 | class InterfaceReg {
28 | public:
29 | InstantiateInterfaceFn m_CreateFn;
30 | const char* m_pName;
31 | InterfaceReg* m_pNext;
32 | };
33 |
34 |
35 | // Helper function to dynamically load interfaces
36 | template
37 | T* getInterface(const char* libname, const char* name, bool exactVersion = false) {
38 |
39 | void* handle = dlopen(libname, RTLD_NOLOAD | RTLD_NOW | RTLD_LOCAL); // idk what the __mode param really does, the docs don't help much: https://www.ibm.com/docs/en/zos/2.3.0?topic=functions-dlopen-gain-access-dynamic-link-library ...but gamesneeze & Kali uses those soooo :shrug:
40 |
41 | // Check if lib couldn't be found
42 | if (!handle) {
43 | logger("getInterface() error: Could not open library!");
44 |
45 | // Close lib and return nothing
46 | dlclose(handle);
47 | return nullptr;
48 | }
49 |
50 | // Get address of interface function
51 | void* addr = dlsym(handle, "s_pInterfaceRegs");
52 |
53 | // Check if function couldn't be found
54 | if (!addr) {
55 | logger("getInterface() error: Function address could not be found!");
56 |
57 | // Close lib and return nothing
58 | dlclose(handle);
59 | return nullptr;
60 | }
61 |
62 | // List all interfaces and close lib afterwards
63 | InterfaceReg* interfaces = *reinterpret_cast(addr);
64 |
65 | dlclose(handle);
66 |
67 | // Loop through all interfaces
68 | for (InterfaceReg* cur = interfaces; cur; cur = cur->m_pNext) {
69 |
70 | // Check if interface equals name, once with exact version and once without
71 | if (exactVersion) {
72 | if (strcmp(cur->m_pName, name) == 0) return reinterpret_cast(cur->m_CreateFn());
73 | } else {
74 | if (strstr(cur->m_pName, name) && strlen(cur->m_pName) - 3 == strlen(name)) return reinterpret_cast(cur->m_CreateFn());
75 | }
76 |
77 | }
78 | }
--------------------------------------------------------------------------------
/src/SDK/interfaces/interfaces.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: interfaces.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 03.04.2022 13:48:11
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 20:07:25
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "interfaces.h"
19 |
20 |
21 | typedef IClientMode* (*getClientModeFunc)();
22 |
23 |
24 | // Gets all the interfaces we care about
25 | void Interfaces::initInterfaces() {
26 |
27 | // Get interfaces of the functions I'm trying to "overwrite"/intercept/whatever
28 | client = getInterface("./csgo/bin/linux64/client_client.so", "VClient");
29 | entityList = getInterface("./csgo/bin/linux64/client_client.so", "VClientEntityList");
30 | engineClient = getInterface("./bin/linux64/engine_client.so", "VEngineClient");
31 |
32 |
33 | // Get clientMode
34 | uintptr_t hudProcessInput = reinterpret_cast(getVTable(client)[10]);
35 |
36 | getClientModeFunc getClientMode = reinterpret_cast(getAbsoluteAddress(hudProcessInput + 11, 1, 5)); // Needed for createMove
37 | clientMode = getClientMode();
38 | }
--------------------------------------------------------------------------------
/src/SDK/interfaces/interfaces.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: interfaces.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 03.04.2022 12:51:04
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 21:03:04
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "getInterface.h"
22 |
23 | #include "files/iBaseClientDLL.h"
24 | #include "files/iClientEntityList.h"
25 | #include "files/iClientMode.h"
26 | #include "files/ivEngineClient.h"
27 | #include "files/ivModelRenderer.h"
28 |
29 |
30 | namespace Interfaces {
31 |
32 | // Pointer for every interface which gets populated at runtime
33 | inline IBaseClientDLL *client = nullptr;
34 | inline IClientMode *clientMode = nullptr;
35 | inline IEntityList *entityList = nullptr;
36 | inline IVEngineClient *engineClient = nullptr;
37 |
38 | // Gets all the interfaces we care about
39 | void initInterfaces();
40 |
41 | }
--------------------------------------------------------------------------------
/src/SDK/netvarManager.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: netvarManager.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 16.02.2023 16:28:14
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 13:01:28
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "sdk.h"
19 |
20 |
21 | /**
22 | * Recursively dump all netvars in a table
23 | * Tutorial used to understand what's happening: https://www.youtube.com/watch?v=VCsNZ0GRVzo
24 | * @param baseClass Network Name of the client class
25 | * @param table RecvTable of the client class
26 | * @param offset Pass 0 on initial call, gets incremented by recursive call
27 | */
28 | void NetvarManager::dump(const char *baseClass, RecvTable *table, uint32_t offset) {
29 |
30 | // Iterate over all props this table contains
31 | for (uint32_t i = 0; i < table->m_nProps; i++) { // m_nProps is the amount of total props
32 |
33 | // Get the prop we are looking at in this iteration
34 | RecvProp *thisProp = &table->m_pProps[i];
35 |
36 | // Skip this iteration if prop is null, has a digit as first char or matches "baseclass"
37 | if (!thisProp || isdigit(thisProp->m_pVarName[0])) continue;
38 | if (fnv::hash(thisProp->m_pVarName) == fnv::hashConst("baseclass")) continue; // Some props store base classes which contain other props and we only care about the props themselves
39 |
40 | // Recursively call dump() again if this prop is a table
41 | if (thisProp->m_RecvType == 6 && thisProp->m_pDataTable && thisProp->m_pDataTable->m_pNetTableName[0] == 'D') {
42 | dump(baseClass, thisProp->m_pDataTable, thisProp->m_Offset + offset);
43 | }
44 |
45 | // Get content of this prop and store it in our map
46 | char name[128] = "";
47 |
48 | snprintf(name, 128, "%s->%s", baseClass, thisProp->m_pVarName);
49 |
50 | netvarMap[fnv::hash(name)] = thisProp->m_Offset + offset;
51 |
52 |
53 | // TODO: What does proxy spotted thing do?
54 | }
55 | }
56 |
57 |
58 | /**
59 | * Calls dump() for all classes in clientClass
60 | */
61 | void NetvarManager::setup() {
62 |
63 | logger("Getting netvars...");
64 |
65 | // Iterate over all classes until we reached the end of the linked list
66 | for (ClientClass *clientClass = Interfaces::client->GetAllClasses(); clientClass; clientClass = clientClass->m_pNext) { // m_pNext is a pointer that points to the next linked list entry
67 |
68 | // Check if table is valid and dump everything it contains
69 | if (clientClass->m_pRecvTable) dump(clientClass->m_pNetworkName, clientClass->m_pRecvTable, 0);
70 |
71 | }
72 |
73 | }
--------------------------------------------------------------------------------
/src/SDK/netvarManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: netvarManager.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 18.02.2023 12:58:50
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 15:45:24
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "interfaces/files/iBaseClientDLL.h"
22 | #include "helpers/fnv.h"
23 |
24 |
25 | namespace NetvarManager {
26 |
27 | /**
28 | * Recursively dump all netvars in a table
29 | * Tutorial used to understand what's happening: https://www.youtube.com/watch?v=VCsNZ0GRVzo
30 | * @param baseClass Network Name of the client class
31 | * @param table RecvTable of the client class
32 | * @param offset Pass 0 on initial call, gets incremented by recursive call
33 | */
34 | void dump(const char *baseClass, RecvTable *table, uint32_t offset);
35 |
36 | // Dumps all netvars
37 | void setup();
38 |
39 | // Map which stores all the offsets we retreived
40 | inline std::unordered_map netvarMap;
41 |
42 | }
43 |
44 |
45 | // Macro to access our retreived netvars (backslashes are for multi-line)
46 | //#define NETVAR(func, netvar, type) type& func() {return *reinterpret_cast(uintptr_t(this) + NetvarManager::netvarMap[fnv::hashConst(netvar)]);}; type* func##_ptr() {return reinterpret_cast(uintptr_t(this) + NetvarManager::netvarMap[fnv::hashConst(netvar)]);}
47 | #define NETVAR(funcName, netvar, type) type& funcName() { \
48 | static auto offset = NetvarManager::netvarMap[fnv::hashConst(netvar)]; \
49 | return *reinterpret_cast((uintptr_t) this + offset); \
50 | }
51 |
--------------------------------------------------------------------------------
/src/SDK/sdk.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: sdk.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 14.02.2023 18:03:56
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 15:11:39
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "interfaces/interfaces.h"
22 |
23 | #include "classes/cEntity.h"
24 | #include "classes/cUserCmd.h"
25 |
26 | #include "helpers/fnv.h"
27 | #include "helpers/vector.h"
28 | #include "helpers/definitions.h"
29 |
30 | #include "netvarManager.h"
--------------------------------------------------------------------------------
/src/hooks/files/createMove.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: createmove.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 03.04.2022 00:17:28
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 18:05:36
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../hooks.h"
19 |
20 |
21 | // Hooks createMove, which is called on every tick, and can "send" commands
22 | bool Hooks::CreateMove::createMoveFunc(void *thisptr, float flInputSampleTime, CUserCmd *cmd) {
23 |
24 | // Call the original function before doing anything else
25 | const bool res = originalCreateMove(thisptr, flInputSampleTime, cmd);
26 |
27 |
28 | if (!cmd->tick_count != 0) {
29 |
30 | // https://www.unknowncheats.me/forum/counterstrike-global-offensive/290258-updating-bsendpacket-linux.html
31 | uintptr_t *rbp;
32 | asm volatile("mov %%rbp, %0" : "=r"(rbp));
33 | bool *sendPacket = ((*(bool **)rbp) - (int)24);
34 | CreateMove::sendPacket = true;
35 |
36 |
37 | // Call our modules
38 | Modules::Bhop::run(cmd);
39 |
40 | }
41 |
42 | return res;
43 | }
44 |
--------------------------------------------------------------------------------
/src/hooks/files/sdlHooks.cpp:
--------------------------------------------------------------------------------
1 | // SDL hooks for adding our ImGUI window to an existing OpenGL window (csgo)
2 | // I did not create this file. Source: https://github.com/seksea/gamesneeze/blob/7ec40e08a9964549672da6c735567ff613262097/src/core/hooks/sdlhook.cpp
3 |
4 |
5 | #include "../hooks.h"
6 |
7 |
8 | template
9 | static constexpr auto relativeToAbsolute(uintptr_t address) noexcept
10 | {
11 | return (T)(address + 4 + *reinterpret_cast(address));
12 | }
13 |
14 |
15 | int Hooks::SDL::PollEvent(SDL_Event* event) {
16 | const auto result = pollEvent(event);
17 | if (Menu::isInit) {
18 | Menu::onPollEvent(event, result);
19 | }
20 | return result;
21 | return 1;
22 | }
23 |
24 | void Hooks::SDL::SwapWindow(SDL_Window* window) {
25 | Menu::onSwapWindow(window);
26 | swapWindow(window);
27 | }
28 |
29 |
30 | // Hook SDL, called on load
31 | void Hooks::SDL::hookSDL() {
32 | const auto libSDL = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_NOLOAD);
33 |
34 | swapWindowAddr = relativeToAbsolute(uintptr_t(dlsym(libSDL, "SDL_GL_SwapWindow")) + 2);
35 | if (swapWindowAddr) {
36 | swapWindow = *reinterpret_cast(swapWindowAddr);
37 | *reinterpret_cast(swapWindowAddr) = SwapWindow;
38 | } // Add else for error handling
39 |
40 | pollEventAddr = relativeToAbsolute(uintptr_t(dlsym(libSDL, "SDL_PollEvent")) + 2);
41 | if (pollEventAddr) {
42 | pollEvent = *reinterpret_cast(pollEventAddr);
43 | *reinterpret_cast(pollEventAddr) = PollEvent;
44 | } // Add else for error handling
45 | }
46 |
47 |
48 | // Unhook SDL, called on unload
49 | void Hooks::SDL::unhookSDL() {
50 | *reinterpret_cast(swapWindowAddr) = swapWindow;
51 | *reinterpret_cast(pollEventAddr) = pollEvent;
52 |
53 | /* if (*reinterpret_cast(swapWindowAddr)!=swapWindow || *reinterpret_cast(pollEventAddr)!=pollEvent) {
54 | //Error
55 | } */
56 | }
--------------------------------------------------------------------------------
/src/hooks/files/vmtHook.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: vmtHook.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 05.04.2022 19:25:04
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 18:35:35
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../hooks.h"
19 |
20 |
21 | int pageSize = sysconf(_SC_PAGE_SIZE);
22 | int pageMask = ~(pageSize - 1);
23 |
24 |
25 | /**
26 | * Hooks a function by intercepting virtual method calls
27 | * @param interface Pointer to the base address of the virtual table
28 | * @param hookFunction Pointer to the function that should be hooked
29 | * @param offset Position of the desired function in the virtual method table
30 | * @returns Pointer to the original function
31 | */
32 | void *Hooks::VMT::hookVMT(void *interface, void *hookFunction, int offset) {
33 |
34 | // Get pointer to the first function in the vtable
35 | intptr_t vTableBase = *((intptr_t *) interface);
36 |
37 | // Add offset to our base pointer to find the function we are searching for
38 | intptr_t vTableFunc = vTableBase + sizeof(intptr_t) * offset;
39 |
40 | // Get the original function
41 | intptr_t vTableOriginalFunc = *((intptr_t *) vTableFunc);
42 |
43 |
44 | // Change protection of the memory area we'd like to modify by adding WRITE permission
45 | mprotect((void *) (vTableFunc & pageMask), pageSize, PROT_READ | PROT_WRITE | PROT_EXEC);
46 |
47 | // Overwrite the pointer to the original function in the VMT with the pointer to our function
48 | *((intptr_t *) vTableFunc) = (intptr_t) hookFunction;
49 | //memcpy(&vTableFunc, hookFunction, sizeof(intptr_t)); // Alternative?
50 |
51 | // Restore memory protection flags to rx only
52 | mprotect((void *) (vTableFunc & pageMask), pageSize, PROT_READ | PROT_EXEC);
53 |
54 |
55 | // Return pointer to the original function
56 | return (void *) vTableOriginalFunc;
57 | }
--------------------------------------------------------------------------------
/src/hooks/hooks.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: hooks.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 01.04.2022 17:38:11
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 18:16:26
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "hooks.h"
19 |
20 |
21 | /**
22 | * Initialize all hooks
23 | */
24 | void Hooks::initHooks() {
25 |
26 | // Hook SDL so we can draw our menu
27 | SDL::hookSDL();
28 |
29 | // Hook createMove
30 | CreateMove::originalCreateMove = (CreateMove::createMoveFuncSignature) VMT::hookVMT(Interfaces::clientMode, (void*) CreateMove::createMoveFunc, 25);
31 |
32 | }
33 |
34 |
35 | /**
36 | * Unload hooks
37 | */
38 | void Hooks::unloadHooks() {
39 |
40 | SDL::unhookSDL();
41 |
42 | VMT::hookVMT(Interfaces::clientMode, (void*)CreateMove::originalCreateMove, 25);
43 |
44 | }
--------------------------------------------------------------------------------
/src/hooks/hooks.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: hooks.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 01.04.2022 17:38:16
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 15:16:05
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../main.h"
22 |
23 |
24 | namespace Hooks {
25 | void initHooks();
26 | void unloadHooks();
27 |
28 |
29 | // SDL hooks
30 | namespace SDL {
31 | void hookSDL();
32 | void unhookSDL();
33 |
34 | inline uintptr_t swapWindowAddr;
35 | inline std::add_pointer_t swapWindow;
36 | inline uintptr_t pollEventAddr;
37 | inline std::add_pointer_t pollEvent;
38 |
39 | void SwapWindow(SDL_Window* window);
40 | int PollEvent(SDL_Event* event);
41 | }
42 |
43 |
44 | // VMT hook
45 | namespace VMT {
46 | void *hookVMT(void *interface, void *hookFunction, int offset);
47 | }
48 |
49 |
50 | // createMove hook
51 | namespace CreateMove {
52 | using createMoveFuncSignature = bool (*)(void *thisptr, float flInputSampleTime, CUserCmd *cmd);
53 |
54 | bool createMoveFunc(void *thisptr, float flInputSampleTime, CUserCmd *cmd);
55 | inline createMoveFuncSignature originalCreateMove;
56 |
57 | inline bool sendPacket;
58 | }
59 | }
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: csgo-simple-linux-cheat.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 31.03.2022 22:52:29
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 15:44:21
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "main.h"
19 |
20 |
21 | // Make a logger call slightly shorter
22 | void logger(const char* str) { std::cout << str << std::endl; }
23 | void logger(std::string str) { std::cout << str.c_str() << std::endl; }
24 |
25 |
26 | // Assigning lib load and unload functions
27 | void __attribute__((constructor)) libLoad();
28 | void __attribute__((destructor)) libUnload();
29 |
30 |
31 | // Called by entry point in a new thread
32 | void MainThread() {
33 |
34 | logger("Loading hooks & interfaces...");
35 |
36 | // Initialize interfaces
37 | Interfaces::initInterfaces();
38 |
39 | // Initialize netvars
40 | NetvarManager::setup();
41 |
42 | // Initialize hooks
43 | Hooks::initHooks();
44 |
45 |
46 | // Temporary main loop for modules which aren't createMove dependent
47 | while(true) {
48 | Modules::Radar::run();
49 | }
50 |
51 | }
52 |
53 |
54 | // Entrypoint, is called on load
55 | void libLoad() {
56 |
57 | std::thread mainThread(MainThread); // Run the cheat itself in a new thread
58 |
59 | // ...and detach thread
60 | mainThread.detach();
61 |
62 | }
63 |
64 |
65 | // Called on unload (does somehow not work atm)
66 | void libUnload() {
67 |
68 | logger("Unloading hooks...");
69 |
70 | // Unload hooks
71 | Hooks::unloadHooks();
72 |
73 | }
--------------------------------------------------------------------------------
/src/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: main.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 11:55:11
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 13:27:31
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | // Libs
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 |
35 | // Export functions declared in main.cpp
36 | extern void logger(const char* str);
37 | extern void logger(std::string str);
38 |
39 |
40 | // Import subfolder files
41 | #include "menu/config.h"
42 | #include "SDK/helpers/misc.h"
43 | #include "SDK/sdk.h"
44 | #include "modules/modules.h"
45 | #include "hooks/hooks.h"
46 | #include "menu/menu.h"
47 |
48 |
49 | inline std::string version = "0.0.1";
50 |
51 | inline int screenSizeX;
52 | inline int screenSizeY;
53 |
54 |
55 | extern void libUnload();
--------------------------------------------------------------------------------
/src/menu/ImGUI/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2019 Omar Cornut
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 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imconfig.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI
3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
5 | //-----------------------------------------------------------------------------
6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
7 | // B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
8 | // If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
9 | // the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
10 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
11 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
12 | //-----------------------------------------------------------------------------
13 |
14 | #pragma once
15 |
16 | #include
17 | #include
18 |
19 | //---- Define assertion handler. Defaults to calling assert().
20 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
21 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
22 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
23 |
24 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
25 | // Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
26 | //#define IMGUI_API __declspec( dllexport )
27 | //#define IMGUI_API __declspec( dllimport )
28 |
29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
30 | #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
31 |
32 | //---- Disable all of Dear ImGui or don't implement standard windows.
33 | // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
34 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
35 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
36 | //#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
37 |
38 | //---- Don't implement some functions to reduce linkage requirements.
39 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
41 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
42 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
43 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
44 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
45 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
46 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
47 |
48 | //---- Include imgui_user.h at the end of imgui.h as a convenience
49 | //#define IMGUI_INCLUDE_IMGUI_USER_H
50 |
51 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
52 | #ifdef _WIN32
53 | #define IMGUI_USE_BGRA_PACKED_COLOR
54 | #endif
55 |
56 | //---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
57 | //#define IMGUI_USE_WCHAR32
58 |
59 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
60 | // By default the embedded implementations are declared static and not available outside of imgui cpp files.
61 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
62 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
63 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
64 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
65 |
66 | //---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
67 | // Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
68 | // #define IMGUI_USE_STB_SPRINTF
69 |
70 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
71 | // This will be inlined as part of ImVec2 and ImVec4 class declarations.
72 | /*
73 | #define IM_VEC2_CLASS_EXTRA \
74 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
75 | operator MyVec2() const { return MyVec2(x,y); }
76 |
77 | #define IM_VEC4_CLASS_EXTRA \
78 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
79 | operator MyVec4() const { return MyVec4(x,y,z,w); }
80 | */
81 |
82 | #define IM_VEC4_CLASS_EXTRA \
83 | ImVec4(const std::array& color) noexcept { x = color[0]; y = color[1]; z = color[2]; w = color[3]; }
84 |
85 | #define IM_VEC2_CLASS_EXTRA \
86 | auto operator==(const ImVec2& other) const { return x == other.x && y == other.y; } \
87 | auto operator!=(const ImVec2& other) const { return !(*this == other); }
88 |
89 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
90 | // Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
91 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
92 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
93 | //#define ImDrawIdx unsigned int
94 |
95 | //---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
96 | //struct ImDrawList;
97 | //struct ImDrawCmd;
98 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
99 | //#define ImDrawCallback MyImDrawCallback
100 |
101 | //---- Debug Tools: Macro to break in Debugger
102 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
103 | //#define IM_DEBUG_BREAK IM_ASSERT(0)
104 | //#define IM_DEBUG_BREAK __debugbreak()
105 |
106 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
107 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
108 | // This adds a small runtime cost which is why it is not enabled by default.
109 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
110 |
111 | //---- Debug Tools: Enable slower asserts
112 | //#define IMGUI_DEBUG_PARANOID
113 |
114 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
115 | /*
116 | namespace ImGui
117 | {
118 | void MyFunction(const char* name, const MyMatrix44& v);
119 | }
120 | */
121 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imgui_impl_opengl3.cpp:
--------------------------------------------------------------------------------
1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
2 | // - Desktop GL: 2.x 3.x 4.x
3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
5 |
6 | // Implemented features:
7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
9 |
10 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
11 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
12 | // https://github.com/ocornut/imgui
13 |
14 | // CHANGELOG
15 | // (minor and older changes stripped away, please see git history for details)
16 | // 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
17 | // 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
18 | // 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
19 | // 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
20 | // 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
21 | // 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
22 | // 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
23 | // 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
24 | // 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
25 | // 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
26 | // 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
27 | // 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
28 | // 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
29 | // 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
30 | // 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
31 | // 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
32 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
33 | // 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT) / GL_CLIP_ORIGIN.
34 | // 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
35 | // 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
36 | // 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
37 | // 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
38 | // 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
39 | // 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
40 | // 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
41 | // 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
42 | // 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
43 | // 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
44 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
45 | // 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
46 | // 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
47 | // 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
48 | // 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
49 | // 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
50 | // 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
51 |
52 | //----------------------------------------
53 | // OpenGL GLSL GLSL
54 | // version version string
55 | //----------------------------------------
56 | // 2.0 110 "#version 110"
57 | // 2.1 120 "#version 120"
58 | // 3.0 130 "#version 130"
59 | // 3.1 140 "#version 140"
60 | // 3.2 150 "#version 150"
61 | // 3.3 330 "#version 330 core"
62 | // 4.0 400 "#version 400 core"
63 | // 4.1 410 "#version 410 core"
64 | // 4.2 420 "#version 410 core"
65 | // 4.3 430 "#version 430 core"
66 | // ES 2.0 100 "#version 100" = WebGL 1.0
67 | // ES 3.0 300 "#version 300 es" = WebGL 2.0
68 | //----------------------------------------
69 |
70 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
71 | #define _CRT_SECURE_NO_WARNINGS
72 | #endif
73 |
74 | #include "imgui.h"
75 | #include "imgui_impl_opengl3.h"
76 | #include
77 | #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
78 | #include // intptr_t
79 | #else
80 | #include // intptr_t
81 | #endif
82 |
83 | // About Desktop OpenGL function loaders:
84 | // Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
85 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
86 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
87 | #include "GL/gl3w.h" // Needs to be initialized with gl3wInit() in user's code
88 |
89 | // Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
90 | #if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
91 | #define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
92 | #else
93 | #define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
94 | #endif
95 |
96 | // OpenGL Data
97 | static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
98 | static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
99 | static GLuint g_FontTexture = 0;
100 | static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
101 | static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
102 | static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
103 | static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
104 |
105 | // Functions
106 | bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
107 | {
108 | // Query for GL version (e.g. 320 for GL 3.2)
109 | #if !defined(IMGUI_IMPL_OPENGL_ES2)
110 | GLint major, minor;
111 | glGetIntegerv(GL_MAJOR_VERSION, &major);
112 | glGetIntegerv(GL_MINOR_VERSION, &minor);
113 | g_GlVersion = (GLuint)(major * 100 + minor * 10);
114 | #else
115 | g_GlVersion = 200; // GLES 2
116 | #endif
117 |
118 | // Setup back-end capabilities flags
119 | ImGuiIO& io = ImGui::GetIO();
120 | io.BackendRendererName = "imgui_impl_opengl3";
121 | #if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
122 | if (g_GlVersion >= 320)
123 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
124 | #endif
125 |
126 | // Store GLSL version string so we can refer to it later in case we recreate shaders.
127 | // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
128 | #if defined(IMGUI_IMPL_OPENGL_ES2)
129 | if (glsl_version == NULL)
130 | glsl_version = "#version 100";
131 | #elif defined(IMGUI_IMPL_OPENGL_ES3)
132 | if (glsl_version == NULL)
133 | glsl_version = "#version 300 es";
134 | #elif defined(__APPLE__)
135 | if (glsl_version == NULL)
136 | glsl_version = "#version 150";
137 | #else
138 | if (glsl_version == NULL)
139 | glsl_version = "#version 130";
140 | #endif
141 | IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
142 | strcpy(g_GlslVersionString, glsl_version);
143 | strcat(g_GlslVersionString, "\n");
144 |
145 | // Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
146 | // The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
147 | // If auto-detection fails or doesn't select the same GL loader file as used by your application,
148 | // you are likely to get a crash below.
149 | // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
150 | const char* gl_loader = "Unknown";
151 | IM_UNUSED(gl_loader);
152 | #if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
153 | gl_loader = "GL3W";
154 | #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
155 | gl_loader = "GLEW";
156 | #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
157 | gl_loader = "GLAD";
158 | #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
159 | gl_loader = "glbinding2";
160 | #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
161 | gl_loader = "glbinding3";
162 | #elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
163 | gl_loader = "custom";
164 | #else
165 | gl_loader = "none";
166 | #endif
167 |
168 | // Make a dummy GL call (we don't actually need the result)
169 | // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
170 | // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
171 | GLint current_texture;
172 | glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
173 |
174 | return true;
175 | }
176 |
177 | void ImGui_ImplOpenGL3_Shutdown()
178 | {
179 | ImGui_ImplOpenGL3_DestroyDeviceObjects();
180 | }
181 |
182 | void ImGui_ImplOpenGL3_NewFrame()
183 | {
184 | if (!g_ShaderHandle)
185 | ImGui_ImplOpenGL3_CreateDeviceObjects();
186 | }
187 |
188 | static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
189 | {
190 | // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
191 | glEnable(GL_BLEND);
192 | glBlendEquation(GL_FUNC_ADD);
193 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
194 | glDisable(GL_CULL_FACE);
195 | glDisable(GL_DEPTH_TEST);
196 | glEnable(GL_SCISSOR_TEST);
197 | #ifdef GL_POLYGON_MODE
198 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
199 | #endif
200 |
201 | // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
202 | bool clip_origin_lower_left = true;
203 | #if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
204 | GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
205 | if (current_clip_origin == GL_UPPER_LEFT)
206 | clip_origin_lower_left = false;
207 | #endif
208 |
209 | // Setup viewport, orthographic projection matrix
210 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
211 | glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
212 | float L = draw_data->DisplayPos.x;
213 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
214 | float T = draw_data->DisplayPos.y;
215 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
216 | if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
217 | const float ortho_projection[4][4] =
218 | {
219 | { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
220 | { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
221 | { 0.0f, 0.0f, -1.0f, 0.0f },
222 | { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
223 | };
224 | glUseProgram(g_ShaderHandle);
225 | glUniform1i(g_AttribLocationTex, 0);
226 | glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
227 | #ifdef GL_SAMPLER_BINDING
228 | glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
229 | #endif
230 |
231 | (void)vertex_array_object;
232 | #ifndef IMGUI_IMPL_OPENGL_ES2
233 | glBindVertexArray(vertex_array_object);
234 | #endif
235 |
236 | // Bind vertex/index buffers and setup attributes for ImDrawVert
237 | glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
238 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
239 | glEnableVertexAttribArray(g_AttribLocationVtxPos);
240 | glEnableVertexAttribArray(g_AttribLocationVtxUV);
241 | glEnableVertexAttribArray(g_AttribLocationVtxColor);
242 | glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
243 | glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
244 | glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
245 | }
246 |
247 | // OpenGL3 Render function.
248 | // (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
249 | // Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
250 | void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
251 | {
252 | // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
253 | int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
254 | int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
255 | if (fb_width <= 0 || fb_height <= 0)
256 | return;
257 |
258 | // Backup GL state
259 | GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
260 | glActiveTexture(GL_TEXTURE0);
261 | GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
262 | GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
263 | #ifdef GL_SAMPLER_BINDING
264 | GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
265 | #endif
266 | GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
267 | #ifndef IMGUI_IMPL_OPENGL_ES2
268 | GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
269 | #endif
270 | #ifdef GL_POLYGON_MODE
271 | GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
272 | #endif
273 | GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
274 | GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
275 | GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
276 | GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
277 | GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
278 | GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
279 | GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
280 | GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
281 | GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
282 | GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
283 | GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
284 | GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
285 |
286 | // Setup desired GL state
287 | // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
288 | // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
289 | GLuint vertex_array_object = 0;
290 | #ifndef IMGUI_IMPL_OPENGL_ES2
291 | glGenVertexArrays(1, &vertex_array_object);
292 | #endif
293 | ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
294 |
295 | // Will project scissor/clipping rectangles into framebuffer space
296 | ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
297 | ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
298 |
299 | // Render command lists
300 | for (int n = 0; n < draw_data->CmdListsCount; n++)
301 | {
302 | const ImDrawList* cmd_list = draw_data->CmdLists[n];
303 |
304 | // Upload vertex/index buffers
305 | glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
306 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
307 |
308 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
309 | {
310 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
311 | if (pcmd->UserCallback != NULL)
312 | {
313 | // User callback, registered via ImDrawList::AddCallback()
314 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
315 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
316 | ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
317 | else
318 | pcmd->UserCallback(cmd_list, pcmd);
319 | }
320 | else
321 | {
322 | // Project scissor/clipping rectangles into framebuffer space
323 | ImVec4 clip_rect;
324 | clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
325 | clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
326 | clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
327 | clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
328 |
329 | if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
330 | {
331 | // Apply scissor/clipping rectangle
332 | glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
333 |
334 | // Bind texture, Draw
335 | glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
336 | #if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
337 | if (g_GlVersion >= 320)
338 | glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
339 | else
340 | #endif
341 | glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
342 | }
343 | }
344 | }
345 | }
346 |
347 | // Destroy the temporary VAO
348 | #ifndef IMGUI_IMPL_OPENGL_ES2
349 | glDeleteVertexArrays(1, &vertex_array_object);
350 | #endif
351 |
352 | // Restore modified GL state
353 | glUseProgram(last_program);
354 | glBindTexture(GL_TEXTURE_2D, last_texture);
355 | #ifdef GL_SAMPLER_BINDING
356 | glBindSampler(0, last_sampler);
357 | #endif
358 | glActiveTexture(last_active_texture);
359 | #ifndef IMGUI_IMPL_OPENGL_ES2
360 | glBindVertexArray(last_vertex_array_object);
361 | #endif
362 | glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
363 | glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
364 | glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
365 | if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
366 | if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
367 | if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
368 | if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
369 | #ifdef GL_POLYGON_MODE
370 | glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
371 | #endif
372 | glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
373 | glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
374 | }
375 |
376 | bool ImGui_ImplOpenGL3_CreateFontsTexture()
377 | {
378 | // Build texture atlas
379 | ImGuiIO& io = ImGui::GetIO();
380 | unsigned char* pixels;
381 | int width, height;
382 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
383 |
384 | // Upload texture to graphics system
385 | GLint last_texture;
386 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
387 | glGenTextures(1, &g_FontTexture);
388 | glBindTexture(GL_TEXTURE_2D, g_FontTexture);
389 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
390 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
391 | #ifdef GL_UNPACK_ROW_LENGTH
392 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
393 | #endif
394 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
395 |
396 | // Store our identifier
397 | io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
398 |
399 | // Restore state
400 | glBindTexture(GL_TEXTURE_2D, last_texture);
401 |
402 | return true;
403 | }
404 |
405 | void ImGui_ImplOpenGL3_DestroyFontsTexture()
406 | {
407 | if (g_FontTexture)
408 | {
409 | ImGuiIO& io = ImGui::GetIO();
410 | glDeleteTextures(1, &g_FontTexture);
411 | io.Fonts->TexID = 0;
412 | g_FontTexture = 0;
413 | }
414 | }
415 |
416 | // If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
417 | static bool CheckShader(GLuint handle, const char* desc)
418 | {
419 | GLint status = 0, log_length = 0;
420 | glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
421 | glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
422 | if ((GLboolean)status == GL_FALSE)
423 | fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
424 | if (log_length > 1)
425 | {
426 | ImVector buf;
427 | buf.resize((int)(log_length + 1));
428 | glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
429 | fprintf(stderr, "%s\n", buf.begin());
430 | }
431 | return (GLboolean)status == GL_TRUE;
432 | }
433 |
434 | // If you get an error please report on GitHub. You may try different GL context version or GLSL version.
435 | static bool CheckProgram(GLuint handle, const char* desc)
436 | {
437 | GLint status = 0, log_length = 0;
438 | glGetProgramiv(handle, GL_LINK_STATUS, &status);
439 | glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
440 | if ((GLboolean)status == GL_FALSE)
441 | fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
442 | if (log_length > 1)
443 | {
444 | ImVector buf;
445 | buf.resize((int)(log_length + 1));
446 | glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
447 | fprintf(stderr, "%s\n", buf.begin());
448 | }
449 | return (GLboolean)status == GL_TRUE;
450 | }
451 |
452 | bool ImGui_ImplOpenGL3_CreateDeviceObjects()
453 | {
454 | // Backup GL state
455 | GLint last_texture, last_array_buffer;
456 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
457 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
458 | #ifndef IMGUI_IMPL_OPENGL_ES2
459 | GLint last_vertex_array;
460 | glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
461 | #endif
462 |
463 | // Parse GLSL version string
464 | int glsl_version = 130;
465 | sscanf(g_GlslVersionString, "#version %d", &glsl_version);
466 |
467 | const GLchar* vertex_shader_glsl_120 =
468 | "uniform mat4 ProjMtx;\n"
469 | "attribute vec2 Position;\n"
470 | "attribute vec2 UV;\n"
471 | "attribute vec4 Color;\n"
472 | "varying vec2 Frag_UV;\n"
473 | "varying vec4 Frag_Color;\n"
474 | "void main()\n"
475 | "{\n"
476 | " Frag_UV = UV;\n"
477 | " Frag_Color = Color;\n"
478 | " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
479 | "}\n";
480 |
481 | const GLchar* vertex_shader_glsl_130 =
482 | "uniform mat4 ProjMtx;\n"
483 | "in vec2 Position;\n"
484 | "in vec2 UV;\n"
485 | "in vec4 Color;\n"
486 | "out vec2 Frag_UV;\n"
487 | "out vec4 Frag_Color;\n"
488 | "void main()\n"
489 | "{\n"
490 | " Frag_UV = UV;\n"
491 | " Frag_Color = Color;\n"
492 | " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
493 | "}\n";
494 |
495 | const GLchar* vertex_shader_glsl_300_es =
496 | "precision mediump float;\n"
497 | "layout (location = 0) in vec2 Position;\n"
498 | "layout (location = 1) in vec2 UV;\n"
499 | "layout (location = 2) in vec4 Color;\n"
500 | "uniform mat4 ProjMtx;\n"
501 | "out vec2 Frag_UV;\n"
502 | "out vec4 Frag_Color;\n"
503 | "void main()\n"
504 | "{\n"
505 | " Frag_UV = UV;\n"
506 | " Frag_Color = Color;\n"
507 | " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
508 | "}\n";
509 |
510 | const GLchar* vertex_shader_glsl_410_core =
511 | "layout (location = 0) in vec2 Position;\n"
512 | "layout (location = 1) in vec2 UV;\n"
513 | "layout (location = 2) in vec4 Color;\n"
514 | "uniform mat4 ProjMtx;\n"
515 | "out vec2 Frag_UV;\n"
516 | "out vec4 Frag_Color;\n"
517 | "void main()\n"
518 | "{\n"
519 | " Frag_UV = UV;\n"
520 | " Frag_Color = Color;\n"
521 | " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
522 | "}\n";
523 |
524 | const GLchar* fragment_shader_glsl_120 =
525 | "#ifdef GL_ES\n"
526 | " precision mediump float;\n"
527 | "#endif\n"
528 | "uniform sampler2D Texture;\n"
529 | "varying vec2 Frag_UV;\n"
530 | "varying vec4 Frag_Color;\n"
531 | "void main()\n"
532 | "{\n"
533 | " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
534 | "}\n";
535 |
536 | const GLchar* fragment_shader_glsl_130 =
537 | "uniform sampler2D Texture;\n"
538 | "in vec2 Frag_UV;\n"
539 | "in vec4 Frag_Color;\n"
540 | "out vec4 Out_Color;\n"
541 | "void main()\n"
542 | "{\n"
543 | " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
544 | "}\n";
545 |
546 | const GLchar* fragment_shader_glsl_300_es =
547 | "precision mediump float;\n"
548 | "uniform sampler2D Texture;\n"
549 | "in vec2 Frag_UV;\n"
550 | "in vec4 Frag_Color;\n"
551 | "layout (location = 0) out vec4 Out_Color;\n"
552 | "void main()\n"
553 | "{\n"
554 | " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
555 | "}\n";
556 |
557 | const GLchar* fragment_shader_glsl_410_core =
558 | "in vec2 Frag_UV;\n"
559 | "in vec4 Frag_Color;\n"
560 | "uniform sampler2D Texture;\n"
561 | "layout (location = 0) out vec4 Out_Color;\n"
562 | "void main()\n"
563 | "{\n"
564 | " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
565 | "}\n";
566 |
567 | // Select shaders matching our GLSL versions
568 | const GLchar* vertex_shader = NULL;
569 | const GLchar* fragment_shader = NULL;
570 | if (glsl_version < 130)
571 | {
572 | vertex_shader = vertex_shader_glsl_120;
573 | fragment_shader = fragment_shader_glsl_120;
574 | }
575 | else if (glsl_version >= 410)
576 | {
577 | vertex_shader = vertex_shader_glsl_410_core;
578 | fragment_shader = fragment_shader_glsl_410_core;
579 | }
580 | else if (glsl_version == 300)
581 | {
582 | vertex_shader = vertex_shader_glsl_300_es;
583 | fragment_shader = fragment_shader_glsl_300_es;
584 | }
585 | else
586 | {
587 | vertex_shader = vertex_shader_glsl_130;
588 | fragment_shader = fragment_shader_glsl_130;
589 | }
590 |
591 | // Create shaders
592 | const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
593 | g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
594 | glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
595 | glCompileShader(g_VertHandle);
596 | CheckShader(g_VertHandle, "vertex shader");
597 |
598 | const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
599 | g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
600 | glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
601 | glCompileShader(g_FragHandle);
602 | CheckShader(g_FragHandle, "fragment shader");
603 |
604 | g_ShaderHandle = glCreateProgram();
605 | glAttachShader(g_ShaderHandle, g_VertHandle);
606 | glAttachShader(g_ShaderHandle, g_FragHandle);
607 | glLinkProgram(g_ShaderHandle);
608 | CheckProgram(g_ShaderHandle, "shader program");
609 |
610 | g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
611 | g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
612 | g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
613 | g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
614 | g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
615 |
616 | // Create buffers
617 | glGenBuffers(1, &g_VboHandle);
618 | glGenBuffers(1, &g_ElementsHandle);
619 |
620 | ImGui_ImplOpenGL3_CreateFontsTexture();
621 |
622 | // Restore modified GL state
623 | glBindTexture(GL_TEXTURE_2D, last_texture);
624 | glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
625 | #ifndef IMGUI_IMPL_OPENGL_ES2
626 | glBindVertexArray(last_vertex_array);
627 | #endif
628 |
629 | return true;
630 | }
631 |
632 | void ImGui_ImplOpenGL3_DestroyDeviceObjects()
633 | {
634 | if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
635 | if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
636 | if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); }
637 | if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); }
638 | if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
639 | if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
640 | if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
641 |
642 | ImGui_ImplOpenGL3_DestroyFontsTexture();
643 | }
644 |
645 | ImTextureID ImGui_CreateTextureRGBA(int width, int height, const unsigned char* data)
646 | {
647 | GLint last_texture;
648 | GLuint texture;
649 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
650 | glGenTextures(1, &texture);
651 | glBindTexture(GL_TEXTURE_2D, texture);
652 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
653 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
654 | #ifdef GL_UNPACK_ROW_LENGTH
655 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
656 | #endif
657 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
658 |
659 | glBindTexture(GL_TEXTURE_2D, last_texture);
660 |
661 | return reinterpret_cast(texture);
662 | }
663 |
664 | void ImGui_DestroyTexture(ImTextureID texture)
665 | {
666 | glDeleteTextures(1, reinterpret_cast(&texture));
667 | }
668 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imgui_impl_opengl3.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
2 | // - Desktop GL: 2.x 3.x 4.x
3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
5 |
6 | // Implemented features:
7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
9 |
10 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
11 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
12 | // https://github.com/ocornut/imgui
13 |
14 | // About Desktop OpenGL function loaders:
15 | // Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
16 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
17 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
18 |
19 | // About GLSL version:
20 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
21 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
22 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
23 |
24 | #pragma once
25 | #include "imgui.h" // IMGUI_IMPL_API
26 |
27 | // Backend API
28 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
29 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
30 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
31 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
32 |
33 | // (Optional) Called by Init/NewFrame/Shutdown
34 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
35 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
36 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
37 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
38 |
39 | IMGUI_IMPL_API ImTextureID ImGui_CreateTextureRGBA(int width, int height, const unsigned char* data);
40 | IMGUI_IMPL_API void ImGui_DestroyTexture(ImTextureID texture);
41 |
42 | // Specific OpenGL ES versions
43 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
44 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
45 |
46 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W
47 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imgui_impl_sdl.cpp:
--------------------------------------------------------------------------------
1 | // dear imgui: Platform Binding for SDL2
2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
3 | // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
4 | // (Requires: SDL 2.0. Prefer SDL 2.0.4+ for full feature support.)
5 |
6 | // Implemented features:
7 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
8 | // [X] Platform: Clipboard support.
9 | // [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
10 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
11 | // Missing features:
12 | // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
13 |
14 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
15 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
16 | // https://github.com/ocornut/imgui
17 |
18 | // CHANGELOG
19 | // (minor and older changes stripped away, please see git history for details)
20 | // 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
21 | // 2020-02-20: Inputs: Fixed mapping for ImGuiKey_KeyPadEnter (using SDL_SCANCODE_KP_ENTER instead of SDL_SCANCODE_RETURN2).
22 | // 2019-12-17: Inputs: On Wayland, use SDL_GetMouseState (because there is no global mouse state).
23 | // 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
24 | // 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
25 | // 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
26 | // 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
27 | // 2018-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls.
28 | // 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
29 | // 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'.
30 | // 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
31 | // 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
32 | // 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples.
33 | // 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter.
34 | // 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText).
35 | // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
36 | // 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
37 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
38 | // 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
39 | // 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
40 | // 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
41 | // 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
42 | // 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
43 | // 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
44 | // 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
45 | // 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
46 |
47 | #include "imgui.h"
48 | #include "imgui_impl_sdl.h"
49 |
50 | // SDL
51 | #include
52 | #include
53 | #if defined(__APPLE__)
54 | #include "TargetConditionals.h"
55 | #endif
56 |
57 | #define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE SDL_VERSION_ATLEAST(2,0,4)
58 | #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
59 |
60 | // Data
61 | static SDL_Window* g_Window = NULL;
62 | static Uint64 g_Time = 0;
63 | static bool g_MousePressed[5] = { false, false, false, false, false };
64 | static char* g_ClipboardTextData = NULL;
65 |
66 | static const char* ImGui_ImplSDL2_GetClipboardText(void*)
67 | {
68 | if (g_ClipboardTextData)
69 | SDL_free(g_ClipboardTextData);
70 | g_ClipboardTextData = SDL_GetClipboardText();
71 | return g_ClipboardTextData;
72 | }
73 |
74 | static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
75 | {
76 | SDL_SetClipboardText(text);
77 | }
78 |
79 | // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
80 | // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
81 | // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
82 | // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
83 | // If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
84 | bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
85 | {
86 | ImGuiIO& io = ImGui::GetIO();
87 | switch (event->type)
88 | {
89 | case SDL_MOUSEWHEEL:
90 | {
91 | if (event->wheel.x > 0) io.MouseWheelH += 1;
92 | if (event->wheel.x < 0) io.MouseWheelH -= 1;
93 | if (event->wheel.y > 0) io.MouseWheel += 1;
94 | if (event->wheel.y < 0) io.MouseWheel -= 1;
95 | return true;
96 | }
97 | case SDL_MOUSEBUTTONDOWN:
98 | {
99 | if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
100 | if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
101 | if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
102 | if (event->button.button == SDL_BUTTON_X1) g_MousePressed[3] = true;
103 | if (event->button.button == SDL_BUTTON_X2) g_MousePressed[4] = true;
104 |
105 | return true;
106 | }
107 | case SDL_TEXTINPUT:
108 | {
109 | io.AddInputCharactersUTF8(event->text.text);
110 | return true;
111 | }
112 | case SDL_KEYDOWN:
113 | case SDL_KEYUP:
114 | {
115 | int key = event->key.keysym.scancode;
116 | IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
117 | io.KeysDown[key] = (event->type == SDL_KEYDOWN);
118 | io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
119 | io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
120 | io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
121 | #ifdef _WIN32
122 | io.KeySuper = false;
123 | #else
124 | io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
125 | #endif
126 | return true;
127 | }
128 | case SDL_MOUSEMOTION:
129 | return true;
130 | }
131 | return false;
132 | }
133 |
134 | static bool ImGui_ImplSDL2_Init(SDL_Window* window)
135 | {
136 | g_Window = window;
137 |
138 | // Setup back-end capabilities flags
139 | ImGuiIO& io = ImGui::GetIO();
140 | io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
141 | io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
142 | io.BackendPlatformName = "imgui_impl_sdl";
143 |
144 | // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
145 | io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
146 | io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
147 | io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
148 | io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
149 | io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
150 | io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
151 | io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
152 | io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
153 | io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
154 | io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
155 | io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
156 | io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
157 | io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
158 | io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
159 | io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
160 | io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER;
161 | io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
162 | io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
163 | io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
164 | io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
165 | io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
166 | io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
167 |
168 | io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
169 | io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
170 | io.ClipboardUserData = NULL;
171 |
172 | return true;
173 | }
174 |
175 | bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
176 | {
177 | (void)sdl_gl_context; // Viewport branch will need this.
178 | return ImGui_ImplSDL2_Init(window);
179 | }
180 |
181 | bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
182 | {
183 | #if !SDL_HAS_VULKAN
184 | IM_ASSERT(0 && "Unsupported");
185 | #endif
186 | return ImGui_ImplSDL2_Init(window);
187 | }
188 |
189 | bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
190 | {
191 | #if !defined(_WIN32)
192 | IM_ASSERT(0 && "Unsupported");
193 | #endif
194 | return ImGui_ImplSDL2_Init(window);
195 | }
196 |
197 | bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
198 | {
199 | return ImGui_ImplSDL2_Init(window);
200 | }
201 |
202 | void ImGui_ImplSDL2_Shutdown()
203 | {
204 | g_Window = NULL;
205 |
206 | // Destroy last known clipboard data
207 | if (g_ClipboardTextData)
208 | SDL_free(g_ClipboardTextData);
209 | g_ClipboardTextData = NULL;
210 | }
211 |
212 | static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
213 | {
214 | ImGuiIO& io = ImGui::GetIO();
215 |
216 | // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
217 | if (io.WantSetMousePos)
218 | SDL_WarpMouseInWindow(g_Window, (int)io.MousePos.x, (int)io.MousePos.y);
219 | else
220 | io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
221 |
222 | int mx, my;
223 | Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
224 | io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
225 | io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
226 | io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
227 | io.MouseDown[3] = g_MousePressed[3] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_X1)) != 0;
228 | io.MouseDown[4] = g_MousePressed[4] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_X2)) != 0;
229 |
230 | g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = g_MousePressed[3] = g_MousePressed[4] = false;
231 |
232 | if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
233 | io.MousePos = ImVec2((float)mx, (float)my);
234 | }
235 |
236 | void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
237 | {
238 | ImGuiIO& io = ImGui::GetIO();
239 | IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
240 |
241 | // Setup display size (every frame to accommodate for window resizing)
242 | int w, h;
243 |
244 | SDL_GetWindowSize(window, &w, &h);
245 | if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
246 | w = h = 0;
247 |
248 | io.DisplaySize = ImVec2((float)w, (float)h);
249 | if (w > 0 && h > 0) {
250 | int display_w, display_h;
251 | SDL_GL_GetDrawableSize(window, &display_w, &display_h);
252 | io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
253 | }
254 | // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
255 | static Uint64 frequency = SDL_GetPerformanceFrequency();
256 | Uint64 current_time = SDL_GetPerformanceCounter();
257 | io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
258 | g_Time = current_time;
259 |
260 | ImGui_ImplSDL2_UpdateMousePosAndButtons();
261 | }
262 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imgui_impl_sdl.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Platform Binding for SDL2
2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
3 | // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
4 |
5 | // Implemented features:
6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
7 | // [X] Platform: Clipboard support.
8 | // [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
9 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
10 | // Missing features:
11 | // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
12 |
13 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
14 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
15 | // https://github.com/ocornut/imgui
16 |
17 | #pragma once
18 | #include "imgui.h" // IMGUI_IMPL_API
19 |
20 | struct SDL_Window;
21 | typedef union SDL_Event SDL_Event;
22 |
23 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
24 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
25 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
26 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
27 | IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
28 | IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
29 | IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
30 |
--------------------------------------------------------------------------------
/src/menu/ImGUI/imstb_rectpack.h:
--------------------------------------------------------------------------------
1 | // [DEAR IMGUI]
2 | // This is a slightly modified version of stb_rect_pack.h 1.00.
3 | // Those changes would need to be pushed into nothings/stb:
4 | // - Added STBRP__CDECL
5 | // Grep for [DEAR IMGUI] to find the changes.
6 |
7 | // stb_rect_pack.h - v1.00 - public domain - rectangle packing
8 | // Sean Barrett 2014
9 | //
10 | // Useful for e.g. packing rectangular textures into an atlas.
11 | // Does not do rotation.
12 | //
13 | // Not necessarily the awesomest packing method, but better than
14 | // the totally naive one in stb_truetype (which is primarily what
15 | // this is meant to replace).
16 | //
17 | // Has only had a few tests run, may have issues.
18 | //
19 | // More docs to come.
20 | //
21 | // No memory allocations; uses qsort() and assert() from stdlib.
22 | // Can override those by defining STBRP_SORT and STBRP_ASSERT.
23 | //
24 | // This library currently uses the Skyline Bottom-Left algorithm.
25 | //
26 | // Please note: better rectangle packers are welcome! Please
27 | // implement them to the same API, but with a different init
28 | // function.
29 | //
30 | // Credits
31 | //
32 | // Library
33 | // Sean Barrett
34 | // Minor features
35 | // Martins Mozeiko
36 | // github:IntellectualKitty
37 | //
38 | // Bugfixes / warning fixes
39 | // Jeremy Jaussaud
40 | // Fabian Giesen
41 | //
42 | // Version history:
43 | //
44 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
45 | // 0.99 (2019-02-07) warning fixes
46 | // 0.11 (2017-03-03) return packing success/fail result
47 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings
48 | // 0.09 (2016-08-27) fix compiler warnings
49 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
50 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
51 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
52 | // 0.05: added STBRP_ASSERT to allow replacing assert
53 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support
54 | // 0.01: initial release
55 | //
56 | // LICENSE
57 | //
58 | // See end of file for license information.
59 |
60 | //////////////////////////////////////////////////////////////////////////////
61 | //
62 | // INCLUDE SECTION
63 | //
64 |
65 | #ifndef STB_INCLUDE_STB_RECT_PACK_H
66 | #define STB_INCLUDE_STB_RECT_PACK_H
67 |
68 | #define STB_RECT_PACK_VERSION 1
69 |
70 | #ifdef STBRP_STATIC
71 | #define STBRP_DEF static
72 | #else
73 | #define STBRP_DEF extern
74 | #endif
75 |
76 | #ifdef __cplusplus
77 | extern "C" {
78 | #endif
79 |
80 | typedef struct stbrp_context stbrp_context;
81 | typedef struct stbrp_node stbrp_node;
82 | typedef struct stbrp_rect stbrp_rect;
83 |
84 | #ifdef STBRP_LARGE_RECTS
85 | typedef int stbrp_coord;
86 | #else
87 | typedef unsigned short stbrp_coord;
88 | #endif
89 |
90 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
91 | // Assign packed locations to rectangles. The rectangles are of type
92 | // 'stbrp_rect' defined below, stored in the array 'rects', and there
93 | // are 'num_rects' many of them.
94 | //
95 | // Rectangles which are successfully packed have the 'was_packed' flag
96 | // set to a non-zero value and 'x' and 'y' store the minimum location
97 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left
98 | // if you imagine y increasing downwards). Rectangles which do not fit
99 | // have the 'was_packed' flag set to 0.
100 | //
101 | // You should not try to access the 'rects' array from another thread
102 | // while this function is running, as the function temporarily reorders
103 | // the array while it executes.
104 | //
105 | // To pack into another rectangle, you need to call stbrp_init_target
106 | // again. To continue packing into the same rectangle, you can call
107 | // this function again. Calling this multiple times with multiple rect
108 | // arrays will probably produce worse packing results than calling it
109 | // a single time with the full rectangle array, but the option is
110 | // available.
111 | //
112 | // The function returns 1 if all of the rectangles were successfully
113 | // packed and 0 otherwise.
114 |
115 | struct stbrp_rect
116 | {
117 | // reserved for your use:
118 | int id;
119 |
120 | // input:
121 | stbrp_coord w, h;
122 |
123 | // output:
124 | stbrp_coord x, y;
125 | int was_packed; // non-zero if valid packing
126 |
127 | }; // 16 bytes, nominally
128 |
129 |
130 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
131 | // Initialize a rectangle packer to:
132 | // pack a rectangle that is 'width' by 'height' in dimensions
133 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long
134 | //
135 | // You must call this function every time you start packing into a new target.
136 | //
137 | // There is no "shutdown" function. The 'nodes' memory must stay valid for
138 | // the following stbrp_pack_rects() call (or calls), but can be freed after
139 | // the call (or calls) finish.
140 | //
141 | // Note: to guarantee best results, either:
142 | // 1. make sure 'num_nodes' >= 'width'
143 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
144 | //
145 | // If you don't do either of the above things, widths will be quantized to multiples
146 | // of small integers to guarantee the algorithm doesn't run out of temporary storage.
147 | //
148 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm
149 | // may run out of temporary storage and be unable to pack some rectangles.
150 |
151 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
152 | // Optionally call this function after init but before doing any packing to
153 | // change the handling of the out-of-temp-memory scenario, described above.
154 | // If you call init again, this will be reset to the default (false).
155 |
156 |
157 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
158 | // Optionally select which packing heuristic the library should use. Different
159 | // heuristics will produce better/worse results for different data sets.
160 | // If you call init again, this will be reset to the default.
161 |
162 | enum
163 | {
164 | STBRP_HEURISTIC_Skyline_default=0,
165 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
166 | STBRP_HEURISTIC_Skyline_BF_sortHeight
167 | };
168 |
169 |
170 | //////////////////////////////////////////////////////////////////////////////
171 | //
172 | // the details of the following structures don't matter to you, but they must
173 | // be visible so you can handle the memory allocations for them
174 |
175 | struct stbrp_node
176 | {
177 | stbrp_coord x,y;
178 | stbrp_node *next;
179 | };
180 |
181 | struct stbrp_context
182 | {
183 | int width;
184 | int height;
185 | int align;
186 | int init_mode;
187 | int heuristic;
188 | int num_nodes;
189 | stbrp_node *active_head;
190 | stbrp_node *free_head;
191 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
192 | };
193 |
194 | #ifdef __cplusplus
195 | }
196 | #endif
197 |
198 | #endif
199 |
200 | //////////////////////////////////////////////////////////////////////////////
201 | //
202 | // IMPLEMENTATION SECTION
203 | //
204 |
205 | #ifdef STB_RECT_PACK_IMPLEMENTATION
206 | #ifndef STBRP_SORT
207 | #include
208 | #define STBRP_SORT qsort
209 | #endif
210 |
211 | #ifndef STBRP_ASSERT
212 | #include
213 | #define STBRP_ASSERT assert
214 | #endif
215 |
216 | // [DEAR IMGUI] Added STBRP__CDECL
217 | #ifdef _MSC_VER
218 | #define STBRP__NOTUSED(v) (void)(v)
219 | #define STBRP__CDECL __cdecl
220 | #else
221 | #define STBRP__NOTUSED(v) (void)sizeof(v)
222 | #define STBRP__CDECL
223 | #endif
224 |
225 | enum
226 | {
227 | STBRP__INIT_skyline = 1
228 | };
229 |
230 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
231 | {
232 | switch (context->init_mode) {
233 | case STBRP__INIT_skyline:
234 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
235 | context->heuristic = heuristic;
236 | break;
237 | default:
238 | STBRP_ASSERT(0);
239 | }
240 | }
241 |
242 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
243 | {
244 | if (allow_out_of_mem)
245 | // if it's ok to run out of memory, then don't bother aligning them;
246 | // this gives better packing, but may fail due to OOM (even though
247 | // the rectangles easily fit). @TODO a smarter approach would be to only
248 | // quantize once we've hit OOM, then we could get rid of this parameter.
249 | context->align = 1;
250 | else {
251 | // if it's not ok to run out of memory, then quantize the widths
252 | // so that num_nodes is always enough nodes.
253 | //
254 | // I.e. num_nodes * align >= width
255 | // align >= width / num_nodes
256 | // align = ceil(width/num_nodes)
257 |
258 | context->align = (context->width + context->num_nodes-1) / context->num_nodes;
259 | }
260 | }
261 |
262 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
263 | {
264 | int i;
265 | #ifndef STBRP_LARGE_RECTS
266 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
267 | #endif
268 |
269 | for (i=0; i < num_nodes-1; ++i)
270 | nodes[i].next = &nodes[i+1];
271 | nodes[i].next = NULL;
272 | context->init_mode = STBRP__INIT_skyline;
273 | context->heuristic = STBRP_HEURISTIC_Skyline_default;
274 | context->free_head = &nodes[0];
275 | context->active_head = &context->extra[0];
276 | context->width = width;
277 | context->height = height;
278 | context->num_nodes = num_nodes;
279 | stbrp_setup_allow_out_of_mem(context, 0);
280 |
281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
282 | context->extra[0].x = 0;
283 | context->extra[0].y = 0;
284 | context->extra[0].next = &context->extra[1];
285 | context->extra[1].x = (stbrp_coord) width;
286 | #ifdef STBRP_LARGE_RECTS
287 | context->extra[1].y = (1<<30);
288 | #else
289 | context->extra[1].y = 65535;
290 | #endif
291 | context->extra[1].next = NULL;
292 | }
293 |
294 | // find minimum y position if it starts at x1
295 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
296 | {
297 | stbrp_node *node = first;
298 | int x1 = x0 + width;
299 | int min_y, visited_width, waste_area;
300 |
301 | STBRP__NOTUSED(c);
302 |
303 | STBRP_ASSERT(first->x <= x0);
304 |
305 | #if 0
306 | // skip in case we're past the node
307 | while (node->next->x <= x0)
308 | ++node;
309 | #else
310 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
311 | #endif
312 |
313 | STBRP_ASSERT(node->x <= x0);
314 |
315 | min_y = 0;
316 | waste_area = 0;
317 | visited_width = 0;
318 | while (node->x < x1) {
319 | if (node->y > min_y) {
320 | // raise min_y higher.
321 | // we've accounted for all waste up to min_y,
322 | // but we'll now add more waste for everything we've visted
323 | waste_area += visited_width * (node->y - min_y);
324 | min_y = node->y;
325 | // the first time through, visited_width might be reduced
326 | if (node->x < x0)
327 | visited_width += node->next->x - x0;
328 | else
329 | visited_width += node->next->x - node->x;
330 | } else {
331 | // add waste area
332 | int under_width = node->next->x - node->x;
333 | if (under_width + visited_width > width)
334 | under_width = width - visited_width;
335 | waste_area += under_width * (min_y - node->y);
336 | visited_width += under_width;
337 | }
338 | node = node->next;
339 | }
340 |
341 | *pwaste = waste_area;
342 | return min_y;
343 | }
344 |
345 | typedef struct
346 | {
347 | int x,y;
348 | stbrp_node **prev_link;
349 | } stbrp__findresult;
350 |
351 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
352 | {
353 | int best_waste = (1<<30), best_x, best_y = (1 << 30);
354 | stbrp__findresult fr;
355 | stbrp_node **prev, *node, *tail, **best = NULL;
356 |
357 | // align to multiple of c->align
358 | width = (width + c->align - 1);
359 | width -= width % c->align;
360 | STBRP_ASSERT(width % c->align == 0);
361 |
362 | // if it can't possibly fit, bail immediately
363 | if (width > c->width || height > c->height) {
364 | fr.prev_link = NULL;
365 | fr.x = fr.y = 0;
366 | return fr;
367 | }
368 |
369 | node = c->active_head;
370 | prev = &c->active_head;
371 | while (node->x + width <= c->width) {
372 | int y,waste;
373 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
374 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
375 | // bottom left
376 | if (y < best_y) {
377 | best_y = y;
378 | best = prev;
379 | }
380 | } else {
381 | // best-fit
382 | if (y + height <= c->height) {
383 | // can only use it if it first vertically
384 | if (y < best_y || (y == best_y && waste < best_waste)) {
385 | best_y = y;
386 | best_waste = waste;
387 | best = prev;
388 | }
389 | }
390 | }
391 | prev = &node->next;
392 | node = node->next;
393 | }
394 |
395 | best_x = (best == NULL) ? 0 : (*best)->x;
396 |
397 | // if doing best-fit (BF), we also have to try aligning right edge to each node position
398 | //
399 | // e.g, if fitting
400 | //
401 | // ____________________
402 | // |____________________|
403 | //
404 | // into
405 | //
406 | // | |
407 | // | ____________|
408 | // |____________|
409 | //
410 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
411 | //
412 | // This makes BF take about 2x the time
413 |
414 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
415 | tail = c->active_head;
416 | node = c->active_head;
417 | prev = &c->active_head;
418 | // find first node that's admissible
419 | while (tail->x < width)
420 | tail = tail->next;
421 | while (tail) {
422 | int xpos = tail->x - width;
423 | int y,waste;
424 | STBRP_ASSERT(xpos >= 0);
425 | // find the left position that matches this
426 | while (node->next->x <= xpos) {
427 | prev = &node->next;
428 | node = node->next;
429 | }
430 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
431 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
432 | if (y + height <= c->height) {
433 | if (y <= best_y) {
434 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
435 | best_x = xpos;
436 | STBRP_ASSERT(y <= best_y);
437 | best_y = y;
438 | best_waste = waste;
439 | best = prev;
440 | }
441 | }
442 | }
443 | tail = tail->next;
444 | }
445 | }
446 |
447 | fr.prev_link = best;
448 | fr.x = best_x;
449 | fr.y = best_y;
450 | return fr;
451 | }
452 |
453 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
454 | {
455 | // find best position according to heuristic
456 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
457 | stbrp_node *node, *cur;
458 |
459 | // bail if:
460 | // 1. it failed
461 | // 2. the best node doesn't fit (we don't always check this)
462 | // 3. we're out of memory
463 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
464 | res.prev_link = NULL;
465 | return res;
466 | }
467 |
468 | // on success, create new node
469 | node = context->free_head;
470 | node->x = (stbrp_coord) res.x;
471 | node->y = (stbrp_coord) (res.y + height);
472 |
473 | context->free_head = node->next;
474 |
475 | // insert the new node into the right starting point, and
476 | // let 'cur' point to the remaining nodes needing to be
477 | // stiched back in
478 |
479 | cur = *res.prev_link;
480 | if (cur->x < res.x) {
481 | // preserve the existing one, so start testing with the next one
482 | stbrp_node *next = cur->next;
483 | cur->next = node;
484 | cur = next;
485 | } else {
486 | *res.prev_link = node;
487 | }
488 |
489 | // from here, traverse cur and free the nodes, until we get to one
490 | // that shouldn't be freed
491 | while (cur->next && cur->next->x <= res.x + width) {
492 | stbrp_node *next = cur->next;
493 | // move the current node to the free list
494 | cur->next = context->free_head;
495 | context->free_head = cur;
496 | cur = next;
497 | }
498 |
499 | // stitch the list back in
500 | node->next = cur;
501 |
502 | if (cur->x < res.x + width)
503 | cur->x = (stbrp_coord) (res.x + width);
504 |
505 | #ifdef _DEBUG
506 | cur = context->active_head;
507 | while (cur->x < context->width) {
508 | STBRP_ASSERT(cur->x < cur->next->x);
509 | cur = cur->next;
510 | }
511 | STBRP_ASSERT(cur->next == NULL);
512 |
513 | {
514 | int count=0;
515 | cur = context->active_head;
516 | while (cur) {
517 | cur = cur->next;
518 | ++count;
519 | }
520 | cur = context->free_head;
521 | while (cur) {
522 | cur = cur->next;
523 | ++count;
524 | }
525 | STBRP_ASSERT(count == context->num_nodes+2);
526 | }
527 | #endif
528 |
529 | return res;
530 | }
531 |
532 | // [DEAR IMGUI] Added STBRP__CDECL
533 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
534 | {
535 | const stbrp_rect *p = (const stbrp_rect *) a;
536 | const stbrp_rect *q = (const stbrp_rect *) b;
537 | if (p->h > q->h)
538 | return -1;
539 | if (p->h < q->h)
540 | return 1;
541 | return (p->w > q->w) ? -1 : (p->w < q->w);
542 | }
543 |
544 | // [DEAR IMGUI] Added STBRP__CDECL
545 | static int STBRP__CDECL rect_original_order(const void *a, const void *b)
546 | {
547 | const stbrp_rect *p = (const stbrp_rect *) a;
548 | const stbrp_rect *q = (const stbrp_rect *) b;
549 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
550 | }
551 |
552 | #ifdef STBRP_LARGE_RECTS
553 | #define STBRP__MAXVAL 0xffffffff
554 | #else
555 | #define STBRP__MAXVAL 0xffff
556 | #endif
557 |
558 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
559 | {
560 | int i, all_rects_packed = 1;
561 |
562 | // we use the 'was_packed' field internally to allow sorting/unsorting
563 | for (i=0; i < num_rects; ++i) {
564 | rects[i].was_packed = i;
565 | }
566 |
567 | // sort according to heuristic
568 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
569 |
570 | for (i=0; i < num_rects; ++i) {
571 | if (rects[i].w == 0 || rects[i].h == 0) {
572 | rects[i].x = rects[i].y = 0; // empty rect needs no space
573 | } else {
574 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
575 | if (fr.prev_link) {
576 | rects[i].x = (stbrp_coord) fr.x;
577 | rects[i].y = (stbrp_coord) fr.y;
578 | } else {
579 | rects[i].x = rects[i].y = STBRP__MAXVAL;
580 | }
581 | }
582 | }
583 |
584 | // unsort
585 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
586 |
587 | // set was_packed flags and all_rects_packed status
588 | for (i=0; i < num_rects; ++i) {
589 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
590 | if (!rects[i].was_packed)
591 | all_rects_packed = 0;
592 | }
593 |
594 | // return the all_rects_packed status
595 | return all_rects_packed;
596 | }
597 | #endif
598 |
599 | /*
600 | ------------------------------------------------------------------------------
601 | This software is available under 2 licenses -- choose whichever you prefer.
602 | ------------------------------------------------------------------------------
603 | ALTERNATIVE A - MIT License
604 | Copyright (c) 2017 Sean Barrett
605 | Permission is hereby granted, free of charge, to any person obtaining a copy of
606 | this software and associated documentation files (the "Software"), to deal in
607 | the Software without restriction, including without limitation the rights to
608 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
609 | of the Software, and to permit persons to whom the Software is furnished to do
610 | so, subject to the following conditions:
611 | The above copyright notice and this permission notice shall be included in all
612 | copies or substantial portions of the Software.
613 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
614 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
615 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
616 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
617 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
618 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
619 | SOFTWARE.
620 | ------------------------------------------------------------------------------
621 | ALTERNATIVE B - Public Domain (www.unlicense.org)
622 | This is free and unencumbered software released into the public domain.
623 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
624 | software, either in source code form or as a compiled binary, for any purpose,
625 | commercial or non-commercial, and by any means.
626 | In jurisdictions that recognize copyright laws, the author or authors of this
627 | software dedicate any and all copyright interest in the software to the public
628 | domain. We make this dedication for the benefit of the public at large and to
629 | the detriment of our heirs and successors. We intend this dedication to be an
630 | overt act of relinquishment in perpetuity of all present and future rights to
631 | this software under copyright law.
632 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
633 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
634 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
635 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
636 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
637 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
638 | ------------------------------------------------------------------------------
639 | */
640 |
--------------------------------------------------------------------------------
/src/menu/config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: config.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 19:50:19
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 11:58:06
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | // Stores all module settings in one place
22 | namespace Config {
23 |
24 | namespace Aimbot {
25 | inline bool enabled = false;
26 | inline float fov = 0.0;
27 | inline float smoothness = 0.0;
28 | inline int hitboxSelected = 0; // Order: Head, Neck, Chest, Stomach, Pelvis
29 | inline bool silentAimEnabled = false;
30 |
31 | inline bool triggerbotEnabled = false;
32 | inline int triggerbotDelay = 0;
33 | }
34 |
35 | namespace Visuals {
36 | inline bool espEnabled = false;
37 | }
38 |
39 | namespace Misc {
40 | inline bool bhopEnabled = false;
41 |
42 | inline bool radarEnabled = false;
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/src/menu/menu.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: menu.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 01.04.2022 15:50:14
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 18:31:28
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "menu.h"
19 |
20 |
21 | // onPollEvent function from https://github.com/seksea/gamesneeze/blob/7ec40e08a9964549672da6c735567ff613262097/src/core/menu/menu.cpp
22 | void Menu::onPollEvent(SDL_Event* event, const int result) {
23 | if (result && ImGui_ImplSDL2_ProcessEvent(event) && Menu::active) {
24 | event->type = 0;
25 | }
26 | }
27 |
28 | // onSwapWindow function (modified) from https://github.com/seksea/gamesneeze/blob/7ec40e08a9964549672da6c735567ff613262097/src/core/menu/menu.cpp
29 | void Menu::onSwapWindow(SDL_Window* window) {
30 | // TODO: Write my own function
31 |
32 | // Run on first call
33 | if (!isInit) {
34 | gl3wInit();
35 | IMGUI_CHECKVERSION();
36 | ImGui::CreateContext();
37 | ImGui::StyleColorsDark();
38 | ImGui_ImplOpenGL3_Init("#version 100");
39 | ImGui_ImplSDL2_InitForOpenGL(window, nullptr);
40 |
41 | isInit = true;
42 | }
43 |
44 | ImGui_ImplOpenGL3_NewFrame();
45 | ImGui_ImplSDL2_NewFrame(window);
46 |
47 | ImGuiIO& io = ImGui::GetIO();
48 |
49 | int w, h;
50 | SDL_GetWindowSize(window, &w, &h);
51 | screenSizeX = w;
52 | screenSizeY = h;
53 |
54 | io.DisplaySize = ImVec2((float)w, (float)h);
55 |
56 | ImGui::NewFrame();
57 |
58 | // Show menu and cursor if menu was activated, otherwise hide cursor
59 | if (Menu::active) {
60 | io.MouseDrawCursor = true;
61 | Menu::showMenu();
62 | } else {
63 | io.MouseDrawCursor = false;
64 | }
65 |
66 | // Activate menu if openKey was pressed
67 | if (ImGui::IsKeyPressed(Menu::openKey, false)) {
68 | Menu::active = !Menu::active;
69 | }
70 |
71 | ImGui::Render();
72 | ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
73 | }
74 |
75 |
76 | /**
77 | * Draws the menu window
78 | */
79 | void Menu::showMenu() {
80 |
81 | // Show title bar of window
82 | ImGui::Begin(("csgo-simple-linux-cheat v" + version + " by 3urobeat").c_str(), &Menu::active);
83 |
84 |
85 | // Show buttons for page selection that will change the currentPage value
86 | if (ImGui::Button("Aimbot", buttonWidth)) Menu::currentPage = 0;
87 |
88 | ImGui::SameLine();
89 | if (ImGui::Button("Visuals", buttonWidth)) Menu::currentPage = 1;
90 |
91 | ImGui::SameLine();
92 | if (ImGui::Button("Misc", buttonWidth)) Menu::currentPage = 2;
93 |
94 | ImGui::SameLine();
95 | if (ImGui::Button("Info", buttonWidth)) Menu::currentPage = 3;
96 |
97 |
98 | // Show desired page
99 | switch (currentPage) {
100 | case 1:
101 | Menu::showVisualsPage();
102 | break;
103 | case 2:
104 | Menu::showMiscPage();
105 | break;
106 | case 3:
107 | Menu::showInfoPage();
108 | break;
109 | default:
110 | Menu::showAimbotPage();
111 | Menu::currentPage = 0;
112 | }
113 |
114 | ImGui::End();
115 | }
--------------------------------------------------------------------------------
/src/menu/menu.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: menu.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 01.04.2022 15:54:37
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 18.02.2023 13:05:25
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../main.h"
22 |
23 | #include "ImGUI/imgui.h"
24 | #include "ImGUI/GL/gl3w.h"
25 | #include "ImGUI/imgui_impl_sdl.h"
26 | #include "ImGUI/imgui_impl_opengl3.h"
27 |
28 |
29 | namespace Menu {
30 | inline bool isInit = false;
31 | inline bool active = true; // Change to false later
32 | inline int currentPage = 0;
33 |
34 | inline auto openKey = SDL_SCANCODE_INSERT;
35 |
36 | inline auto buttonWidth = ImVec2(75, 20);
37 |
38 | void showMenu();
39 | void onPollEvent(SDL_Event* event, const int result);
40 | void onSwapWindow(SDL_Window* window);
41 |
42 | void showAimbotPage();
43 | void showVisualsPage();
44 | void showMiscPage();
45 | void showInfoPage();
46 | }
--------------------------------------------------------------------------------
/src/menu/pages/aimbotPage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: aimbotPage.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 17:36:38
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 13.02.2023 21:50:43
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../../main.h"
19 |
20 |
21 | const char *_hitboxes[]{"Head", "Neck", "Chest", "Stomach", "Pelvis"};
22 |
23 |
24 | void Menu::showAimbotPage() {
25 | ImGui::Checkbox("Active", &Config::Aimbot::enabled);
26 | ImGui::SliderFloat("FOV", &Config::Aimbot::fov, 0.0, 360.0, "%.1f");
27 | ImGui::SliderFloat("Smoothness", &Config::Aimbot::smoothness, 0.0, 100.0, "%.1f");
28 | ImGui::Combo("Hitbox", &Config::Aimbot::hitboxSelected, _hitboxes, IM_ARRAYSIZE(_hitboxes));
29 | ImGui::Checkbox("Silent Aim", &Config::Aimbot::silentAimEnabled);
30 | ImGui::Checkbox("Triggerbot", &Config::Aimbot::triggerbotEnabled);
31 | ImGui::SliderInt("Delay", &Config::Aimbot::triggerbotDelay, 0, 2500);
32 | }
--------------------------------------------------------------------------------
/src/menu/pages/infoPage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: infoPage.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 18:18:52
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 14.02.2023 16:02:34
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include
19 |
20 | #include "../../main.h"
21 |
22 |
23 | void Menu::showInfoPage() {
24 | ImGui::Text( "csgo-simple-linux-cheat");
25 | ImGui::Text(("Version: " + version).c_str());
26 | ImGui::Text( "Author: 3urobeat");
27 | ImGui::Text(("Source: https://github.com/HerrEurobeat/csgo-simple-linux-cheat"));
28 | ImGui::Text("");
29 |
30 | ImGui::Text(("Resolution: " + std::to_string(screenSizeX) + "x" + std::to_string(screenSizeY)).c_str());
31 | ImGui::Text(("Bhop enabled: " + std::to_string(Config::Misc::bhopEnabled)).c_str());
32 |
33 | // Provide unload button
34 | if (ImGui::Button("Unhook", buttonWidth)) libUnload();
35 | }
--------------------------------------------------------------------------------
/src/menu/pages/miscPage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: miscPage.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 17:36:52
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 16.02.2023 22:00:25
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../../main.h"
19 |
20 |
21 | void Menu::showMiscPage() {
22 |
23 | ImGui::Checkbox("Bhop", &Config::Misc::bhopEnabled);
24 |
25 | ImGui::Checkbox("Radar", &Config::Misc::radarEnabled);
26 |
27 | }
--------------------------------------------------------------------------------
/src/menu/pages/visualsPage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: visualsPage.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 17:36:46
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 11:58:25
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../../main.h"
19 |
20 |
21 | void Menu::showVisualsPage() {
22 |
23 | ImGui::Checkbox("ESP", &Config::Visuals::espEnabled);
24 |
25 | }
--------------------------------------------------------------------------------
/src/modules/misc/bhop.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: bhop.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 20:31:50
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 17.02.2023 16:10:25
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../modules.h"
19 |
20 |
21 | /**
22 | * Misc: Bunny Hop module
23 | * @param cmd createMove cmd that will be send to the server
24 | */
25 | void Modules::Bhop::run(CUserCmd *cmd) {
26 |
27 | // Check if this module should run
28 | if (!Config::Misc::bhopEnabled) return; // Check if module is enabled
29 | if (!ImGui::IsKeyDown(ImGuiKey_Space)) return; // Only bother if user tries to bhop (aka holding space bar) (using ImGui's key press functions to make checking easier)
30 |
31 | // Send jump command
32 | cmd->buttons &= ~IN_JUMP;
33 |
34 | }
--------------------------------------------------------------------------------
/src/modules/misc/radar.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: radar.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 16.02.2023 21:33:28
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 20.02.2023 13:35:39
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../modules.h"
19 |
20 |
21 | /**
22 | * Misc: Radar Hack module which sets spotted of all entities to true
23 | */
24 | void Modules::Radar::run() {
25 |
26 | // Check if this module should run
27 | if (!Config::Misc::radarEnabled) return; // Check if module is enabled
28 |
29 |
30 | // Iterate over all entities (start at 1 as 0 is the world entity)
31 | for (int i = 1; i <= Interfaces::engineClient->GetMaxClients(); i++) {
32 | CEntity *entity = Interfaces::entityList->GetClientEntity(i); // Get this entity
33 |
34 | if (!entity) continue; // Ignore if invalid
35 | // TODO: Ignore if not a player
36 | // TODO: Ignore if dead
37 |
38 | entity->spotted() = true; // Set spotted to true so it will appear on the radar
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/src/modules/modules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: modules.h
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 02.04.2022 20:12:38
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 11:57:14
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2022 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #pragma once
19 |
20 |
21 | #include "../main.h"
22 | #include "../SDK/classes/cUserCmd.h"
23 |
24 |
25 | // Registers all modules
26 | namespace Modules {
27 |
28 | // Visuals
29 | namespace ESP {
30 | void run();
31 | }
32 |
33 | // Misc
34 | namespace Bhop {
35 | void run(CUserCmd *cmd);
36 | }
37 |
38 | namespace Radar {
39 | void run();
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/src/modules/visuals/esp.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: esp.cpp
3 | * Project: csgo-simple-linux-cheat
4 | * Created Date: 19.02.2023 11:49:51
5 | * Author: 3urobeat
6 | *
7 | * Last Modified: 19.02.2023 11:59:04
8 | * Modified By: 3urobeat
9 | *
10 | * Copyright (c) 2023 3urobeat
11 | *
12 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 | * You should have received a copy of the GNU General Public License along with this program. If not, see .
15 | */
16 |
17 |
18 | #include "../modules.h"
19 |
20 |
21 | /**
22 | * Visuals: Draws a box around all entities, visible through walls
23 | */
24 | void Modules::ESP::run() {
25 |
26 | // Check if this module should run
27 | if (!Config::Visuals::espEnabled) return; // Check if module is enabled
28 |
29 | }
--------------------------------------------------------------------------------
/tools:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # File: tools
4 | # Project: csgo-simple-linux-cheat
5 | # Created Date: 02.04.2022 16:20:10
6 | # Author: 3urobeat
7 | #
8 | # Last Modified: 02.04.2022 16:31:16
9 | # Modified By: 3urobeat
10 | #
11 | # Copyright (c) 2022 3urobeat
12 | #
13 | # This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
14 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 | # You should have received a copy of the GNU General Public License along with this program. If not, see .
16 |
17 |
18 | trap 'exit 130' INT # Make sure script exits on SIGINT
19 |
20 | csgo_pid=$(pidof csgo_linux64)
21 | filename="libcsgo-simple-linux-cheat.so"
22 | libname="libMangoHud.so" # pretend to be something else
23 | threads=6 #amount of CPU threads the script should use
24 |
25 |
26 | # Check if user set more threads than available
27 | maxThreads=$(nproc --all)
28 |
29 | if (($threads > $maxThreads)); then
30 | echo "You set more threads than your CPU has available! Setting to $maxThreads..."
31 | threads=$maxThreads
32 | fi
33 |
34 |
35 | # Build function
36 | function build {
37 | cd build
38 |
39 | echo "Refreshing Makefile using CMake..."
40 | cmake ..
41 |
42 | echo ""
43 | echo "Building with make using $threads threads..."
44 | make -j $threads
45 | cd ..
46 |
47 | echo ""
48 | echo "Done! You can now load/inject using the '-l' flag if no errors occurred!"
49 | }
50 |
51 |
52 | # Used load function from https://github.com/ArnoldasMk/Kali/blob/dev/Kali (modified) until I get a better understanding of gdb and injecting itself
53 | function load {
54 | if [ -z "$csgo_pid" ]; then
55 | echo "CS:GO needs to be open before you can inject, exiting..."
56 | exit 1
57 | fi
58 |
59 | # pBypass for crash dumps being sent
60 | # You may also want to consider using -nobreakpad in your launch options.
61 | sudo rm -rf /tmp/dumps # Remove if it exists
62 | sudo mkdir --mode=000 /tmp/dumps # Make it as root with no permissions
63 |
64 | # Credit: Aixxe @ aixxe.net
65 | if grep -q "$libname" /proc/"$csgo_pid"/maps; then
66 | echo "Already injected? Exiting..."
67 | exit
68 | fi
69 | echo "Injecting $filename from ./build as $libname..."
70 |
71 | # https://www.kernel.org/doc/Documentation/security/Yama.txt
72 | echo "2" | sudo tee /proc/sys/kernel/yama/ptrace_scope # Only allows root to inject code. This is temporary until reboot.
73 |
74 | sudo cp "./build/$filename" "/usr/lib/${libname}"
75 |
76 | sudo killall -19 steam
77 | sudo killall -19 steamwebhelper
78 |
79 | lib_dir_name="lib"
80 | if [ $(getconf LONG_BIT) = 64 ]; then
81 | lib_dir_name+="64"
82 | fi
83 |
84 | input="$(
85 | sudo gdb -n -q -batch-silent \
86 | -ex "set logging on" \
87 | -ex "set logging file /dev/null" \
88 | -ex "set logging redirect on" \
89 | -ex "set auto-load safe-path /usr/share/gdb/auto-load/usr/$lib_dir_name/:/usr/$lib_dir_name/" \
90 | -ex "attach $csgo_pid" \
91 | -ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
92 | -ex "call \$dlopen(\"/usr/lib/$libname\", 1)" \
93 | -ex "detach" \
94 | -ex "quit"
95 | )"
96 |
97 | sleep 1
98 | sudo killall -18 steamwebhelper
99 | sudo killall -18 steam
100 |
101 | last_line="${input##*$'\n'}"
102 |
103 | if [ "$last_line" != "\$1 = (void *) 0x0" ]; then
104 | echo "Successfully injected!"
105 | else
106 | echo "Injection failed!"
107 | fi
108 | }
109 |
110 |
111 | # Used unload function from https://github.com/ArnoldasMk/Kali/blob/dev/Kali (modified)
112 | function unload {
113 | if grep -q "$libname" /proc/"$csgo_pid"/maps; then
114 | echo "Unloading $libname..."
115 | echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
116 |
117 | sudo gdb -n -q -batch-silent \
118 | -ex "set logging on" \
119 | -ex "set logging file /dev/null" \
120 | -ex "set logging redirect on" \
121 | -ex "attach $csgo_pid" \
122 | -ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
123 | -ex "set \$dlclose = (int(*)(void*)) dlclose" \
124 | -ex "set \$library = \$dlopen(\"/usr/lib/$libname\", 6)" \
125 | -ex "call \$dlclose(\$library)" \
126 | -ex "call \$dlclose(\$library)" \
127 | -ex "detach" \
128 | -ex "quit"
129 |
130 | sudo rm "/usr/lib/${libname}"
131 |
132 | echo "Unloaded!"
133 | else
134 | echo "Not injected? Exiting..."
135 | exit
136 | fi
137 | }
138 |
139 |
140 | function usage {
141 | echo "Arguments:
142 | -b Build/Compile (Run this first, only load when done)
143 | -l Load/Inject
144 | -u Unload/uninject"
145 | }
146 |
147 |
148 | while getopts 'bluh' flag; do
149 | case "${flag}" in
150 | b) build ;;
151 | l) load ;;
152 | u) unload ;;
153 | h) usage ;;
154 | *) usage
155 | exit 1 ;;
156 | esac
157 | done
--------------------------------------------------------------------------------