init
This commit is contained in:
commit
266e902411
12
.clang-format
Normal file
12
.clang-format
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
SortIncludes: false
|
||||
|
||||
# Regroup causes unnecessary noise due to clang-format bug.
|
||||
IncludeBlocks: Preserve
|
||||
|
||||
---
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.html linguist-detectable=false
|
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: gitsubmodule
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
52
.github/workflows/build.yml
vendored
Normal file
52
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build binaries
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
matrix:
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
steps:
|
||||
- name: Check out files
|
||||
uses: actions/checkout@v3.5.2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
# NOTE - If LFS ever starts getting used during builds, switch this to true!
|
||||
lfs: false
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.3.1
|
||||
|
||||
- name: Generate project files
|
||||
run: tools/premake5 vs2022
|
||||
|
||||
- name: Set up problem matching
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Build ${{matrix.configuration}} binaries
|
||||
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/iw4-sp.sln
|
||||
|
||||
- name: Upload ${{matrix.configuration}} binaries
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: ${{matrix.configuration}} binaries
|
||||
path: |
|
||||
build/bin/Win32/${{matrix.configuration}}/iw4-sp.exe
|
||||
build/bin/Win32/${{matrix.configuration}}/iw4-sp.pdb
|
150
.gitignore
vendored
Normal file
150
.gitignore
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
### Windows
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Shortcuts
|
||||
*.lnk
|
||||
|
||||
### OSX
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Visual Studio
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
build
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
|
||||
#Visual Studio Code
|
||||
.vscode/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
### IDA
|
||||
*.id0
|
||||
*.id1
|
||||
*.id2
|
||||
*.nam
|
||||
*.til
|
||||
|
||||
### Custom user files
|
||||
# User scripts
|
||||
user*.bat
|
24
.gitmodules
vendored
Normal file
24
.gitmodules
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
[submodule "deps/GSL"]
|
||||
path = deps/GSL
|
||||
url = https://github.com/microsoft/GSL.git
|
||||
[submodule "deps/udis86"]
|
||||
path = deps/udis86
|
||||
url = https://github.com/vmt/udis86.git
|
||||
[submodule "deps/minhook"]
|
||||
path = deps/minhook
|
||||
url = https://github.com/TsudaKageyu/minhook.git
|
||||
[submodule "deps/zlib"]
|
||||
path = deps/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
[submodule "deps/rapidjson"]
|
||||
path = deps/rapidjson
|
||||
url = https://github.com/Tencent/rapidjson.git
|
||||
[submodule "deps/discord-rpc"]
|
||||
path = deps/discord-rpc
|
||||
url = https://github.com/discord/discord-rpc.git
|
||||
[submodule "deps/libtommath"]
|
||||
path = deps/libtommath
|
||||
url = https://github.com/libtom/libtommath.git
|
||||
[submodule "deps/libtomcrypt"]
|
||||
path = deps/libtomcrypt
|
||||
url = https://github.com/libtom/libtomcrypt.git
|
674
LICENSE
Normal file
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
27
README.md
Normal file
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
[![build](https://github.com/alterware/iw4-sp/workflows/Build/badge.svg)](https://github.com/alterware/iw4-sp/actions)
|
||||
|
||||
# IW4: SP Client
|
||||
|
||||
This is a client modification for IW4 (Singleplayer) 159
|
||||
**NOTE**: You must legally own Call of Duty®: Modern Warfare® 2 (2009) to run this mod. Cracked/Pirated versions of the game are **NOT** supported.
|
||||
|
||||
## How to compile
|
||||
|
||||
- Run `premake5 vs2022` or use the delivered `generate.bat`.
|
||||
- Build via solution file in `build\iw4-sp.sln`.
|
||||
|
||||
## Premake arguments
|
||||
|
||||
| Argument | Description |
|
||||
|:----------------------------|:-----------------------------------------------|
|
||||
| `--copy-to=PATH` | Optional, copy the exe to a custom folder after build. |
|
||||
|
||||
## Command line arguments
|
||||
|
||||
| Argument | Description |
|
||||
|:------------------------|:-----------------------------------------------|
|
||||
| `-nosteam` | Disable Steam integration. |
|
||||
|
||||
## Disclaimer
|
||||
|
||||
This software has been created purely for the purposes of academic research. It is not intended to be used to attack other systems. Project maintainers are not responsible or liable for misuse of the software. Use responsibly.
|
1
deps/GSL
vendored
Submodule
1
deps/GSL
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 303d964a241cb2f2a058fe0baa14013eb9afa116
|
1
deps/discord-rpc
vendored
Submodule
1
deps/discord-rpc
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 963aa9f3e5ce81a4682c6ca3d136cddda614db33
|
5946
deps/extra/udis86/libudis86/itab.c
vendored
Normal file
5946
deps/extra/udis86/libudis86/itab.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
939
deps/extra/udis86/libudis86/itab.h
vendored
Normal file
939
deps/extra/udis86/libudis86/itab.h
vendored
Normal file
@ -0,0 +1,939 @@
|
||||
#ifndef UD_ITAB_H
|
||||
#define UD_ITAB_H
|
||||
|
||||
/* itab.h -- generated by udis86:scripts/ud_itab.py, do no edit */
|
||||
|
||||
/* ud_table_type -- lookup table types (see decode.c) */
|
||||
enum ud_table_type {
|
||||
UD_TAB__OPC_VEX,
|
||||
UD_TAB__OPC_TABLE,
|
||||
UD_TAB__OPC_X87,
|
||||
UD_TAB__OPC_MOD,
|
||||
UD_TAB__OPC_RM,
|
||||
UD_TAB__OPC_OSIZE,
|
||||
UD_TAB__OPC_MODE,
|
||||
UD_TAB__OPC_VEX_L,
|
||||
UD_TAB__OPC_3DNOW,
|
||||
UD_TAB__OPC_REG,
|
||||
UD_TAB__OPC_ASIZE,
|
||||
UD_TAB__OPC_VEX_W,
|
||||
UD_TAB__OPC_SSE,
|
||||
UD_TAB__OPC_VENDOR
|
||||
};
|
||||
|
||||
/* ud_mnemonic -- mnemonic constants */
|
||||
enum ud_mnemonic_code {
|
||||
UD_Iaaa,
|
||||
UD_Iaad,
|
||||
UD_Iaam,
|
||||
UD_Iaas,
|
||||
UD_Iadc,
|
||||
UD_Iadd,
|
||||
UD_Iaddpd,
|
||||
UD_Iaddps,
|
||||
UD_Iaddsd,
|
||||
UD_Iaddss,
|
||||
UD_Iaddsubpd,
|
||||
UD_Iaddsubps,
|
||||
UD_Iaesdec,
|
||||
UD_Iaesdeclast,
|
||||
UD_Iaesenc,
|
||||
UD_Iaesenclast,
|
||||
UD_Iaesimc,
|
||||
UD_Iaeskeygenassist,
|
||||
UD_Iand,
|
||||
UD_Iandnpd,
|
||||
UD_Iandnps,
|
||||
UD_Iandpd,
|
||||
UD_Iandps,
|
||||
UD_Iarpl,
|
||||
UD_Iblendpd,
|
||||
UD_Iblendps,
|
||||
UD_Iblendvpd,
|
||||
UD_Iblendvps,
|
||||
UD_Ibound,
|
||||
UD_Ibsf,
|
||||
UD_Ibsr,
|
||||
UD_Ibswap,
|
||||
UD_Ibt,
|
||||
UD_Ibtc,
|
||||
UD_Ibtr,
|
||||
UD_Ibts,
|
||||
UD_Icall,
|
||||
UD_Icbw,
|
||||
UD_Icdq,
|
||||
UD_Icdqe,
|
||||
UD_Iclc,
|
||||
UD_Icld,
|
||||
UD_Iclflush,
|
||||
UD_Iclgi,
|
||||
UD_Icli,
|
||||
UD_Iclts,
|
||||
UD_Icmc,
|
||||
UD_Icmova,
|
||||
UD_Icmovae,
|
||||
UD_Icmovb,
|
||||
UD_Icmovbe,
|
||||
UD_Icmovg,
|
||||
UD_Icmovge,
|
||||
UD_Icmovl,
|
||||
UD_Icmovle,
|
||||
UD_Icmovno,
|
||||
UD_Icmovnp,
|
||||
UD_Icmovns,
|
||||
UD_Icmovnz,
|
||||
UD_Icmovo,
|
||||
UD_Icmovp,
|
||||
UD_Icmovs,
|
||||
UD_Icmovz,
|
||||
UD_Icmp,
|
||||
UD_Icmppd,
|
||||
UD_Icmpps,
|
||||
UD_Icmpsb,
|
||||
UD_Icmpsd,
|
||||
UD_Icmpsq,
|
||||
UD_Icmpss,
|
||||
UD_Icmpsw,
|
||||
UD_Icmpxchg,
|
||||
UD_Icmpxchg16b,
|
||||
UD_Icmpxchg8b,
|
||||
UD_Icomisd,
|
||||
UD_Icomiss,
|
||||
UD_Icpuid,
|
||||
UD_Icqo,
|
||||
UD_Icrc32,
|
||||
UD_Icvtdq2pd,
|
||||
UD_Icvtdq2ps,
|
||||
UD_Icvtpd2dq,
|
||||
UD_Icvtpd2pi,
|
||||
UD_Icvtpd2ps,
|
||||
UD_Icvtpi2pd,
|
||||
UD_Icvtpi2ps,
|
||||
UD_Icvtps2dq,
|
||||
UD_Icvtps2pd,
|
||||
UD_Icvtps2pi,
|
||||
UD_Icvtsd2si,
|
||||
UD_Icvtsd2ss,
|
||||
UD_Icvtsi2sd,
|
||||
UD_Icvtsi2ss,
|
||||
UD_Icvtss2sd,
|
||||
UD_Icvtss2si,
|
||||
UD_Icvttpd2dq,
|
||||
UD_Icvttpd2pi,
|
||||
UD_Icvttps2dq,
|
||||
UD_Icvttps2pi,
|
||||
UD_Icvttsd2si,
|
||||
UD_Icvttss2si,
|
||||
UD_Icwd,
|
||||
UD_Icwde,
|
||||
UD_Idaa,
|
||||
UD_Idas,
|
||||
UD_Idec,
|
||||
UD_Idiv,
|
||||
UD_Idivpd,
|
||||
UD_Idivps,
|
||||
UD_Idivsd,
|
||||
UD_Idivss,
|
||||
UD_Idppd,
|
||||
UD_Idpps,
|
||||
UD_Iemms,
|
||||
UD_Ienter,
|
||||
UD_Iextractps,
|
||||
UD_If2xm1,
|
||||
UD_Ifabs,
|
||||
UD_Ifadd,
|
||||
UD_Ifaddp,
|
||||
UD_Ifbld,
|
||||
UD_Ifbstp,
|
||||
UD_Ifchs,
|
||||
UD_Ifclex,
|
||||
UD_Ifcmovb,
|
||||
UD_Ifcmovbe,
|
||||
UD_Ifcmove,
|
||||
UD_Ifcmovnb,
|
||||
UD_Ifcmovnbe,
|
||||
UD_Ifcmovne,
|
||||
UD_Ifcmovnu,
|
||||
UD_Ifcmovu,
|
||||
UD_Ifcom,
|
||||
UD_Ifcom2,
|
||||
UD_Ifcomi,
|
||||
UD_Ifcomip,
|
||||
UD_Ifcomp,
|
||||
UD_Ifcomp3,
|
||||
UD_Ifcomp5,
|
||||
UD_Ifcompp,
|
||||
UD_Ifcos,
|
||||
UD_Ifdecstp,
|
||||
UD_Ifdiv,
|
||||
UD_Ifdivp,
|
||||
UD_Ifdivr,
|
||||
UD_Ifdivrp,
|
||||
UD_Ifemms,
|
||||
UD_Iffree,
|
||||
UD_Iffreep,
|
||||
UD_Ifiadd,
|
||||
UD_Ificom,
|
||||
UD_Ificomp,
|
||||
UD_Ifidiv,
|
||||
UD_Ifidivr,
|
||||
UD_Ifild,
|
||||
UD_Ifimul,
|
||||
UD_Ifincstp,
|
||||
UD_Ifist,
|
||||
UD_Ifistp,
|
||||
UD_Ifisttp,
|
||||
UD_Ifisub,
|
||||
UD_Ifisubr,
|
||||
UD_Ifld,
|
||||
UD_Ifld1,
|
||||
UD_Ifldcw,
|
||||
UD_Ifldenv,
|
||||
UD_Ifldl2e,
|
||||
UD_Ifldl2t,
|
||||
UD_Ifldlg2,
|
||||
UD_Ifldln2,
|
||||
UD_Ifldpi,
|
||||
UD_Ifldz,
|
||||
UD_Ifmul,
|
||||
UD_Ifmulp,
|
||||
UD_Ifndisi,
|
||||
UD_Ifneni,
|
||||
UD_Ifninit,
|
||||
UD_Ifnop,
|
||||
UD_Ifnsave,
|
||||
UD_Ifnsetpm,
|
||||
UD_Ifnstcw,
|
||||
UD_Ifnstenv,
|
||||
UD_Ifnstsw,
|
||||
UD_Ifpatan,
|
||||
UD_Ifprem,
|
||||
UD_Ifprem1,
|
||||
UD_Ifptan,
|
||||
UD_Ifrndint,
|
||||
UD_Ifrstor,
|
||||
UD_Ifrstpm,
|
||||
UD_Ifscale,
|
||||
UD_Ifsin,
|
||||
UD_Ifsincos,
|
||||
UD_Ifsqrt,
|
||||
UD_Ifst,
|
||||
UD_Ifstp,
|
||||
UD_Ifstp1,
|
||||
UD_Ifstp8,
|
||||
UD_Ifstp9,
|
||||
UD_Ifsub,
|
||||
UD_Ifsubp,
|
||||
UD_Ifsubr,
|
||||
UD_Ifsubrp,
|
||||
UD_Iftst,
|
||||
UD_Ifucom,
|
||||
UD_Ifucomi,
|
||||
UD_Ifucomip,
|
||||
UD_Ifucomp,
|
||||
UD_Ifucompp,
|
||||
UD_Ifxam,
|
||||
UD_Ifxch,
|
||||
UD_Ifxch4,
|
||||
UD_Ifxch7,
|
||||
UD_Ifxrstor,
|
||||
UD_Ifxsave,
|
||||
UD_Ifxtract,
|
||||
UD_Ifyl2x,
|
||||
UD_Ifyl2xp1,
|
||||
UD_Igetsec,
|
||||
UD_Ihaddpd,
|
||||
UD_Ihaddps,
|
||||
UD_Ihlt,
|
||||
UD_Ihsubpd,
|
||||
UD_Ihsubps,
|
||||
UD_Iidiv,
|
||||
UD_Iimul,
|
||||
UD_Iin,
|
||||
UD_Iinc,
|
||||
UD_Iinsb,
|
||||
UD_Iinsd,
|
||||
UD_Iinsertps,
|
||||
UD_Iinsw,
|
||||
UD_Iint,
|
||||
UD_Iint1,
|
||||
UD_Iint3,
|
||||
UD_Iinto,
|
||||
UD_Iinvd,
|
||||
UD_Iinvept,
|
||||
UD_Iinvlpg,
|
||||
UD_Iinvlpga,
|
||||
UD_Iinvvpid,
|
||||
UD_Iiretd,
|
||||
UD_Iiretq,
|
||||
UD_Iiretw,
|
||||
UD_Ija,
|
||||
UD_Ijae,
|
||||
UD_Ijb,
|
||||
UD_Ijbe,
|
||||
UD_Ijcxz,
|
||||
UD_Ijecxz,
|
||||
UD_Ijg,
|
||||
UD_Ijge,
|
||||
UD_Ijl,
|
||||
UD_Ijle,
|
||||
UD_Ijmp,
|
||||
UD_Ijno,
|
||||
UD_Ijnp,
|
||||
UD_Ijns,
|
||||
UD_Ijnz,
|
||||
UD_Ijo,
|
||||
UD_Ijp,
|
||||
UD_Ijrcxz,
|
||||
UD_Ijs,
|
||||
UD_Ijz,
|
||||
UD_Ilahf,
|
||||
UD_Ilar,
|
||||
UD_Ilddqu,
|
||||
UD_Ildmxcsr,
|
||||
UD_Ilds,
|
||||
UD_Ilea,
|
||||
UD_Ileave,
|
||||
UD_Iles,
|
||||
UD_Ilfence,
|
||||
UD_Ilfs,
|
||||
UD_Ilgdt,
|
||||
UD_Ilgs,
|
||||
UD_Ilidt,
|
||||
UD_Illdt,
|
||||
UD_Ilmsw,
|
||||
UD_Ilock,
|
||||
UD_Ilodsb,
|
||||
UD_Ilodsd,
|
||||
UD_Ilodsq,
|
||||
UD_Ilodsw,
|
||||
UD_Iloop,
|
||||
UD_Iloope,
|
||||
UD_Iloopne,
|
||||
UD_Ilsl,
|
||||
UD_Ilss,
|
||||
UD_Iltr,
|
||||
UD_Imaskmovdqu,
|
||||
UD_Imaskmovq,
|
||||
UD_Imaxpd,
|
||||
UD_Imaxps,
|
||||
UD_Imaxsd,
|
||||
UD_Imaxss,
|
||||
UD_Imfence,
|
||||
UD_Iminpd,
|
||||
UD_Iminps,
|
||||
UD_Iminsd,
|
||||
UD_Iminss,
|
||||
UD_Imonitor,
|
||||
UD_Imontmul,
|
||||
UD_Imov,
|
||||
UD_Imovapd,
|
||||
UD_Imovaps,
|
||||
UD_Imovbe,
|
||||
UD_Imovd,
|
||||
UD_Imovddup,
|
||||
UD_Imovdq2q,
|
||||
UD_Imovdqa,
|
||||
UD_Imovdqu,
|
||||
UD_Imovhlps,
|
||||
UD_Imovhpd,
|
||||
UD_Imovhps,
|
||||
UD_Imovlhps,
|
||||
UD_Imovlpd,
|
||||
UD_Imovlps,
|
||||
UD_Imovmskpd,
|
||||
UD_Imovmskps,
|
||||
UD_Imovntdq,
|
||||
UD_Imovntdqa,
|
||||
UD_Imovnti,
|
||||
UD_Imovntpd,
|
||||
UD_Imovntps,
|
||||
UD_Imovntq,
|
||||
UD_Imovq,
|
||||
UD_Imovq2dq,
|
||||
UD_Imovsb,
|
||||
UD_Imovsd,
|
||||
UD_Imovshdup,
|
||||
UD_Imovsldup,
|
||||
UD_Imovsq,
|
||||
UD_Imovss,
|
||||
UD_Imovsw,
|
||||
UD_Imovsx,
|
||||
UD_Imovsxd,
|
||||
UD_Imovupd,
|
||||
UD_Imovups,
|
||||
UD_Imovzx,
|
||||
UD_Impsadbw,
|
||||
UD_Imul,
|
||||
UD_Imulpd,
|
||||
UD_Imulps,
|
||||
UD_Imulsd,
|
||||
UD_Imulss,
|
||||
UD_Imwait,
|
||||
UD_Ineg,
|
||||
UD_Inop,
|
||||
UD_Inot,
|
||||
UD_Ior,
|
||||
UD_Iorpd,
|
||||
UD_Iorps,
|
||||
UD_Iout,
|
||||
UD_Ioutsb,
|
||||
UD_Ioutsd,
|
||||
UD_Ioutsw,
|
||||
UD_Ipabsb,
|
||||
UD_Ipabsd,
|
||||
UD_Ipabsw,
|
||||
UD_Ipackssdw,
|
||||
UD_Ipacksswb,
|
||||
UD_Ipackusdw,
|
||||
UD_Ipackuswb,
|
||||
UD_Ipaddb,
|
||||
UD_Ipaddd,
|
||||
UD_Ipaddq,
|
||||
UD_Ipaddsb,
|
||||
UD_Ipaddsw,
|
||||
UD_Ipaddusb,
|
||||
UD_Ipaddusw,
|
||||
UD_Ipaddw,
|
||||
UD_Ipalignr,
|
||||
UD_Ipand,
|
||||
UD_Ipandn,
|
||||
UD_Ipavgb,
|
||||
UD_Ipavgusb,
|
||||
UD_Ipavgw,
|
||||
UD_Ipblendvb,
|
||||
UD_Ipblendw,
|
||||
UD_Ipclmulqdq,
|
||||
UD_Ipcmpeqb,
|
||||
UD_Ipcmpeqd,
|
||||
UD_Ipcmpeqq,
|
||||
UD_Ipcmpeqw,
|
||||
UD_Ipcmpestri,
|
||||
UD_Ipcmpestrm,
|
||||
UD_Ipcmpgtb,
|
||||
UD_Ipcmpgtd,
|
||||
UD_Ipcmpgtq,
|
||||
UD_Ipcmpgtw,
|
||||
UD_Ipcmpistri,
|
||||
UD_Ipcmpistrm,
|
||||
UD_Ipextrb,
|
||||
UD_Ipextrd,
|
||||
UD_Ipextrq,
|
||||
UD_Ipextrw,
|
||||
UD_Ipf2id,
|
||||
UD_Ipf2iw,
|
||||
UD_Ipfacc,
|
||||
UD_Ipfadd,
|
||||
UD_Ipfcmpeq,
|
||||
UD_Ipfcmpge,
|
||||
UD_Ipfcmpgt,
|
||||
UD_Ipfmax,
|
||||
UD_Ipfmin,
|
||||
UD_Ipfmul,
|
||||
UD_Ipfnacc,
|
||||
UD_Ipfpnacc,
|
||||
UD_Ipfrcp,
|
||||
UD_Ipfrcpit1,
|
||||
UD_Ipfrcpit2,
|
||||
UD_Ipfrsqit1,
|
||||
UD_Ipfrsqrt,
|
||||
UD_Ipfsub,
|
||||
UD_Ipfsubr,
|
||||
UD_Iphaddd,
|
||||
UD_Iphaddsw,
|
||||
UD_Iphaddw,
|
||||
UD_Iphminposuw,
|
||||
UD_Iphsubd,
|
||||
UD_Iphsubsw,
|
||||
UD_Iphsubw,
|
||||
UD_Ipi2fd,
|
||||
UD_Ipi2fw,
|
||||
UD_Ipinsrb,
|
||||
UD_Ipinsrd,
|
||||
UD_Ipinsrq,
|
||||
UD_Ipinsrw,
|
||||
UD_Ipmaddubsw,
|
||||
UD_Ipmaddwd,
|
||||
UD_Ipmaxsb,
|
||||
UD_Ipmaxsd,
|
||||
UD_Ipmaxsw,
|
||||
UD_Ipmaxub,
|
||||
UD_Ipmaxud,
|
||||
UD_Ipmaxuw,
|
||||
UD_Ipminsb,
|
||||
UD_Ipminsd,
|
||||
UD_Ipminsw,
|
||||
UD_Ipminub,
|
||||
UD_Ipminud,
|
||||
UD_Ipminuw,
|
||||
UD_Ipmovmskb,
|
||||
UD_Ipmovsxbd,
|
||||
UD_Ipmovsxbq,
|
||||
UD_Ipmovsxbw,
|
||||
UD_Ipmovsxdq,
|
||||
UD_Ipmovsxwd,
|
||||
UD_Ipmovsxwq,
|
||||
UD_Ipmovzxbd,
|
||||
UD_Ipmovzxbq,
|
||||
UD_Ipmovzxbw,
|
||||
UD_Ipmovzxdq,
|
||||
UD_Ipmovzxwd,
|
||||
UD_Ipmovzxwq,
|
||||
UD_Ipmuldq,
|
||||
UD_Ipmulhrsw,
|
||||
UD_Ipmulhrw,
|
||||
UD_Ipmulhuw,
|
||||
UD_Ipmulhw,
|
||||
UD_Ipmulld,
|
||||
UD_Ipmullw,
|
||||
UD_Ipmuludq,
|
||||
UD_Ipop,
|
||||
UD_Ipopa,
|
||||
UD_Ipopad,
|
||||
UD_Ipopcnt,
|
||||
UD_Ipopfd,
|
||||
UD_Ipopfq,
|
||||
UD_Ipopfw,
|
||||
UD_Ipor,
|
||||
UD_Iprefetch,
|
||||
UD_Iprefetchnta,
|
||||
UD_Iprefetcht0,
|
||||
UD_Iprefetcht1,
|
||||
UD_Iprefetcht2,
|
||||
UD_Ipsadbw,
|
||||
UD_Ipshufb,
|
||||
UD_Ipshufd,
|
||||
UD_Ipshufhw,
|
||||
UD_Ipshuflw,
|
||||
UD_Ipshufw,
|
||||
UD_Ipsignb,
|
||||
UD_Ipsignd,
|
||||
UD_Ipsignw,
|
||||
UD_Ipslld,
|
||||
UD_Ipslldq,
|
||||
UD_Ipsllq,
|
||||
UD_Ipsllw,
|
||||
UD_Ipsrad,
|
||||
UD_Ipsraw,
|
||||
UD_Ipsrld,
|
||||
UD_Ipsrldq,
|
||||
UD_Ipsrlq,
|
||||
UD_Ipsrlw,
|
||||
UD_Ipsubb,
|
||||
UD_Ipsubd,
|
||||
UD_Ipsubq,
|
||||
UD_Ipsubsb,
|
||||
UD_Ipsubsw,
|
||||
UD_Ipsubusb,
|
||||
UD_Ipsubusw,
|
||||
UD_Ipsubw,
|
||||
UD_Ipswapd,
|
||||
UD_Iptest,
|
||||
UD_Ipunpckhbw,
|
||||
UD_Ipunpckhdq,
|
||||
UD_Ipunpckhqdq,
|
||||
UD_Ipunpckhwd,
|
||||
UD_Ipunpcklbw,
|
||||
UD_Ipunpckldq,
|
||||
UD_Ipunpcklqdq,
|
||||
UD_Ipunpcklwd,
|
||||
UD_Ipush,
|
||||
UD_Ipusha,
|
||||
UD_Ipushad,
|
||||
UD_Ipushfd,
|
||||
UD_Ipushfq,
|
||||
UD_Ipushfw,
|
||||
UD_Ipxor,
|
||||
UD_Ircl,
|
||||
UD_Ircpps,
|
||||
UD_Ircpss,
|
||||
UD_Ircr,
|
||||
UD_Irdmsr,
|
||||
UD_Irdpmc,
|
||||
UD_Irdrand,
|
||||
UD_Irdtsc,
|
||||
UD_Irdtscp,
|
||||
UD_Irep,
|
||||
UD_Irepne,
|
||||
UD_Iret,
|
||||
UD_Iretf,
|
||||
UD_Irol,
|
||||
UD_Iror,
|
||||
UD_Iroundpd,
|
||||
UD_Iroundps,
|
||||
UD_Iroundsd,
|
||||
UD_Iroundss,
|
||||
UD_Irsm,
|
||||
UD_Irsqrtps,
|
||||
UD_Irsqrtss,
|
||||
UD_Isahf,
|
||||
UD_Isalc,
|
||||
UD_Isar,
|
||||
UD_Isbb,
|
||||
UD_Iscasb,
|
||||
UD_Iscasd,
|
||||
UD_Iscasq,
|
||||
UD_Iscasw,
|
||||
UD_Iseta,
|
||||
UD_Isetae,
|
||||
UD_Isetb,
|
||||
UD_Isetbe,
|
||||
UD_Isetg,
|
||||
UD_Isetge,
|
||||
UD_Isetl,
|
||||
UD_Isetle,
|
||||
UD_Isetno,
|
||||
UD_Isetnp,
|
||||
UD_Isetns,
|
||||
UD_Isetnz,
|
||||
UD_Iseto,
|
||||
UD_Isetp,
|
||||
UD_Isets,
|
||||
UD_Isetz,
|
||||
UD_Isfence,
|
||||
UD_Isgdt,
|
||||
UD_Ishl,
|
||||
UD_Ishld,
|
||||
UD_Ishr,
|
||||
UD_Ishrd,
|
||||
UD_Ishufpd,
|
||||
UD_Ishufps,
|
||||
UD_Isidt,
|
||||
UD_Iskinit,
|
||||
UD_Isldt,
|
||||
UD_Ismsw,
|
||||
UD_Isqrtpd,
|
||||
UD_Isqrtps,
|
||||
UD_Isqrtsd,
|
||||
UD_Isqrtss,
|
||||
UD_Istc,
|
||||
UD_Istd,
|
||||
UD_Istgi,
|
||||
UD_Isti,
|
||||
UD_Istmxcsr,
|
||||
UD_Istosb,
|
||||
UD_Istosd,
|
||||
UD_Istosq,
|
||||
UD_Istosw,
|
||||
UD_Istr,
|
||||
UD_Isub,
|
||||
UD_Isubpd,
|
||||
UD_Isubps,
|
||||
UD_Isubsd,
|
||||
UD_Isubss,
|
||||
UD_Iswapgs,
|
||||
UD_Isyscall,
|
||||
UD_Isysenter,
|
||||
UD_Isysexit,
|
||||
UD_Isysret,
|
||||
UD_Itest,
|
||||
UD_Iucomisd,
|
||||
UD_Iucomiss,
|
||||
UD_Iud2,
|
||||
UD_Iunpckhpd,
|
||||
UD_Iunpckhps,
|
||||
UD_Iunpcklpd,
|
||||
UD_Iunpcklps,
|
||||
UD_Ivaddpd,
|
||||
UD_Ivaddps,
|
||||
UD_Ivaddsd,
|
||||
UD_Ivaddss,
|
||||
UD_Ivaddsubpd,
|
||||
UD_Ivaddsubps,
|
||||
UD_Ivaesdec,
|
||||
UD_Ivaesdeclast,
|
||||
UD_Ivaesenc,
|
||||
UD_Ivaesenclast,
|
||||
UD_Ivaesimc,
|
||||
UD_Ivaeskeygenassist,
|
||||
UD_Ivandnpd,
|
||||
UD_Ivandnps,
|
||||
UD_Ivandpd,
|
||||
UD_Ivandps,
|
||||
UD_Ivblendpd,
|
||||
UD_Ivblendps,
|
||||
UD_Ivblendvpd,
|
||||
UD_Ivblendvps,
|
||||
UD_Ivbroadcastsd,
|
||||
UD_Ivbroadcastss,
|
||||
UD_Ivcmppd,
|
||||
UD_Ivcmpps,
|
||||
UD_Ivcmpsd,
|
||||
UD_Ivcmpss,
|
||||
UD_Ivcomisd,
|
||||
UD_Ivcomiss,
|
||||
UD_Ivcvtdq2pd,
|
||||
UD_Ivcvtdq2ps,
|
||||
UD_Ivcvtpd2dq,
|
||||
UD_Ivcvtpd2ps,
|
||||
UD_Ivcvtps2dq,
|
||||
UD_Ivcvtps2pd,
|
||||
UD_Ivcvtsd2si,
|
||||
UD_Ivcvtsd2ss,
|
||||
UD_Ivcvtsi2sd,
|
||||
UD_Ivcvtsi2ss,
|
||||
UD_Ivcvtss2sd,
|
||||
UD_Ivcvtss2si,
|
||||
UD_Ivcvttpd2dq,
|
||||
UD_Ivcvttps2dq,
|
||||
UD_Ivcvttsd2si,
|
||||
UD_Ivcvttss2si,
|
||||
UD_Ivdivpd,
|
||||
UD_Ivdivps,
|
||||
UD_Ivdivsd,
|
||||
UD_Ivdivss,
|
||||
UD_Ivdppd,
|
||||
UD_Ivdpps,
|
||||
UD_Iverr,
|
||||
UD_Iverw,
|
||||
UD_Ivextractf128,
|
||||
UD_Ivextractps,
|
||||
UD_Ivhaddpd,
|
||||
UD_Ivhaddps,
|
||||
UD_Ivhsubpd,
|
||||
UD_Ivhsubps,
|
||||
UD_Ivinsertf128,
|
||||
UD_Ivinsertps,
|
||||
UD_Ivlddqu,
|
||||
UD_Ivmaskmovdqu,
|
||||
UD_Ivmaskmovpd,
|
||||
UD_Ivmaskmovps,
|
||||
UD_Ivmaxpd,
|
||||
UD_Ivmaxps,
|
||||
UD_Ivmaxsd,
|
||||
UD_Ivmaxss,
|
||||
UD_Ivmcall,
|
||||
UD_Ivmclear,
|
||||
UD_Ivminpd,
|
||||
UD_Ivminps,
|
||||
UD_Ivminsd,
|
||||
UD_Ivminss,
|
||||
UD_Ivmlaunch,
|
||||
UD_Ivmload,
|
||||
UD_Ivmmcall,
|
||||
UD_Ivmovapd,
|
||||
UD_Ivmovaps,
|
||||
UD_Ivmovd,
|
||||
UD_Ivmovddup,
|
||||
UD_Ivmovdqa,
|
||||
UD_Ivmovdqu,
|
||||
UD_Ivmovhlps,
|
||||
UD_Ivmovhpd,
|
||||
UD_Ivmovhps,
|
||||
UD_Ivmovlhps,
|
||||
UD_Ivmovlpd,
|
||||
UD_Ivmovlps,
|
||||
UD_Ivmovmskpd,
|
||||
UD_Ivmovmskps,
|
||||
UD_Ivmovntdq,
|
||||
UD_Ivmovntdqa,
|
||||
UD_Ivmovntpd,
|
||||
UD_Ivmovntps,
|
||||
UD_Ivmovq,
|
||||
UD_Ivmovsd,
|
||||
UD_Ivmovshdup,
|
||||
UD_Ivmovsldup,
|
||||
UD_Ivmovss,
|
||||
UD_Ivmovupd,
|
||||
UD_Ivmovups,
|
||||
UD_Ivmpsadbw,
|
||||
UD_Ivmptrld,
|
||||
UD_Ivmptrst,
|
||||
UD_Ivmread,
|
||||
UD_Ivmresume,
|
||||
UD_Ivmrun,
|
||||
UD_Ivmsave,
|
||||
UD_Ivmulpd,
|
||||
UD_Ivmulps,
|
||||
UD_Ivmulsd,
|
||||
UD_Ivmulss,
|
||||
UD_Ivmwrite,
|
||||
UD_Ivmxoff,
|
||||
UD_Ivmxon,
|
||||
UD_Ivorpd,
|
||||
UD_Ivorps,
|
||||
UD_Ivpabsb,
|
||||
UD_Ivpabsd,
|
||||
UD_Ivpabsw,
|
||||
UD_Ivpackssdw,
|
||||
UD_Ivpacksswb,
|
||||
UD_Ivpackusdw,
|
||||
UD_Ivpackuswb,
|
||||
UD_Ivpaddb,
|
||||
UD_Ivpaddd,
|
||||
UD_Ivpaddq,
|
||||
UD_Ivpaddsb,
|
||||
UD_Ivpaddsw,
|
||||
UD_Ivpaddusb,
|
||||
UD_Ivpaddusw,
|
||||
UD_Ivpaddw,
|
||||
UD_Ivpalignr,
|
||||
UD_Ivpand,
|
||||
UD_Ivpandn,
|
||||
UD_Ivpavgb,
|
||||
UD_Ivpavgw,
|
||||
UD_Ivpblendvb,
|
||||
UD_Ivpblendw,
|
||||
UD_Ivpclmulqdq,
|
||||
UD_Ivpcmpeqb,
|
||||
UD_Ivpcmpeqd,
|
||||
UD_Ivpcmpeqq,
|
||||
UD_Ivpcmpeqw,
|
||||
UD_Ivpcmpestri,
|
||||
UD_Ivpcmpestrm,
|
||||
UD_Ivpcmpgtb,
|
||||
UD_Ivpcmpgtd,
|
||||
UD_Ivpcmpgtq,
|
||||
UD_Ivpcmpgtw,
|
||||
UD_Ivpcmpistri,
|
||||
UD_Ivpcmpistrm,
|
||||
UD_Ivperm2f128,
|
||||
UD_Ivpermilpd,
|
||||
UD_Ivpermilps,
|
||||
UD_Ivpextrb,
|
||||
UD_Ivpextrd,
|
||||
UD_Ivpextrq,
|
||||
UD_Ivpextrw,
|
||||
UD_Ivphaddd,
|
||||
UD_Ivphaddsw,
|
||||
UD_Ivphaddw,
|
||||
UD_Ivphminposuw,
|
||||
UD_Ivphsubd,
|
||||
UD_Ivphsubsw,
|
||||
UD_Ivphsubw,
|
||||
UD_Ivpinsrb,
|
||||
UD_Ivpinsrd,
|
||||
UD_Ivpinsrq,
|
||||
UD_Ivpinsrw,
|
||||
UD_Ivpmaddubsw,
|
||||
UD_Ivpmaddwd,
|
||||
UD_Ivpmaxsb,
|
||||
UD_Ivpmaxsd,
|
||||
UD_Ivpmaxsw,
|
||||
UD_Ivpmaxub,
|
||||
UD_Ivpmaxud,
|
||||
UD_Ivpmaxuw,
|
||||
UD_Ivpminsb,
|
||||
UD_Ivpminsd,
|
||||
UD_Ivpminsw,
|
||||
UD_Ivpminub,
|
||||
UD_Ivpminud,
|
||||
UD_Ivpminuw,
|
||||
UD_Ivpmovmskb,
|
||||
UD_Ivpmovsxbd,
|
||||
UD_Ivpmovsxbq,
|
||||
UD_Ivpmovsxbw,
|
||||
UD_Ivpmovsxwd,
|
||||
UD_Ivpmovsxwq,
|
||||
UD_Ivpmovzxbd,
|
||||
UD_Ivpmovzxbq,
|
||||
UD_Ivpmovzxbw,
|
||||
UD_Ivpmovzxdq,
|
||||
UD_Ivpmovzxwd,
|
||||
UD_Ivpmovzxwq,
|
||||
UD_Ivpmuldq,
|
||||
UD_Ivpmulhrsw,
|
||||
UD_Ivpmulhuw,
|
||||
UD_Ivpmulhw,
|
||||
UD_Ivpmulld,
|
||||
UD_Ivpmullw,
|
||||
UD_Ivpor,
|
||||
UD_Ivpsadbw,
|
||||
UD_Ivpshufb,
|
||||
UD_Ivpshufd,
|
||||
UD_Ivpshufhw,
|
||||
UD_Ivpshuflw,
|
||||
UD_Ivpsignb,
|
||||
UD_Ivpsignd,
|
||||
UD_Ivpsignw,
|
||||
UD_Ivpslld,
|
||||
UD_Ivpslldq,
|
||||
UD_Ivpsllq,
|
||||
UD_Ivpsllw,
|
||||
UD_Ivpsrad,
|
||||
UD_Ivpsraw,
|
||||
UD_Ivpsrld,
|
||||
UD_Ivpsrldq,
|
||||
UD_Ivpsrlq,
|
||||
UD_Ivpsrlw,
|
||||
UD_Ivpsubb,
|
||||
UD_Ivpsubd,
|
||||
UD_Ivpsubq,
|
||||
UD_Ivpsubsb,
|
||||
UD_Ivpsubsw,
|
||||
UD_Ivpsubusb,
|
||||
UD_Ivpsubusw,
|
||||
UD_Ivpsubw,
|
||||
UD_Ivptest,
|
||||
UD_Ivpunpckhbw,
|
||||
UD_Ivpunpckhdq,
|
||||
UD_Ivpunpckhqdq,
|
||||
UD_Ivpunpckhwd,
|
||||
UD_Ivpunpcklbw,
|
||||
UD_Ivpunpckldq,
|
||||
UD_Ivpunpcklqdq,
|
||||
UD_Ivpunpcklwd,
|
||||
UD_Ivpxor,
|
||||
UD_Ivrcpps,
|
||||
UD_Ivrcpss,
|
||||
UD_Ivroundpd,
|
||||
UD_Ivroundps,
|
||||
UD_Ivroundsd,
|
||||
UD_Ivroundss,
|
||||
UD_Ivrsqrtps,
|
||||
UD_Ivrsqrtss,
|
||||
UD_Ivshufpd,
|
||||
UD_Ivshufps,
|
||||
UD_Ivsqrtpd,
|
||||
UD_Ivsqrtps,
|
||||
UD_Ivsqrtsd,
|
||||
UD_Ivsqrtss,
|
||||
UD_Ivstmxcsr,
|
||||
UD_Ivsubpd,
|
||||
UD_Ivsubps,
|
||||
UD_Ivsubsd,
|
||||
UD_Ivsubss,
|
||||
UD_Ivtestpd,
|
||||
UD_Ivtestps,
|
||||
UD_Ivucomisd,
|
||||
UD_Ivucomiss,
|
||||
UD_Ivunpckhpd,
|
||||
UD_Ivunpckhps,
|
||||
UD_Ivunpcklpd,
|
||||
UD_Ivunpcklps,
|
||||
UD_Ivxorpd,
|
||||
UD_Ivxorps,
|
||||
UD_Ivzeroall,
|
||||
UD_Ivzeroupper,
|
||||
UD_Iwait,
|
||||
UD_Iwbinvd,
|
||||
UD_Iwrmsr,
|
||||
UD_Ixadd,
|
||||
UD_Ixchg,
|
||||
UD_Ixcryptcbc,
|
||||
UD_Ixcryptcfb,
|
||||
UD_Ixcryptctr,
|
||||
UD_Ixcryptecb,
|
||||
UD_Ixcryptofb,
|
||||
UD_Ixgetbv,
|
||||
UD_Ixlatb,
|
||||
UD_Ixor,
|
||||
UD_Ixorpd,
|
||||
UD_Ixorps,
|
||||
UD_Ixrstor,
|
||||
UD_Ixsave,
|
||||
UD_Ixsetbv,
|
||||
UD_Ixsha1,
|
||||
UD_Ixsha256,
|
||||
UD_Ixstore,
|
||||
UD_Iinvalid,
|
||||
UD_I3dnow,
|
||||
UD_Inone,
|
||||
UD_Idb,
|
||||
UD_Ipause,
|
||||
UD_MAX_MNEMONIC_CODE
|
||||
};
|
||||
|
||||
extern const char * ud_mnemonics_str[];
|
||||
|
||||
#endif /* UD_ITAB_H */
|
1
deps/libtomcrypt
vendored
Submodule
1
deps/libtomcrypt
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fae62af0ab16f469c2512ec04575dd60ca018657
|
1
deps/libtommath
vendored
Submodule
1
deps/libtommath
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 0df542cb70f621bbeec207be1949832fb1442479
|
1
deps/minhook
vendored
Submodule
1
deps/minhook
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 0f25a2449b3cf878bcbdbf91b693c38149ecf029
|
39
deps/premake/discord-rpc.lua
vendored
Normal file
39
deps/premake/discord-rpc.lua
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
discordrpc = {
|
||||
source = path.join(dependencies.basePath, "discord-rpc"),
|
||||
}
|
||||
|
||||
function discordrpc.import()
|
||||
links { "discord-rpc" }
|
||||
discordrpc.includes()
|
||||
end
|
||||
|
||||
function discordrpc.includes()
|
||||
includedirs {
|
||||
path.join(discordrpc.source, "include"),
|
||||
}
|
||||
end
|
||||
|
||||
function discordrpc.project()
|
||||
project "discord-rpc"
|
||||
language "C++"
|
||||
|
||||
discordrpc.includes()
|
||||
rapidjson.import();
|
||||
|
||||
files {
|
||||
path.join(discordrpc.source, "src/*.h"),
|
||||
path.join(discordrpc.source, "src/*.cpp"),
|
||||
}
|
||||
|
||||
removefiles {
|
||||
path.join(discordrpc.source, "src/dllmain.cpp"),
|
||||
path.join(discordrpc.source, "src/*_linux.cpp"),
|
||||
path.join(discordrpc.source, "src/*_unix.cpp"),
|
||||
path.join(discordrpc.source, "src/*_osx.cpp"),
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, discordrpc)
|
19
deps/premake/gsl.lua
vendored
Normal file
19
deps/premake/gsl.lua
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
gsl = {
|
||||
source = path.join(dependencies.basePath, "GSL")
|
||||
}
|
||||
|
||||
function gsl.import()
|
||||
gsl.includes()
|
||||
end
|
||||
|
||||
function gsl.includes()
|
||||
includedirs {
|
||||
path.join(gsl.source, "include")
|
||||
}
|
||||
end
|
||||
|
||||
function gsl.project()
|
||||
|
||||
end
|
||||
|
||||
table.insert(dependencies, gsl)
|
64
deps/premake/libtomcrypt.lua
vendored
Normal file
64
deps/premake/libtomcrypt.lua
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
libtomcrypt = {
|
||||
source = path.join(dependencies.basePath, "libtomcrypt"),
|
||||
}
|
||||
|
||||
function libtomcrypt.import()
|
||||
links {
|
||||
"libtomcrypt"
|
||||
}
|
||||
|
||||
libtomcrypt.includes()
|
||||
end
|
||||
|
||||
function libtomcrypt.includes()
|
||||
includedirs {
|
||||
path.join(libtomcrypt.source, "src/headers")
|
||||
}
|
||||
|
||||
defines {
|
||||
"LTC_NO_FAST",
|
||||
"LTC_NO_PROTOTYPES",
|
||||
"LTC_NO_RSA_BLINDING",
|
||||
"LTC_NO_FILE",
|
||||
"ARGTYPE=4",
|
||||
}
|
||||
end
|
||||
|
||||
function libtomcrypt.project()
|
||||
project "libtomcrypt"
|
||||
language "C"
|
||||
|
||||
libtomcrypt.includes()
|
||||
libtommath.import()
|
||||
|
||||
files {
|
||||
path.join(libtomcrypt.source, "src/**.c"),
|
||||
}
|
||||
|
||||
removefiles {
|
||||
path.join(libtomcrypt.source, "src/**/*_test.c"),
|
||||
path.join(libtomcrypt.source, "src/**/*tab.c"),
|
||||
path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"),
|
||||
}
|
||||
|
||||
defines {
|
||||
"_CRT_SECURE_NO_WARNINGS",
|
||||
"LTC_SOURCE",
|
||||
"_LIB",
|
||||
"USE_LTM"
|
||||
}
|
||||
|
||||
removedefines {
|
||||
"_DLL",
|
||||
"_USRDLL"
|
||||
}
|
||||
|
||||
linkoptions {
|
||||
"-IGNORE:4221"
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, libtomcrypt)
|
52
deps/premake/libtommath.lua
vendored
Normal file
52
deps/premake/libtommath.lua
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
libtommath = {
|
||||
source = path.join(dependencies.basePath, "libtommath"),
|
||||
}
|
||||
|
||||
function libtommath.import()
|
||||
links {
|
||||
"libtommath"
|
||||
}
|
||||
|
||||
libtommath.includes()
|
||||
end
|
||||
|
||||
function libtommath.includes()
|
||||
includedirs {
|
||||
libtommath.source
|
||||
}
|
||||
|
||||
defines {
|
||||
"LTM_DESC",
|
||||
"__STDC_IEC_559__",
|
||||
"MP_NO_DEV_URANDOM",
|
||||
}
|
||||
end
|
||||
|
||||
function libtommath.project()
|
||||
project "libtommath"
|
||||
language "C"
|
||||
|
||||
libtommath.includes()
|
||||
|
||||
files {
|
||||
path.join(libtommath.source, "*.c"),
|
||||
}
|
||||
|
||||
defines {
|
||||
"_LIB"
|
||||
}
|
||||
|
||||
removedefines {
|
||||
"_DLL",
|
||||
"_USRDLL"
|
||||
}
|
||||
|
||||
linkoptions {
|
||||
"-IGNORE:4221"
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, libtommath)
|
31
deps/premake/minhook.lua
vendored
Normal file
31
deps/premake/minhook.lua
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
minhook = {
|
||||
source = path.join(dependencies.basePath, "minhook"),
|
||||
}
|
||||
|
||||
function minhook.import()
|
||||
links { "minhook" }
|
||||
minhook.includes()
|
||||
end
|
||||
|
||||
function minhook.includes()
|
||||
includedirs {
|
||||
path.join(minhook.source, "include")
|
||||
}
|
||||
end
|
||||
|
||||
function minhook.project()
|
||||
project "minhook"
|
||||
language "C"
|
||||
|
||||
minhook.includes()
|
||||
|
||||
files {
|
||||
path.join(minhook.source, "src/**.h"),
|
||||
path.join(minhook.source, "src/**.c"),
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, minhook)
|
43
deps/premake/minizip.lua
vendored
Normal file
43
deps/premake/minizip.lua
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
minizip = {
|
||||
source = path.join(dependencies.basePath, "zlib/contrib/minizip"),
|
||||
}
|
||||
|
||||
function minizip.import()
|
||||
links { "minizip" }
|
||||
zlib.import()
|
||||
minizip.includes()
|
||||
end
|
||||
|
||||
function minizip.includes()
|
||||
includedirs {
|
||||
minizip.source
|
||||
}
|
||||
|
||||
zlib.includes()
|
||||
end
|
||||
|
||||
function minizip.project()
|
||||
project "minizip"
|
||||
language "C"
|
||||
|
||||
minizip.includes()
|
||||
|
||||
files {
|
||||
path.join(minizip.source, "*.h"),
|
||||
path.join(minizip.source, "*.c"),
|
||||
}
|
||||
|
||||
removefiles {
|
||||
path.join(minizip.source, "miniunz.c"),
|
||||
path.join(minizip.source, "minizip.c"),
|
||||
}
|
||||
|
||||
defines {
|
||||
"_CRT_SECURE_NO_DEPRECATE",
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, minizip)
|
19
deps/premake/rapidjson.lua
vendored
Normal file
19
deps/premake/rapidjson.lua
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
rapidjson = {
|
||||
source = path.join(dependencies.basePath, "rapidjson"),
|
||||
}
|
||||
|
||||
function rapidjson.import()
|
||||
rapidjson.includes()
|
||||
end
|
||||
|
||||
function rapidjson.includes()
|
||||
includedirs {
|
||||
path.join(rapidjson.source, "include"),
|
||||
}
|
||||
end
|
||||
|
||||
function rapidjson.project()
|
||||
|
||||
end
|
||||
|
||||
table.insert(dependencies, rapidjson)
|
37
deps/premake/udis86.lua
vendored
Normal file
37
deps/premake/udis86.lua
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
udis86 = {
|
||||
source = path.join(dependencies.basePath, "udis86"),
|
||||
}
|
||||
|
||||
function udis86.import()
|
||||
links {
|
||||
"udis86"
|
||||
}
|
||||
|
||||
udis86.includes()
|
||||
end
|
||||
|
||||
function udis86.includes()
|
||||
includedirs {
|
||||
udis86.source,
|
||||
path.join(udis86.source, "libudis86"),
|
||||
path.join(dependencies.basePath, "extra/udis86"),
|
||||
path.join(dependencies.basePath, "extra/udis86/libudis86"),
|
||||
}
|
||||
end
|
||||
|
||||
function udis86.project()
|
||||
project "udis86"
|
||||
language "C"
|
||||
|
||||
udis86.includes()
|
||||
|
||||
files {
|
||||
path.join(udis86.source, "libudis86/*.c"),
|
||||
path.join(dependencies.basePath, "extra/udis86/libudis86/*.c"),
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, udis86)
|
39
deps/premake/zlib.lua
vendored
Normal file
39
deps/premake/zlib.lua
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
zlib = {
|
||||
source = path.join(dependencies.basePath, "zlib"),
|
||||
}
|
||||
|
||||
function zlib.import()
|
||||
links { "zlib" }
|
||||
zlib.includes()
|
||||
end
|
||||
|
||||
function zlib.includes()
|
||||
includedirs {
|
||||
zlib.source
|
||||
}
|
||||
|
||||
defines {
|
||||
"ZLIB_CONST",
|
||||
}
|
||||
end
|
||||
|
||||
function zlib.project()
|
||||
project "zlib"
|
||||
language "C"
|
||||
|
||||
zlib.includes()
|
||||
|
||||
files {
|
||||
path.join(zlib.source, "*.h"),
|
||||
path.join(zlib.source, "*.c"),
|
||||
}
|
||||
|
||||
defines {
|
||||
"_CRT_SECURE_NO_DEPRECATE",
|
||||
}
|
||||
|
||||
warnings "Off"
|
||||
kind "StaticLib"
|
||||
end
|
||||
|
||||
table.insert(dependencies, zlib)
|
1
deps/rapidjson
vendored
Submodule
1
deps/rapidjson
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 973dc9c06dcd3d035ebd039cfb9ea457721ec213
|
1
deps/udis86
vendored
Submodule
1
deps/udis86
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 56ff6c87c11de0ffa725b14339004820556e343d
|
1
deps/zlib
vendored
Submodule
1
deps/zlib
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 04f42ceca40f73e2978b50e93806c2a18c1281fc
|
4
generate.bat
Normal file
4
generate.bat
Normal file
@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
echo Updating submodules...
|
||||
call git submodule update --init --recursive
|
||||
call tools\premake5 %* vs2022
|
331
premake5.lua
Normal file
331
premake5.lua
Normal file
@ -0,0 +1,331 @@
|
||||
gitVersioningCommand = "git describe --tags --dirty --always"
|
||||
gitCurrentBranchCommand = "git symbolic-ref -q --short HEAD"
|
||||
|
||||
-- Quote the given string input as a C string
|
||||
function cstrquote(value)
|
||||
if value == nil then
|
||||
return "\"\""
|
||||
end
|
||||
result = value:gsub("\\", "\\\\")
|
||||
result = result:gsub("\"", "\\\"")
|
||||
result = result:gsub("\n", "\\n")
|
||||
result = result:gsub("\t", "\\t")
|
||||
result = result:gsub("\r", "\\r")
|
||||
result = result:gsub("\a", "\\a")
|
||||
result = result:gsub("\b", "\\b")
|
||||
result = "\"" .. result .. "\""
|
||||
return result
|
||||
end
|
||||
|
||||
-- Converts tags in "vX.X.X" format and given revision number Y to an array of numbers {X,X,X,Y}.
|
||||
-- In the case where the format does not work fall back to padding with zeroes and just ending with the revision number.
|
||||
-- partscount can be either 3 or 4.
|
||||
function vertonumarr(value, vernumber, partscount)
|
||||
vernum = {}
|
||||
for num in string.gmatch(value or "", "%d+") do
|
||||
if #vernum < 3 then
|
||||
table.insert(vernum, tonumber(num))
|
||||
end
|
||||
end
|
||||
while #vernum < 3 do
|
||||
table.insert(vernum, 0)
|
||||
end
|
||||
if #vernum < partscount then
|
||||
table.insert(vernum, tonumber(vernumber))
|
||||
end
|
||||
return vernum
|
||||
end
|
||||
|
||||
dependencies = {
|
||||
basePath = "./deps"
|
||||
}
|
||||
|
||||
function dependencies.load()
|
||||
dir = path.join(dependencies.basePath, "premake/*.lua")
|
||||
deps = os.matchfiles(dir)
|
||||
|
||||
for i, dep in pairs(deps) do
|
||||
dep = dep:gsub(".lua", "")
|
||||
require(dep)
|
||||
end
|
||||
end
|
||||
|
||||
function dependencies.imports()
|
||||
for i, proj in pairs(dependencies) do
|
||||
if type(i) == 'number' then
|
||||
proj.import()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function dependencies.projects()
|
||||
for i, proj in pairs(dependencies) do
|
||||
if type(i) == 'number' then
|
||||
proj.project()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newoption {
|
||||
trigger = "copy-to",
|
||||
description = "Optional, copy the exe to a custom folder after build, define the path here if wanted.",
|
||||
value = "PATH"
|
||||
}
|
||||
|
||||
newaction {
|
||||
trigger = "version",
|
||||
description = "Returns the version string for the current commit of the source code.",
|
||||
onWorkspace = function(wks)
|
||||
-- get current version via git
|
||||
local proc = assert(io.popen(gitVersioningCommand, "r"))
|
||||
local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "")
|
||||
proc:close()
|
||||
local version = gitDescribeOutput
|
||||
|
||||
proc = assert(io.popen(gitCurrentBranchCommand, "r"))
|
||||
local gitCurrentBranchOutput = assert(proc:read('*a')):gsub("%s+", "")
|
||||
local gitCurrentBranchSuccess = proc:close()
|
||||
if gitCurrentBranchSuccess then
|
||||
-- We got a branch name, check if it is a feature branch
|
||||
if gitCurrentBranchOutput ~= "develop" and gitCurrentBranchOutput ~= "master" then
|
||||
version = version .. "-" .. gitCurrentBranchOutput
|
||||
end
|
||||
end
|
||||
|
||||
print(version)
|
||||
os.exit(0)
|
||||
end
|
||||
}
|
||||
|
||||
newaction {
|
||||
trigger = "generate-buildinfo",
|
||||
description = "Sets up build information file like version.h.",
|
||||
onWorkspace = function(wks)
|
||||
-- get old version number from version.hpp if any
|
||||
local oldVersion = "(none)"
|
||||
local oldVersionHeader = io.open(wks.location .. "/src/version.h", "r")
|
||||
if oldVersionHeader ~= nil then
|
||||
local oldVersionHeaderContent = assert(oldVersionHeader:read('*l'))
|
||||
while oldVersionHeaderContent do
|
||||
m = string.match(oldVersionHeaderContent, "#define GIT_DESCRIBE (.+)%s*$")
|
||||
if m ~= nil then
|
||||
oldVersion = m
|
||||
end
|
||||
|
||||
oldVersionHeaderContent = oldVersionHeader:read('*l')
|
||||
end
|
||||
end
|
||||
|
||||
-- get current version via git
|
||||
local proc = assert(io.popen(gitVersioningCommand, "r"))
|
||||
local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "")
|
||||
proc:close()
|
||||
|
||||
-- generate version.hpp with a revision number if not equal
|
||||
gitDescribeOutputQuoted = cstrquote(gitDescribeOutput)
|
||||
if oldVersion ~= gitDescribeOutputQuoted then
|
||||
-- get current git hash and write to version.txt (used by the preliminary updater)
|
||||
-- TODO - remove once proper updater and release versioning exists
|
||||
local proc = assert(io.popen("git rev-parse HEAD", "r"))
|
||||
local gitCommitHash = assert(proc:read('*a')):gsub("%s+", "")
|
||||
proc:close()
|
||||
|
||||
-- get whether this is a clean revision (no uncommitted changes)
|
||||
proc = assert(io.popen("git status --porcelain", "r"))
|
||||
local revDirty = (assert(proc:read('*a')) ~= "")
|
||||
if revDirty then revDirty = 1 else revDirty = 0 end
|
||||
proc:close()
|
||||
|
||||
-- get current tag name
|
||||
proc = assert(io.popen("git describe --tags --abbrev=0"))
|
||||
local tagName = proc:read('*l')
|
||||
|
||||
-- get current branch name
|
||||
proc = assert(io.popen("git branch --show-current"))
|
||||
local branchName = proc:read('*l')
|
||||
|
||||
-- branch for ci
|
||||
if branchName == nil or branchName == '' then
|
||||
proc = assert(io.popen("git show -s --pretty=%d HEAD"))
|
||||
local branchInfo = proc:read('*l')
|
||||
m = string.match(branchInfo, ".+,.+, ([^)]+)")
|
||||
if m ~= nil then
|
||||
branchName = m
|
||||
end
|
||||
end
|
||||
|
||||
if branchName == nil then
|
||||
branchName = "develop"
|
||||
end
|
||||
|
||||
print("Detected branch: " .. branchName)
|
||||
|
||||
-- get revision number via git
|
||||
local proc = assert(io.popen("git rev-list --count HEAD", "r"))
|
||||
local revNumber = assert(proc:read('*a')):gsub("%s+", "")
|
||||
|
||||
print ("Update " .. oldVersion .. " -> " .. gitDescribeOutputQuoted)
|
||||
|
||||
-- write to version.txt for preliminary updater
|
||||
-- NOTE - remove this once we have a proper updater and proper release versioning
|
||||
local versionFile = assert(io.open(wks.location .. "/version.txt", "w"))
|
||||
versionFile:write(gitCommitHash)
|
||||
versionFile:close()
|
||||
|
||||
-- write version header
|
||||
local versionHeader = assert(io.open(wks.location .. "/src/version.h", "w"))
|
||||
versionHeader:write("/*\n")
|
||||
versionHeader:write(" * Automatically generated by premake5.\n")
|
||||
versionHeader:write(" * Do not touch!\n")
|
||||
versionHeader:write(" */\n")
|
||||
versionHeader:write("\n")
|
||||
versionHeader:write("#define GIT_DESCRIBE " .. gitDescribeOutputQuoted .. "\n")
|
||||
versionHeader:write("#define GIT_DIRTY " .. revDirty .. "\n")
|
||||
versionHeader:write("#define GIT_HASH " .. cstrquote(gitCommitHash) .. "\n")
|
||||
versionHeader:write("#define GIT_TAG " .. cstrquote(tagName) .. "\n")
|
||||
versionHeader:write("#define GIT_BRANCH " .. cstrquote(branchName) .. "\n")
|
||||
versionHeader:write("\n")
|
||||
versionHeader:write("// Version transformed for RC files\n")
|
||||
versionHeader:write("#define VERSION_PRODUCT_RC " .. table.concat(vertonumarr(tagName, revNumber, 3), ",") .. "\n")
|
||||
versionHeader:write("#define VERSION_PRODUCT " .. cstrquote(table.concat(vertonumarr(tagName, revNumber, 3), ".")) .. "\n")
|
||||
versionHeader:write("#define VERSION_FILE_RC " .. table.concat(vertonumarr(tagName, revNumber, 4), ",") .. "\n")
|
||||
versionHeader:write("#define VERSION_FILE " .. cstrquote(table.concat(vertonumarr(tagName, revNumber, 4), ".")) .. "\n")
|
||||
versionHeader:write("\n")
|
||||
versionHeader:write("// Alias definitions\n")
|
||||
versionHeader:write("#define VERSION GIT_DESCRIBE\n")
|
||||
versionHeader:write("#define SHORTVERSION VERSION_PRODUCT\n")
|
||||
versionHeader:close()
|
||||
local versionHeader = assert(io.open(wks.location .. "/src/version.hpp", "w"))
|
||||
versionHeader:write("/*\n")
|
||||
versionHeader:write(" * Automatically generated by premake5.\n")
|
||||
versionHeader:write(" * Do not touch!\n")
|
||||
versionHeader:write(" *\n")
|
||||
versionHeader:write(" * This file exists for reasons of complying with our coding standards.\n")
|
||||
versionHeader:write(" *\n")
|
||||
versionHeader:write(" * The Resource Compiler will ignore any content from C++ header files if they're not from STDInclude.hpp.\n")
|
||||
versionHeader:write(" * That's the reason why we now place all version info in version.h instead.\n")
|
||||
versionHeader:write(" */\n")
|
||||
versionHeader:write("\n")
|
||||
versionHeader:write("#include \".\\version.h\"\n")
|
||||
versionHeader:close()
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
dependencies.load()
|
||||
|
||||
workspace "iw4-sp"
|
||||
startproject "client"
|
||||
location "./build"
|
||||
objdir "%{wks.location}/obj"
|
||||
targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}"
|
||||
|
||||
configurations {"Debug", "Release"}
|
||||
|
||||
language "C++"
|
||||
cppdialect "C++20"
|
||||
|
||||
architecture "x86"
|
||||
platforms "Win32"
|
||||
|
||||
systemversion "latest"
|
||||
symbols "On"
|
||||
staticruntime "On"
|
||||
editandcontinue "Off"
|
||||
warnings "Extra"
|
||||
characterset "ASCII"
|
||||
|
||||
if os.getenv("CI") then
|
||||
defines {"CI"}
|
||||
end
|
||||
|
||||
flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks"}
|
||||
|
||||
filter "platforms:Win*"
|
||||
defines {"_WINDOWS", "WIN32"}
|
||||
filter {}
|
||||
|
||||
filter "configurations:Release"
|
||||
optimize "Size"
|
||||
buildoptions {"/GL"}
|
||||
linkoptions {"/IGNORE:4702", "/LTCG"}
|
||||
defines {"NDEBUG"}
|
||||
flags {"FatalCompileWarnings"}
|
||||
filter {}
|
||||
|
||||
filter "configurations:Debug"
|
||||
optimize "Debug"
|
||||
defines {"DEBUG", "_DEBUG"}
|
||||
filter {}
|
||||
|
||||
project "common"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
|
||||
files {"./src/common/**.hpp", "./src/common/**.cpp"}
|
||||
|
||||
includedirs {"./src/common", "%{prj.location}/src"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
dependencies.imports()
|
||||
|
||||
project "runner"
|
||||
kind "WindowedApp"
|
||||
language "C++"
|
||||
|
||||
files {"./src/runner/**.rc", "./src/runner/**.hpp", "./src/runner/**.cpp", "./src/runner/resources/**.*"}
|
||||
|
||||
includedirs {"./src/runner", "./src/common", "%{prj.location}/src"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
links {"common"}
|
||||
|
||||
dependencies.imports()
|
||||
|
||||
project "client"
|
||||
kind "WindowedApp"
|
||||
language "C++"
|
||||
|
||||
targetname "iw4-sp"
|
||||
|
||||
pchheader "std_include.hpp"
|
||||
pchsource "src/client/std_include.cpp"
|
||||
|
||||
linkoptions {"/IGNORE:4254", "/DYNAMICBASE:NO", "/SAFESEH:NO", "/LARGEADDRESSAWARE", "/LAST:.main", "/PDBCompress"}
|
||||
|
||||
files {"./src/client/**.rc", "./src/client/**.hpp", "./src/client/**.cpp", "./src/resources/**.*"}
|
||||
|
||||
includedirs {"./src/client", "./src/common", "%{prj.location}/src"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
links {"common"}
|
||||
|
||||
prebuildcommands {"pushd %{_MAIN_SCRIPT_DIR}", "tools\\premake5 generate-buildinfo", "popd"}
|
||||
|
||||
if _OPTIONS["copy-to"] then
|
||||
postbuildcommands {
|
||||
"copy /y \"$(TargetDir)*.exe\" \"" .. _OPTIONS["copy-to"] .. "\""
|
||||
}
|
||||
end
|
||||
|
||||
dependencies.imports()
|
||||
|
||||
project "tlsdll"
|
||||
kind "SharedLib"
|
||||
language "C++"
|
||||
|
||||
files {"./src/tlsdll/**.rc", "./src/tlsdll/**.hpp", "./src/tlsdll/**.cpp", "./src/tlsdll/resources/**.*"}
|
||||
|
||||
includedirs {"./src/tlsdll", "%{prj.location}/src"}
|
||||
|
||||
links {"common"}
|
||||
|
||||
resincludedirs {"$(ProjectDir)src"}
|
||||
|
||||
dependencies.imports()
|
||||
|
||||
group "Dependencies"
|
||||
dependencies.projects()
|
49
src/client/component/asset_restrict.cpp
Normal file
49
src/client/component/asset_restrict.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/memory.hpp>
|
||||
|
||||
namespace asset_restrict {
|
||||
namespace {
|
||||
game::XAssetEntry entry_pool[789312];
|
||||
|
||||
game::XAssetHeader reallocate_asset_pool(game::XAssetType type,
|
||||
const int size) {
|
||||
const auto entry_size =
|
||||
reinterpret_cast<int (*)()>(game::DB_GetXAssetSizeHandlers[type])();
|
||||
const game::XAssetHeader pool_entry = {
|
||||
.data = utils::memory::allocate(entry_size * size)};
|
||||
game::DB_XAssetPool[type] = pool_entry.data;
|
||||
game::g_poolSize[type] = size;
|
||||
|
||||
return pool_entry;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
patch_entry_pool_sp();
|
||||
reallocate_asset_pool(game::ASSET_TYPE_GAMEWORLD_MP, 1);
|
||||
}
|
||||
|
||||
static void patch_entry_pool_sp() {
|
||||
// Apply new size
|
||||
utils::hook::set<std::uint32_t>(0x581740, sizeof(entry_pool) /
|
||||
sizeof(game::XAssetEntry));
|
||||
utils::hook::set<game::XAssetEntry*>(0x581721, entry_pool + 1);
|
||||
utils::hook::set<game::XAssetEntry*>(0x581732, entry_pool + 1);
|
||||
|
||||
utils::hook::signature signature(0x411000, 0x200000);
|
||||
|
||||
signature.add({"\x60\xB3\xB2\x00", "xxxx", [](char* address) {
|
||||
utils::hook::set<game::XAssetEntry*>(address, entry_pool);
|
||||
}});
|
||||
|
||||
signature.process();
|
||||
}
|
||||
};
|
||||
} // namespace asset_restrict
|
||||
|
||||
REGISTER_COMPONENT(asset_restrict::component)
|
60
src/client/component/assets/assets.cpp
Normal file
60
src/client/component/assets/assets.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "localize_entry.hpp"
|
||||
#include "map_ents.hpp"
|
||||
#include "raw_file.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace assets {
|
||||
namespace {
|
||||
void load_asset(game::XAssetType type, game::XAssetHeader* header) {
|
||||
if (header) {
|
||||
switch (type) {
|
||||
case game::ASSET_TYPE_LOCALIZE_ENTRY:
|
||||
process_localize_entry(*header);
|
||||
break;
|
||||
case game::ASSET_TYPE_MAP_ENTS:
|
||||
process_map_ents(*header);
|
||||
break;
|
||||
case game::ASSET_TYPE_RAWFILE:
|
||||
process_raw_file(*header);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) db_add_x_asset_stub() {
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
push [esp + 0x20 + 0x8];
|
||||
push [esp + 0x20 + 0x8];
|
||||
call load_asset;
|
||||
add esp, 0x8;
|
||||
|
||||
popad;
|
||||
|
||||
sub esp, 0x14;
|
||||
mov eax, dword ptr [esp + 0x1C];
|
||||
|
||||
push 0x581EE7;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class asset final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// We may modify assets to some extents here or just dump them
|
||||
utils::hook(0x581EE0, db_add_x_asset_stub, HOOK_JUMP).install()->quick();
|
||||
utils::hook::nop(0x581EE5, 2);
|
||||
}
|
||||
};
|
||||
} // namespace assets
|
||||
|
||||
REGISTER_COMPONENT(assets::asset)
|
26
src/client/component/assets/localize_entry.cpp
Normal file
26
src/client/component/assets/localize_entry.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include "localize_entry.hpp"
|
||||
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/flags.hpp>
|
||||
|
||||
namespace assets {
|
||||
namespace {
|
||||
bool is_enabled() { IS_FLAG_ENABLED(dump_localize_entry); }
|
||||
} // namespace
|
||||
|
||||
void process_localize_entry(game::XAssetHeader header) {
|
||||
if (!is_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* localize = header.localize;
|
||||
const auto filename =
|
||||
utils::string::va("raw/localizedstrings/{0}", localize->name);
|
||||
|
||||
// Simple format, should be fine for now
|
||||
utils::io::write_file(filename, localize->value);
|
||||
}
|
||||
} // namespace assets
|
5
src/client/component/assets/localize_entry.hpp
Normal file
5
src/client/component/assets/localize_entry.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace assets {
|
||||
void process_localize_entry(game::XAssetHeader header);
|
||||
}
|
30
src/client/component/assets/map_ents.cpp
Normal file
30
src/client/component/assets/map_ents.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include "component/filesystem.hpp"
|
||||
|
||||
#include "map_ents.hpp"
|
||||
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace assets {
|
||||
namespace {
|
||||
std::string map_entities;
|
||||
|
||||
void load_map_entities(game::MapEnts* entry) {
|
||||
const auto file_name = utils::string::va("{0}.ents", entry->name);
|
||||
const filesystem::file ent_file(file_name, game::FS_THREAD_DATABASE);
|
||||
|
||||
// Load ent file from raw if it exists
|
||||
if (ent_file.exists()) {
|
||||
map_entities = ent_file.get_buffer();
|
||||
entry->entityString = map_entities.data();
|
||||
entry->numEntityChars = static_cast<int>(map_entities.size()) + 1;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void process_map_ents(game::XAssetHeader header) {
|
||||
auto* map_ents = header.mapEnts;
|
||||
load_map_entities(map_ents);
|
||||
}
|
||||
} // namespace assets
|
5
src/client/component/assets/map_ents.hpp
Normal file
5
src/client/component/assets/map_ents.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace assets {
|
||||
void process_map_ents(game::XAssetHeader header);
|
||||
}
|
181
src/client/component/assets/raw_file.cpp
Normal file
181
src/client/component/assets/raw_file.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "raw_file.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/flags.hpp>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
namespace assets {
|
||||
namespace {
|
||||
utils::hook::detour db_read_raw_file_hook;
|
||||
utils::hook::detour com_load_info_string_hook;
|
||||
|
||||
char* db_read_raw_file_stub(const char* filename, char* buf, int size) {
|
||||
auto file_handle = 0;
|
||||
const auto file_size = game::FS_FOpenFileRead(filename, &file_handle);
|
||||
|
||||
if (file_handle != 0) {
|
||||
if ((file_size + 1) <= size) {
|
||||
game::FS_Read(buf, file_size, file_handle);
|
||||
buf[file_size] = '\0';
|
||||
game::FS_FCloseFile(file_handle);
|
||||
return buf;
|
||||
}
|
||||
|
||||
game::FS_FCloseFile(file_handle);
|
||||
game::Com_PrintError(
|
||||
game::CON_CHANNEL_ERROR,
|
||||
"Ignoring raw file '%s' as it exceeds buffer size %i > %i\n", filename,
|
||||
file_size, size);
|
||||
}
|
||||
|
||||
auto* rawfile =
|
||||
game::DB_FindXAssetHeader(game::ASSET_TYPE_RAWFILE, filename).rawfile;
|
||||
if (game::DB_IsXAssetDefault(game::ASSET_TYPE_RAWFILE, filename)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
game::DB_GetRawBuffer(rawfile, buf, size);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* com_load_info_string_fast_file(const char* file_name,
|
||||
const char* file_desc,
|
||||
const char* ident,
|
||||
char* load_buffer) {
|
||||
const static DWORD Com_LoadInfoString_FastFile_t = 0x602FA0;
|
||||
const char* result{};
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov ebx, load_buffer;
|
||||
mov edi, file_name;
|
||||
push ident;
|
||||
push file_desc;
|
||||
call Com_LoadInfoString_FastFile_t;
|
||||
add esp, 0x8;
|
||||
mov result, eax;
|
||||
|
||||
popad;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* com_load_info_string_load_obj(const char* file_name,
|
||||
const char* file_desc,
|
||||
const char* ident,
|
||||
char* load_buffer) {
|
||||
int file_handle;
|
||||
|
||||
const auto file_len =
|
||||
game::FS_FOpenFileByMode(file_name, &file_handle, game::FS_READ);
|
||||
if (file_len < 0) {
|
||||
game::Com_DPrintf(game::CON_CHANNEL_SYSTEM,
|
||||
"Could not load %s [%s] as rawfile", file_desc,
|
||||
file_name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto ident_len = static_cast<int>(std::strlen(ident));
|
||||
game::FS_Read(load_buffer, ident_len, file_handle);
|
||||
load_buffer[ident_len] = '\0';
|
||||
|
||||
if (std::strncmp(load_buffer, ident, ident_len) != 0) {
|
||||
game::Com_Error(game::ERR_DROP,
|
||||
"\x15"
|
||||
"File [%s] is not a %s\n",
|
||||
file_name, file_desc);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((file_len - ident_len) >= 0x4000) {
|
||||
game::Com_Error(game::ERR_DROP,
|
||||
"\x15"
|
||||
"File [%s] is too long of a %s to parse\n",
|
||||
file_name, file_desc);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
game::FS_Read(load_buffer, file_len - ident_len, file_handle);
|
||||
load_buffer[file_len - ident_len] = '\0';
|
||||
game::FS_FCloseFile(file_handle);
|
||||
|
||||
return load_buffer;
|
||||
}
|
||||
|
||||
const char* com_load_info_string_stub(const char* file_name,
|
||||
const char* file_desc, const char* ident,
|
||||
char* load_buffer) {
|
||||
const auto* buffer =
|
||||
com_load_info_string_load_obj(file_name, file_desc, ident, load_buffer);
|
||||
if (!buffer) {
|
||||
buffer = com_load_info_string_fast_file(file_name, file_desc, ident,
|
||||
load_buffer);
|
||||
}
|
||||
|
||||
if (!game::Info_Validate(buffer)) {
|
||||
game::Com_Error(game::ERR_DROP,
|
||||
"\x15"
|
||||
"File [%s] is not a valid %s\n",
|
||||
file_name, file_desc);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool is_enabled() { IS_FLAG_ENABLED(dump_raw_file); }
|
||||
} // namespace
|
||||
|
||||
void process_raw_file(game::XAssetHeader header) {
|
||||
if (!is_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* raw_file = header.rawfile;
|
||||
const auto filename = utils::string::va("raw/{0}", raw_file->name);
|
||||
|
||||
if (raw_file->compressedLen > 0) {
|
||||
std::vector<std::uint8_t> uncompressed;
|
||||
uncompressed.resize(raw_file->len);
|
||||
|
||||
if (uncompress(uncompressed.data(), (uLongf*)&raw_file->len,
|
||||
(const Bytef*)raw_file->buffer,
|
||||
raw_file->compressedLen) == Z_OK) {
|
||||
std::string data;
|
||||
data.assign(uncompressed.begin(), uncompressed.end());
|
||||
|
||||
utils::io::write_file(filename, data);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If uncompressed just dump it
|
||||
utils::io::write_file(filename, raw_file->buffer);
|
||||
}
|
||||
|
||||
class raw_file final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// Remove fs_game check for moddable raw files
|
||||
// allows non-fs_game to modify raw files
|
||||
utils::hook::nop(0x612932, 2);
|
||||
|
||||
db_read_raw_file_hook.create(0x46DA60, &db_read_raw_file_stub);
|
||||
|
||||
com_load_info_string_hook.create(0x42DB20, &com_load_info_string_stub);
|
||||
}
|
||||
|
||||
void pre_destroy() override { db_read_raw_file_hook.clear(); }
|
||||
};
|
||||
} // namespace assets
|
||||
|
||||
REGISTER_COMPONENT(assets::raw_file)
|
5
src/client/component/assets/raw_file.hpp
Normal file
5
src/client/component/assets/raw_file.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace assets {
|
||||
void process_raw_file(game::XAssetHeader header);
|
||||
}
|
84
src/client/component/auth.cpp
Normal file
84
src/client/component/auth.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/cryptography.hpp>
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/smbios.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include "auth.hpp"
|
||||
|
||||
namespace auth {
|
||||
namespace {
|
||||
std::string get_hw_profile_guid() {
|
||||
HW_PROFILE_INFO info;
|
||||
if (!GetCurrentHwProfileA(&info)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return std::string{info.szHwProfileGuid, sizeof(info.szHwProfileGuid)};
|
||||
}
|
||||
|
||||
std::string get_protected_data() {
|
||||
std::string input = "Alter-Ware-IW4-SP-Auth";
|
||||
|
||||
DATA_BLOB data_in{}, data_out{};
|
||||
data_in.pbData = reinterpret_cast<std::uint8_t*>(input.data());
|
||||
data_in.cbData = static_cast<DWORD>(input.size());
|
||||
if (CryptProtectData(&data_in, nullptr, nullptr, nullptr, nullptr,
|
||||
CRYPTPROTECT_LOCAL_MACHINE, &data_out) != TRUE) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto size = std::min<std::uint32_t>(data_out.cbData, 52);
|
||||
std::string result(reinterpret_cast<char*>(data_out.pbData), size);
|
||||
LocalFree(data_out.pbData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string get_hdd_serial() {
|
||||
DWORD serial{};
|
||||
if (!GetVolumeInformationA("C:\\", nullptr, 0, &serial, nullptr, nullptr,
|
||||
nullptr, 0)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return utils::string::va("{0:08X}", serial);
|
||||
}
|
||||
|
||||
std::string get_key_entropy() {
|
||||
std::string entropy{};
|
||||
entropy.append(utils::smbios::get_uuid());
|
||||
entropy.append(get_hw_profile_guid());
|
||||
entropy.append(get_protected_data());
|
||||
entropy.append(get_hdd_serial());
|
||||
|
||||
if (entropy.empty()) {
|
||||
entropy.resize(32);
|
||||
utils::cryptography::random::get_data(entropy.data(), entropy.size());
|
||||
}
|
||||
|
||||
return entropy;
|
||||
}
|
||||
|
||||
utils::cryptography::ecc::key& get_key() {
|
||||
static auto key =
|
||||
utils::cryptography::ecc::generate_key(512, get_key_entropy());
|
||||
return key;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::uint64_t get_guid() { return get_key().get_hash(); }
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// Patch Steam_GetClientIDAsXUID
|
||||
utils::hook::set<std::uint32_t>(0x4911B0, 0xC301B0);
|
||||
}
|
||||
};
|
||||
} // namespace auth
|
||||
|
||||
REGISTER_COMPONENT(auth::component)
|
5
src/client/component/auth.hpp
Normal file
5
src/client/component/auth.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace auth {
|
||||
std::uint64_t get_guid();
|
||||
}
|
254
src/client/component/botlib/l_precomp.cpp
Normal file
254
src/client/component/botlib/l_precomp.cpp
Normal file
@ -0,0 +1,254 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include "l_precomp.hpp"
|
||||
#include "l_script.hpp"
|
||||
|
||||
namespace pc {
|
||||
constexpr auto DEFINEHASHSIZE = 1024;
|
||||
|
||||
constexpr auto MAX_SOURCEFILES = 64;
|
||||
|
||||
game::define_s* globaldefines;
|
||||
|
||||
void free_token(game::token_s* token) {
|
||||
game::FreeMemory(token);
|
||||
--*game::numtokens;
|
||||
}
|
||||
|
||||
game::define_s* define_from_string(const char* string) {
|
||||
game::source_s src;
|
||||
|
||||
auto* script = load_script_memory(
|
||||
string, static_cast<int>(std::strlen(string)), "*extern");
|
||||
// create a new source
|
||||
std::memset(&src, 0, sizeof(game::source_s));
|
||||
strncpy_s(src.filename, "*extern", _TRUNCATE);
|
||||
|
||||
src.scriptstack = script;
|
||||
src.definehash = static_cast<game::define_s**>(
|
||||
game::GetClearedMemory(DEFINEHASHSIZE * sizeof(game::define_s*)));
|
||||
|
||||
// create a define from the source
|
||||
auto res = game::PC_Directive_define(&src);
|
||||
|
||||
// free any tokens if left
|
||||
for (auto* t = src.tokens; t; t = src.tokens) {
|
||||
src.tokens = src.tokens->next;
|
||||
free_token(t);
|
||||
}
|
||||
|
||||
game::define_s* def = nullptr;
|
||||
for (auto i = 0; i < DEFINEHASHSIZE; ++i) {
|
||||
if (src.definehash[i]) {
|
||||
def = src.definehash[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game::FreeMemory(src.definehash);
|
||||
free_script(script);
|
||||
|
||||
// if the define was created successfully
|
||||
if (res > 0) {
|
||||
return def;
|
||||
}
|
||||
|
||||
// free the define is created
|
||||
if (src.defines) {
|
||||
game::PC_FreeDefine(def);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int name_hash(char* name) {
|
||||
auto hash = 0;
|
||||
for (auto i = 0; name[i] != '\0'; ++i) {
|
||||
hash += name[i] * (119 + i);
|
||||
}
|
||||
|
||||
hash = (hash ^ (hash >> 10) ^ (hash >> 20)) & (DEFINEHASHSIZE - 1);
|
||||
return hash;
|
||||
}
|
||||
|
||||
void add_define_to_hash(game::define_s* define, game::define_s** definehash) {
|
||||
auto hash = name_hash(define->name);
|
||||
define->hashnext = definehash[hash];
|
||||
definehash[hash] = define;
|
||||
}
|
||||
|
||||
int add_define(game::source_s* source, const char* string) {
|
||||
|
||||
auto* define = define_from_string(string);
|
||||
if (!define) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
add_define_to_hash(define, source->definehash);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
game::define_s* copy_define([[maybe_unused]] game::source_s* source,
|
||||
game::define_s* define) {
|
||||
game::token_s *token, *newtoken, *lasttoken;
|
||||
|
||||
auto* newdefine = static_cast<game::define_s*>(
|
||||
game::GetMemory(sizeof(game::define_s) + strlen(define->name) + 1));
|
||||
|
||||
// copy the define name
|
||||
newdefine->name = (char*)newdefine + sizeof(game::define_s);
|
||||
std::memcpy(newdefine->name, define->name, std::strlen(define->name) + 1);
|
||||
|
||||
newdefine->flags = define->flags;
|
||||
newdefine->builtin = define->builtin;
|
||||
newdefine->numparms = define->numparms;
|
||||
|
||||
// the define is not linked
|
||||
newdefine->next = nullptr;
|
||||
newdefine->hashnext = nullptr;
|
||||
|
||||
// copy the define tokens
|
||||
newdefine->tokens = nullptr;
|
||||
for (lasttoken = nullptr, token = define->tokens; token;
|
||||
token = token->next) {
|
||||
newtoken = game::PC_CopyToken(token);
|
||||
newtoken->next = nullptr;
|
||||
if (lasttoken) {
|
||||
lasttoken->next = newtoken;
|
||||
} else {
|
||||
newdefine->tokens = newtoken;
|
||||
}
|
||||
|
||||
lasttoken = newtoken;
|
||||
}
|
||||
|
||||
// copy the define parameters
|
||||
newdefine->parms = nullptr;
|
||||
for (lasttoken = nullptr, token = define->parms; token; token = token->next) {
|
||||
newtoken = game::PC_CopyToken(token);
|
||||
newtoken->next = nullptr;
|
||||
if (lasttoken) {
|
||||
lasttoken->next = newtoken;
|
||||
} else {
|
||||
newdefine->parms = newtoken;
|
||||
}
|
||||
|
||||
lasttoken = newtoken;
|
||||
}
|
||||
|
||||
return newdefine;
|
||||
}
|
||||
|
||||
void add_global_defines_to_source(game::source_s* source) {
|
||||
for (auto* define = globaldefines; define; define = define->next) {
|
||||
auto* newdefine = copy_define(source, define);
|
||||
|
||||
add_define_to_hash(newdefine, source->definehash);
|
||||
}
|
||||
}
|
||||
|
||||
game::source_s* load_source_file(const char* filename) {
|
||||
auto* script = load_script_file(filename);
|
||||
if (!script) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
script->next = nullptr;
|
||||
|
||||
auto* source =
|
||||
static_cast<game::source_s*>(game::GetMemory(sizeof(game::source_s)));
|
||||
std::memset(source, 0, sizeof(game::source_s));
|
||||
|
||||
strncpy_s(source->filename, filename, _TRUNCATE);
|
||||
source->scriptstack = script;
|
||||
source->tokens = nullptr;
|
||||
source->defines = nullptr;
|
||||
source->indentstack = nullptr;
|
||||
source->skip = 0;
|
||||
|
||||
source->definehash = static_cast<game::define_s**>(
|
||||
game::GetClearedMemory(DEFINEHASHSIZE * sizeof(game::define_s*)));
|
||||
|
||||
add_global_defines_to_source(source);
|
||||
return source;
|
||||
}
|
||||
|
||||
int load_source_handle(const char* filename, const char** builtin_defines) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i < MAX_SOURCEFILES; ++i) {
|
||||
if (!game::sourceFiles[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= MAX_SOURCEFILES) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto* source = load_source_file(filename);
|
||||
if (!source) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (builtin_defines) {
|
||||
for (auto define_iter = 0; builtin_defines[define_iter]; ++define_iter) {
|
||||
add_define(source, builtin_defines[define_iter]);
|
||||
}
|
||||
}
|
||||
|
||||
game::sourceFiles[i] = source;
|
||||
return i;
|
||||
}
|
||||
|
||||
void free_source(game::source_s* source) {
|
||||
// free all the scripts
|
||||
while (source->scriptstack) {
|
||||
auto* script = source->scriptstack;
|
||||
source->scriptstack = source->scriptstack->next;
|
||||
free_script(script);
|
||||
}
|
||||
|
||||
// free all the tokens
|
||||
while (source->tokens) {
|
||||
auto* token = source->tokens;
|
||||
source->tokens = source->tokens->next;
|
||||
free_token(token);
|
||||
}
|
||||
|
||||
for (auto i = 0; i < DEFINEHASHSIZE; ++i) {
|
||||
while (source->definehash[i]) {
|
||||
auto* define = source->definehash[i];
|
||||
source->definehash[i] = source->definehash[i]->hashnext;
|
||||
game::PC_FreeDefine(define);
|
||||
}
|
||||
}
|
||||
|
||||
// free all indents
|
||||
while (source->indentstack) {
|
||||
auto* indent = source->indentstack;
|
||||
source->indentstack = source->indentstack->next;
|
||||
game::FreeMemory(indent);
|
||||
}
|
||||
|
||||
if (source->definehash) {
|
||||
game::FreeMemory(source->definehash);
|
||||
}
|
||||
|
||||
// free the source itself
|
||||
game::FreeMemory(source);
|
||||
}
|
||||
|
||||
int free_source_handle(int handle) {
|
||||
if (handle < 1 || handle >= MAX_SOURCEFILES)
|
||||
return 0;
|
||||
|
||||
if (!game::sourceFiles[handle])
|
||||
return 0;
|
||||
|
||||
free_source(game::sourceFiles[handle]);
|
||||
game::sourceFiles[handle] = nullptr;
|
||||
return 1;
|
||||
}
|
||||
} // namespace pc
|
6
src/client/component/botlib/l_precomp.hpp
Normal file
6
src/client/component/botlib/l_precomp.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace pc {
|
||||
int load_source_handle(const char* filename, const char** builtin_defines);
|
||||
int free_source_handle(int handle);
|
||||
} // namespace pc
|
204
src/client/component/botlib/l_script.cpp
Normal file
204
src/client/component/botlib/l_script.cpp
Normal file
@ -0,0 +1,204 @@
|
||||
#include <std_include.hpp>
|
||||
#include "l_script.hpp"
|
||||
|
||||
namespace pc {
|
||||
// clang-format off
|
||||
game::punctuation_s default_punctuations[] =
|
||||
{
|
||||
{ ">>=", P_RSHIFT_ASSIGN, nullptr },
|
||||
{ "<<=", P_LSHIFT_ASSIGN, nullptr },
|
||||
|
||||
{ "...", P_PARMS, nullptr },
|
||||
// define merge operator
|
||||
{ "##", P_PRECOMPMERGE, nullptr },
|
||||
// logic operators
|
||||
{ "&&", P_LOGIC_AND, nullptr },
|
||||
{ "||", P_LOGIC_OR, nullptr },
|
||||
{ ">=", P_LOGIC_GEQ, nullptr },
|
||||
{ "<=", P_LOGIC_LEQ, nullptr },
|
||||
{ "==", P_LOGIC_EQ, nullptr },
|
||||
{ "!=", P_LOGIC_UNEQ, nullptr },
|
||||
// arithmatic operators
|
||||
{ "*=", P_MUL_ASSIGN, nullptr },
|
||||
{ "/=",P_DIV_ASSIGN, nullptr },
|
||||
{ "%=", P_MOD_ASSIGN, nullptr },
|
||||
{ "+=", P_ADD_ASSIGN, nullptr },
|
||||
{ "-=", P_SUB_ASSIGN,nullptr },
|
||||
{ "++", P_INC, nullptr },
|
||||
{ "--", P_DEC, nullptr },
|
||||
// binary operators
|
||||
{ "&=", P_BIN_AND_ASSIGN, nullptr },
|
||||
{ "|=", P_BIN_OR_ASSIGN, nullptr },
|
||||
{ "^=", P_BIN_XOR_ASSIGN, nullptr },
|
||||
{ ">>", P_RSHIFT, nullptr },
|
||||
{ "<<", P_LSHIFT, nullptr },
|
||||
// reference operators
|
||||
{ "->", P_POINTERREF, nullptr },
|
||||
// C++
|
||||
{ "::", P_CPP1, nullptr },
|
||||
{ ".*", P_CPP2, nullptr },
|
||||
// arithmatic operators
|
||||
{ "*", P_MUL, nullptr },
|
||||
{ "/", P_DIV,nullptr },
|
||||
{ "%", P_MOD, nullptr },
|
||||
{ "+", P_ADD, nullptr },
|
||||
{ "-", P_SUB, nullptr },
|
||||
{ "=", P_ASSIGN, nullptr },
|
||||
// binary operators
|
||||
{ "&", P_BIN_AND, nullptr },
|
||||
{ "|", P_BIN_OR, nullptr },
|
||||
{ "^", P_BIN_XOR, nullptr },
|
||||
{ "~", P_BIN_NOT, nullptr },
|
||||
// logic operators
|
||||
{ "!", P_LOGIC_NOT, nullptr },
|
||||
{ ">", P_LOGIC_GREATER, nullptr },
|
||||
{ "<", P_LOGIC_LESS, nullptr },
|
||||
// reference operator
|
||||
{ ".", P_REF, nullptr },
|
||||
// seperators
|
||||
{ ",", P_COMMA, nullptr },
|
||||
{ ";", P_SEMICOLON, nullptr },
|
||||
// label indication
|
||||
{ ":", P_COLON, nullptr },
|
||||
// if statement
|
||||
{ "?", P_QUESTIONMARK, nullptr },
|
||||
// embracements
|
||||
{ "(", P_PARENTHESESOPEN, nullptr },
|
||||
{ ")", P_PARENTHESESCLOSE, nullptr },
|
||||
{ "{", P_BRACEOPEN, nullptr },
|
||||
{ "}", P_BRACECLOSE, nullptr },
|
||||
{ "[", P_SQBRACKETOPEN, nullptr },
|
||||
{ "]", P_SQBRACKETCLOSE, nullptr },
|
||||
//
|
||||
{ "\\", P_BACKSLASH, nullptr },
|
||||
// precompiler operator
|
||||
{ "#", P_PRECOMP, nullptr },
|
||||
{ "$", P_DOLLAR, nullptr },
|
||||
{ nullptr, 0, nullptr },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
void create_punctuation_table(game::script_s* script,
|
||||
game::punctuation_s* punctuations) {
|
||||
game::punctuation_s* p;
|
||||
|
||||
// get memory for the table
|
||||
if (!script->punctuationtable) {
|
||||
script->punctuationtable = static_cast<game::punctuation_s**>(
|
||||
game::GetMemory(256 * sizeof(game::punctuation_s*)));
|
||||
}
|
||||
|
||||
std::memset(script->punctuationtable, 0, 256 * sizeof(game::punctuation_s*));
|
||||
|
||||
// add the punctuations in the list to the punctuation table
|
||||
for (auto i = 0; punctuations[i].p; ++i) {
|
||||
auto* newp = &punctuations[i];
|
||||
game::punctuation_s* lastp = nullptr;
|
||||
|
||||
// sort the punctuations in this table entry on length (longer punctuations
|
||||
// first)
|
||||
for (p = script->punctuationtable[(unsigned int)newp->p[0]]; p;
|
||||
p = p->next) {
|
||||
if (std::strlen(p->p) < std::strlen(newp->p)) {
|
||||
newp->next = p;
|
||||
if (lastp) {
|
||||
lastp->next = newp;
|
||||
} else {
|
||||
script->punctuationtable[(unsigned int)newp->p[0]] = newp;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
lastp = p;
|
||||
}
|
||||
|
||||
if (!p) {
|
||||
newp->next = nullptr;
|
||||
if (lastp) {
|
||||
lastp->next = newp;
|
||||
} else {
|
||||
script->punctuationtable[(unsigned int)newp->p[0]] = newp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_script_punctuations(game::script_s* script) {
|
||||
create_punctuation_table(script, default_punctuations);
|
||||
script->punctuations = default_punctuations;
|
||||
}
|
||||
|
||||
game::script_s* load_script_file(const char* filename) {
|
||||
int fp;
|
||||
char pathname[game::MAX_QPATH];
|
||||
|
||||
sprintf_s(pathname, "%s", filename);
|
||||
const auto length = game::FS_FOpenFileRead(pathname, &fp);
|
||||
if (!fp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* buffer = game::GetClearedMemory(sizeof(game::script_s) + length + 1);
|
||||
auto* script = static_cast<game::script_s*>(buffer);
|
||||
strncpy_s(script->filename, filename, _TRUNCATE);
|
||||
|
||||
script->buffer = static_cast<char*>(buffer) + sizeof(game::script_s);
|
||||
script->buffer[length] = '\0';
|
||||
script->length = length;
|
||||
// pointer in script buffer
|
||||
script->script_p = script->buffer;
|
||||
// pointer in script buffer before reading token
|
||||
script->lastscript_p = script->buffer;
|
||||
// pointer to end of script buffer
|
||||
script->end_p = &script->buffer[length];
|
||||
// set if there's a token available in script->token
|
||||
script->tokenavailable = 0;
|
||||
|
||||
script->line = 1;
|
||||
script->lastline = 1;
|
||||
|
||||
set_script_punctuations(script);
|
||||
|
||||
game::FS_Read(script->buffer, length, fp);
|
||||
game::FS_FCloseFile(fp);
|
||||
|
||||
script->length = game::Com_Compress(script->buffer);
|
||||
return script;
|
||||
}
|
||||
|
||||
game::script_s* load_script_memory(const char* ptr, int length,
|
||||
const char* name) {
|
||||
auto* buffer = game::GetClearedMemory(sizeof(game::script_s) + length + 1);
|
||||
auto* script = static_cast<game::script_s*>(buffer);
|
||||
|
||||
strncpy_s(script->filename, name, _TRUNCATE);
|
||||
script->buffer = static_cast<char*>(buffer) + sizeof(game::script_s);
|
||||
script->buffer[length] = '\0';
|
||||
script->length = length;
|
||||
// pointer in script buffer
|
||||
script->script_p = script->buffer;
|
||||
// pointer in script buffer before reading token
|
||||
script->lastscript_p = script->buffer;
|
||||
// pointer to end of script buffer
|
||||
script->end_p = &script->buffer[length];
|
||||
// set if there's a token available in script->token
|
||||
script->tokenavailable = 0;
|
||||
|
||||
script->line = 1;
|
||||
script->lastline = 1;
|
||||
|
||||
set_script_punctuations(script);
|
||||
|
||||
std::memcpy(script->buffer, ptr, length);
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
void free_script(game::script_s* script) {
|
||||
if (script->punctuationtable)
|
||||
game::FreeMemory(script->punctuationtable);
|
||||
|
||||
game::FreeMemory(script);
|
||||
}
|
||||
} // namespace pc
|
70
src/client/component/botlib/l_script.hpp
Normal file
70
src/client/component/botlib/l_script.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#define P_RSHIFT_ASSIGN 1
|
||||
#define P_LSHIFT_ASSIGN 2
|
||||
#define P_PARMS 3
|
||||
#define P_PRECOMPMERGE 4
|
||||
|
||||
#define P_LOGIC_AND 5
|
||||
#define P_LOGIC_OR 6
|
||||
#define P_LOGIC_GEQ 7
|
||||
#define P_LOGIC_LEQ 8
|
||||
#define P_LOGIC_EQ 9
|
||||
#define P_LOGIC_UNEQ 10
|
||||
|
||||
#define P_MUL_ASSIGN 11
|
||||
#define P_DIV_ASSIGN 12
|
||||
#define P_MOD_ASSIGN 13
|
||||
#define P_ADD_ASSIGN 14
|
||||
#define P_SUB_ASSIGN 15
|
||||
#define P_INC 16
|
||||
#define P_DEC 17
|
||||
|
||||
#define P_BIN_AND_ASSIGN 18
|
||||
#define P_BIN_OR_ASSIGN 19
|
||||
#define P_BIN_XOR_ASSIGN 20
|
||||
#define P_RSHIFT 21
|
||||
#define P_LSHIFT 22
|
||||
|
||||
#define P_POINTERREF 23
|
||||
#define P_CPP1 24
|
||||
#define P_CPP2 25
|
||||
#define P_MUL 26
|
||||
#define P_DIV 27
|
||||
#define P_MOD 28
|
||||
#define P_ADD 29
|
||||
#define P_SUB 30
|
||||
#define P_ASSIGN 31
|
||||
|
||||
#define P_BIN_AND 32
|
||||
#define P_BIN_OR 33
|
||||
#define P_BIN_XOR 34
|
||||
#define P_BIN_NOT 35
|
||||
|
||||
#define P_LOGIC_NOT 36
|
||||
#define P_LOGIC_GREATER 37
|
||||
#define P_LOGIC_LESS 38
|
||||
|
||||
#define P_REF 39
|
||||
#define P_COMMA 40
|
||||
#define P_SEMICOLON 41
|
||||
#define P_COLON 42
|
||||
#define P_QUESTIONMARK 43
|
||||
|
||||
#define P_PARENTHESESOPEN 44
|
||||
#define P_PARENTHESESCLOSE 45
|
||||
#define P_BRACEOPEN 46
|
||||
#define P_BRACECLOSE 47
|
||||
#define P_SQBRACKETOPEN 48
|
||||
#define P_SQBRACKETCLOSE 49
|
||||
#define P_BACKSLASH 50
|
||||
|
||||
#define P_PRECOMP 51
|
||||
#define P_DOLLAR 52
|
||||
|
||||
namespace pc {
|
||||
game::script_s* load_script_file(const char* filename);
|
||||
game::script_s* load_script_memory(const char* ptr, int length,
|
||||
const char* name);
|
||||
void free_script(game::script_s* script);
|
||||
} // namespace pc
|
123
src/client/component/branding.cpp
Normal file
123
src/client/component/branding.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <version.h>
|
||||
|
||||
namespace branding {
|
||||
namespace {
|
||||
#ifdef _DEBUG
|
||||
constexpr auto* BUILD_TYPE = "IW4_DEV SP";
|
||||
#else
|
||||
constexpr auto* BUILD_TYPE = "IW4 SP";
|
||||
#endif
|
||||
|
||||
constexpr const char* get_build_number() {
|
||||
return SHORTVERSION " latest " __DATE__ " " __TIME__;
|
||||
}
|
||||
|
||||
const char* get_version_string() {
|
||||
const auto* result = utils::string::va(
|
||||
"{} {} build {} {}", BUILD_TYPE, "(Alpha)", get_build_number(),
|
||||
reinterpret_cast<const char*>(0x6A1574));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void dvar_set_version_string(const game::dvar_t* dvar, const char* /*value*/) {
|
||||
const auto* result = get_version_string();
|
||||
utils::hook::invoke<void>(0x480E70, dvar, result);
|
||||
}
|
||||
|
||||
void cg_draw_version() {
|
||||
assert(game::ScrPlace_IsFullScreenActive());
|
||||
|
||||
// Default values
|
||||
constexpr auto font_scale = 0.25f;
|
||||
constexpr auto max_chars = std::numeric_limits<int>::max();
|
||||
// Default colours
|
||||
constexpr float shadow_color[] = {0.0f, 0.0f, 0.0f, 0.69f};
|
||||
constexpr float color[] = {0.4f, 0.69f, 1.0f, 0.69f};
|
||||
|
||||
auto* const placement = game::ScrPlace_GetUnsafeFullPlacement();
|
||||
auto* const font = game::UI_GetFontHandle(placement, 0, 0.583f);
|
||||
|
||||
const auto width = game::UI_TextWidth((*dvars::version)->current.string, 0,
|
||||
font, font_scale);
|
||||
const auto height = game::UI_TextHeight(font, font_scale);
|
||||
|
||||
// clang-format off
|
||||
game::UI_DrawText(placement, (*dvars::version)->current.string, max_chars,
|
||||
font,
|
||||
1.0f - (dvars::cg_drawVersionX->current.value +
|
||||
static_cast<float>(width)),
|
||||
1.0f - (dvars::cg_drawVersionY->current.value +
|
||||
static_cast<float>(height)),
|
||||
3, 3, font_scale, shadow_color, 0);
|
||||
game::UI_DrawText(placement, (*dvars::version)->current.string, max_chars,
|
||||
font,
|
||||
(0.0f - static_cast<float>(width)) -
|
||||
dvars::cg_drawVersionX->current.value,
|
||||
(0.0f - static_cast<float>(height)) -
|
||||
dvars::cg_drawVersionY->current.value,
|
||||
3, 3, font_scale, color, 0);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void cg_draw_full_screen_debug_overlays_stub(int local_client_num) {
|
||||
assert(game::ScrPlace_IsFullScreenActive());
|
||||
|
||||
if (dvars::cg_drawVersion->current.enabled) {
|
||||
cg_draw_version();
|
||||
}
|
||||
|
||||
utils::hook::invoke<void>(0x44BD00, local_client_num);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x46F570, get_build_number, HOOK_JUMP).install()->quick();
|
||||
utils::hook(0x60429A, dvar_set_version_string, HOOK_CALL)
|
||||
.install()
|
||||
->quick();
|
||||
|
||||
utils::hook::set<const char*>(0x446A48, "iw4-sp: Console");
|
||||
utils::hook::set<const char*>(0x50C110, "iw4-sp: Game");
|
||||
|
||||
utils::hook::set<const char*>(0x579364, "iw4-sp: " SHORTVERSION "> ");
|
||||
|
||||
// Com_Init_Try_Block_Function
|
||||
utils::hook::set<const char*>(0x604004, BUILD_TYPE);
|
||||
utils::hook::set<const char*>(0x603FFF, SHORTVERSION);
|
||||
utils::hook::set<const char*>(0x603FF5, __DATE__);
|
||||
|
||||
register_branding_dvars();
|
||||
utils::hook(0x57DAFF, cg_draw_full_screen_debug_overlays_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick();
|
||||
}
|
||||
|
||||
static void register_branding_dvars() {
|
||||
#ifdef _DEBUG
|
||||
constexpr auto value = true;
|
||||
#else
|
||||
constexpr auto value = false;
|
||||
#endif
|
||||
dvars::cg_drawVersion = game::Dvar_RegisterBool(
|
||||
"cg_drawVersion", value, game::DVAR_NONE, "Draw the game version");
|
||||
dvars::cg_drawVersionX = game::Dvar_RegisterFloat(
|
||||
"cg_drawVersionX", 50.0f, 0.0f, 512.0f, game::DVAR_NONE,
|
||||
"X offset for the version string");
|
||||
dvars::cg_drawVersionY = game::Dvar_RegisterFloat(
|
||||
"cg_drawVersionY", 18.0f, 0.0f, 512.0f, game::DVAR_NONE,
|
||||
"Y offset for the version string");
|
||||
}
|
||||
};
|
||||
} // namespace branding
|
||||
|
||||
REGISTER_COMPONENT(branding::component)
|
38
src/client/component/ceg.cpp
Normal file
38
src/client/component/ceg.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace ceg {
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// Some unnecessary CEG functions.
|
||||
// Important functions are patched in the exe already
|
||||
|
||||
utils::hook::set<std::uint32_t>(0x44AD80, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x476A20, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x4E3B90, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x4E3B90, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x411160, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x41E390, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x47C2E0, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x4EEA90, 0xC301B0);
|
||||
utils::hook::set<std::uint32_t>(0x40E380, 0xC301B0);
|
||||
|
||||
// Killer caller
|
||||
utils::hook::set<std::uint8_t>(0x43F320, 0xC3);
|
||||
utils::hook::set<std::uint8_t>(0x458ED0, 0xC3);
|
||||
utils::hook::set<std::uint8_t>(0x47A140, 0xC3);
|
||||
|
||||
utils::hook::nop(0x411166, 9);
|
||||
|
||||
// Remove 'Steam Start' check
|
||||
utils::hook::nop(0x43FAD5, 12);
|
||||
// Shutdown
|
||||
utils::hook::set<std::uint8_t>(0x4619B0, 0xC3);
|
||||
}
|
||||
};
|
||||
} // namespace ceg
|
||||
|
||||
REGISTER_COMPONENT(ceg::component)
|
152
src/client/component/command.cpp
Normal file
152
src/client/component/command.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/memory.hpp>
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "command.hpp"
|
||||
|
||||
namespace command {
|
||||
namespace {
|
||||
utils::hook::detour client_command_hook;
|
||||
|
||||
std::unordered_map<std::string, std::function<void(params&)>> handlers;
|
||||
std::unordered_map<std::string,
|
||||
std::function<void(game::gentity_s*, params_sv&)>>
|
||||
handlers_sv;
|
||||
|
||||
void main_handler() {
|
||||
params params;
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
if (handlers.contains(command)) {
|
||||
handlers[command](params);
|
||||
}
|
||||
}
|
||||
|
||||
void client_command_stub(int client_num, const char* s) {
|
||||
|
||||
auto* entity = &game::g_entities[client_num];
|
||||
|
||||
params_sv params;
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
const auto got = handlers_sv.find(command);
|
||||
|
||||
if (got != handlers_sv.end()) {
|
||||
got->second(entity, params);
|
||||
return;
|
||||
}
|
||||
|
||||
client_command_hook.invoke<void>(client_num, s);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
params::params() : nesting_(game::cmd_args->nesting) {
|
||||
assert(game::cmd_args->nesting < game::CMD_MAX_NESTING);
|
||||
}
|
||||
|
||||
int params::size() const { return game::cmd_args->argc[this->nesting_]; }
|
||||
|
||||
const char* params::get(const int index) const {
|
||||
if (index >= this->size()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return game::cmd_args->argv[this->nesting_][index];
|
||||
}
|
||||
|
||||
std::string params::join(const int index) const {
|
||||
std::string result;
|
||||
|
||||
for (auto i = index; i < this->size(); i++) {
|
||||
if (i > index)
|
||||
result.append(" ");
|
||||
result.append(this->get(i));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
params_sv::params_sv() : nesting_(game::sv_cmd_args->nesting) {
|
||||
assert(game::sv_cmd_args->nesting < game::CMD_MAX_NESTING);
|
||||
}
|
||||
|
||||
int params_sv::size() const { return game::sv_cmd_args->argc[this->nesting_]; }
|
||||
|
||||
const char* params_sv::get(const int index) const {
|
||||
if (index >= this->size()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return game::sv_cmd_args->argv[this->nesting_][index];
|
||||
}
|
||||
|
||||
std::string params_sv::join(const int index) const {
|
||||
std::string result;
|
||||
|
||||
for (auto i = index; i < this->size(); i++) {
|
||||
if (i > index)
|
||||
result.append(" ");
|
||||
result.append(this->get(i));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void add_raw(const char* name, void (*callback)(), const int is_key) {
|
||||
assert(is_key == 0 || is_key == 1);
|
||||
|
||||
game::Cmd_AddCommand(
|
||||
name, callback,
|
||||
utils::memory::get_allocator()->allocate<game::cmd_function_s>(), is_key);
|
||||
}
|
||||
|
||||
void add(const char* name, const std::function<void(const params&)>& callback) {
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (!handlers.contains(command)) {
|
||||
add_raw(name, main_handler);
|
||||
}
|
||||
|
||||
handlers[command] = callback;
|
||||
}
|
||||
|
||||
void add(const char* name, const std::function<void()>& callback) {
|
||||
add(name, [callback](const params&) { callback(); });
|
||||
}
|
||||
|
||||
void add_sv(const char* name,
|
||||
std::function<void(game::gentity_s*, const params_sv&)> callback) {
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (!handlers_sv.contains(command)) {
|
||||
handlers_sv[command] = callback;
|
||||
}
|
||||
}
|
||||
|
||||
void execute(std::string command, const bool sync) {
|
||||
command += "\n";
|
||||
|
||||
if (sync) {
|
||||
game::Cmd_ExecuteSingleCommand(0, 0, command.data());
|
||||
} else {
|
||||
game::Cbuf_AddText(0, command.data());
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(game::cmd_function_s) == 0x18);
|
||||
static_assert(offsetof(game::gentity_s, client) == 0x108);
|
||||
|
||||
void post_load() override {
|
||||
client_command_hook.create(0x4DF4B0, client_command_stub);
|
||||
}
|
||||
|
||||
void pre_destroy() override { client_command_hook.clear(); }
|
||||
};
|
||||
} // namespace command
|
||||
|
||||
REGISTER_COMPONENT(command::component)
|
40
src/client/component/command.hpp
Normal file
40
src/client/component/command.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
namespace command {
|
||||
class params {
|
||||
public:
|
||||
params();
|
||||
|
||||
[[nodiscard]] int size() const;
|
||||
[[nodiscard]] const char* get(int index) const;
|
||||
[[nodiscard]] std::string join(int index) const;
|
||||
|
||||
const char* operator[](const int index) const { return this->get(index); }
|
||||
|
||||
private:
|
||||
int nesting_;
|
||||
};
|
||||
|
||||
class params_sv {
|
||||
public:
|
||||
params_sv();
|
||||
|
||||
[[nodiscard]] int size() const;
|
||||
[[nodiscard]] const char* get(int index) const;
|
||||
[[nodiscard]] std::string join(int index) const;
|
||||
|
||||
const char* operator[](const int index) const { return this->get(index); }
|
||||
|
||||
private:
|
||||
int nesting_;
|
||||
};
|
||||
|
||||
void add_raw(const char* name, void (*callback)(), int is_key = 0);
|
||||
void add(const char* name, const std::function<void(const params&)>& callback);
|
||||
void add(const char* name, const std::function<void()>& callback);
|
||||
|
||||
void add_sv(const char* name,
|
||||
std::function<void(game::gentity_s*, const params_sv&)> callback);
|
||||
|
||||
void execute(std::string command, bool sync = false);
|
||||
} // namespace command
|
71
src/client/component/console.cpp
Normal file
71
src/client/component/console.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "dvar.hpp"
|
||||
|
||||
namespace console {
|
||||
namespace {
|
||||
bool is_command;
|
||||
|
||||
void con_toggle_console() {
|
||||
game::Field_Clear(game::g_consoleField);
|
||||
|
||||
if (game::conDrawInputGlob->matchIndex >= 0 &&
|
||||
game::conDrawInputGlob->autoCompleteChoice[0] != '\0') {
|
||||
game::conDrawInputGlob->matchIndex = -1;
|
||||
game::conDrawInputGlob->autoCompleteChoice[0] = '\0';
|
||||
}
|
||||
|
||||
game::g_consoleField->widthInPixels = *game::g_console_field_width;
|
||||
game::g_consoleField->charHeight = *game::g_console_char_height;
|
||||
game::g_consoleField->fixedSize = 1;
|
||||
game::con->outputVisible = false;
|
||||
|
||||
// clientUIActives[0].keyCatchers
|
||||
utils::hook::set<std::uint32_t>(0x929140,
|
||||
*reinterpret_cast<std::uint32_t*>(0x929140) ^
|
||||
game::KEYCATCH_CONSOLE);
|
||||
}
|
||||
|
||||
bool con_is_dvar_command_stub(const char* cmd) {
|
||||
is_command = game::Con_IsDvarCommand(cmd);
|
||||
return is_command;
|
||||
}
|
||||
|
||||
void cmd_for_each_stub(void (*callback)(const char* str)) {
|
||||
if (!is_command) {
|
||||
utils::hook::invoke<void>(0x4B7000, callback);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(game::field_t) == 0x118);
|
||||
static_assert(sizeof(game::ConDrawInputGlob) == 0x64);
|
||||
|
||||
void post_start() override {
|
||||
// Prevents console from opening
|
||||
dvar::override::register_bool("monkeytoy", false, game::DVAR_NONE);
|
||||
}
|
||||
|
||||
void post_load() override {
|
||||
utils::hook(0x44317E, con_toggle_console, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // CL_KeyEvent
|
||||
utils::hook(0x442E8E, con_toggle_console, HOOK_JUMP)
|
||||
.install()
|
||||
->quick(); // CL_KeyEvent
|
||||
|
||||
// Con_DrawInput
|
||||
utils::hook(0x57946D, con_is_dvar_command_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick();
|
||||
utils::hook(0x57951C, cmd_for_each_stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
};
|
||||
} // namespace console
|
||||
|
||||
REGISTER_COMPONENT(console::component)
|
129
src/client/component/debug.cpp
Normal file
129
src/client/component/debug.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
#include "game/engine/scoped_critical_section.hpp"
|
||||
#include "game/engine/large_local.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "command.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
namespace debug {
|
||||
namespace {
|
||||
void com_assert_f() { assert("a" && false); }
|
||||
|
||||
void com_bug_f(const command::params& params) {
|
||||
char new_file_name[0x105]{};
|
||||
char to_ospath[MAX_PATH]{};
|
||||
char from_ospath[MAX_PATH]{};
|
||||
const char* bug;
|
||||
|
||||
if (!*game::logfile) {
|
||||
game::Com_PrintError(game::CON_CHANNEL_ERROR,
|
||||
"CopyFile failed: logfile wasn't opened\n");
|
||||
}
|
||||
|
||||
if (params.size() == 2) {
|
||||
bug = params.get(1);
|
||||
} else {
|
||||
assert(dvars::bug_name);
|
||||
bug = dvars::bug_name->current.string;
|
||||
}
|
||||
|
||||
sprintf_s(new_file_name, "%s_%s.log", bug, game::Live_GetLocalClientName(0));
|
||||
|
||||
game::engine::scoped_critical_section _(game::CRITSECT_CONSOLE,
|
||||
game::SCOPED_CRITSECT_NORMAL);
|
||||
|
||||
if (*game::logfile) {
|
||||
game::FS_FCloseFile(*game::logfile);
|
||||
*game::logfile = 0;
|
||||
}
|
||||
|
||||
game::FS_BuildOSPath(std::filesystem::current_path().string().data(), "",
|
||||
"console.log", from_ospath);
|
||||
game::FS_BuildOSPath(std::filesystem::current_path().string().data(), "",
|
||||
new_file_name, to_ospath);
|
||||
const auto result = CopyFileA(from_ospath, to_ospath, 0);
|
||||
game::Com_OpenLogFile();
|
||||
|
||||
if (!result) {
|
||||
game::Com_PrintError(game::CON_CHANNEL_ERROR, "CopyFile failed(%d) %s %s\n",
|
||||
GetLastError(), "console.log", new_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
void com_bug_name_inc_f() {
|
||||
char buf[260]{};
|
||||
|
||||
if (std::strlen(dvars::bug_name->current.string) < 4) {
|
||||
game::Dvar_SetString(dvars::bug_name, "bug0");
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::strncmp(dvars::bug_name->current.string, "bug", 3) != 0) {
|
||||
game::Dvar_SetString(dvars::bug_name, "bug0");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto n = std::strtol(dvars::bug_name->current.string + 3, nullptr, 10);
|
||||
sprintf_s(buf, "bug%d", n + 1);
|
||||
game::Dvar_SetString(dvars::bug_name, buf);
|
||||
}
|
||||
|
||||
void g_print_fast_file_errors(const char* fastfile) {
|
||||
assert(fastfile);
|
||||
|
||||
game::engine::large_local rawfile_buf_large_local(0x18000);
|
||||
auto* rawfile_buf = static_cast<char*>(rawfile_buf_large_local.get_buf());
|
||||
|
||||
auto* text = game::DB_ReadRawFile(fastfile, rawfile_buf, 0x18000);
|
||||
|
||||
assert(text);
|
||||
|
||||
if (*text) {
|
||||
game::Com_PrintError(game::CON_CHANNEL_ERROR,
|
||||
"There were errors when building fast file '%s'\n",
|
||||
fastfile);
|
||||
game::Com_PrintError(game::CON_CHANNEL_ERROR, "%s", text);
|
||||
}
|
||||
}
|
||||
|
||||
void g_init_game_stub() {
|
||||
utils::hook::invoke<void>(0x4D6410);
|
||||
|
||||
g_print_fast_file_errors("code_post_gfx");
|
||||
g_print_fast_file_errors("common");
|
||||
g_print_fast_file_errors((*dvars::sv_mapname)->current.string);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(RTL_CRITICAL_SECTION) == 0x18);
|
||||
|
||||
void post_load() override {
|
||||
utils::hook::set<void (*)()>(0x604203, com_assert_f);
|
||||
|
||||
scheduler::once(
|
||||
[] {
|
||||
dvars::bug_name = game::Dvar_RegisterString(
|
||||
"bug_name", "bug0", game::DVAR_CHEAT | game::DVAR_CODINFO,
|
||||
"Name appended to the copied console log");
|
||||
},
|
||||
scheduler::pipeline::main);
|
||||
|
||||
command::add("bug", com_bug_f);
|
||||
command::add("bug_name_inc", com_bug_name_inc_f);
|
||||
|
||||
#ifdef _DEBUG
|
||||
utils::hook(0x4C79DF, g_init_game_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // Scr_FreeEntityList
|
||||
#endif
|
||||
}
|
||||
};
|
||||
} // namespace debug
|
||||
|
||||
REGISTER_COMPONENT(debug::component)
|
77
src/client/component/discord.cpp
Normal file
77
src/client/component/discord.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <discord_rpc.h>
|
||||
|
||||
#include "scheduler.hpp"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace discord {
|
||||
namespace {
|
||||
DiscordRichPresence discord_presence;
|
||||
|
||||
void update_discord() {
|
||||
Discord_RunCallbacks();
|
||||
|
||||
if (!discord_presence.startTimestamp) {
|
||||
discord_presence.startTimestamp =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
}
|
||||
|
||||
Discord_UpdatePresence(&discord_presence);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
DiscordEventHandlers handlers;
|
||||
ZeroMemory(&handlers, sizeof(handlers));
|
||||
handlers.ready = ready;
|
||||
handlers.errored = errored;
|
||||
handlers.disconnected = errored;
|
||||
handlers.joinGame = nullptr;
|
||||
handlers.spectateGame = nullptr;
|
||||
handlers.joinRequest = nullptr;
|
||||
|
||||
Discord_Initialize("978049907585863710", &handlers, 1, nullptr);
|
||||
|
||||
scheduler::once(
|
||||
[] {
|
||||
scheduler::once(update_discord, scheduler::pipeline::async);
|
||||
scheduler::loop(update_discord, scheduler::pipeline::async, 15s);
|
||||
},
|
||||
scheduler::pipeline::main);
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
void pre_destroy() override {
|
||||
if (initialized_) {
|
||||
Discord_Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool initialized_ = false;
|
||||
|
||||
static void ready(const DiscordUser* request) {
|
||||
ZeroMemory(&discord_presence, sizeof(discord_presence));
|
||||
|
||||
discord_presence.state = "Singleplayer";
|
||||
discord_presence.instance = 1;
|
||||
discord_presence.startTimestamp = 0;
|
||||
printf("Discord: Ready\n");
|
||||
Discord_UpdatePresence(&discord_presence);
|
||||
}
|
||||
|
||||
static void errored(const int error_code, const char* message) {
|
||||
printf("Discord: (%i) %s", error_code, message);
|
||||
}
|
||||
};
|
||||
} // namespace discord
|
||||
|
||||
REGISTER_COMPONENT(discord::component)
|
172
src/client/component/dvar.cpp
Normal file
172
src/client/component/dvar.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "dvar.hpp"
|
||||
|
||||
namespace dvar {
|
||||
struct dvar_base {
|
||||
std::uint16_t flags{};
|
||||
};
|
||||
|
||||
struct dvar_bool : dvar_base {
|
||||
bool value{};
|
||||
};
|
||||
|
||||
struct dvar_float : dvar_base {
|
||||
float value{};
|
||||
float min{};
|
||||
float max{};
|
||||
};
|
||||
|
||||
struct dvar_int : dvar_base {
|
||||
int value{};
|
||||
int min{};
|
||||
int max{};
|
||||
};
|
||||
|
||||
struct dvar_string : dvar_base {
|
||||
std::string value{};
|
||||
};
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
T* find_dvar(std::unordered_map<std::string, T>& map, const std::string& name) {
|
||||
auto i = map.find(name);
|
||||
if (i != map.end()) {
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace override {
|
||||
static std::unordered_map<std::string, dvar_bool> register_bool_overrides;
|
||||
static std::unordered_map<std::string, dvar_float> register_float_overrides;
|
||||
static std::unordered_map<std::string, dvar_int> register_int_overrides;
|
||||
static std::unordered_map<std::string, dvar_string> register_string_overrides;
|
||||
|
||||
void register_bool(const std::string& name, const bool value,
|
||||
const std::uint16_t flags) {
|
||||
dvar_bool values;
|
||||
values.value = value;
|
||||
values.flags = flags;
|
||||
register_bool_overrides[name] = values;
|
||||
}
|
||||
|
||||
void register_float(const std::string& name, const float value, const float min,
|
||||
const float max, const std::uint16_t flags) {
|
||||
dvar_float values;
|
||||
values.value = value;
|
||||
values.min = min;
|
||||
values.max = max;
|
||||
values.flags = flags;
|
||||
register_float_overrides[name] = values;
|
||||
}
|
||||
|
||||
void register_int(const std::string& name, const int value, const int min,
|
||||
const int max, const std::uint16_t flags) {
|
||||
dvar_int values;
|
||||
values.value = value;
|
||||
values.min = min;
|
||||
values.max = max;
|
||||
values.flags = flags;
|
||||
register_int_overrides[name] = values;
|
||||
}
|
||||
|
||||
void register_string(const std::string& name, const std::string& value,
|
||||
const std::uint16_t flags) {
|
||||
dvar_string values;
|
||||
values.value = value;
|
||||
values.flags = flags;
|
||||
register_string_overrides[name] = values;
|
||||
}
|
||||
} // namespace override
|
||||
|
||||
namespace {
|
||||
utils::hook::detour dvar_register_bool_hook;
|
||||
utils::hook::detour dvar_register_float_hook;
|
||||
utils::hook::detour dvar_register_int_hook;
|
||||
utils::hook::detour dvar_register_string_hook;
|
||||
|
||||
const game::dvar_t* dvar_register_bool_stub(const char* name, bool value,
|
||||
std::uint16_t flags,
|
||||
const char* description) {
|
||||
auto* var = find_dvar(override::register_bool_overrides, name);
|
||||
if (var) {
|
||||
value = var->value;
|
||||
flags = var->flags;
|
||||
}
|
||||
|
||||
return dvar_register_bool_hook.invoke<const game::dvar_t*>(name, value, flags,
|
||||
description);
|
||||
}
|
||||
|
||||
const game::dvar_t* dvar_register_float_stub(const char* name, float value,
|
||||
float min, float max,
|
||||
std::uint16_t flags,
|
||||
const char* description) {
|
||||
auto* var = find_dvar(override::register_float_overrides, name);
|
||||
if (var) {
|
||||
value = var->value;
|
||||
min = var->min;
|
||||
max = var->max;
|
||||
flags = var->flags;
|
||||
}
|
||||
|
||||
return dvar_register_float_hook.invoke<const game::dvar_t*>(
|
||||
name, value, min, max, flags, description);
|
||||
}
|
||||
|
||||
const game::dvar_t* dvar_register_int_stub(const char* name, int value, int min,
|
||||
int max, std::uint16_t flags,
|
||||
const char* description) {
|
||||
auto* var = find_dvar(override::register_int_overrides, name);
|
||||
if (var) {
|
||||
value = var->value;
|
||||
min = var->min;
|
||||
max = var->max;
|
||||
flags = var->flags;
|
||||
}
|
||||
|
||||
return dvar_register_int_hook.invoke<const game::dvar_t*>(
|
||||
name, value, min, max, flags, description);
|
||||
}
|
||||
|
||||
const game::dvar_t* dvar_register_string_stub(const char* name,
|
||||
const char* value,
|
||||
std::uint16_t flags,
|
||||
const char* description) {
|
||||
auto* var = find_dvar(override::register_string_overrides, name);
|
||||
if (var) {
|
||||
value = var->value.data();
|
||||
flags = var->flags;
|
||||
}
|
||||
|
||||
return dvar_register_string_hook.invoke<const game::dvar_t*>(
|
||||
name, value, flags, description);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
dvar_register_bool_hook.create(0x429390, &dvar_register_bool_stub);
|
||||
dvar_register_float_hook.create(0x4051D0, &dvar_register_float_stub);
|
||||
dvar_register_int_hook.create(0x4E9490, &dvar_register_int_stub);
|
||||
dvar_register_string_hook.create(0x49E0B0, &dvar_register_string_stub);
|
||||
}
|
||||
|
||||
void pre_destroy() override {
|
||||
dvar_register_bool_hook.clear();
|
||||
dvar_register_float_hook.clear();
|
||||
dvar_register_int_hook.clear();
|
||||
dvar_register_string_hook.clear();
|
||||
}
|
||||
};
|
||||
} // namespace dvar
|
||||
|
||||
REGISTER_COMPONENT(dvar::component)
|
13
src/client/component/dvar.hpp
Normal file
13
src/client/component/dvar.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
namespace dvar {
|
||||
namespace override {
|
||||
void register_bool(const std::string& name, bool value, std::uint16_t flags);
|
||||
void register_float(const std::string& name, float value, float min, float max,
|
||||
std::uint16_t flags);
|
||||
void register_int(const std::string& name, int value, int min, int max,
|
||||
std::uint16_t flags);
|
||||
void register_string(const std::string& name, const std::string& value,
|
||||
std::uint16_t flags);
|
||||
} // namespace override
|
||||
} // namespace dvar
|
68
src/client/component/dvar_patches.cpp
Normal file
68
src/client/component/dvar_patches.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "scheduler.hpp"
|
||||
#include "dvar.hpp"
|
||||
|
||||
namespace dvar_patches {
|
||||
namespace {
|
||||
const game::dvar_t* dvar_register_name(const char* dvar_name, const char* value,
|
||||
unsigned __int16 flags,
|
||||
const char* description) {
|
||||
return game::Dvar_RegisterString(
|
||||
dvar_name, value, game::DVAR_ARCHIVE | game::DVAR_USERINFO, description);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_start() override {
|
||||
dvar::override::register_bool("intro", true, game::DVAR_NONE);
|
||||
dvar::override::register_float("cg_fov", 65.0f, 65.0f, 160.0f,
|
||||
game::DVAR_ARCHIVE);
|
||||
dvar::override::register_string("fs_basegame", BASEGAME, game::DVAR_INIT);
|
||||
|
||||
#ifdef _DEBUG
|
||||
dvar::override::register_bool("sv_cheats", true, game::DVAR_NONE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void post_load() override {
|
||||
utils::hook(0x475156, dvar_register_name, HOOK_CALL).install()->quick();
|
||||
patch_sp();
|
||||
}
|
||||
|
||||
private:
|
||||
static void patch_sp() {
|
||||
utils::hook::set<std::uint8_t>(0x635841, 0xEB); // Read only
|
||||
utils::hook::set<std::uint8_t>(0x635913, 0xEB); // Cheat protected
|
||||
utils::hook::set<std::uint8_t>(0x6358A5, 0xEB); // Write protected
|
||||
utils::hook::set<std::uint8_t>(0x635974, 0xEB); // Latched
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Nop Dvar_RegisterVariant for sv_cheats in Dvar_Init
|
||||
utils::hook::nop(0x471522, 5);
|
||||
#endif
|
||||
|
||||
// Skip dvar output
|
||||
utils::hook::set<std::uint8_t>(0x4CD2B7, 0xEB);
|
||||
|
||||
// Ignore server dvar change for clients
|
||||
utils::hook::set<std::uint8_t>(0x63580B, 0xEB);
|
||||
|
||||
scheduler::once(
|
||||
[] {
|
||||
game::Dvar_RegisterBool("scr_damageFeedback", true, game::DVAR_NONE,
|
||||
"Show marker when hitting enemies");
|
||||
game::Dvar_RegisterString("connect_ip", "127.0.0.1:28960",
|
||||
game::DVAR_NONE,
|
||||
"Temporary dvar used to connect");
|
||||
},
|
||||
scheduler::pipeline::main);
|
||||
}
|
||||
};
|
||||
} // namespace dvar_patches
|
||||
|
||||
REGISTER_COMPONENT(dvar_patches::component)
|
82
src/client/component/filesystem.cpp
Normal file
82
src/client/component/filesystem.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include "game_module.hpp"
|
||||
#include "filesystem.hpp"
|
||||
|
||||
namespace filesystem {
|
||||
namespace {
|
||||
const char* sys_default_install_path_stub() {
|
||||
static auto current_path = std::filesystem::current_path().string();
|
||||
return current_path.data();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<std::string> vectored_file_list(const std::string& path,
|
||||
const std::string& extension) {
|
||||
std::vector<std::string> file_list;
|
||||
|
||||
auto num_files = 0;
|
||||
const auto** files = game::FS_ListFiles(path.data(), extension.data(),
|
||||
game::FS_LIST_ALL, &num_files, 10);
|
||||
|
||||
if (files) {
|
||||
for (auto i = 0; i < num_files; ++i) {
|
||||
if (files[i]) {
|
||||
file_list.emplace_back(files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
game::FS_FreeFileList(files, 10);
|
||||
}
|
||||
|
||||
return file_list;
|
||||
}
|
||||
|
||||
std::string get_binary_directory() {
|
||||
const auto dir = game_module::get_host_module().get_folder();
|
||||
return utils::string::replace(dir, "/", "\\");
|
||||
}
|
||||
|
||||
file::file(std::string name, game::FsThread thread) : name_(std::move(name)) {
|
||||
assert(!this->name_.empty());
|
||||
|
||||
auto handle = 0;
|
||||
const auto len =
|
||||
game::FS_FOpenFileReadForThread(name_.data(), &handle, thread);
|
||||
|
||||
if (!handle) {
|
||||
this->valid_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
auto* buf = static_cast<char*>(game::Hunk_AllocateTempMemory(len + 1));
|
||||
game::FS_Read(buf, len, handle);
|
||||
buf[len] = '\0';
|
||||
|
||||
game::FS_FCloseFile(handle);
|
||||
|
||||
this->valid_ = true;
|
||||
this->buffer_.append(buf, len);
|
||||
}
|
||||
|
||||
bool file::exists() const { return this->valid_; }
|
||||
|
||||
const std::string& file::get_buffer() const { return this->buffer_; }
|
||||
|
||||
const std::string& file::get_name() const { return this->name_; }
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x465B90, sys_default_install_path_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // Sys_CreateFile
|
||||
}
|
||||
};
|
||||
} // namespace filesystem
|
||||
|
||||
REGISTER_COMPONENT(filesystem::component)
|
21
src/client/component/filesystem.hpp
Normal file
21
src/client/component/filesystem.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace filesystem {
|
||||
std::vector<std::string> vectored_file_list(const std::string& path,
|
||||
const std::string& extension);
|
||||
std::string get_binary_directory();
|
||||
|
||||
class file {
|
||||
public:
|
||||
file(std::string name, game::FsThread thread);
|
||||
|
||||
[[nodiscard]] bool exists() const;
|
||||
[[nodiscard]] const std::string& get_buffer() const;
|
||||
[[nodiscard]] const std::string& get_name() const;
|
||||
|
||||
private:
|
||||
bool valid_ = false;
|
||||
std::string name_;
|
||||
std::string buffer_;
|
||||
};
|
||||
} // namespace filesystem
|
115
src/client/component/game_log.cpp
Normal file
115
src/client/component/game_log.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "gsc/extension.hpp"
|
||||
|
||||
#include "game_log.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
namespace game_log {
|
||||
namespace {
|
||||
int log_file = 0;
|
||||
|
||||
void g_scr_log_print() {
|
||||
char string[1024]{};
|
||||
std::size_t i_string_len = 0;
|
||||
|
||||
const auto i_num_parms = game::Scr_GetNumParam();
|
||||
for (std::size_t i = 0; i < i_num_parms; ++i) {
|
||||
const auto* psz_token = game::Scr_GetString(i);
|
||||
const auto i_token_len = std::strlen(psz_token);
|
||||
|
||||
i_string_len += i_token_len;
|
||||
if (i_string_len >= sizeof(string)) {
|
||||
// Do not overflow the buffer
|
||||
break;
|
||||
}
|
||||
|
||||
strncat_s(string, psz_token, _TRUNCATE);
|
||||
}
|
||||
|
||||
log_printf("%s", string);
|
||||
}
|
||||
|
||||
void g_init_game_stub() {
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER,
|
||||
"------- Game Initialization -------\n");
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER, "gamename: iw4-sp\n");
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER, "gamedate: %s\n", __DATE__);
|
||||
|
||||
if (*dvars::g_log->current.string == '\0') {
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER, "Not logging to disk.\n");
|
||||
} else {
|
||||
game::FS_FOpenFileByMode(dvars::g_log->current.string, &log_file,
|
||||
game::FS_APPEND_SYNC);
|
||||
|
||||
if (!log_file) {
|
||||
game::Com_PrintWarning(game::CON_CHANNEL_SERVER,
|
||||
"WARNING: Couldn't open logfile: %s\n");
|
||||
} else {
|
||||
log_printf(
|
||||
"------------------------------------------------------------\n");
|
||||
log_printf("InitGame\n");
|
||||
}
|
||||
}
|
||||
|
||||
utils::hook::invoke<void>(0x4FA880); // Vehicle_ClearServerDefs
|
||||
}
|
||||
|
||||
void g_shutdown_game_stub() {
|
||||
if (log_file) {
|
||||
log_printf("ShutdownGame:\n");
|
||||
log_printf(
|
||||
"------------------------------------------------------------\n");
|
||||
|
||||
game::FS_FCloseFile(log_file);
|
||||
log_file = 0;
|
||||
}
|
||||
|
||||
utils::hook::invoke<void>(0x455F90); // Actor_ClearThreatBiasGroups
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void log_printf(const char* fmt, ...) {
|
||||
char string[1024]{};
|
||||
char string2[1024]{};
|
||||
va_list ap;
|
||||
|
||||
if (!log_file) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf_s(string2, _TRUNCATE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
const auto time = game::level->time / 1000;
|
||||
const auto len = sprintf_s(string, "%3i:%i%i %s", time / 60, time % 60 / 10,
|
||||
time % 60 % 10, string2);
|
||||
game::FS_Write(string, len, log_file);
|
||||
}
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(offsetof(game::level_locals_t, time) == 0x34);
|
||||
|
||||
void post_load() override {
|
||||
utils::hook(0x4C75E0, g_init_game_stub, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x418B5A, g_shutdown_game_stub, HOOK_CALL).install()->quick();
|
||||
|
||||
scheduler::once(
|
||||
[] {
|
||||
dvars::g_log = game::Dvar_RegisterString(
|
||||
"g_log", "games_sp.log", game::DVAR_NONE, "Log file name");
|
||||
},
|
||||
scheduler::pipeline::main);
|
||||
|
||||
gsc::add_function("logprint", g_scr_log_print);
|
||||
}
|
||||
};
|
||||
} // namespace game_log
|
||||
|
||||
REGISTER_COMPONENT(game_log::component)
|
5
src/client/component/game_log.hpp
Normal file
5
src/client/component/game_log.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace game_log {
|
||||
void log_printf(const char* fmt, ...);
|
||||
}
|
110
src/client/component/game_module.cpp
Normal file
110
src/client/component/game_module.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#ifdef INJECT_HOST_AS_LIB
|
||||
#include <utils/hook.hpp>
|
||||
#endif
|
||||
|
||||
#include <utils/nt.hpp>
|
||||
|
||||
#include "game_module.hpp"
|
||||
|
||||
namespace game_module {
|
||||
#ifdef INJECT_HOST_AS_LIB
|
||||
namespace {
|
||||
utils::hook::detour handle_a_hook;
|
||||
utils::hook::detour handle_w_hook;
|
||||
utils::hook::detour handle_ex_a_hook;
|
||||
utils::hook::detour handle_ex_w_hook;
|
||||
utils::hook::detour file_name_a_hook;
|
||||
utils::hook::detour file_name_w_hook;
|
||||
|
||||
HMODULE WINAPI get_module_handle_a(const LPCSTR module_name) {
|
||||
if (!module_name) {
|
||||
return get_game_module();
|
||||
}
|
||||
|
||||
return handle_a_hook.invoke<HMODULE>(module_name);
|
||||
}
|
||||
|
||||
HMODULE WINAPI get_module_handle_w(const LPWSTR module_name) {
|
||||
if (!module_name) {
|
||||
return get_game_module();
|
||||
}
|
||||
|
||||
return handle_w_hook.invoke<HMODULE>(module_name);
|
||||
}
|
||||
|
||||
BOOL WINAPI get_module_handle_ex_a(const DWORD flags, const LPCSTR module_name,
|
||||
HMODULE* hmodule) {
|
||||
if (!module_name) {
|
||||
*hmodule = get_game_module();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return handle_ex_a_hook.invoke<BOOL>(flags, module_name, hmodule);
|
||||
}
|
||||
|
||||
BOOL WINAPI get_module_handle_ex_w(const DWORD flags, const LPCWSTR module_name,
|
||||
HMODULE* hmodule) {
|
||||
if (!module_name) {
|
||||
*hmodule = get_game_module();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return handle_ex_w_hook.invoke<BOOL>(flags, module_name, hmodule);
|
||||
}
|
||||
|
||||
DWORD WINAPI get_module_file_name_a(HMODULE hmodule, const LPSTR filename,
|
||||
const DWORD size) {
|
||||
if (!hmodule) {
|
||||
hmodule = get_game_module();
|
||||
}
|
||||
|
||||
return file_name_a_hook.invoke<DWORD>(hmodule, filename, size);
|
||||
}
|
||||
|
||||
DWORD WINAPI get_module_file_name_w(HMODULE hmodule, const LPWSTR filename,
|
||||
const DWORD size) {
|
||||
if (!hmodule || utils::nt::library(hmodule) == get_game_module()) {
|
||||
hmodule = get_host_module();
|
||||
}
|
||||
|
||||
return file_name_w_hook.invoke<DWORD>(hmodule, filename, size);
|
||||
}
|
||||
|
||||
void hook_module_resolving() {
|
||||
handle_a_hook.create(&GetModuleHandleA, &get_module_handle_a);
|
||||
handle_w_hook.create(&GetModuleHandleW, &get_module_handle_w);
|
||||
handle_ex_w_hook.create(&GetModuleHandleExA, &get_module_handle_ex_a);
|
||||
handle_ex_w_hook.create(&GetModuleHandleExW, &get_module_handle_ex_w);
|
||||
file_name_a_hook.create(&GetModuleFileNameA, &get_module_file_name_a);
|
||||
file_name_w_hook.create(&GetModuleFileNameW, &get_module_file_name_w);
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
utils::nt::library get_game_module() {
|
||||
static utils::nt::library game{reinterpret_cast<HMODULE>(0x400000)};
|
||||
return game;
|
||||
}
|
||||
|
||||
utils::nt::library get_host_module() {
|
||||
static utils::nt::library host{};
|
||||
return host;
|
||||
}
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_start() override { get_host_module(); }
|
||||
|
||||
void post_load() override {
|
||||
#ifdef INJECT_HOST_AS_LIB
|
||||
hook_module_resolving();
|
||||
#else
|
||||
assert(get_host_module() == get_game_module());
|
||||
#endif
|
||||
}
|
||||
};
|
||||
} // namespace game_module
|
||||
|
||||
REGISTER_COMPONENT(game_module::component)
|
6
src/client/component/game_module.hpp
Normal file
6
src/client/component/game_module.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace game_module {
|
||||
utils::nt::library get_game_module();
|
||||
utils::nt::library get_host_module();
|
||||
} // namespace game_module
|
126
src/client/component/gsc/extension.cpp
Normal file
126
src/client/component/gsc/extension.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include "extension.hpp"
|
||||
|
||||
namespace gsc {
|
||||
#define GSC_DEBUG_FUNCTIONS
|
||||
|
||||
namespace {
|
||||
struct script_function_def {
|
||||
game::BuiltinFunction actionFunc;
|
||||
bool type;
|
||||
};
|
||||
|
||||
struct script_method_def {
|
||||
game::BuiltinMethod actionFunc;
|
||||
bool type;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, script_function_def> custom_scr_funcs;
|
||||
std::unordered_map<std::string, script_method_def> custom_scr_meths;
|
||||
|
||||
game::BuiltinFunction built_in_get_function_stub(const char** p_name,
|
||||
int* type) {
|
||||
if (p_name) {
|
||||
const auto itr = custom_scr_funcs.find(utils::string::to_lower(*p_name));
|
||||
if (itr != custom_scr_funcs.end()) {
|
||||
*type = itr->second.type;
|
||||
return itr->second.actionFunc;
|
||||
}
|
||||
} else {
|
||||
for (const auto& [name, func] : custom_scr_funcs) {
|
||||
game::Scr_RegisterFunction(reinterpret_cast<int>(func.actionFunc),
|
||||
name.data());
|
||||
}
|
||||
}
|
||||
|
||||
// If no function was found let's call BuiltIn_GetFunction
|
||||
return utils::hook::invoke<game::BuiltinFunction>(0x4DD160, p_name, type);
|
||||
}
|
||||
|
||||
game::BuiltinMethod built_in_get_method_stub(const char** p_name, int* type) {
|
||||
if (p_name) {
|
||||
const auto itr = custom_scr_meths.find(utils::string::to_lower(*p_name));
|
||||
if (itr != custom_scr_meths.end()) {
|
||||
*type = itr->second.type;
|
||||
return itr->second.actionFunc;
|
||||
}
|
||||
} else {
|
||||
for (const auto& [name, meth] : custom_scr_meths) {
|
||||
game::Scr_RegisterFunction(reinterpret_cast<int>(meth.actionFunc),
|
||||
name.data());
|
||||
}
|
||||
}
|
||||
|
||||
// If no method was found let's call BuiltIn_GetMethod
|
||||
return utils::hook::invoke<game::BuiltinMethod>(0x5DB850, p_name, type);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void add_function(const char* name, game::BuiltinFunction func, bool type) {
|
||||
script_function_def def;
|
||||
def.actionFunc = func;
|
||||
def.type = type;
|
||||
|
||||
custom_scr_funcs.emplace(utils::string::to_lower(name), def);
|
||||
}
|
||||
|
||||
void add_method(const char* name, game::BuiltinMethod func, bool type) {
|
||||
script_method_def def;
|
||||
def.actionFunc = func;
|
||||
def.type = type;
|
||||
|
||||
custom_scr_meths.emplace(utils::string::to_lower(name), def);
|
||||
}
|
||||
|
||||
class extension final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// Fetch custom functions
|
||||
utils::hook(0x4ADF9C, built_in_get_function_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // Scr_GetFunction
|
||||
|
||||
utils::hook(0x444827, built_in_get_method_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // Scr_GetMethod
|
||||
|
||||
add_functions();
|
||||
#ifdef GSC_DEBUG_FUNCTIONS
|
||||
add_debug_functions();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void add_functions() {
|
||||
add_function("Float", [] {
|
||||
switch (game::Scr_GetType(0)) {
|
||||
case game::VAR_STRING:
|
||||
game::Scr_AddFloat(
|
||||
static_cast<float>(std::atof(game::Scr_GetString(0))));
|
||||
break;
|
||||
case game::VAR_FLOAT:
|
||||
game::Scr_AddFloat(game::Scr_GetFloat(0));
|
||||
break;
|
||||
case game::VAR_INTEGER:
|
||||
game::Scr_AddFloat(static_cast<float>(game::Scr_GetInt(0)));
|
||||
break;
|
||||
default:
|
||||
game::Scr_ParamError(0, utils::string::va("cannot cast {0} to float",
|
||||
game::Scr_GetTypeName(0)));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void add_debug_functions() {
|
||||
add_function("AddDebugCommand",
|
||||
[] { game::Cbuf_AddText(0, game::Scr_GetString(0)); });
|
||||
}
|
||||
};
|
||||
} // namespace gsc
|
||||
|
||||
REGISTER_COMPONENT(gsc::extension)
|
7
src/client/component/gsc/extension.hpp
Normal file
7
src/client/component/gsc/extension.hpp
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace gsc {
|
||||
void add_function(const char* name, game::BuiltinFunction func,
|
||||
bool type = false);
|
||||
void add_method(const char* name, game::BuiltinMethod func, bool type = false);
|
||||
} // namespace gsc
|
88
src/client/component/gsc/loading.cpp
Normal file
88
src/client/component/gsc/loading.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace gsc {
|
||||
namespace {
|
||||
std::vector<int> main_handles;
|
||||
std::vector<int> init_handles;
|
||||
|
||||
// Do not use C++ objects because Scr_LoadScript may longjmp
|
||||
void g_scr_load_scripts_stub() {
|
||||
// Clear handles (from previous GSC loading session)
|
||||
main_handles.clear();
|
||||
init_handles.clear();
|
||||
|
||||
char path[MAX_PATH]{};
|
||||
|
||||
auto num_files = 0;
|
||||
const auto** files =
|
||||
game::FS_ListFiles("scripts/", "gsc", game::FS_LIST_ALL, &num_files, 10);
|
||||
|
||||
for (auto i = 0; i < num_files; ++i) {
|
||||
const auto* script_file = files[i];
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER, "Loading script %s...\n",
|
||||
script_file);
|
||||
|
||||
const auto len = sprintf_s(path, "%s/%s", "scripts", script_file);
|
||||
if (len == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Scr_LoadScriptInternal will add the '.gsc' suffix so we remove it
|
||||
path[len - 4] = '\0';
|
||||
|
||||
if (!game::Scr_LoadScript(path)) {
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER,
|
||||
"Script %s encountered an error while loading\n", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER,
|
||||
"Script %s.gsc loaded successfully\n", path);
|
||||
|
||||
const auto main_handle = game::Scr_GetFunctionHandle(path, "main");
|
||||
if (main_handle) {
|
||||
main_handles.push_back(main_handle);
|
||||
}
|
||||
|
||||
const auto init_handle = game::Scr_GetFunctionHandle(path, "init");
|
||||
if (init_handle) {
|
||||
init_handles.push_back(init_handle);
|
||||
}
|
||||
// Allow scripts with no handles
|
||||
}
|
||||
|
||||
game::FS_FreeFileList(files, 10);
|
||||
}
|
||||
|
||||
void scr_load_level_stub() {
|
||||
for (const auto& handle : main_handles) {
|
||||
const auto id = game::Scr_ExecThread(handle, 0);
|
||||
game::Scr_FreeThread(static_cast<std::uint16_t>(id));
|
||||
}
|
||||
|
||||
utils::hook::invoke<void>(0x470860); // Scr_LoadLevel
|
||||
|
||||
for (const auto& handle : init_handles) {
|
||||
const auto id = game::Scr_ExecThread(handle, 0);
|
||||
game::Scr_FreeThread(static_cast<std::uint16_t>(id));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class loading final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x4054C2, g_scr_load_scripts_stub, HOOK_JUMP)
|
||||
.install()
|
||||
->quick();
|
||||
|
||||
utils::hook(0x4C1E34, scr_load_level_stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
};
|
||||
} // namespace gsc
|
||||
|
||||
REGISTER_COMPONENT(gsc::loading)
|
83
src/client/component/gsc/string.cpp
Normal file
83
src/client/component/gsc/string.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "extension.hpp"
|
||||
|
||||
namespace gsc {
|
||||
namespace {
|
||||
void scr_str_i_cmp() {
|
||||
const auto* string1 = game::SL_ConvertToString(game::Scr_GetConstString(0));
|
||||
const auto* string2 = game::SL_ConvertToString(game::Scr_GetConstString(1));
|
||||
|
||||
game::Scr_AddInt(game::I_stricmp(string1, string2));
|
||||
}
|
||||
|
||||
void scr_is_end_str() {
|
||||
const auto* str = game::Scr_GetString(0);
|
||||
const auto* suffix = game::Scr_GetString(1);
|
||||
|
||||
const auto str_len = std::strlen(str);
|
||||
const auto suffix_len = std::strlen(suffix);
|
||||
|
||||
if (suffix_len > str_len) {
|
||||
game::Scr_AddInt(0);
|
||||
return;
|
||||
}
|
||||
|
||||
game::Scr_AddInt(
|
||||
std::memcmp(str + str_len - suffix_len, suffix, suffix_len) == 0);
|
||||
}
|
||||
|
||||
void scr_to_upper() {
|
||||
const auto script_value = game::Scr_GetConstString(0);
|
||||
const auto* string = game::SL_ConvertToString(script_value);
|
||||
|
||||
char out[1024]{};
|
||||
bool changed = false;
|
||||
|
||||
std::size_t i = 0;
|
||||
while (i < sizeof(out)) {
|
||||
const auto value = *string;
|
||||
const auto result =
|
||||
static_cast<char>(std::toupper(static_cast<unsigned char>(value)));
|
||||
|
||||
out[i] = result;
|
||||
|
||||
if (value != result) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (result == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
++string;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i >= sizeof(out)) {
|
||||
game::Scr_Error("string too long");
|
||||
return;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
game::Scr_AddString(out);
|
||||
} else {
|
||||
game::SL_AddRefToString(script_value);
|
||||
game::Scr_AddConstString(script_value);
|
||||
game::SL_RemoveRefToString(script_value);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class string final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
add_function("StrICmp", scr_str_i_cmp);
|
||||
add_function("IsEndStr", scr_is_end_str);
|
||||
add_function("ToUpper", scr_to_upper);
|
||||
}
|
||||
};
|
||||
} // namespace gsc
|
||||
|
||||
REGISTER_COMPONENT(gsc::string)
|
16
src/client/component/images.cpp
Normal file
16
src/client/component/images.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace images {
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
// Skip version check
|
||||
utils::hook::set<std::uint8_t>(0x544746, 0xEB);
|
||||
}
|
||||
};
|
||||
} // namespace images
|
||||
|
||||
REGISTER_COMPONENT(images::component)
|
73
src/client/component/lean.cpp
Normal file
73
src/client/component/lean.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "command.hpp"
|
||||
|
||||
namespace lean {
|
||||
namespace {
|
||||
game::kbutton_t in_lean_left;
|
||||
game::kbutton_t in_lean_right;
|
||||
|
||||
void in_lean_left_down() { game::IN_KeyDown(&in_lean_left); }
|
||||
|
||||
void in_lean_left_up() { game::IN_KeyUp(&in_lean_left); }
|
||||
|
||||
void in_lean_right_down() { game::IN_KeyDown(&in_lean_right); }
|
||||
|
||||
void in_lean_right_up() { game::IN_KeyUp(&in_lean_right); }
|
||||
|
||||
void set_lean_flags(game::usercmd_s* cmd) {
|
||||
if (in_lean_left.active || in_lean_left.wasPressed) {
|
||||
cmd->buttons |= game::CMD_BUTTON_LEAN_LEFT;
|
||||
}
|
||||
|
||||
if (in_lean_right.active || in_lean_right.wasPressed) {
|
||||
cmd->buttons |= game::CMD_BUTTON_LEAN_RIGHT;
|
||||
}
|
||||
|
||||
in_lean_left.wasPressed = false;
|
||||
in_lean_right.wasPressed = false;
|
||||
}
|
||||
|
||||
void __declspec(naked) cl_cmd_buttons_stub() {
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
push esi;
|
||||
call set_lean_flags;
|
||||
add esp, 0x4;
|
||||
|
||||
popad;
|
||||
|
||||
// code skipped by our hook
|
||||
mov eax, ecx;
|
||||
imul eax, eax, 0x21C;
|
||||
|
||||
// CL_CmdButton
|
||||
push 0x57B2B8;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(game::kbutton_t) == 0x14);
|
||||
static_assert(sizeof(game::usercmd_s) == 0x40);
|
||||
|
||||
void post_load() override {
|
||||
command::add_raw("+leanleft", in_lean_left_down, TRUE);
|
||||
command::add_raw("-leanleft", in_lean_left_up, TRUE);
|
||||
|
||||
command::add_raw("+leanright", in_lean_right_down, TRUE);
|
||||
command::add_raw("-leanright", in_lean_right_up, TRUE);
|
||||
|
||||
utils::hook(0x57B2B0, cl_cmd_buttons_stub, HOOK_JUMP).install()->quick();
|
||||
utils::hook::nop(0x57B2B0 + 5, 3);
|
||||
}
|
||||
};
|
||||
} // namespace lean
|
||||
|
||||
REGISTER_COMPONENT(lean::component)
|
83
src/client/component/network.cpp
Normal file
83
src/client/component/network.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "command.hpp"
|
||||
#include "network.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace network {
|
||||
namespace {
|
||||
void cl_co_op_connect(const command::params& params) {
|
||||
// Valid format is IP Port
|
||||
if (params.size() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto input = std::strtol(params.get(2), nullptr, 10);
|
||||
const auto port = ::htons(static_cast<std::uint16_t>(input));
|
||||
|
||||
command::execute(
|
||||
utils::string::va("connect_coop {0} {1}", params.get(1), port));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override { patch_sp(); }
|
||||
|
||||
private:
|
||||
static void patch_sp() {
|
||||
// Ignore protocol mismatch
|
||||
utils::hook::set<std::uint8_t>(0x65D0C2, 0xEB);
|
||||
utils::hook::set<std::uint8_t>(0x65D0ED, 0xEB);
|
||||
|
||||
// Disable matchmaking stuff
|
||||
utils::hook::set<std::uint8_t>(0x43BAE0, 0xEB);
|
||||
|
||||
// Ignore 'MAX_PACKET_USERCMDS'
|
||||
utils::hook::set<std::uint8_t>(0x4B1436, 0xEB);
|
||||
|
||||
// Disable IWNet stuff
|
||||
utils::hook::set<std::uint8_t>(0x44E824, 0xEB);
|
||||
utils::hook::set<std::uint8_t>(0x44E808, 0xEB);
|
||||
|
||||
// Disable MP packet handler
|
||||
utils::hook::set<std::uint8_t>(0x65E717, 0xEB);
|
||||
|
||||
// Disable LSP packet handler
|
||||
utils::hook::set<std::uint8_t>(0x65E3A4, 0xEB);
|
||||
|
||||
// Avoid spam
|
||||
utils::hook(0x65E786, game::Com_DPrintf, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x65D659, game::Com_DPrintf, HOOK_CALL).install()->quick();
|
||||
|
||||
// Disable BigShort in NET_AdrToString
|
||||
utils::hook(0x4BF4D1, game::ShortNoSwap, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x4BF50C, game::ShortNoSwap, HOOK_CALL).install()->quick();
|
||||
|
||||
// Fix NET_StringToAdr (Only known workaround that actually works)
|
||||
utils::hook::set<const char*>(0x475417, "connect_coop");
|
||||
command::add("connect", cl_co_op_connect);
|
||||
|
||||
// Disable BigShort in GetLocalAddressForEncryptedConnection
|
||||
utils::hook(0x4CF42D, game::ShortNoSwap, HOOK_CALL).install()->quick();
|
||||
|
||||
// Parse port as unsigned short in Net_AddrToString
|
||||
utils::hook::set<const char*>(0x4BF4F3, "%u.%u.%u.%u:%hu");
|
||||
|
||||
// Force Win socket initialization
|
||||
utils::hook::nop(0x42B649, 2);
|
||||
|
||||
// Kill LSP
|
||||
utils::hook::set<std::uint8_t>(0x4553F0, 0xC3); // Hello
|
||||
utils::hook::set<std::uint8_t>(0x428D00, 0xC3); // LSP_SendLogRequest
|
||||
utils::hook::set<std::uint8_t>(0x4D13C0, 0xC3); // LSP_ParsePacket
|
||||
utils::hook::set<std::uint8_t>(0x66D440, 0xC3); // LSP_AddKeepAlive
|
||||
utils::hook::nop(0x494E68, 5); // Don't create LSP socket
|
||||
}
|
||||
};
|
||||
} // namespace network
|
||||
|
||||
REGISTER_COMPONENT(network::component)
|
5
src/client/component/network.hpp
Normal file
5
src/client/component/network.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace network {
|
||||
using callback = std::function<void(const game::netadr_t&, const std::string&)>;
|
||||
}
|
43
src/client/component/no_border.cpp
Normal file
43
src/client/component/no_border.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace no_border {
|
||||
namespace {
|
||||
void __declspec(naked) window_style_stub() {
|
||||
__asm {
|
||||
push eax;
|
||||
mov eax, dvars::r_noBorder;
|
||||
cmp byte ptr [eax + 0x10], 1;
|
||||
pop eax;
|
||||
|
||||
je remove_border;
|
||||
|
||||
mov ebp, WS_VISIBLE | WS_SYSMENU | WS_CAPTION;
|
||||
jmp safe_return;
|
||||
|
||||
remove_border:
|
||||
mov ebp, WS_VISIBLE | WS_POPUP;
|
||||
|
||||
safe_return:
|
||||
push 0x50C0B8;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x50C0B3, window_style_stub, HOOK_JUMP).install()->quick();
|
||||
|
||||
dvars::r_noBorder =
|
||||
game::Dvar_RegisterBool("r_noBorder", false, game::DVAR_ARCHIVE,
|
||||
"Do not use a border in windowed mode");
|
||||
}
|
||||
};
|
||||
} // namespace no_border
|
||||
|
||||
REGISTER_COMPONENT(no_border::component)
|
103
src/client/component/patches.cpp
Normal file
103
src/client/component/patches.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/nt.hpp>
|
||||
|
||||
#include "command.hpp"
|
||||
#include "filesystem.hpp"
|
||||
|
||||
namespace patches {
|
||||
namespace {
|
||||
void sys_init_stub() {
|
||||
game::Cmd_SetAutoComplete("exec", "", "cfg");
|
||||
utils::hook::invoke<void>(0x4EEB20);
|
||||
}
|
||||
|
||||
void cl_play_unskippable_cinematic_f() {
|
||||
// CL_PlayCinematic_f
|
||||
utils::hook::invoke<void>(0x4CC950);
|
||||
*game::cin_skippable = true;
|
||||
}
|
||||
|
||||
void cl_start_multiplayer_f() {
|
||||
utils::nt::update_dll_search_path(filesystem::get_binary_directory());
|
||||
utils::nt::launch_process("iw4mp.exe", "-multiplayer");
|
||||
command::execute("quit", false);
|
||||
}
|
||||
|
||||
const char* live_get_local_client_name_stub() {
|
||||
return game::Dvar_FindVar("name")->current.string;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x6042A2, sys_init_stub, HOOK_CALL).install()->quick();
|
||||
|
||||
utils::hook(0x492EF0, live_get_local_client_name_stub, HOOK_JUMP)
|
||||
.install()
|
||||
->quick();
|
||||
|
||||
patch_sp();
|
||||
}
|
||||
|
||||
private:
|
||||
static void patch_sp() {
|
||||
// Force external console
|
||||
utils::hook::nop(0x604071, 21);
|
||||
|
||||
// Remove limit on IWD file loading
|
||||
utils::hook::set<std::uint8_t>(0x630FF3, 0xEB);
|
||||
|
||||
// Ignore XUID match
|
||||
utils::hook::set<std::uint8_t>(0x65D1AF, 0xEB);
|
||||
|
||||
// Remove this particular string from the log file
|
||||
utils::hook::nop(0x6030A6, 5);
|
||||
|
||||
// Config related
|
||||
utils::hook::set<std::uint8_t>(0x4D3FD3, 0xEB);
|
||||
|
||||
// Improper quit popup
|
||||
utils::hook::nop(0x4F5B3A, 2);
|
||||
|
||||
// Remove fs_game check
|
||||
utils::hook::nop(0x612932, 2);
|
||||
|
||||
// Build os path stuff
|
||||
utils::hook::set<std::uint8_t>(0x6300BF, 0xEB);
|
||||
|
||||
// Show intro (or not)
|
||||
utils::hook::set<std::uint8_t>(0x6035BD, 0x0);
|
||||
|
||||
// raw -> main
|
||||
utils::hook::set<std::uint32_t>(0x50A0B2, 0x723390);
|
||||
|
||||
// Disable 'replay' output
|
||||
utils::hook::nop(0x65F14A, 5);
|
||||
|
||||
// Disable heartbeat output
|
||||
utils::hook::nop(0x57EF87, 5);
|
||||
|
||||
// Allow intro to be skipped
|
||||
utils::hook::set<void (*)()>(0x47529F, cl_play_unskippable_cinematic_f);
|
||||
|
||||
// Start IW4 MP
|
||||
utils::hook::set<void (*)()>(0x475327, cl_start_multiplayer_f);
|
||||
|
||||
// Enable commandline arguments
|
||||
utils::hook::set<std::uint8_t>(0x453B24, 0xEB);
|
||||
|
||||
// Rename config
|
||||
utils::hook::set<const char*>(0x6040F2, CLIENT_CONFIG);
|
||||
utils::hook::set<const char*>(0x602D38, CLIENT_CONFIG);
|
||||
utils::hook::set<const char*>(0x6037C9, CLIENT_CONFIG);
|
||||
utils::hook::set<const char*>(0x4D3FDB, CLIENT_CONFIG);
|
||||
utils::hook::set<const char*>(0x469DB6, CLIENT_CONFIG);
|
||||
}
|
||||
};
|
||||
} // namespace patches
|
||||
|
||||
REGISTER_COMPONENT(patches::component)
|
180
src/client/component/player_movement.cpp
Normal file
180
src/client/component/player_movement.cpp
Normal file
@ -0,0 +1,180 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include "gsc/extension.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace player_movement {
|
||||
namespace {
|
||||
void __declspec(naked) pm_step_slide_move_stub() {
|
||||
__asm {
|
||||
push eax;
|
||||
mov eax, dvars::pm_bounce;
|
||||
cmp byte ptr [eax + 0x10], 1;
|
||||
pop eax;
|
||||
|
||||
je bounce;
|
||||
|
||||
cmp dword ptr [esp + 0x24], 0;
|
||||
jnz no_bounce;
|
||||
|
||||
bounce:
|
||||
push 0x4E905B;
|
||||
ret;
|
||||
|
||||
no_bounce:
|
||||
push 0x4E906F;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
|
||||
void pm_project_velocity_stub(const float* vel_in, const float* normal,
|
||||
float* vel_out) {
|
||||
const auto length_squared_2d = vel_in[0] * vel_in[0] + vel_in[1] * vel_in[1];
|
||||
|
||||
if (std::fabsf(normal[2]) < 0.001f || length_squared_2d == 0.0f) {
|
||||
vel_out[0] = vel_in[0];
|
||||
vel_out[1] = vel_in[1];
|
||||
vel_out[2] = vel_in[2];
|
||||
return;
|
||||
}
|
||||
|
||||
auto new_z = vel_in[0] * normal[0] + vel_in[1] * normal[1];
|
||||
new_z = -new_z / normal[2];
|
||||
|
||||
const auto length_scale =
|
||||
std::sqrtf((vel_in[2] * vel_in[2] + length_squared_2d) /
|
||||
(new_z * new_z + length_squared_2d));
|
||||
|
||||
if (dvars::pm_bouncingAllAngles->current.enabled ||
|
||||
(length_scale < 1.f || new_z < 0.f || vel_in[2] > 0.f)) {
|
||||
vel_out[0] = vel_in[0] * length_scale;
|
||||
vel_out[1] = vel_in[1] * length_scale;
|
||||
vel_out[2] = new_z * length_scale;
|
||||
}
|
||||
}
|
||||
|
||||
game::gentity_s* weapon_rocket_launcher_fire_stub(
|
||||
game::gentity_s* ent, unsigned int weapon_index, float spread,
|
||||
game::weaponParms* wp, const float* gun_vel,
|
||||
game::lockonFireParms* lock_parms, bool magic_bullet) {
|
||||
auto* result = utils::hook::invoke<game::gentity_s*>(
|
||||
0x443F20, ent, weapon_index, spread, wp, gun_vel, lock_parms,
|
||||
magic_bullet);
|
||||
|
||||
if (ent->client && dvars::pm_rocketJump->current.enabled) {
|
||||
const auto scale = dvars::pm_rocketJumpScale->current.value;
|
||||
ent->client->ps.velocity[0] += (0.0f - wp->forward[0]) * scale;
|
||||
ent->client->ps.velocity[1] += (0.0f - wp->forward[1]) * scale;
|
||||
ent->client->ps.velocity[2] += (0.0f - wp->forward[2]) * scale;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cm_transformed_capsule_trace_stub(game::trace_t* results,
|
||||
const float* start, const float* end,
|
||||
const game::Bounds* bounds,
|
||||
const game::Bounds* capsule,
|
||||
int contents, const float* origin,
|
||||
const float* angles) {
|
||||
if (dvars::pm_playerCollision->current.enabled) {
|
||||
utils::hook::invoke<void>(0x47C7D0, results, start, end, bounds, capsule,
|
||||
contents, origin, angles);
|
||||
}
|
||||
}
|
||||
|
||||
void pm_trace_stub(game::pmove_t* pm, game::trace_t* results,
|
||||
const float* start, const float* end,
|
||||
const game::Bounds* bounds, int pass_entity_num,
|
||||
int content_mask) {
|
||||
game::PM_trace(pm, results, start, end, bounds, pass_entity_num,
|
||||
content_mask);
|
||||
// Allow the player to stand even when there is no headroom
|
||||
if (dvars::pm_elevators->current.enabled) {
|
||||
results->allsolid = false;
|
||||
}
|
||||
}
|
||||
|
||||
void pm_player_trace_stub(game::pmove_t* pm, game::trace_t* results,
|
||||
const float* start, const float* end,
|
||||
const game::Bounds* bounds, int pass_entity_num,
|
||||
int content_mask) {
|
||||
game::PM_playerTrace(pm, results, start, end, bounds, pass_entity_num,
|
||||
content_mask);
|
||||
|
||||
if (dvars::pm_elevators->current.enabled) {
|
||||
results->startsolid = false;
|
||||
}
|
||||
}
|
||||
void g_scr_is_sprinting(const game::scr_entref_t entref) {
|
||||
const auto* client = game::GetEntity(entref)->client;
|
||||
if (!client) {
|
||||
game::Scr_Error("IsSprinting can only be called on a player");
|
||||
return;
|
||||
}
|
||||
|
||||
game::Scr_AddInt(game::PM_IsSprinting(&client->ps));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(game::weaponParms) == 0x48);
|
||||
static_assert(sizeof(game::lockonFireParms) == 0x18);
|
||||
|
||||
void post_load() override {
|
||||
utils::hook(0x4E9054, pm_step_slide_move_stub, HOOK_JUMP)
|
||||
.install()
|
||||
->quick(); // PM_StepSlideMove
|
||||
utils::hook(0x4E90BE, pm_project_velocity_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // PM_StepSlideMove
|
||||
|
||||
utils::hook(0x4FA809, weapon_rocket_launcher_fire_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // FireWeapon
|
||||
|
||||
utils::hook(0x4B6FC0, cm_transformed_capsule_trace_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // SV_ClipMoveToEntity
|
||||
utils::hook(0x57635F, cm_transformed_capsule_trace_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // CG_ClipMoveToEntity
|
||||
|
||||
utils::hook(0x64F439, pm_trace_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // PM_CheckDuck
|
||||
utils::hook(0x651A60, pm_player_trace_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // PM_CorrectAllSolid
|
||||
utils::hook(0x651AF2, pm_player_trace_stub, HOOK_CALL)
|
||||
.install()
|
||||
->quick(); // PM_CorrectAllSolid
|
||||
|
||||
gsc::add_method("IsSprinting", g_scr_is_sprinting);
|
||||
register_dvars();
|
||||
}
|
||||
|
||||
static void register_dvars() {
|
||||
// clang-format off
|
||||
dvars::pm_bounce = game::Dvar_RegisterBool(
|
||||
"pm_bounce", false, game::DVAR_NONE, "CoD4 Bounces");
|
||||
dvars::pm_bouncingAllAngles = game::Dvar_RegisterBool(
|
||||
"pm_bouncingAllAngles", false, game::DVAR_NONE, "Enable bouncing from all angles");
|
||||
dvars::pm_rocketJump = game::Dvar_RegisterBool(
|
||||
"pm_rocketJump", true, game::DVAR_NONE, "CoD4 rocket jumps");
|
||||
dvars::pm_rocketJumpScale = game::Dvar_RegisterFloat(
|
||||
"pm_rocketJumpScale", 64.0f, 0.0f, 1024.0f, game::DVAR_NONE, "");
|
||||
dvars::pm_playerCollision = game::Dvar_RegisterBool(
|
||||
"pm_playerCollision", true, game::DVAR_NONE, "Push intersecting players away from each other");
|
||||
dvars::pm_elevators = game::Dvar_RegisterBool(
|
||||
"pm_elevators", false, game::DVAR_NONE, "CoD4 elevators");
|
||||
// clang-format on
|
||||
}
|
||||
};
|
||||
} // namespace player_movement
|
||||
|
||||
REGISTER_COMPONENT(player_movement::component)
|
163
src/client/component/scheduler.cpp
Normal file
163
src/client/component/scheduler.cpp
Normal file
@ -0,0 +1,163 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/concurrency.hpp>
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/thread.hpp>
|
||||
|
||||
#include "scheduler.hpp"
|
||||
|
||||
namespace scheduler {
|
||||
namespace {
|
||||
struct task {
|
||||
std::function<bool()> handler{};
|
||||
std::chrono::milliseconds interval{};
|
||||
std::chrono::high_resolution_clock::time_point last_call{};
|
||||
};
|
||||
|
||||
using task_list = std::vector<task>;
|
||||
|
||||
class task_pipeline {
|
||||
public:
|
||||
void add(task&& task) {
|
||||
new_callbacks_.access([&task, this](task_list& tasks) {
|
||||
tasks.emplace_back(std::move(task));
|
||||
});
|
||||
}
|
||||
|
||||
void clear() {
|
||||
callbacks_.access([&](task_list& tasks) {
|
||||
this->merge_callbacks();
|
||||
tasks.clear();
|
||||
});
|
||||
}
|
||||
|
||||
void execute() {
|
||||
callbacks_.access([&](task_list& tasks) {
|
||||
this->merge_callbacks();
|
||||
|
||||
for (auto i = tasks.begin(); i != tasks.end();) {
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
const auto diff = now - i->last_call;
|
||||
|
||||
if (diff < i->interval) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
i->last_call = now;
|
||||
|
||||
const auto res = i->handler();
|
||||
if (res == cond_end) {
|
||||
i = tasks.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
utils::concurrency::container<task_list> new_callbacks_;
|
||||
utils::concurrency::container<task_list, std::recursive_mutex> callbacks_;
|
||||
|
||||
void merge_callbacks() {
|
||||
callbacks_.access([&](task_list& tasks) {
|
||||
new_callbacks_.access([&](task_list& new_tasks) {
|
||||
tasks.insert(tasks.end(),
|
||||
std::move_iterator<task_list::iterator>(new_tasks.begin()),
|
||||
std::move_iterator<task_list::iterator>(new_tasks.end()));
|
||||
new_tasks = {};
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
volatile bool kill = false;
|
||||
std::thread thread;
|
||||
task_pipeline pipelines[pipeline::count];
|
||||
|
||||
void execute(const pipeline type) {
|
||||
assert(type >= 0 && type < pipeline::count);
|
||||
pipelines[type].execute();
|
||||
}
|
||||
|
||||
void g_glass_update_stub() {
|
||||
utils::hook::invoke<void>(0x43D7E0);
|
||||
execute(pipeline::server);
|
||||
}
|
||||
|
||||
void r_end_frame_stub() {
|
||||
utils::hook::invoke<void>(0x50F540);
|
||||
execute(pipeline::renderer);
|
||||
}
|
||||
|
||||
void main_frame_stub() {
|
||||
utils::hook::invoke<void>(0x4D3FC0);
|
||||
execute(pipeline::main);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void clear_tasks(const pipeline type) { return pipelines[type].clear(); }
|
||||
|
||||
void schedule(const std::function<bool()>& callback, const pipeline type,
|
||||
const std::chrono::milliseconds delay) {
|
||||
assert(type >= 0 && type < pipeline::count);
|
||||
|
||||
task task;
|
||||
task.handler = callback;
|
||||
task.interval = delay;
|
||||
task.last_call = std::chrono::high_resolution_clock::now();
|
||||
|
||||
pipelines[type].add(std::move(task));
|
||||
}
|
||||
|
||||
void loop(const std::function<void()>& callback, const pipeline type,
|
||||
const std::chrono::milliseconds delay) {
|
||||
schedule(
|
||||
[callback]() {
|
||||
callback();
|
||||
return cond_continue;
|
||||
},
|
||||
type, delay);
|
||||
}
|
||||
|
||||
void once(const std::function<void()>& callback, const pipeline type,
|
||||
const std::chrono::milliseconds delay) {
|
||||
schedule(
|
||||
[callback]() {
|
||||
callback();
|
||||
return cond_end;
|
||||
},
|
||||
type, delay);
|
||||
}
|
||||
|
||||
unsigned int thread_id;
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_start() override {
|
||||
thread = utils::thread::create_named_thread("Async Scheduler", [] {
|
||||
while (!kill) {
|
||||
execute(pipeline::async);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void post_load() override {
|
||||
utils::hook(0x4EDBDD, g_glass_update_stub, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x49C3AF, main_frame_stub, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x57DB13, r_end_frame_stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
|
||||
void pre_destroy() override {
|
||||
kill = true;
|
||||
if (thread.joinable()) {
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace scheduler
|
||||
|
||||
REGISTER_COMPONENT(scheduler::component)
|
33
src/client/component/scheduler.hpp
Normal file
33
src/client/component/scheduler.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace scheduler {
|
||||
enum pipeline {
|
||||
// Asynchronuous pipeline, disconnected from the game
|
||||
async = 0,
|
||||
|
||||
// The game's rendering pipeline
|
||||
renderer,
|
||||
|
||||
// The game's server thread
|
||||
server,
|
||||
|
||||
// The game's main thread
|
||||
main,
|
||||
|
||||
count,
|
||||
};
|
||||
|
||||
static constexpr auto cond_continue = false;
|
||||
static constexpr auto cond_end = true;
|
||||
|
||||
void clear_tasks(pipeline type);
|
||||
|
||||
void schedule(const std::function<bool()>& callback, pipeline type,
|
||||
std::chrono::milliseconds delay = 0ms);
|
||||
void loop(const std::function<void()>& callback, pipeline type,
|
||||
std::chrono::milliseconds delay = 0ms);
|
||||
void once(const std::function<void()>& callback, pipeline type,
|
||||
std::chrono::milliseconds delay = 0ms);
|
||||
} // namespace scheduler
|
47
src/client/component/steam_patches.cpp
Normal file
47
src/client/component/steam_patches.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace steam_patches {
|
||||
namespace {
|
||||
void __declspec(naked) steam_init() {
|
||||
const static DWORD Steam_IsClientSignedInLocally_t = 0x4293F0;
|
||||
|
||||
__asm {
|
||||
call Steam_IsClientSignedInLocally_t;
|
||||
test al, al;
|
||||
jz return_safe;
|
||||
|
||||
push 0x43FAF9;
|
||||
ret;
|
||||
|
||||
return_safe:
|
||||
mov al, 1;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
patch_sp();
|
||||
utils::hook(0x43FAF0, steam_init, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
|
||||
static void patch_sp() {
|
||||
// Prevent stat loading from steam
|
||||
utils::hook::set<std::uint8_t>(0x43FB33, 0xC3);
|
||||
|
||||
// Steam must be running
|
||||
utils::hook::nop(0x6040A3, 30);
|
||||
|
||||
// No-Steam
|
||||
utils::hook::nop(0x4E9458, 7);
|
||||
utils::hook::nop(0x4E9470, 7);
|
||||
}
|
||||
};
|
||||
} // namespace steam_patches
|
||||
|
||||
REGISTER_COMPONENT(steam_patches::component)
|
197
src/client/component/steam_proxy.cpp
Normal file
197
src/client/component/steam_proxy.cpp
Normal file
@ -0,0 +1,197 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/binary_resource.hpp>
|
||||
#include <utils/flags.hpp>
|
||||
#include <utils/nt.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <resource.hpp>
|
||||
|
||||
#include "steam/steam.hpp"
|
||||
#include "steam/interface.hpp"
|
||||
|
||||
#include "scheduler.hpp"
|
||||
|
||||
namespace {
|
||||
enum class ownership_state {
|
||||
success,
|
||||
unowned,
|
||||
nosteam,
|
||||
error,
|
||||
};
|
||||
|
||||
utils::binary_resource runner_file(RUNNER, "iw4sp-runner.exe");
|
||||
|
||||
bool is_disabled() {
|
||||
static const auto disabled = utils::flags::has_flag("nosteam");
|
||||
return disabled;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class steam_proxy final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
if (is_disabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->load_client();
|
||||
this->clean_up_on_error();
|
||||
|
||||
try {
|
||||
this->start_mod("iw4-sp Singleplayer", 10180);
|
||||
} catch (const std::exception& ex) {
|
||||
printf("Steam: %s\n", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
void pre_destroy() override {
|
||||
if (this->steam_client_module_) {
|
||||
if (this->steam_pipe_) {
|
||||
if (this->global_user_) {
|
||||
this->steam_client_module_.invoke<void>(
|
||||
"Steam_ReleaseUser", this->steam_pipe_, this->global_user_);
|
||||
}
|
||||
|
||||
this->steam_client_module_.invoke<bool>("Steam_BReleaseSteamPipe",
|
||||
this->steam_pipe_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
utils::nt::library steam_client_module_{};
|
||||
|
||||
steam::interface client_engine_ {};
|
||||
steam::interface client_user_ {};
|
||||
steam::interface client_utils_ {};
|
||||
|
||||
void* steam_pipe_ = nullptr;
|
||||
void* global_user_ = nullptr;
|
||||
|
||||
[[nodiscard]] void* load_client_engine() const {
|
||||
if (!this->steam_client_module_)
|
||||
return nullptr;
|
||||
|
||||
for (auto i = 1; i < 1000; ++i) {
|
||||
const auto* name =
|
||||
utils::string::va("CLIENTENGINE_INTERFACE_VERSION{0:03}", i);
|
||||
|
||||
auto* const client_engine = this->steam_client_module_.invoke<void*>(
|
||||
"CreateInterface", name, nullptr);
|
||||
if (client_engine)
|
||||
return client_engine;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void load_client() {
|
||||
const auto steam_path = steam::get_steam_install_directory();
|
||||
if (steam_path.empty())
|
||||
return;
|
||||
|
||||
utils::nt::library::load(steam_path / "tier0_s.dll");
|
||||
utils::nt::library::load(steam_path / "vstdlib_s.dll");
|
||||
this->steam_client_module_ =
|
||||
utils::nt::library::load(steam_path / "steamclient.dll");
|
||||
if (!this->steam_client_module_)
|
||||
return;
|
||||
|
||||
this->client_engine_ = load_client_engine();
|
||||
if (!this->client_engine_)
|
||||
return;
|
||||
|
||||
this->steam_pipe_ =
|
||||
this->steam_client_module_.invoke<void*>("Steam_CreateSteamPipe");
|
||||
this->global_user_ = this->steam_client_module_.invoke<void*>(
|
||||
"Steam_ConnectToGlobalUser", this->steam_pipe_);
|
||||
this->client_user_ = this->client_engine_.invoke<void*>(
|
||||
8, this->steam_pipe_, this->global_user_); // GetIClientUser
|
||||
this->client_utils_ = this->client_engine_.invoke<void*>(
|
||||
14, this->steam_pipe_); // GetIClientUtils
|
||||
}
|
||||
|
||||
ownership_state start_mod(const std::string& title,
|
||||
const std::size_t app_id) {
|
||||
__try {
|
||||
return this->start_mod_unsafe(title, app_id);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
this->do_cleanup();
|
||||
return ownership_state::error;
|
||||
}
|
||||
}
|
||||
|
||||
ownership_state start_mod_unsafe(const std::string& title,
|
||||
std::size_t app_id) {
|
||||
if (!this->client_utils_ || !this->client_user_)
|
||||
return ownership_state::nosteam;
|
||||
|
||||
if (!this->client_user_.invoke<bool>("BIsSubscribedApp", app_id)) {
|
||||
#ifdef _DEBUG
|
||||
app_id = 480; // Spacewar
|
||||
#else
|
||||
return ownership_state::unowned;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (is_disabled()) {
|
||||
return ownership_state::success;
|
||||
}
|
||||
|
||||
this->client_utils_.invoke<void>("SetAppIDForCurrentPipe", app_id, false);
|
||||
|
||||
char our_directory[MAX_PATH] = {0};
|
||||
GetCurrentDirectoryA(sizeof(our_directory), our_directory);
|
||||
|
||||
const auto path = runner_file.get_extracted_file();
|
||||
const auto* cmd_line =
|
||||
utils::string::va("\"{0}\" -proc {1}", path, GetCurrentProcessId());
|
||||
|
||||
game_id game_id;
|
||||
game_id.raw.type = 1; // k_EGameIDTypeGameMod
|
||||
game_id.raw.app_id = app_id & 0xFFFFFF;
|
||||
|
||||
const auto* mod_id = "IW4";
|
||||
game_id.raw.mod_id =
|
||||
*reinterpret_cast<const unsigned int*>(mod_id) | 0x80000000;
|
||||
|
||||
this->client_user_.invoke<bool>("SpawnProcess", path.data(), cmd_line,
|
||||
our_directory, game_id.bits, title.data(),
|
||||
app_id, 0, 0, 0);
|
||||
|
||||
return ownership_state::success;
|
||||
}
|
||||
|
||||
void do_cleanup() {
|
||||
this->client_engine_ = nullptr;
|
||||
this->client_user_ = nullptr;
|
||||
this->client_utils_ = nullptr;
|
||||
|
||||
this->steam_pipe_ = nullptr;
|
||||
this->global_user_ = nullptr;
|
||||
|
||||
this->steam_client_module_ = utils::nt::library{nullptr};
|
||||
}
|
||||
|
||||
void clean_up_on_error() {
|
||||
scheduler::schedule(
|
||||
[this] {
|
||||
if (this->steam_client_module_ && this->steam_pipe_ &&
|
||||
this->global_user_ &&
|
||||
this->steam_client_module_.invoke<bool>(
|
||||
"Steam_BConnected", this->global_user_, this->steam_pipe_) &&
|
||||
this->steam_client_module_.invoke<bool>(
|
||||
"Steam_BLoggedOn", this->global_user_, this->steam_pipe_)) {
|
||||
return scheduler::cond_continue;
|
||||
}
|
||||
|
||||
this->do_cleanup();
|
||||
return scheduler::cond_end;
|
||||
},
|
||||
scheduler::pipeline::async);
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_COMPONENT(steam_proxy)
|
74
src/client/component/ultra_wide.cpp
Normal file
74
src/client/component/ultra_wide.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace ultra_wide {
|
||||
const game::dvar_t* r_customAspectRatio;
|
||||
|
||||
const game::dvar_t* dvar_register_aspect_ratio(const char* dvar_name,
|
||||
const char** /*value_list*/,
|
||||
int default_index,
|
||||
unsigned __int16 flags,
|
||||
const char* description) {
|
||||
static const char* values[] = {"auto", "standard", "wide 16:10",
|
||||
"wide 16:9", "custom", nullptr};
|
||||
|
||||
// register enumeration dvar
|
||||
return game::Dvar_RegisterEnum(dvar_name, values, default_index, flags,
|
||||
description);
|
||||
}
|
||||
|
||||
void set_aspect_ratio() {
|
||||
*reinterpret_cast<float*>(0x1C91A78) = r_customAspectRatio->current.value;
|
||||
}
|
||||
|
||||
__declspec(naked) void set_aspect_ratio_stub() {
|
||||
__asm {
|
||||
mov eax, [eax + 0x10];
|
||||
cmp eax, 4;
|
||||
|
||||
mov dword ptr ds:0x1C91A68, edx;
|
||||
mov dword ptr ds:0x1C91A6C, esi;
|
||||
mov dword ptr ds:0x1C91A74, ecx;
|
||||
|
||||
ja default_case;
|
||||
je custom_ratio;
|
||||
|
||||
push 0x50AE6C;
|
||||
ret;
|
||||
|
||||
default_case:
|
||||
push 0x50AF6C;
|
||||
ret;
|
||||
|
||||
custom_ratio:
|
||||
pushad;
|
||||
call set_aspect_ratio;
|
||||
popad;
|
||||
|
||||
mov eax, 1; // set widescreen to 1
|
||||
|
||||
push 0x50AF05;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override {
|
||||
utils::hook(0x51E80B, &dvar_register_aspect_ratio, HOOK_CALL)
|
||||
.install()
|
||||
->quick();
|
||||
|
||||
utils::hook(0x50AE4E, &set_aspect_ratio_stub, HOOK_JUMP).install()->quick();
|
||||
utils::hook::nop(0x50AE4E + 5, 1);
|
||||
|
||||
r_customAspectRatio = game::Dvar_RegisterFloat(
|
||||
"r_customAspectRatio", 16.0f / 9.0f, 4.0f / 3.0f, 63.0f / 9.0f,
|
||||
game::DVAR_ARCHIVE, "Screen aspect ratio");
|
||||
}
|
||||
};
|
||||
} // namespace ultra_wide
|
||||
|
||||
REGISTER_COMPONENT(ultra_wide::component)
|
48
src/client/component/weapons.cpp
Normal file
48
src/client/component/weapons.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace weapons {
|
||||
namespace {
|
||||
game::WeaponCompleteDef*
|
||||
bg_load_weapon_variant_def_fast_file_stub(const char* name) {
|
||||
if (auto* raw_weapon_file =
|
||||
game::BG_LoadWeaponVariantDefInternal("sp", name)) {
|
||||
return raw_weapon_file;
|
||||
}
|
||||
|
||||
auto* zone_weapon_file =
|
||||
game::DB_FindXAssetHeader(game::ASSET_TYPE_WEAPON, name).weapon;
|
||||
return game::DB_IsXAssetDefault(game::ASSET_TYPE_WEAPON, name)
|
||||
? nullptr
|
||||
: zone_weapon_file;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_load() override { patch_sp(); }
|
||||
|
||||
private:
|
||||
static void patch_sp() {
|
||||
// Weapon asset existence check
|
||||
utils::hook::nop(0x43E1D8, 5);
|
||||
// Is asset default
|
||||
utils::hook::nop(0x43E1E0, 5);
|
||||
// Do not jump
|
||||
utils::hook::nop(0x43E1EA, 2);
|
||||
|
||||
// Ignore missing default weapon
|
||||
utils::hook::set<std::uint8_t>(0x659DBE, 0xEB);
|
||||
|
||||
utils::hook(0x659E00, bg_load_weapon_variant_def_fast_file_stub, HOOK_JUMP)
|
||||
.install()
|
||||
->quick();
|
||||
// Disable warning if raw weapon file cannot be found
|
||||
utils::hook::nop(0x659730, 5);
|
||||
}
|
||||
};
|
||||
} // namespace weapons
|
||||
|
||||
REGISTER_COMPONENT(weapons::component)
|
25
src/client/component/zone.cpp
Normal file
25
src/client/component/zone.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace zone {
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
static_assert(sizeof(game::XZoneInfo) == 0xC);
|
||||
|
||||
void post_load() override { patch_sp(); }
|
||||
|
||||
private:
|
||||
static void patch_sp() {
|
||||
// Ignore zone version mismatch
|
||||
utils::hook::set<std::uint8_t>(0x4256D8, 0xEB);
|
||||
|
||||
// Disc read error
|
||||
utils::hook::nop(0x4B7335, 2);
|
||||
utils::hook::set<std::uint8_t>(0x4256B9, 0xEB);
|
||||
}
|
||||
};
|
||||
} // namespace zone
|
||||
|
||||
REGISTER_COMPONENT(zone::component)
|
30
src/client/game/dvars.cpp
Normal file
30
src/client/game/dvars.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
namespace dvars {
|
||||
const game::dvar_t* r_noBorder = nullptr;
|
||||
|
||||
const game::dvar_t* pm_bounce = nullptr;
|
||||
const game::dvar_t* pm_bouncingAllAngles = nullptr;
|
||||
const game::dvar_t* pm_rocketJump = nullptr;
|
||||
const game::dvar_t* pm_rocketJumpScale = nullptr;
|
||||
const game::dvar_t* pm_playerCollision = nullptr;
|
||||
const game::dvar_t* pm_elevators = nullptr;
|
||||
|
||||
const game::dvar_t* cg_drawVersion = nullptr;
|
||||
const game::dvar_t* cg_drawVersionX = nullptr;
|
||||
const game::dvar_t* cg_drawVersionY = nullptr;
|
||||
|
||||
const game::dvar_t* bug_name = nullptr;
|
||||
|
||||
const game::dvar_t* g_log = nullptr;
|
||||
|
||||
// Game dvars
|
||||
const game::dvar_t** g_specialops =
|
||||
reinterpret_cast<const game::dvar_t**>(0x1B2E1E8);
|
||||
|
||||
const game::dvar_t** sv_mapname =
|
||||
reinterpret_cast<const game::dvar_t**>(0x1B2E1E4);
|
||||
|
||||
const game::dvar_t** version =
|
||||
reinterpret_cast<const game::dvar_t**>(0x145D690);
|
||||
} // namespace dvars
|
27
src/client/game/dvars.hpp
Normal file
27
src/client/game/dvars.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
namespace dvars {
|
||||
extern const game::dvar_t* r_noBorder;
|
||||
|
||||
extern const game::dvar_t* pm_bounce;
|
||||
extern const game::dvar_t* pm_bouncingAllAngles;
|
||||
extern const game::dvar_t* pm_rocketJump;
|
||||
extern const game::dvar_t* pm_rocketJumpScale;
|
||||
extern const game::dvar_t* pm_playerCollision;
|
||||
extern const game::dvar_t* pm_elevators;
|
||||
|
||||
extern const game::dvar_t* cg_drawVersion;
|
||||
extern const game::dvar_t* cg_drawVersionX;
|
||||
extern const game::dvar_t* cg_drawVersionY;
|
||||
|
||||
extern const game::dvar_t* bug_name;
|
||||
|
||||
extern const game::dvar_t* g_log;
|
||||
|
||||
// Game dvars
|
||||
extern const game::dvar_t** g_specialops;
|
||||
|
||||
extern const game::dvar_t** sv_mapname;
|
||||
|
||||
extern const game::dvar_t** version;
|
||||
} // namespace dvars
|
34
src/client/game/engine/fast_critical_section.cpp
Normal file
34
src/client/game/engine/fast_critical_section.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <std_include.hpp>
|
||||
#include <game/game.hpp>
|
||||
|
||||
#include "fast_critical_section.hpp"
|
||||
|
||||
namespace game::engine {
|
||||
fast_critical_section_scope_read::fast_critical_section_scope_read(
|
||||
FastCriticalSection* cs)
|
||||
: cs_(cs) {
|
||||
if (this->cs_) {
|
||||
Sys_LockRead(this->cs_);
|
||||
}
|
||||
}
|
||||
|
||||
fast_critical_section_scope_read::~fast_critical_section_scope_read() {
|
||||
if (this->cs_) {
|
||||
Sys_UnlockRead(this->cs_);
|
||||
}
|
||||
}
|
||||
|
||||
fast_critical_section_scope_write::fast_critical_section_scope_write(
|
||||
FastCriticalSection* cs)
|
||||
: cs_(cs) {
|
||||
if (this->cs_) {
|
||||
Sys_LockWrite(this->cs_);
|
||||
}
|
||||
}
|
||||
|
||||
fast_critical_section_scope_write::~fast_critical_section_scope_write() {
|
||||
if (this->cs_) {
|
||||
Sys_UnlockWrite(this->cs_);
|
||||
}
|
||||
}
|
||||
} // namespace game::engine
|
21
src/client/game/engine/fast_critical_section.hpp
Normal file
21
src/client/game/engine/fast_critical_section.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace game::engine {
|
||||
class fast_critical_section_scope_read {
|
||||
public:
|
||||
fast_critical_section_scope_read(FastCriticalSection* cs);
|
||||
~fast_critical_section_scope_read();
|
||||
|
||||
private:
|
||||
FastCriticalSection* cs_;
|
||||
};
|
||||
|
||||
class fast_critical_section_scope_write {
|
||||
public:
|
||||
fast_critical_section_scope_write(FastCriticalSection* cs);
|
||||
~fast_critical_section_scope_write();
|
||||
|
||||
private:
|
||||
FastCriticalSection* cs_;
|
||||
};
|
||||
} // namespace game::engine
|
87
src/client/game/engine/large_local.cpp
Normal file
87
src/client/game/engine/large_local.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include "large_local.hpp"
|
||||
|
||||
namespace game::engine {
|
||||
namespace {
|
||||
constexpr auto PAGE_SIZE = 4096;
|
||||
|
||||
int can_use_server_large_local() { return Sys_IsServerThread(); }
|
||||
|
||||
void large_local_end(int start_pos) {
|
||||
assert(Sys_IsMainThread());
|
||||
assert(g_largeLocalBuf);
|
||||
|
||||
*g_largeLocalPos = start_pos;
|
||||
|
||||
assert(((*g_maxLargeLocalPos + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1)) <=
|
||||
(*g_minLargeLocalRightPos & ~(PAGE_SIZE - 1)));
|
||||
}
|
||||
|
||||
void large_local_end_right(int start_pos) {
|
||||
assert(can_use_server_large_local());
|
||||
assert(g_largeLocalBuf);
|
||||
|
||||
*g_largeLocalRightPos = start_pos;
|
||||
|
||||
assert(((*g_maxLargeLocalPos + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1)) <=
|
||||
(*g_minLargeLocalRightPos & ~(PAGE_SIZE - 1)));
|
||||
}
|
||||
|
||||
void* large_local_get_buf(int start_pos, int size) {
|
||||
assert(Sys_IsMainThread() || can_use_server_large_local());
|
||||
assert(g_largeLocalBuf);
|
||||
assert(!(size & 127));
|
||||
|
||||
if (Sys_IsMainThread()) {
|
||||
return &g_largeLocalBuf[start_pos];
|
||||
}
|
||||
|
||||
const auto start_index = start_pos - size;
|
||||
assert(start_index >= 0);
|
||||
|
||||
return &g_largeLocalBuf[start_index];
|
||||
}
|
||||
} // namespace
|
||||
|
||||
large_local::large_local(int size_param) {
|
||||
assert(size_param);
|
||||
assert(Sys_IsMainThread() || can_use_server_large_local());
|
||||
|
||||
size_param = ((size_param + (128 - 1)) & ~(128 - 1));
|
||||
|
||||
if (Sys_IsMainThread()) {
|
||||
this->start_pos_ = LargeLocalBegin(size_param);
|
||||
} else {
|
||||
this->start_pos_ = LargeLocalBeginRight(size_param);
|
||||
}
|
||||
|
||||
this->size_ = size_param;
|
||||
}
|
||||
|
||||
large_local::~large_local() {
|
||||
if (this->size_) {
|
||||
this->pop_buf();
|
||||
}
|
||||
}
|
||||
|
||||
void large_local::pop_buf() {
|
||||
assert(this->size_);
|
||||
assert(Sys_IsMainThread() || can_use_server_large_local());
|
||||
|
||||
if (Sys_IsMainThread()) {
|
||||
large_local_end(this->start_pos_);
|
||||
} else {
|
||||
large_local_end_right(this->start_pos_);
|
||||
}
|
||||
|
||||
this->size_ = 0;
|
||||
}
|
||||
|
||||
void* large_local::get_buf() const {
|
||||
assert(this->size_);
|
||||
assert(Sys_IsMainThread() || can_use_server_large_local());
|
||||
|
||||
return large_local_get_buf(this->start_pos_, this->size_);
|
||||
}
|
||||
} // namespace game::engine
|
22
src/client/game/engine/large_local.hpp
Normal file
22
src/client/game/engine/large_local.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
namespace game::engine {
|
||||
class large_local {
|
||||
public:
|
||||
explicit large_local(int size_param);
|
||||
~large_local();
|
||||
|
||||
large_local(large_local&&) = delete;
|
||||
large_local(const large_local&) = delete;
|
||||
large_local& operator=(large_local&&) = delete;
|
||||
large_local& operator=(const large_local&) = delete;
|
||||
|
||||
[[nodiscard]] void* get_buf() const;
|
||||
|
||||
private:
|
||||
void pop_buf();
|
||||
|
||||
int start_pos_;
|
||||
int size_;
|
||||
};
|
||||
} // namespace game::engine
|
63
src/client/game/engine/scoped_critical_section.cpp
Normal file
63
src/client/game/engine/scoped_critical_section.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include "scoped_critical_section.hpp"
|
||||
|
||||
namespace game::engine {
|
||||
scoped_critical_section::scoped_critical_section(
|
||||
const CriticalSection s, const ScopedCriticalSectionType type)
|
||||
: s_(s), is_scoped_release_(false) {
|
||||
if (type == SCOPED_CRITSECT_NORMAL) {
|
||||
Sys_EnterCriticalSection(this->s_);
|
||||
this->has_ownership_ = true;
|
||||
} else {
|
||||
if (type == SCOPED_CRITSECT_TRY) {
|
||||
this->has_ownership_ = Sys_TryEnterCriticalSection(this->s_);
|
||||
} else {
|
||||
if (type == SCOPED_CRITSECT_RELEASE) {
|
||||
Sys_LeaveCriticalSection(this->s_);
|
||||
this->is_scoped_release_ = true;
|
||||
}
|
||||
this->has_ownership_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scoped_critical_section::~scoped_critical_section() {
|
||||
if (!this->has_ownership_ || this->is_scoped_release_) {
|
||||
if (!this->has_ownership_ && this->is_scoped_release_)
|
||||
Sys_EnterCriticalSection(this->s_);
|
||||
} else {
|
||||
Sys_LeaveCriticalSection(this->s_);
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_critical_section::enter_crit_sect() {
|
||||
assert(!this->has_ownership_);
|
||||
|
||||
this->has_ownership_ = true;
|
||||
Sys_EnterCriticalSection(this->s_);
|
||||
}
|
||||
|
||||
void scoped_critical_section::leave_crit_sect() {
|
||||
assert(this->has_ownership_);
|
||||
|
||||
this->has_ownership_ = false;
|
||||
Sys_LeaveCriticalSection(this->s_);
|
||||
}
|
||||
|
||||
bool scoped_critical_section::try_enter_crit_sect() {
|
||||
assert(!this->has_ownership_);
|
||||
|
||||
const auto result = Sys_TryEnterCriticalSection(this->s_);
|
||||
this->has_ownership_ = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool scoped_critical_section::has_ownership() const {
|
||||
return this->has_ownership_;
|
||||
}
|
||||
|
||||
bool scoped_critical_section::is_scoped_release() const {
|
||||
return this->is_scoped_release_;
|
||||
}
|
||||
} // namespace game::engine
|
21
src/client/game/engine/scoped_critical_section.hpp
Normal file
21
src/client/game/engine/scoped_critical_section.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace game::engine {
|
||||
class scoped_critical_section {
|
||||
public:
|
||||
scoped_critical_section(CriticalSection s, ScopedCriticalSectionType type);
|
||||
~scoped_critical_section();
|
||||
|
||||
void enter_crit_sect();
|
||||
void leave_crit_sect();
|
||||
bool try_enter_crit_sect();
|
||||
|
||||
[[nodiscard]] bool has_ownership() const;
|
||||
[[nodiscard]] bool is_scoped_release() const;
|
||||
|
||||
private:
|
||||
CriticalSection s_;
|
||||
bool has_ownership_;
|
||||
bool is_scoped_release_;
|
||||
};
|
||||
} // namespace game::engine
|
119
src/client/game/game.cpp
Normal file
119
src/client/game/game.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
namespace game {
|
||||
int FS_FOpenFileReadForThread(const char* filename, int* file,
|
||||
FsThread thread) {
|
||||
const static DWORD FS_FOpenFileReadForThread_t = 0x630380;
|
||||
int result{};
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov eax, file;
|
||||
push thread;
|
||||
push filename;
|
||||
call FS_FOpenFileReadForThread_t;
|
||||
add esp, 0x8;
|
||||
mov result, eax;
|
||||
|
||||
popad;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void IN_KeyDown(kbutton_t* b) {
|
||||
const static DWORD IN_KeyDown_t = 0x57A350;
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov esi, b;
|
||||
call IN_KeyDown_t;
|
||||
|
||||
popad;
|
||||
}
|
||||
}
|
||||
|
||||
void IN_KeyUp(kbutton_t* b) {
|
||||
const static DWORD IN_KeyUp_t = 0x57A3F0;
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov esi, b;
|
||||
call IN_KeyUp_t;
|
||||
|
||||
popad;
|
||||
}
|
||||
}
|
||||
|
||||
bool ScrPlace_IsFullScreenActive() {
|
||||
return *activeScreenPlacementMode == SCRMODE_FULL;
|
||||
}
|
||||
|
||||
ScreenPlacement* ScrPlace_GetUnsafeFullPlacement() {
|
||||
return scrPlaceFullUnsafe;
|
||||
}
|
||||
|
||||
bool Sys_TryEnterCriticalSection(CriticalSection critSect) {
|
||||
assert(static_cast<std::uint32_t>(critSect) <
|
||||
static_cast<std::uint32_t>(CRITSECT_COUNT));
|
||||
|
||||
return TryEnterCriticalSection(&s_criticalSection[critSect]) != FALSE;
|
||||
}
|
||||
|
||||
void Sys_LockRead(FastCriticalSection* critSect) {
|
||||
InterlockedIncrement(&critSect->readCount);
|
||||
while (critSect->writeCount) {
|
||||
Sys_Sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Sys_UnlockRead(FastCriticalSection* critSect) {
|
||||
assert(critSect->readCount > 0);
|
||||
InterlockedDecrement(&critSect->readCount);
|
||||
}
|
||||
|
||||
void Sys_UnlockWrite(FastCriticalSection* critSect) {
|
||||
assert(critSect->writeCount > 0);
|
||||
InterlockedDecrement(&critSect->writeCount);
|
||||
Sys_TempPriorityEnd(&critSect->tempPriority);
|
||||
}
|
||||
|
||||
int PC_Int_Parse(int handle, int* i) {
|
||||
const static DWORD PC_Int_Parse_t = 0x62DF10;
|
||||
int result{};
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov eax, handle;
|
||||
mov esi, i;
|
||||
call PC_Int_Parse_t;
|
||||
mov result, eax;
|
||||
|
||||
popad;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int PC_Float_Parse(int handle, float* f) {
|
||||
const static DWORD PC_Float_Parse_t = 0x62DE40;
|
||||
int result{};
|
||||
|
||||
__asm {
|
||||
pushad;
|
||||
|
||||
mov eax, handle;
|
||||
mov esi, f;
|
||||
call PC_Float_Parse_t;
|
||||
mov result, eax;
|
||||
|
||||
popad;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace game
|
54
src/client/game/game.hpp
Normal file
54
src/client/game/game.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
namespace game {
|
||||
template <typename T> struct base_symbol {
|
||||
base_symbol(const std::size_t address) : address_(address) {}
|
||||
|
||||
[[nodiscard]] T* get() const { return reinterpret_cast<T*>(this->address_); }
|
||||
|
||||
operator T*() const { return this->get(); }
|
||||
|
||||
T* operator->() const { return this->get(); }
|
||||
|
||||
private:
|
||||
std::size_t address_{};
|
||||
};
|
||||
|
||||
template <typename T> struct symbol : base_symbol<T> {
|
||||
using base_symbol<T>::base_symbol;
|
||||
};
|
||||
|
||||
template <typename T, typename... Args>
|
||||
struct symbol<T(Args...)> : base_symbol<T(Args...)> {
|
||||
using func_type = T(Args...);
|
||||
using base_symbol<func_type>::base_symbol;
|
||||
};
|
||||
|
||||
// Functions that require asm stubs to be called
|
||||
// or have been inlined
|
||||
|
||||
int FS_FOpenFileReadForThread(const char* filename, int* file, FsThread thread);
|
||||
|
||||
void IN_KeyDown(kbutton_t* b);
|
||||
void IN_KeyUp(kbutton_t* b);
|
||||
|
||||
bool ScrPlace_IsFullScreenActive();
|
||||
ScreenPlacement* ScrPlace_GetUnsafeFullPlacement();
|
||||
|
||||
bool Sys_TryEnterCriticalSection(CriticalSection critSect);
|
||||
void Sys_LockRead(FastCriticalSection* critSect);
|
||||
void Sys_UnlockRead(FastCriticalSection* critSect);
|
||||
void Sys_UnlockWrite(FastCriticalSection* critSect);
|
||||
|
||||
int PC_Int_Parse(int handle, int* i);
|
||||
int PC_Float_Parse(int handle, float* f);
|
||||
|
||||
// Global definitions
|
||||
constexpr auto CMD_MAX_NESTING = 8;
|
||||
|
||||
constexpr std::size_t MAX_LOCAL_CLIENTS = 1;
|
||||
|
||||
constexpr auto MAX_QPATH = 64;
|
||||
} // namespace game
|
||||
|
||||
#include "symbols.hpp"
|
926
src/client/game/structs.hpp
Normal file
926
src/client/game/structs.hpp
Normal file
@ -0,0 +1,926 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4324)
|
||||
|
||||
namespace game {
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
struct scr_entref_t {
|
||||
unsigned __int16 entnum;
|
||||
unsigned __int16 classnum;
|
||||
};
|
||||
|
||||
typedef void(__cdecl* BuiltinMethod)(scr_entref_t);
|
||||
|
||||
typedef void(__cdecl* BuiltinFunction)();
|
||||
|
||||
struct BuiltinMethodDef {
|
||||
const char* actionString;
|
||||
void(__cdecl* actionFunc)(scr_entref_t);
|
||||
int type;
|
||||
};
|
||||
|
||||
struct BuiltinFunctionDef {
|
||||
const char* actionString;
|
||||
void(__cdecl* actionFunc)();
|
||||
int type;
|
||||
};
|
||||
|
||||
enum {
|
||||
VAR_STRING = 0x2,
|
||||
VAR_FLOAT = 0x5,
|
||||
VAR_INTEGER = 0x6,
|
||||
};
|
||||
|
||||
enum {
|
||||
CON_CHANNEL_DONT_FILTER = 0x0,
|
||||
CON_CHANNEL_ERROR = 0x1,
|
||||
CON_CHANNEL_GAMENOTIFY = 0x2,
|
||||
CON_CHANNEL_BOLDGAME = 0x3,
|
||||
CON_CHANNEL_SUBTITLE = 0x4,
|
||||
CON_CHANNEL_OBITUARY = 0x5,
|
||||
CON_CHANNEL_LOGFILEONLY = 0x6,
|
||||
CON_CHANNEL_CONSOLEONLY = 0x7,
|
||||
CON_CHANNEL_GFX = 0x8,
|
||||
CON_CHANNEL_SOUND = 0x9,
|
||||
CON_CHANNEL_FILES = 0xA,
|
||||
CON_CHANNEL_DEVGUI = 0xB,
|
||||
CON_CHANNEL_PROFILE = 0xC,
|
||||
CON_CHANNEL_UI = 0xD,
|
||||
CON_CHANNEL_CLIENT = 0xE,
|
||||
CON_CHANNEL_SERVER = 0xF,
|
||||
CON_CHANNEL_SYSTEM = 0x10,
|
||||
CON_CHANNEL_PLAYERWEAP = 0x11,
|
||||
CON_CHANNEL_AI = 0x12,
|
||||
CON_CHANNEL_ANIM = 0x13,
|
||||
CON_CHANNEL_PHYS = 0x14,
|
||||
CON_CHANNEL_FX = 0x15,
|
||||
CON_CHANNEL_LEADERBOARDS = 0x16,
|
||||
CON_CHANNEL_PARSERSCRIPT = 0x17,
|
||||
CON_CHANNEL_SCRIPT = 0x18,
|
||||
CON_CHANNEL_NETWORK = 0x19,
|
||||
|
||||
CON_BUILTIN_CHANNEL_COUNT = 0x1A,
|
||||
};
|
||||
|
||||
enum XAssetType {
|
||||
ASSET_TYPE_PHYSPRESET = 0,
|
||||
ASSET_TYPE_PHYSCOLLMAP = 1,
|
||||
ASSET_TYPE_XANIMPARTS = 2,
|
||||
ASSET_TYPE_XMODEL_SURFS = 3,
|
||||
ASSET_TYPE_XMODEL = 4,
|
||||
ASSET_TYPE_MATERIAL = 5,
|
||||
ASSET_TYPE_PIXELSHADER = 6,
|
||||
ASSET_TYPE_VERTEXSHADER = 7,
|
||||
ASSET_TYPE_VERTEXDECL = 8,
|
||||
ASSET_TYPE_TECHNIQUE_SET = 9,
|
||||
ASSET_TYPE_IMAGE = 10,
|
||||
ASSET_TYPE_SOUND = 11,
|
||||
ASSET_TYPE_SOUND_CURVE = 12,
|
||||
ASSET_TYPE_LOADED_SOUND = 13,
|
||||
ASSET_TYPE_CLIPMAP_SP = 14,
|
||||
ASSET_TYPE_CLIPMAP_MP = 15,
|
||||
ASSET_TYPE_COMWORLD = 16,
|
||||
ASSET_TYPE_GAMEWORLD_SP = 17,
|
||||
ASSET_TYPE_GAMEWORLD_MP = 18,
|
||||
ASSET_TYPE_MAP_ENTS = 19,
|
||||
ASSET_TYPE_FXWORLD = 20,
|
||||
ASSET_TYPE_GFXWORLD = 21,
|
||||
ASSET_TYPE_LIGHT_DEF = 22,
|
||||
ASSET_TYPE_UI_MAP = 23,
|
||||
ASSET_TYPE_FONT = 24,
|
||||
ASSET_TYPE_MENULIST = 25,
|
||||
ASSET_TYPE_MENU = 26,
|
||||
ASSET_TYPE_LOCALIZE_ENTRY = 27,
|
||||
ASSET_TYPE_WEAPON = 28,
|
||||
ASSET_TYPE_SNDDRIVER_GLOBALS = 29,
|
||||
ASSET_TYPE_FX = 30,
|
||||
ASSET_TYPE_IMPACT_FX = 31,
|
||||
ASSET_TYPE_AITYPE = 32,
|
||||
ASSET_TYPE_MPTYPE = 33,
|
||||
ASSET_TYPE_CHARACTER = 34,
|
||||
ASSET_TYPE_XMODELALIAS = 35,
|
||||
ASSET_TYPE_RAWFILE = 36,
|
||||
ASSET_TYPE_STRINGTABLE = 37,
|
||||
ASSET_TYPE_LEADERBOARD = 38,
|
||||
ASSET_TYPE_STRUCTURED_DATA_DEF = 39,
|
||||
ASSET_TYPE_TRACER = 40,
|
||||
ASSET_TYPE_VEHICLE = 41,
|
||||
ASSET_TYPE_ADDON_MAP_ENTS = 42,
|
||||
|
||||
ASSET_TYPE_COUNT = 43,
|
||||
};
|
||||
|
||||
enum FsThread {
|
||||
FS_THREAD_MAIN = 0x0,
|
||||
FS_THREAD_STREAM = 0x1,
|
||||
FS_THREAD_DATABASE = 0x2,
|
||||
FS_THREAD_BACKEND = 0x3,
|
||||
FS_THREAD_SERVER = 0x4,
|
||||
FS_THREAD_COUNT = 0x5,
|
||||
FS_THREAD_INVALID = 0x6,
|
||||
};
|
||||
|
||||
enum FsListBehavior_e {
|
||||
FS_LIST_PURE_ONLY = 0x0,
|
||||
FS_LIST_ALL = 0x1,
|
||||
};
|
||||
|
||||
enum fsMode_t {
|
||||
FS_READ = 0x0,
|
||||
FS_WRITE = 0x1,
|
||||
FS_APPEND = 0x2,
|
||||
FS_APPEND_SYNC = 0x3,
|
||||
};
|
||||
|
||||
struct token_s {
|
||||
char string[1024];
|
||||
int type;
|
||||
int subtype;
|
||||
unsigned int intvalue;
|
||||
long double floatvalue;
|
||||
char* whitespace_p;
|
||||
char* endwhitespace_p;
|
||||
int line;
|
||||
int linescrossed;
|
||||
token_s* next;
|
||||
};
|
||||
|
||||
static_assert(sizeof(token_s) == 0x430);
|
||||
|
||||
struct define_s {
|
||||
char* name;
|
||||
int flags;
|
||||
int builtin;
|
||||
int numparms;
|
||||
token_s* parms;
|
||||
token_s* tokens;
|
||||
define_s* next;
|
||||
define_s* hashnext;
|
||||
};
|
||||
|
||||
struct punctuation_s {
|
||||
const char* p;
|
||||
int n;
|
||||
punctuation_s* next;
|
||||
};
|
||||
|
||||
struct script_s {
|
||||
char filename[64];
|
||||
char* buffer;
|
||||
char* script_p;
|
||||
char* end_p;
|
||||
char* lastscript_p;
|
||||
char* whitespace_p;
|
||||
char* endwhitespace_p;
|
||||
int length;
|
||||
int line;
|
||||
int lastline;
|
||||
int tokenavailable;
|
||||
int flags;
|
||||
punctuation_s* punctuations;
|
||||
punctuation_s** punctuationtable;
|
||||
token_s token;
|
||||
script_s* next;
|
||||
};
|
||||
|
||||
enum parseSkip_t {
|
||||
SKIP_NO = 0x0,
|
||||
SKIP_YES = 0x1,
|
||||
SKIP_ALL_ELIFS = 0x2,
|
||||
};
|
||||
|
||||
struct indent_s {
|
||||
int type;
|
||||
parseSkip_t skip;
|
||||
script_s* script;
|
||||
indent_s* next;
|
||||
};
|
||||
|
||||
struct source_s {
|
||||
char filename[64];
|
||||
char includepath[64];
|
||||
punctuation_s* punctuations;
|
||||
script_s* scriptstack;
|
||||
token_s* tokens;
|
||||
define_s* defines;
|
||||
define_s** definehash;
|
||||
indent_s* indentstack;
|
||||
int skip;
|
||||
token_s token;
|
||||
};
|
||||
|
||||
struct pc_token_s {
|
||||
int type;
|
||||
int subtype;
|
||||
int intvalue;
|
||||
float floatvalue;
|
||||
char string[1024];
|
||||
};
|
||||
|
||||
struct cmd_function_s {
|
||||
cmd_function_s* next;
|
||||
const char* name;
|
||||
const char* autoCompleteDir;
|
||||
const char* autoCompleteExt;
|
||||
void(__cdecl* function)();
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct CmdArgs {
|
||||
int nesting;
|
||||
int localClientNum[8];
|
||||
int controllerIndex[8];
|
||||
int argc[8];
|
||||
const char** argv[8];
|
||||
};
|
||||
|
||||
struct msg_t {
|
||||
int overflowed;
|
||||
int readOnly;
|
||||
unsigned char* data;
|
||||
unsigned char* splitData;
|
||||
int maxsize;
|
||||
int cursize;
|
||||
int splitSize;
|
||||
int readcount;
|
||||
int bit;
|
||||
int lastEntityRef;
|
||||
};
|
||||
|
||||
static_assert(sizeof(msg_t) == 0x28);
|
||||
|
||||
typedef enum {
|
||||
ERR_FATAL = 0x0,
|
||||
ERR_DROP = 0x1,
|
||||
ERR_SERVERDISCONNECT = 0x2,
|
||||
ERR_DISCONNECT = 0x3,
|
||||
ERR_SCRIPT = 0x4,
|
||||
ERR_SCRIPT_DROP = 0x5,
|
||||
ERR_LOCALIZATION = 0x6,
|
||||
ERR_MAPLOADERRORSUMMARY = 0x7,
|
||||
} errorParm_t;
|
||||
|
||||
enum DvarFlags : std::uint16_t {
|
||||
DVAR_NONE = 0,
|
||||
DVAR_ARCHIVE = 1 << 0,
|
||||
DVAR_LATCH = 1 << 1,
|
||||
DVAR_CHEAT = 1 << 2,
|
||||
DVAR_CODINFO = 1 << 3,
|
||||
DVAR_SCRIPTINFO = 1 << 4,
|
||||
DVAR_TEMP = 1 << 5,
|
||||
DVAR_SAVED = 1 << 6,
|
||||
DVAR_INTERNAL = 1 << 7,
|
||||
DVAR_EXTERNAL = 1 << 8,
|
||||
DVAR_USERINFO = 1 << 9,
|
||||
DVAR_SERVERINFO = 1 << 10,
|
||||
DVAR_INIT = 1 << 11,
|
||||
DVAR_SYSTEMINFO = 1 << 12,
|
||||
DVAR_ROM = 1 << 13,
|
||||
DVAR_CHANGEABLE_RESET = 1 << 14,
|
||||
DVAR_AUTOEXEC = 1 << 15,
|
||||
};
|
||||
|
||||
enum : std::int8_t {
|
||||
DVAR_TYPE_BOOL = 0x0,
|
||||
DVAR_TYPE_FLOAT = 0x1,
|
||||
DVAR_TYPE_FLOAT_2 = 0x2,
|
||||
DVAR_TYPE_FLOAT_3 = 0x3,
|
||||
DVAR_TYPE_FLOAT_4 = 0x4,
|
||||
DVAR_TYPE_INT = 0x5,
|
||||
DVAR_TYPE_ENUM = 0x6,
|
||||
DVAR_TYPE_STRING = 0x7,
|
||||
DVAR_TYPE_COLOR = 0x8,
|
||||
DVAR_TYPE_FLOAT_3_COLOR = 0x9,
|
||||
};
|
||||
|
||||
enum DvarSetSource {
|
||||
DVAR_SOURCE_INTERNAL,
|
||||
DVAR_SOURCE_EXTERNAL,
|
||||
DVAR_SOURCE_SCRIPT,
|
||||
DVAR_SOURCE_DEVGUI,
|
||||
};
|
||||
|
||||
union DvarValue {
|
||||
bool enabled;
|
||||
int integer;
|
||||
unsigned int unsignedInt;
|
||||
float value;
|
||||
float vector[4];
|
||||
const char* string;
|
||||
unsigned char color[4];
|
||||
};
|
||||
|
||||
struct enum_limit {
|
||||
int stringCount;
|
||||
const char** strings;
|
||||
};
|
||||
|
||||
struct int_limit {
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
|
||||
struct float_limit {
|
||||
float min;
|
||||
float max;
|
||||
};
|
||||
|
||||
union DvarLimits {
|
||||
enum_limit enumeration;
|
||||
int_limit integer;
|
||||
float_limit value;
|
||||
float_limit vector;
|
||||
};
|
||||
|
||||
struct dvar_t {
|
||||
const char* name;
|
||||
const char* description;
|
||||
unsigned int flags;
|
||||
char type;
|
||||
bool modified;
|
||||
DvarValue current;
|
||||
DvarValue latched;
|
||||
DvarValue reset;
|
||||
DvarLimits domain;
|
||||
bool(__cdecl* domainFunc)(dvar_t*, DvarValue);
|
||||
dvar_t* hashNext;
|
||||
};
|
||||
|
||||
enum netsrc_t {
|
||||
NS_CLIENT1 = 0x0,
|
||||
NS_SERVER = 0x1,
|
||||
NS_MAXCLIENTS = 0x1,
|
||||
NS_PACKET = 0x2,
|
||||
};
|
||||
|
||||
enum netadrtype_t {
|
||||
NA_BOT = 0x0,
|
||||
NA_BAD = 0x1,
|
||||
NA_LOOPBACK = 0x2,
|
||||
NA_BROADCAST = 0x3,
|
||||
NA_IP = 0x4,
|
||||
NA_IPX = 0x5,
|
||||
NA_BROADCAST_IPX = 0x6,
|
||||
};
|
||||
|
||||
struct netadr_t {
|
||||
netadrtype_t type;
|
||||
unsigned char ip[4];
|
||||
unsigned __int16 port;
|
||||
char ipx[10];
|
||||
};
|
||||
|
||||
static_assert(sizeof(netadr_t) == 0x14);
|
||||
|
||||
struct Bounds {
|
||||
float midPoint[3];
|
||||
float halfSize[3];
|
||||
};
|
||||
|
||||
struct TriggerModel {
|
||||
int contents;
|
||||
unsigned __int16 hullCount;
|
||||
unsigned __int16 firstHull;
|
||||
};
|
||||
|
||||
struct TriggerHull {
|
||||
Bounds bounds;
|
||||
int contents;
|
||||
unsigned __int16 slabCount;
|
||||
unsigned __int16 firstSlab;
|
||||
};
|
||||
|
||||
struct TriggerSlab {
|
||||
float dir[3];
|
||||
float midPoint;
|
||||
float halfSize;
|
||||
};
|
||||
|
||||
struct MapTriggers {
|
||||
unsigned int count;
|
||||
TriggerModel* models;
|
||||
unsigned int hullCount;
|
||||
TriggerHull* hulls;
|
||||
unsigned int slabCount;
|
||||
TriggerSlab* slabs;
|
||||
};
|
||||
|
||||
struct Stage {
|
||||
const char* name;
|
||||
float origin[3];
|
||||
unsigned __int16 triggerIndex;
|
||||
char sunPrimaryLightIndex;
|
||||
};
|
||||
|
||||
struct MapEnts {
|
||||
const char* name;
|
||||
char* entityString;
|
||||
int numEntityChars;
|
||||
MapTriggers trigger;
|
||||
Stage* stages;
|
||||
char stageCount;
|
||||
};
|
||||
|
||||
struct WeaponCompleteDef {
|
||||
const char* szInternalName;
|
||||
}; // Incomplete
|
||||
|
||||
struct Font_s {
|
||||
const char* fontName;
|
||||
int pixelHeight;
|
||||
int glyphCount;
|
||||
void* material;
|
||||
void* glowMaterial;
|
||||
void* glyphs;
|
||||
};
|
||||
|
||||
struct RawFile {
|
||||
const char* name;
|
||||
int compressedLen;
|
||||
int len;
|
||||
const char* buffer;
|
||||
};
|
||||
|
||||
struct G_GlassPiece {
|
||||
unsigned __int16 damageTaken;
|
||||
unsigned __int16 collapseTime;
|
||||
int lastStateChangeTime;
|
||||
char impactDir;
|
||||
char impactPos[2];
|
||||
};
|
||||
|
||||
static_assert(sizeof(G_GlassPiece) == 0xC);
|
||||
|
||||
struct G_GlassName {
|
||||
char* nameStr;
|
||||
unsigned __int16 name;
|
||||
unsigned __int16 pieceCount;
|
||||
unsigned __int16* pieceIndices;
|
||||
};
|
||||
|
||||
static_assert(sizeof(G_GlassName) == 0xC);
|
||||
|
||||
struct G_GlassData {
|
||||
G_GlassPiece* glassPieces;
|
||||
unsigned int pieceCount;
|
||||
unsigned __int16 damageToWeaken;
|
||||
unsigned __int16 damageToDestroy;
|
||||
unsigned int glassNameCount;
|
||||
G_GlassName* glassNames;
|
||||
unsigned __int8 pad[108];
|
||||
};
|
||||
|
||||
static_assert(sizeof(G_GlassData) == 0x80);
|
||||
|
||||
struct GameWorldMp {
|
||||
const char* name;
|
||||
G_GlassData* g_glassData;
|
||||
};
|
||||
|
||||
struct GameWorldSp {
|
||||
const char* name;
|
||||
unsigned char __pad0[0x30];
|
||||
G_GlassData* g_glassData;
|
||||
};
|
||||
|
||||
static_assert(sizeof(GameWorldSp) == 0x38);
|
||||
|
||||
struct MenuList {
|
||||
const char* name;
|
||||
int menuCount;
|
||||
void** menus;
|
||||
};
|
||||
|
||||
struct LocalizeEntry {
|
||||
const char* value;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
union XAssetHeader {
|
||||
GameWorldSp* gameWorldSp;
|
||||
GameWorldMp* gameWorldMp;
|
||||
MapEnts* mapEnts;
|
||||
Font_s* font;
|
||||
MenuList* menuList;
|
||||
LocalizeEntry* localize;
|
||||
WeaponCompleteDef* weapon;
|
||||
RawFile* rawfile;
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct XAsset {
|
||||
XAssetType type;
|
||||
XAssetHeader header;
|
||||
};
|
||||
|
||||
struct XAssetEntry {
|
||||
XAsset asset;
|
||||
unsigned char zoneIndex;
|
||||
volatile unsigned char inuseMask;
|
||||
bool printedMissingAsset;
|
||||
unsigned __int16 nextHash;
|
||||
unsigned __int16 nextOverride;
|
||||
};
|
||||
|
||||
static_assert(sizeof(XAssetEntry) == 0x10);
|
||||
|
||||
struct XZoneInfo {
|
||||
const char* name;
|
||||
int allocFlags;
|
||||
int freeFlags;
|
||||
};
|
||||
|
||||
struct playerState_s {
|
||||
int commandTime;
|
||||
int pm_type;
|
||||
int pm_time;
|
||||
int pm_flags;
|
||||
int otherFlags;
|
||||
int linkFlags;
|
||||
int bobCycle;
|
||||
float origin[3];
|
||||
float velocity[3];
|
||||
unsigned char __pad0[0xAC70];
|
||||
};
|
||||
|
||||
static_assert(sizeof(playerState_s) == 0xACA4);
|
||||
|
||||
struct gclient_s {
|
||||
playerState_s ps;
|
||||
unsigned char __pad0[0xB0];
|
||||
int flags; // 0xAD54
|
||||
unsigned char __pad1[0x27C];
|
||||
};
|
||||
|
||||
static_assert(sizeof(gclient_s) == 0xAFD4);
|
||||
|
||||
struct entityState_s {
|
||||
unsigned char eType; // 0
|
||||
unsigned char __pad0[0x7D];
|
||||
unsigned __int16 number; // 0x7E
|
||||
unsigned char __pad1[0x2C];
|
||||
};
|
||||
|
||||
static_assert(sizeof(entityState_s) == 0xAC);
|
||||
|
||||
struct entityShared_t {
|
||||
unsigned char __pad0[0x5C];
|
||||
};
|
||||
|
||||
static_assert(sizeof(entityShared_t) == 0x5C);
|
||||
|
||||
struct gentity_s {
|
||||
entityState_s s;
|
||||
entityShared_t r;
|
||||
gclient_s* client;
|
||||
unsigned char __pad0[0x164];
|
||||
};
|
||||
|
||||
static_assert(sizeof(gentity_s) == 0x270);
|
||||
|
||||
struct client_t {
|
||||
unsigned char __pad0[0x1674];
|
||||
};
|
||||
|
||||
static_assert(sizeof(client_t) == 0x1674);
|
||||
|
||||
struct level_locals_t {
|
||||
unsigned char __pad0[0x34];
|
||||
int time;
|
||||
unsigned char __pad1[0x4748];
|
||||
};
|
||||
|
||||
static_assert(sizeof(level_locals_t) == 0x4780);
|
||||
|
||||
struct field_t {
|
||||
int cursor;
|
||||
int scroll;
|
||||
int drawWidth;
|
||||
int widthInPixels;
|
||||
float charHeight;
|
||||
int fixedSize;
|
||||
char buffer[256];
|
||||
};
|
||||
|
||||
struct ConDrawInputGlob {
|
||||
char autoCompleteChoice[64];
|
||||
int matchIndex;
|
||||
int matchCount;
|
||||
const char* inputText;
|
||||
int inputTextLen;
|
||||
bool hasExactMatch;
|
||||
bool mayAutoComplete;
|
||||
float x;
|
||||
float y;
|
||||
float leftX;
|
||||
float fontHeight;
|
||||
};
|
||||
|
||||
struct MessageLine {
|
||||
int messageIndex;
|
||||
int textBufPos;
|
||||
int textBufSize;
|
||||
int typingStartTime;
|
||||
int lastTypingSoundTime;
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct Message {
|
||||
int startTime;
|
||||
int endTime;
|
||||
};
|
||||
|
||||
struct MessageWindow {
|
||||
MessageLine* lines;
|
||||
Message* messages;
|
||||
char* circularTextBuffer;
|
||||
int textBufSize;
|
||||
int lineCount;
|
||||
int padding;
|
||||
int scrollTime;
|
||||
int fadeIn;
|
||||
int fadeOut;
|
||||
int textBufPos;
|
||||
int firstLineIndex;
|
||||
int activeLineCount;
|
||||
int messageIndex;
|
||||
};
|
||||
|
||||
struct MessageBuffer {
|
||||
char gamemsgText[4][2048];
|
||||
MessageWindow gamemsgWindows[4];
|
||||
MessageLine gamemsgLines[4][12];
|
||||
Message gamemsgMessages[4][12];
|
||||
char miniconText[4096];
|
||||
MessageWindow miniconWindow;
|
||||
MessageLine miniconLines[100];
|
||||
Message miniconMessages[100];
|
||||
char errorText[1024];
|
||||
MessageWindow errorWindow;
|
||||
MessageLine errorLines[5];
|
||||
Message errorMessages[5];
|
||||
};
|
||||
|
||||
struct Console {
|
||||
MessageWindow consoleWindow;
|
||||
MessageLine consoleLines[1024];
|
||||
Message consoleMessages[1024];
|
||||
char consoleText[65536];
|
||||
char textTempLine[512];
|
||||
unsigned int lineOffset;
|
||||
int displayLineOffset;
|
||||
int prevChannel;
|
||||
bool outputVisible;
|
||||
int fontHeight;
|
||||
int visibleLineCount;
|
||||
int visiblePixelWidth;
|
||||
float screenMin[2];
|
||||
float screenMax[2];
|
||||
MessageBuffer messageBuffer[1];
|
||||
float color[4];
|
||||
};
|
||||
|
||||
enum {
|
||||
KEYCATCH_CONSOLE = 0x1,
|
||||
};
|
||||
|
||||
enum ScreenPlacementMode {
|
||||
SCRMODE_FULL = 0x0,
|
||||
SCRMODE_DISPLAY = 0x1,
|
||||
SCRMODE_INVALID = 0x2,
|
||||
SCRMODE_COUNT = 0x3,
|
||||
};
|
||||
|
||||
struct ScreenPlacement {
|
||||
float scaleVirtualToReal[2];
|
||||
float scaleVirtualToFull[2];
|
||||
float scaleRealToVirtual[2];
|
||||
float realViewportPosition[2];
|
||||
float realViewportSize[2];
|
||||
float virtualViewableMin[2];
|
||||
float virtualViewableMax[2];
|
||||
float realViewableMin[2];
|
||||
float realViewableMax[2];
|
||||
float virtualAdjustableMin[2];
|
||||
float virtualAdjustableMax[2];
|
||||
float realAdjustableMin[2];
|
||||
float realAdjustableMax[2];
|
||||
float subScreenLeft;
|
||||
};
|
||||
|
||||
enum usercmdButtonBits {
|
||||
CMD_BUTTON_LEAN_LEFT = 0x40,
|
||||
CMD_BUTTON_LEAN_RIGHT = 0x80,
|
||||
};
|
||||
|
||||
struct kbutton_t {
|
||||
int down[2];
|
||||
unsigned int downtime;
|
||||
unsigned int msec;
|
||||
bool active;
|
||||
bool wasPressed;
|
||||
};
|
||||
|
||||
struct usercmd_s {
|
||||
int serverTime;
|
||||
int buttons;
|
||||
int angles[3];
|
||||
unsigned __int16 weapon;
|
||||
unsigned __int16 primaryWeaponForAltMode;
|
||||
unsigned __int16 offHandIndex;
|
||||
char forwardmove;
|
||||
char rightmove;
|
||||
unsigned char upmove;
|
||||
unsigned char downmove;
|
||||
char pitchmove;
|
||||
char yawmove;
|
||||
float gunPitch;
|
||||
float gunYaw;
|
||||
float gunXOfs;
|
||||
float gunYOfs;
|
||||
float gunZOfs;
|
||||
float meleeChargeYaw;
|
||||
unsigned char meleeChargeDist;
|
||||
char selectedLoc[2];
|
||||
unsigned char selectedLocAngle;
|
||||
char remoteControlAngles[2];
|
||||
};
|
||||
|
||||
struct weaponParms {
|
||||
float forward[3];
|
||||
float right[3];
|
||||
float up[3];
|
||||
float muzzleTrace[3];
|
||||
float gunForward[3];
|
||||
unsigned int weaponIndex;
|
||||
const void* weapDef;
|
||||
const void* weapCompleteDef;
|
||||
};
|
||||
|
||||
struct lockonFireParms {
|
||||
bool lockon;
|
||||
gentity_s* target;
|
||||
float targetPosOrOffset[3];
|
||||
bool topFire;
|
||||
};
|
||||
|
||||
enum TraceHitType {
|
||||
TRACE_HITTYPE_NONE = 0x0,
|
||||
TRACE_HITTYPE_ENTITY = 0x1,
|
||||
TRACE_HITTYPE_DYNENT_MODEL = 0x2,
|
||||
TRACE_HITTYPE_DYNENT_BRUSH = 0x3,
|
||||
TRACE_HITTYPE_GLASS = 0x4,
|
||||
};
|
||||
|
||||
struct trace_t {
|
||||
float fraction;
|
||||
float normal[3];
|
||||
int surfaceFlags;
|
||||
int contents;
|
||||
const char* material;
|
||||
TraceHitType hitType;
|
||||
unsigned __int16 hitId;
|
||||
unsigned __int16 modelIndex;
|
||||
unsigned __int16 partName;
|
||||
unsigned __int16 partGroup;
|
||||
bool allsolid;
|
||||
bool startsolid;
|
||||
bool walkable;
|
||||
};
|
||||
|
||||
static_assert(sizeof(trace_t) == 0x2C);
|
||||
|
||||
struct pml_t {
|
||||
float forward[3];
|
||||
float right[3];
|
||||
float up[3];
|
||||
float frametime;
|
||||
int msec;
|
||||
int walking;
|
||||
int groundPlane;
|
||||
trace_t groundTrace;
|
||||
float impactSpeed;
|
||||
float previous_origin[3];
|
||||
float previous_velocity[3];
|
||||
unsigned int holdrand;
|
||||
};
|
||||
|
||||
static_assert(sizeof(pml_t) == 0x80);
|
||||
|
||||
struct pmove_t {
|
||||
playerState_s* ps;
|
||||
usercmd_s cmd;
|
||||
usercmd_s oldcmd;
|
||||
int tracemask;
|
||||
int numtouch;
|
||||
int touchents[32];
|
||||
Bounds bounds;
|
||||
float xyspeed;
|
||||
int proneChange;
|
||||
int viewChangeTime;
|
||||
float viewChange;
|
||||
float fTorsoPitch;
|
||||
float fWaistPitch;
|
||||
unsigned char handler;
|
||||
};
|
||||
|
||||
static_assert(sizeof(pmove_t) == 0x140);
|
||||
|
||||
enum ScopedCriticalSectionType {
|
||||
SCOPED_CRITSECT_NORMAL = 0x0,
|
||||
SCOPED_CRITSECT_DISABLED = 0x1,
|
||||
SCOPED_CRITSECT_RELEASE = 0x2,
|
||||
SCOPED_CRITSECT_TRY = 0x3,
|
||||
};
|
||||
|
||||
enum CriticalSection {
|
||||
CRITSECT_CONSOLE = 0x0,
|
||||
CRITSECT_LSP = 0x1A,
|
||||
CRITSECT_CBUF = 0x21,
|
||||
CRITSECT_COUNT = 0x28,
|
||||
};
|
||||
|
||||
enum {
|
||||
THREAD_VALUE_PROF_STACK = 0x0,
|
||||
THREAD_VALUE_VA = 0x1,
|
||||
THREAD_VALUE_COM_ERROR = 0x2,
|
||||
THREAD_VALUE_TRACE = 0x3,
|
||||
THREAD_VALUE_COUNT = 0x4,
|
||||
};
|
||||
|
||||
struct TempPriority {
|
||||
void* threadHandle;
|
||||
int oldPriority;
|
||||
};
|
||||
|
||||
struct FastCriticalSection {
|
||||
volatile long readCount;
|
||||
volatile long writeCount;
|
||||
TempPriority tempPriority;
|
||||
};
|
||||
|
||||
struct ProfileAtom {
|
||||
unsigned int value[1];
|
||||
};
|
||||
|
||||
volatile struct ProfileReadable {
|
||||
unsigned int hits;
|
||||
ProfileAtom total;
|
||||
ProfileAtom self;
|
||||
};
|
||||
|
||||
struct ProfileWritable {
|
||||
int nesting;
|
||||
unsigned int hits;
|
||||
ProfileAtom start[3];
|
||||
ProfileAtom total;
|
||||
ProfileAtom child;
|
||||
};
|
||||
|
||||
struct profile_t {
|
||||
ProfileWritable write;
|
||||
ProfileReadable read;
|
||||
};
|
||||
|
||||
struct profile_guard_t {
|
||||
int id;
|
||||
profile_t** ppStack;
|
||||
};
|
||||
|
||||
struct ProfileStack {
|
||||
profile_t prof_root;
|
||||
profile_t* prof_pStack[16384];
|
||||
profile_t** prof_ppStack;
|
||||
profile_t prof_array[443];
|
||||
ProfileAtom prof_overhead_internal;
|
||||
ProfileAtom prof_overhead_external;
|
||||
profile_guard_t prof_guardstack[32];
|
||||
int prof_guardpos;
|
||||
float prof_timescale;
|
||||
};
|
||||
|
||||
struct va_info_t {
|
||||
char va_string[2][1024];
|
||||
int index;
|
||||
};
|
||||
|
||||
static_assert(sizeof(va_info_t) == 0x804);
|
||||
|
||||
struct TraceCheckCount {
|
||||
int global;
|
||||
int* partitions;
|
||||
};
|
||||
|
||||
struct TraceThreadInfo {
|
||||
TraceCheckCount checkcount;
|
||||
};
|
||||
|
||||
static_assert(sizeof(TraceThreadInfo) == 0x8);
|
||||
} // namespace game
|
||||
|
||||
#pragma warning(pop)
|
259
src/client/game/symbols.hpp
Normal file
259
src/client/game/symbols.hpp
Normal file
@ -0,0 +1,259 @@
|
||||
#pragma once
|
||||
|
||||
#define WEAK __declspec(selectany)
|
||||
|
||||
namespace game {
|
||||
// Com
|
||||
WEAK symbol<void(int channel, const char* fmt, ...)> Com_Printf{0x41BD20};
|
||||
WEAK symbol<void(int channel, const char* fmt, ...)> Com_PrintWarning{0x406320};
|
||||
WEAK symbol<void(int channel, const char* fmt, ...)> Com_PrintError{0x4C6980};
|
||||
WEAK symbol<void(int channel, const char* fmt, ...)> Com_DPrintf{0x42B1F0};
|
||||
WEAK symbol<void(errorParm_t code, const char* fmt, ...)> Com_Error{0x43DD90};
|
||||
WEAK symbol<void()> Com_OpenLogFile{0x603030};
|
||||
WEAK symbol<int(char* data_p)> Com_Compress{0x4316A0};
|
||||
WEAK symbol<void()> Com_EventLoop{0x4987C0};
|
||||
WEAK symbol<void()> Com_ServerPacketEvent{0x47FD30};
|
||||
|
||||
WEAK symbol<const char*(const char* fmt, ...)> va{0x4869F0};
|
||||
|
||||
// Con
|
||||
WEAK symbol<bool(const char* cmd)> Con_IsDvarCommand{0x4B6610};
|
||||
|
||||
// Sys
|
||||
WEAK symbol<void(const char* exeName)> Sys_QuitAndStartProcess{0x4D69A0};
|
||||
WEAK symbol<void(CriticalSection critSect)> Sys_EnterCriticalSection{0x4A4CD0};
|
||||
WEAK symbol<void(CriticalSection critSect)> Sys_LeaveCriticalSection{0x4F78E0};
|
||||
WEAK symbol<void(TempPriority*)> Sys_TempPriorityEnd{0x4FB800};
|
||||
WEAK symbol<void(FastCriticalSection* critSect)> Sys_LockWrite{0x43C1D0};
|
||||
WEAK symbol<int()> Sys_Milliseconds{0x44E130};
|
||||
WEAK symbol<bool()> Sys_IsMainThread{0x42FA00};
|
||||
WEAK symbol<bool()> Sys_IsServerThread{0x4590E0};
|
||||
WEAK symbol<bool()> Sys_IsDatabaseThread{0x4C9380};
|
||||
WEAK symbol<void(int valueIndex, void* data)> Sys_SetValue{0x483310};
|
||||
WEAK symbol<void(int msec)> Sys_Sleep{0x4CFBE0};
|
||||
|
||||
WEAK symbol<short(short l)> BigShort{0x40E7E0};
|
||||
WEAK symbol<short(short l)> ShortNoSwap{0x4261A0};
|
||||
|
||||
WEAK symbol<int(int size)> LargeLocalBegin{0x43fA50};
|
||||
WEAK symbol<int(int size)> LargeLocalBeginRight{0x6317D0};
|
||||
|
||||
// CL
|
||||
WEAK symbol<int(int localClientNum)> CL_IsCgameInitialized{0x4EEA50};
|
||||
WEAK symbol<void()> CL_CoOpConnect{0x57D240};
|
||||
|
||||
// BG
|
||||
WEAK symbol<WeaponCompleteDef*(const char* name, const char* folder)>
|
||||
BG_LoadWeaponVariantDefInternal{0x4F5AF0};
|
||||
|
||||
// Game
|
||||
WEAK symbol<int()> G_GetTime{0x4E94E0};
|
||||
|
||||
WEAK symbol<void(int, const char* text)> Cbuf_AddText{0x4A1090};
|
||||
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)>
|
||||
Cmd_ExecuteSingleCommand{0x46AFD0};
|
||||
WEAK symbol<void(const char* cmdName, void(*function),
|
||||
cmd_function_s* allocedCmd, int isKey)>
|
||||
Cmd_AddCommand{0x4478A0};
|
||||
WEAK symbol<void(const char* cmdName, const char* dir, const char* ext)>
|
||||
Cmd_SetAutoComplete{0x48A880};
|
||||
|
||||
// Dvars
|
||||
WEAK symbol<dvar_t*(const char* dvarName)> Dvar_FindVar{0x4B29D0};
|
||||
WEAK symbol<const dvar_t*(const char* dvarName, const char* value,
|
||||
unsigned __int16 flags, const char* description)>
|
||||
Dvar_RegisterString{0x49E0B0};
|
||||
WEAK symbol<const dvar_t*(const char* dvarName, bool value,
|
||||
unsigned __int16 flags, const char* description)>
|
||||
Dvar_RegisterBool{0x429390};
|
||||
WEAK symbol<const dvar_t*(const char* dvarName, const char** valueList,
|
||||
int defaultIndex, unsigned __int16 flags,
|
||||
const char* description)>
|
||||
Dvar_RegisterEnum{0x4CB7C0};
|
||||
WEAK symbol<const dvar_t*(const char* dvarName, float value, float min,
|
||||
float max, unsigned __int16 flags,
|
||||
const char* description)>
|
||||
Dvar_RegisterFloat{0x4051D0};
|
||||
WEAK symbol<const dvar_t*(const char* dvarName, int value, int min, int max,
|
||||
unsigned __int16 flags, const char* description)>
|
||||
Dvar_RegisterInt{0x4E9490};
|
||||
|
||||
WEAK symbol<void(const char* dvarName, double value)> Dvar_SetFloatByName{
|
||||
0x497250};
|
||||
WEAK symbol<void(const char* dvarName, const char* value)> Dvar_SetStringByName{
|
||||
0x440C60};
|
||||
WEAK symbol<void(const dvar_t* dvar, int value)> Dvar_SetInt{0x4FA540};
|
||||
WEAK symbol<void(const dvar_t* dvar, bool value)> Dvar_SetBool{0x4E57E0};
|
||||
WEAK symbol<void(const dvar_t* dvar, const char* value)> Dvar_SetString{
|
||||
0x480E70};
|
||||
WEAK symbol<const char*(const char* dvarName)> Dvar_GetString{0x411F50};
|
||||
WEAK symbol<bool(const char* dvarName)> Dvar_GetBool{0x481010};
|
||||
|
||||
// Script
|
||||
WEAK symbol<void(const char* error)> Scr_Error{0x4E9C50};
|
||||
WEAK symbol<void(const char* error)> Scr_ObjectError{0x470600};
|
||||
WEAK symbol<void(unsigned int paramIndex, const char* error)> Scr_ParamError{
|
||||
0x42C880};
|
||||
WEAK symbol<gentity_s*(scr_entref_t entref)> GetEntity{0x4678C0};
|
||||
|
||||
WEAK symbol<unsigned int()> Scr_GetNumParam{0x4443F0};
|
||||
WEAK symbol<void()> Scr_ClearOutParams{0x4A3A00};
|
||||
WEAK symbol<const char*(unsigned int index)> Scr_GetTypeName{0x4CE240};
|
||||
WEAK symbol<const char*(unsigned int index)> Scr_GetString{0x4D39C0};
|
||||
WEAK symbol<void(const char* value)> Scr_AddString{0x4CD670};
|
||||
WEAK symbol<unsigned int(unsigned int index)> Scr_GetConstString{0x4AF1B0};
|
||||
WEAK symbol<void(unsigned int value)> Scr_AddConstString{0x404CF0};
|
||||
WEAK symbol<int(unsigned int index)> Scr_GetInt{0x454520};
|
||||
WEAK symbol<void(int value)> Scr_AddInt{0x4865B0};
|
||||
WEAK symbol<float(unsigned int index)> Scr_GetFloat{0x4AE590};
|
||||
WEAK symbol<void(float value)> Scr_AddFloat{0x4986E0};
|
||||
WEAK symbol<int(unsigned int index)> Scr_GetType{0x464EE0};
|
||||
WEAK symbol<void(int func, const char* name)> Scr_RegisterFunction{0x4F59C0};
|
||||
WEAK symbol<unsigned int(unsigned int index)> Scr_GetFunc{0x438E10};
|
||||
|
||||
WEAK symbol<char*(const char* filename, const char* extFilename,
|
||||
const char* codePos, bool archive)>
|
||||
Scr_AddSourceBuffer{0x4173C0};
|
||||
WEAK symbol<unsigned int(const char* filename)> Scr_LoadScript{0x46CD90};
|
||||
WEAK symbol<int(const char* filename, const char* name)> Scr_GetFunctionHandle{
|
||||
0x462750};
|
||||
WEAK symbol<int(int handle, unsigned int paramcount)> Scr_ExecThread{0x41A2C0};
|
||||
WEAK symbol<void(unsigned __int16 handle)> Scr_FreeThread{0x4C44A0};
|
||||
|
||||
// SL
|
||||
WEAK symbol<const char*(unsigned int stringValue)> SL_ConvertToString{0x40E990};
|
||||
WEAK symbol<void(unsigned int stringValue)> SL_AddRefToString{0x4C4BD0};
|
||||
WEAK symbol<void(unsigned int stringValue)> SL_RemoveRefToString{0x4698E0};
|
||||
|
||||
WEAK symbol<const char*(netadr_t a)> NET_AdrToString{0x4BF490};
|
||||
WEAK symbol<const char*()> NET_ErrorString{0x430390};
|
||||
|
||||
// Memory
|
||||
WEAK symbol<void*(int size)> Hunk_AllocateTempMemory{0x492DF0};
|
||||
WEAK symbol<void*(int size, int alignment)> Hunk_AllocAlignInternal{0x486C40};
|
||||
|
||||
// Zone
|
||||
WEAK symbol<void*(int size)> Z_VirtualAllocInternal{0x4D9CF0};
|
||||
WEAK symbol<void*(int size, const char* name)> Z_TryVirtualAllocInternal{
|
||||
0x4D9590};
|
||||
WEAK symbol<void(void* ptr)> Z_VirtualFreeInternal{0x4FE260};
|
||||
|
||||
// DB
|
||||
WEAK symbol<XAssetHeader(XAssetType type, const char* name)>
|
||||
DB_FindXAssetHeader{0x40B200};
|
||||
WEAK symbol<int(XAssetType type, const char* name)> DB_IsXAssetDefault{
|
||||
0x41AB70};
|
||||
WEAK symbol<void(RawFile* rawfile, char* buffer, int size)> DB_GetRawBuffer{
|
||||
0x4345E0};
|
||||
WEAK symbol<void(XZoneInfo* zoneInfo, unsigned int zoneCount,
|
||||
unsigned int syncMode)>
|
||||
DB_LoadXAssets{0x4CFC90};
|
||||
WEAK symbol<char*(const char* filename, char* buf, int size)> DB_ReadRawFile{
|
||||
0x46DA60};
|
||||
|
||||
// FS
|
||||
WEAK symbol<int(const char* qpath, void** buffer)> _FS_ReadFile{0x4A5480};
|
||||
WEAK symbol<unsigned int(void* buffer, int len, int h)> FS_Read{0x42EDC0};
|
||||
WEAK symbol<int(const void* buffer, int len, int h)> FS_Write{0x449FA0};
|
||||
WEAK symbol<void(int h)> FS_FCloseFile{0x44E0A0};
|
||||
WEAK symbol<int(const char* qpath, int* f, fsMode_t mode)> FS_FOpenFileByMode{
|
||||
0x41DF70};
|
||||
WEAK symbol<int(const char* filename, int* file)> FS_FOpenFileRead{0x48DD10};
|
||||
WEAK symbol<const char**(const char* path, const char* extension,
|
||||
FsListBehavior_e behavior, int* numfiles,
|
||||
int allocTrackType)>
|
||||
FS_ListFiles{0x4448F0};
|
||||
WEAK symbol<void(const char** list, int allocTrackType)> FS_FreeFileList{
|
||||
0x41C7A0};
|
||||
WEAK symbol<void(const char* base, const char* game, const char* qpath,
|
||||
char* ospath)>
|
||||
FS_BuildOSPath{0x4E48F0};
|
||||
WEAK symbol<void(const char* gameName)> FS_Startup{0x47AF20};
|
||||
|
||||
// UI
|
||||
WEAK symbol<Font_s*(const ScreenPlacement* scrPlace, int fontEnum, float scale)>
|
||||
UI_GetFontHandle{0x4C2600};
|
||||
WEAK symbol<int(const char* text, int maxChars, Font_s* font, float scale)>
|
||||
UI_TextWidth{0x4F5070};
|
||||
WEAK symbol<int(Font_s* font, float scale)> UI_TextHeight{0x407710};
|
||||
WEAK symbol<void(const ScreenPlacement* scrPlace, const char* text,
|
||||
int maxChars, Font_s* font, float x, float y, int horzAlign,
|
||||
int vertAlign, float scale, const float* color, int style)>
|
||||
UI_DrawText{0x40FC70};
|
||||
|
||||
// PC
|
||||
WEAK symbol<int(source_s* source)> PC_Directive_define{0x4F8CF0};
|
||||
WEAK symbol<void(define_s* define)> PC_FreeDefine{0x464F40};
|
||||
WEAK symbol<token_s*(token_s* token)> PC_CopyToken{0x4D3670};
|
||||
WEAK symbol<int(int handle, pc_token_s* pc_token)> PC_ReadTokenHandle{0x46C3B0};
|
||||
WEAK symbol<void(int handle, const char* format, ...)> PC_SourceError{0x43A6D0};
|
||||
|
||||
WEAK symbol<void*(unsigned int size)> GetMemory{0x441880};
|
||||
WEAK symbol<void*(unsigned int size)> GetClearedMemory{0x41BCD0};
|
||||
WEAK symbol<void(void* ptr)> FreeMemory{0x4A7D20};
|
||||
|
||||
// PM
|
||||
WEAK symbol<void(pmove_t* pm, trace_t* results, const float* start,
|
||||
const float* end, const Bounds* bounds, int passEntityNum,
|
||||
int contentMask)>
|
||||
PM_trace{0x4B7A20};
|
||||
WEAK symbol<void(pmove_t* pm, trace_t* results, const float* start,
|
||||
const float* end, const Bounds* bounds, int passEntityNum,
|
||||
int contentMask)>
|
||||
PM_playerTrace{0x447B90};
|
||||
WEAK symbol<bool(const playerState_s* ps)> PM_IsSprinting{0x47CF70};
|
||||
|
||||
// Live
|
||||
WEAK symbol<const char*(int controllerIndex)> Live_GetLocalClientName{0x492EF0};
|
||||
|
||||
// Info
|
||||
WEAK symbol<int(const char* s)> Info_Validate{0x425530};
|
||||
|
||||
// IW functions, could use Microsoft specific functions but who cares
|
||||
WEAK symbol<int(const char* s0, const char* s1)> I_stricmp{0x409B80};
|
||||
WEAK symbol<int(const char* s0, const char* s1, int n)> I_strnicmp{0x491E60};
|
||||
|
||||
WEAK symbol<void(field_t* edit)> Field_Clear{0x45C350};
|
||||
|
||||
// Variables
|
||||
WEAK symbol<CmdArgs> cmd_args{0x144FED0};
|
||||
WEAK symbol<CmdArgs> sv_cmd_args{0x145ABA0};
|
||||
WEAK symbol<gentity_s> g_entities{0xEAAC38};
|
||||
WEAK symbol<gclient_s> g_clients{0x10911E8};
|
||||
|
||||
WEAK symbol<int> com_frameTime{0x145EC7C};
|
||||
|
||||
WEAK symbol<bool> cin_skippable{0x73264C};
|
||||
|
||||
WEAK symbol<field_t> g_consoleField{0x88C700};
|
||||
WEAK symbol<ConDrawInputGlob> conDrawInputGlob{0x86E788};
|
||||
WEAK symbol<Console> con{0x86ED88};
|
||||
WEAK symbol<float> g_console_char_height{0x732658};
|
||||
WEAK symbol<int> g_console_field_width{0x732654};
|
||||
WEAK symbol<ScreenPlacementMode> activeScreenPlacementMode{0x93AAF4};
|
||||
WEAK symbol<ScreenPlacement> scrPlaceFullUnsafe{0x93AB70};
|
||||
|
||||
WEAK symbol<int> logfile{0x145EC6C};
|
||||
|
||||
WEAK symbol<level_locals_t> level{0x10A7190};
|
||||
|
||||
WEAK symbol<RTL_CRITICAL_SECTION> s_criticalSection{0x19FBA28};
|
||||
WEAK symbol<SOCKET> ip_socket{0x1A040C8};
|
||||
|
||||
WEAK symbol<source_s*> sourceFiles{0x7440E8};
|
||||
WEAK symbol<int> numtokens{0x7441F0};
|
||||
|
||||
WEAK symbol<void*> DB_GetXAssetSizeHandlers{0x733408};
|
||||
WEAK symbol<void*> DB_XAssetPool{0x7337F8};
|
||||
WEAK symbol<unsigned int> g_poolSize{0x733510};
|
||||
|
||||
WEAK symbol<unsigned char*> g_largeLocalBuf{0x195AAF8};
|
||||
|
||||
WEAK symbol<int> g_largeLocalPos{0x1963998};
|
||||
WEAK symbol<int> g_maxLargeLocalPos{0x195AAFC};
|
||||
|
||||
WEAK symbol<int> g_largeLocalRightPos{0x195AAE8};
|
||||
WEAK symbol<int> g_minLargeLocalRightPos{0x195AB00};
|
||||
|
||||
WEAK symbol<unsigned long> g_dwTlsIndex{0x1BFC750};
|
||||
} // namespace game
|
27
src/client/loader/binary_loader.cpp
Normal file
27
src/client/loader/binary_loader.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <std_include.hpp>
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/cryptography.hpp>
|
||||
|
||||
#include "binary_loader.hpp"
|
||||
|
||||
#define SP_HASH \
|
||||
"39E9C4FACEA4B19017BB8C2FC64E4149708927AC40C7C3DEACC25BDD25E93D32"
|
||||
|
||||
namespace binary_loader {
|
||||
std::string load_base() {
|
||||
std::string data;
|
||||
if (!utils::io::read_file("iw4sp.exe", &data)) {
|
||||
throw std::runtime_error("Failed to read game binary (iw4sp.exe)!");
|
||||
}
|
||||
|
||||
const auto hash = utils::cryptography::sha256::compute(data, true);
|
||||
if (hash != SP_HASH) {
|
||||
throw std::runtime_error(
|
||||
"Your iw4sp.exe is incompatible with this client.");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::string load() { return load_base(); }
|
||||
} // namespace binary_loader
|
5
src/client/loader/binary_loader.hpp
Normal file
5
src/client/loader/binary_loader.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace binary_loader {
|
||||
std::string load();
|
||||
}
|
19
src/client/loader/component_interface.hpp
Normal file
19
src/client/loader/component_interface.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
class component_interface {
|
||||
public:
|
||||
virtual ~component_interface() = default;
|
||||
|
||||
virtual void post_start() {}
|
||||
|
||||
virtual void post_load() {}
|
||||
|
||||
virtual void pre_destroy() {}
|
||||
|
||||
virtual void* load_import([[maybe_unused]] const std::string& library,
|
||||
[[maybe_unused]] const std::string& function) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual bool is_supported() { return true; }
|
||||
};
|
100
src/client/loader/component_loader.cpp
Normal file
100
src/client/loader/component_loader.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
#include <std_include.hpp>
|
||||
#include "component_loader.hpp"
|
||||
|
||||
void component_loader::register_component(
|
||||
std::unique_ptr<component_interface>&& component_) {
|
||||
get_components().push_back(std::move(component_));
|
||||
}
|
||||
|
||||
bool component_loader::post_start() {
|
||||
static auto handled = false;
|
||||
if (handled)
|
||||
return true;
|
||||
handled = true;
|
||||
|
||||
try {
|
||||
for (const auto& component_ : get_components()) {
|
||||
component_->post_start();
|
||||
}
|
||||
} catch (premature_shutdown_trigger&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader::post_load() {
|
||||
static auto handled = false;
|
||||
if (handled)
|
||||
return true;
|
||||
handled = true;
|
||||
|
||||
clean();
|
||||
|
||||
try {
|
||||
for (const auto& component_ : get_components()) {
|
||||
component_->post_load();
|
||||
}
|
||||
} catch (premature_shutdown_trigger&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void component_loader::pre_destroy() {
|
||||
static auto handled = false;
|
||||
if (handled)
|
||||
return;
|
||||
handled = true;
|
||||
|
||||
for (const auto& component_ : get_components()) {
|
||||
component_->pre_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void component_loader::clean() {
|
||||
auto& components = get_components();
|
||||
for (auto i = components.begin(); i != components.end();) {
|
||||
if (!(*i)->is_supported()) {
|
||||
(*i)->pre_destroy();
|
||||
i = components.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* component_loader::load_import(const std::string& library,
|
||||
const std::string& function) {
|
||||
void* function_ptr = nullptr;
|
||||
|
||||
for (const auto& component_ : get_components()) {
|
||||
auto* const component_function_ptr =
|
||||
component_->load_import(library, function);
|
||||
if (component_function_ptr) {
|
||||
function_ptr = component_function_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
return function_ptr;
|
||||
}
|
||||
|
||||
void component_loader::trigger_premature_shutdown() {
|
||||
throw premature_shutdown_trigger();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<component_interface>>&
|
||||
component_loader::get_components() {
|
||||
using component_vector = std::vector<std::unique_ptr<component_interface>>;
|
||||
using component_vector_container =
|
||||
std::unique_ptr<component_vector, std::function<void(component_vector*)>>;
|
||||
|
||||
static component_vector_container components(
|
||||
new component_vector, [](component_vector* component_vector) {
|
||||
pre_destroy();
|
||||
delete component_vector;
|
||||
});
|
||||
|
||||
return *components;
|
||||
}
|
50
src/client/loader/component_loader.hpp
Normal file
50
src/client/loader/component_loader.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "component_interface.hpp"
|
||||
|
||||
class component_loader final {
|
||||
public:
|
||||
class premature_shutdown_trigger final : public std::exception {
|
||||
[[nodiscard]] const char* what() const noexcept override {
|
||||
return "Premature shutdown requested";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> class installer final {
|
||||
static_assert(std::is_base_of<component_interface, T>::value,
|
||||
"component has invalid base class");
|
||||
|
||||
public:
|
||||
installer() { register_component(std::make_unique<T>()); }
|
||||
};
|
||||
|
||||
template <typename T> static T* get() {
|
||||
for (const auto& component_ : get_components()) {
|
||||
if (typeid(*component_.get()) == typeid(T)) {
|
||||
return reinterpret_cast<T*>(component_.get());
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void
|
||||
register_component(std::unique_ptr<component_interface>&& component);
|
||||
|
||||
static bool post_start();
|
||||
static bool post_load();
|
||||
static void pre_destroy();
|
||||
static void clean();
|
||||
|
||||
static void* load_import(const std::string& library,
|
||||
const std::string& function);
|
||||
|
||||
static void trigger_premature_shutdown();
|
||||
|
||||
private:
|
||||
static std::vector<std::unique_ptr<component_interface>>& get_components();
|
||||
};
|
||||
|
||||
#define REGISTER_COMPONENT(name) \
|
||||
namespace { \
|
||||
static component_loader::installer<name> __component; \
|
||||
}
|
190
src/client/loader/loader.cpp
Normal file
190
src/client/loader/loader.cpp
Normal file
@ -0,0 +1,190 @@
|
||||
#include <std_include.hpp>
|
||||
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "loader.hpp"
|
||||
#include "tls.hpp"
|
||||
|
||||
FARPROC loader::load(const utils::nt::library& library,
|
||||
const std::string& buffer) const {
|
||||
|
||||
if (buffer.empty())
|
||||
return nullptr;
|
||||
|
||||
const utils::nt::library source(HMODULE(buffer.data()));
|
||||
if (!source)
|
||||
return nullptr;
|
||||
|
||||
this->load_sections(library, source);
|
||||
this->load_imports(library, source);
|
||||
this->load_tls(library, source);
|
||||
|
||||
DWORD oldProtect;
|
||||
VirtualProtect(library.get_nt_headers(), 0x1000, PAGE_EXECUTE_READWRITE,
|
||||
&oldProtect);
|
||||
|
||||
library.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] =
|
||||
source.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
|
||||
std::memmove(library.get_nt_headers(), source.get_nt_headers(),
|
||||
sizeof(IMAGE_NT_HEADERS) +
|
||||
source.get_nt_headers()->FileHeader.NumberOfSections *
|
||||
sizeof(IMAGE_SECTION_HEADER));
|
||||
|
||||
return FARPROC(library.get_ptr() + source.get_relative_entry_point());
|
||||
}
|
||||
|
||||
FARPROC loader::load_library(const std::string& filename) const {
|
||||
const auto target = utils::nt::library::load(filename);
|
||||
if (!target) {
|
||||
throw std::runtime_error{"Failed to map binary!"};
|
||||
}
|
||||
|
||||
const auto base = size_t(target.get_ptr());
|
||||
if (base != 0x400000) {
|
||||
throw std::runtime_error{
|
||||
utils::string::va("Binary was mapped at {0:#x} (instead of {1:#x}). "
|
||||
"Something is severely broken :(",
|
||||
base, 0x400000)};
|
||||
}
|
||||
|
||||
this->load_imports(target, target);
|
||||
this->load_tls(target, target);
|
||||
|
||||
return FARPROC(target.get_ptr() + target.get_relative_entry_point());
|
||||
}
|
||||
|
||||
void loader::set_import_resolver(
|
||||
const std::function<void*(const std::string&, const std::string&)>&
|
||||
resolver) {
|
||||
this->import_resolver_ = resolver;
|
||||
}
|
||||
|
||||
void loader::load_section(const utils::nt::library& target,
|
||||
const utils::nt::library& source,
|
||||
IMAGE_SECTION_HEADER* section) {
|
||||
void* target_ptr = target.get_ptr() + section->VirtualAddress;
|
||||
const void* source_ptr = source.get_ptr() + section->PointerToRawData;
|
||||
|
||||
if (PBYTE(target_ptr) >= (target.get_ptr() + BINARY_PAYLOAD_SIZE)) {
|
||||
throw std::runtime_error(
|
||||
"Section exceeds the binary payload size, please increase it!");
|
||||
}
|
||||
|
||||
if (section->SizeOfRawData > 0) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(target_ptr, section->Misc.VirtualSize,
|
||||
PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
|
||||
std::memmove(target_ptr, source_ptr, section->SizeOfRawData);
|
||||
}
|
||||
}
|
||||
|
||||
void loader::load_sections(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const {
|
||||
for (auto& section : source.get_section_headers()) {
|
||||
this->load_section(target, source, section);
|
||||
}
|
||||
}
|
||||
|
||||
void loader::load_imports(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const {
|
||||
const auto import_directory =
|
||||
&source.get_optional_header()
|
||||
->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
|
||||
|
||||
auto descriptor = PIMAGE_IMPORT_DESCRIPTOR(target.get_ptr() +
|
||||
import_directory->VirtualAddress);
|
||||
|
||||
while (descriptor->Name) {
|
||||
std::string name = LPSTR(target.get_ptr() + descriptor->Name);
|
||||
|
||||
auto name_table_entry = reinterpret_cast<uintptr_t*>(
|
||||
target.get_ptr() + descriptor->OriginalFirstThunk);
|
||||
auto address_table_entry =
|
||||
reinterpret_cast<uintptr_t*>(target.get_ptr() + descriptor->FirstThunk);
|
||||
|
||||
if (!descriptor->OriginalFirstThunk) {
|
||||
name_table_entry = reinterpret_cast<uintptr_t*>(target.get_ptr() +
|
||||
descriptor->FirstThunk);
|
||||
}
|
||||
|
||||
while (*name_table_entry) {
|
||||
FARPROC function = nullptr;
|
||||
std::string function_name;
|
||||
const char* function_procname;
|
||||
|
||||
if (IMAGE_SNAP_BY_ORDINAL(*name_table_entry)) {
|
||||
function_name = "#" + std::to_string(IMAGE_ORDINAL(*name_table_entry));
|
||||
function_procname = MAKEINTRESOURCEA(IMAGE_ORDINAL(*name_table_entry));
|
||||
} else {
|
||||
auto* import =
|
||||
PIMAGE_IMPORT_BY_NAME(target.get_ptr() + *name_table_entry);
|
||||
function_name = import->Name;
|
||||
function_procname = function_name.data();
|
||||
}
|
||||
|
||||
if (this->import_resolver_)
|
||||
function = FARPROC(this->import_resolver_(name, function_name));
|
||||
|
||||
if (!function) {
|
||||
auto library = utils::nt::library::load(name);
|
||||
if (library) {
|
||||
function = GetProcAddress(library, function_procname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function) {
|
||||
throw std::runtime_error(
|
||||
utils::string::va("Unable to load import '{0}' from library {1}'",
|
||||
function_name, name));
|
||||
}
|
||||
|
||||
utils::hook::set(address_table_entry,
|
||||
reinterpret_cast<uintptr_t>(function));
|
||||
|
||||
name_table_entry++;
|
||||
address_table_entry++;
|
||||
}
|
||||
|
||||
descriptor++;
|
||||
}
|
||||
}
|
||||
|
||||
void loader::load_tls(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const {
|
||||
if (!target.get_optional_header()
|
||||
->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]
|
||||
.Size) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* target_tls = tls::allocate_tls_index();
|
||||
const auto* const source_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(
|
||||
target.get_ptr() + target.get_optional_header()
|
||||
->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]
|
||||
.VirtualAddress);
|
||||
|
||||
auto* target_tls_start = PVOID(target_tls->StartAddressOfRawData);
|
||||
auto* tls_start = PVOID(source_tls->StartAddressOfRawData);
|
||||
const auto tls_size =
|
||||
source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData;
|
||||
const auto tls_index = *reinterpret_cast<DWORD*>(target_tls->AddressOfIndex);
|
||||
|
||||
utils::hook::set<DWORD>(source_tls->AddressOfIndex, tls_index);
|
||||
|
||||
if (target_tls->AddressOfCallBacks) {
|
||||
utils::hook::set<void*>(target_tls->AddressOfCallBacks, nullptr);
|
||||
}
|
||||
|
||||
DWORD old_protect;
|
||||
VirtualProtect(target_tls_start, tls_size, PAGE_READWRITE, &old_protect);
|
||||
|
||||
auto* const tls_base =
|
||||
*reinterpret_cast<LPVOID*>(__readfsdword(0x2C) + 4 * tls_index);
|
||||
std::memmove(tls_base, tls_start, tls_size);
|
||||
std::memmove(target_tls_start, tls_start, tls_size);
|
||||
|
||||
VirtualProtect(target_tls, sizeof(*target_tls), PAGE_READWRITE, &old_protect);
|
||||
*target_tls = *source_tls;
|
||||
}
|
25
src/client/loader/loader.hpp
Normal file
25
src/client/loader/loader.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
class loader final {
|
||||
public:
|
||||
FARPROC load(const utils::nt::library& library,
|
||||
const std::string& buffer) const;
|
||||
FARPROC load_library(const std::string& filename) const;
|
||||
|
||||
void set_import_resolver(
|
||||
const std::function<void*(const std::string&, const std::string&)>&
|
||||
resolver);
|
||||
|
||||
private:
|
||||
std::function<void*(const std::string&, const std::string&)> import_resolver_;
|
||||
|
||||
static void load_section(const utils::nt::library& target,
|
||||
const utils::nt::library& source,
|
||||
IMAGE_SECTION_HEADER* section);
|
||||
void load_sections(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const;
|
||||
void load_imports(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const;
|
||||
void load_tls(const utils::nt::library& target,
|
||||
const utils::nt::library& source) const;
|
||||
};
|
34
src/client/loader/tls.cpp
Normal file
34
src/client/loader/tls.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <std_include.hpp>
|
||||
#include "tls.hpp"
|
||||
|
||||
#include <utils/nt.hpp>
|
||||
#include <utils/binary_resource.hpp>
|
||||
|
||||
#include <resource.hpp>
|
||||
|
||||
namespace tls {
|
||||
namespace {
|
||||
utils::binary_resource tls_dll_file(TLS_DLL, "iw4sp-tlsdll.dll");
|
||||
}
|
||||
|
||||
PIMAGE_TLS_DIRECTORY allocate_tls_index() {
|
||||
static auto already_allocated = false;
|
||||
if (already_allocated) {
|
||||
throw std::runtime_error(
|
||||
"Currently only a single allocation is supported!");
|
||||
}
|
||||
|
||||
already_allocated = true;
|
||||
|
||||
const auto dll_path = tls_dll_file.get_extracted_file();
|
||||
const auto tls_dll = utils::nt::library::load(dll_path);
|
||||
if (!tls_dll) {
|
||||
throw std::runtime_error("Failed to load TLS DLL");
|
||||
}
|
||||
|
||||
return reinterpret_cast<PIMAGE_TLS_DIRECTORY>(
|
||||
tls_dll.get_ptr() + tls_dll.get_optional_header()
|
||||
->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]
|
||||
.VirtualAddress);
|
||||
}
|
||||
} // namespace tls
|
5
src/client/loader/tls.hpp
Normal file
5
src/client/loader/tls.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace tls {
|
||||
PIMAGE_TLS_DIRECTORY allocate_tls_index();
|
||||
}
|
150
src/client/main.cpp
Normal file
150
src/client/main.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
#include "std_include.hpp"
|
||||
#include <utils/nt.hpp>
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include "loader/binary_loader.hpp"
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "loader/loader.hpp"
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include <version.hpp>
|
||||
#include <DbgHelp.h>
|
||||
|
||||
LONG WINAPI exception_handler(PEXCEPTION_POINTERS exception_info) {
|
||||
if (exception_info->ExceptionRecord->ExceptionCode == 0x406D1388) {
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
if (exception_info->ExceptionRecord->ExceptionCode < 0x80000000 ||
|
||||
exception_info->ExceptionRecord->ExceptionCode == 0xE06D7363) {
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION exception_information = {
|
||||
GetCurrentThreadId(), exception_info, FALSE};
|
||||
const auto type = MiniDumpIgnoreInaccessibleMemory //
|
||||
| MiniDumpWithHandleData //
|
||||
| MiniDumpScanMemory //
|
||||
| MiniDumpWithProcessThreadData //
|
||||
| MiniDumpWithFullMemoryInfo //
|
||||
| MiniDumpWithThreadInfo;
|
||||
|
||||
CreateDirectoryA("minidumps", nullptr);
|
||||
const auto* file_name =
|
||||
utils::string::va("minidumps\\iw4-sp_{0}.dmp", SHORTVERSION);
|
||||
constexpr auto file_share = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
const auto file_handle =
|
||||
CreateFileA(file_name, GENERIC_WRITE | GENERIC_READ, file_share, nullptr,
|
||||
CREATE_ALWAYS, NULL, nullptr);
|
||||
|
||||
if (!MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
|
||||
file_handle, static_cast<MINIDUMP_TYPE>(type),
|
||||
&exception_information, nullptr, nullptr)) {
|
||||
char buf[4096]{};
|
||||
sprintf_s(buf, "An exception 0x%08X occurred at location 0x%p\n",
|
||||
exception_info->ExceptionRecord->ExceptionCode,
|
||||
exception_info->ExceptionRecord->ExceptionAddress);
|
||||
MessageBoxA(nullptr, buf, "Fatal Error", MB_ICONERROR);
|
||||
}
|
||||
|
||||
CloseHandle(file_handle);
|
||||
TerminateProcess(GetCurrentProcess(),
|
||||
exception_info->ExceptionRecord->ExceptionCode);
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
DECLSPEC_NORETURN void WINAPI exit_hook(const int code) {
|
||||
component_loader::pre_destroy();
|
||||
std::exit(code);
|
||||
}
|
||||
|
||||
FARPROC load_binary() {
|
||||
loader loader;
|
||||
utils::nt::library self;
|
||||
|
||||
loader.set_import_resolver(
|
||||
[self](const std::string& library, const std::string& function) -> void* {
|
||||
if (library == "steam_api.dll") {
|
||||
return self.get_proc<FARPROC>(function);
|
||||
}
|
||||
if (function == "ExitProcess") {
|
||||
return exit_hook;
|
||||
}
|
||||
|
||||
return component_loader::load_import(library, function);
|
||||
});
|
||||
|
||||
const auto buffer = binary_loader::load();
|
||||
return loader.load(self, buffer);
|
||||
}
|
||||
|
||||
void enable_dpi_awareness() {
|
||||
const utils::nt::library user32{"user32.dll"};
|
||||
const auto set_dpi =
|
||||
user32 ? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>(
|
||||
"SetProcessDpiAwarenessContext")
|
||||
: nullptr;
|
||||
if (set_dpi) {
|
||||
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
}
|
||||
}
|
||||
|
||||
void apply_environment() {
|
||||
char* buffer{};
|
||||
std::size_t size{};
|
||||
if (_dupenv_s(&buffer, &size, "MW2_INSTALL") != 0 || buffer == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto _ = gsl::finally([&] { std::free(buffer); });
|
||||
|
||||
SetCurrentDirectoryA(buffer);
|
||||
SetDllDirectoryA(buffer);
|
||||
}
|
||||
|
||||
int main() {
|
||||
AddVectoredExceptionHandler(0, exception_handler);
|
||||
SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
|
||||
|
||||
FARPROC entry_point;
|
||||
enable_dpi_awareness();
|
||||
|
||||
std::srand(std::uint32_t(time(nullptr)) ^
|
||||
~(GetTickCount() * GetCurrentProcessId()));
|
||||
|
||||
{
|
||||
auto premature_shutdown = true;
|
||||
const auto _0 = gsl::finally([&premature_shutdown] {
|
||||
if (premature_shutdown) {
|
||||
component_loader::pre_destroy();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
apply_environment();
|
||||
|
||||
if (!component_loader::post_start())
|
||||
return 0;
|
||||
|
||||
entry_point = load_binary();
|
||||
if (!entry_point) {
|
||||
throw std::runtime_error("Unable to load binary into memory");
|
||||
}
|
||||
|
||||
if (!component_loader::post_load())
|
||||
return 0;
|
||||
|
||||
premature_shutdown = false;
|
||||
} catch (const std::exception& ex) {
|
||||
MessageBoxA(nullptr, ex.what(), "ERROR", MB_ICONERROR);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return entry_point();
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE, HINSTANCE, PSTR, int) { return main(); }
|
8
src/client/resource.hpp
Normal file
8
src/client/resource.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#define ID_ICON 102
|
||||
|
||||
#define TLS_DLL 301
|
||||
#define RUNNER 302
|
||||
|
||||
#define ICON_IMAGE 303
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user