├── .gitignore
├── Contributing.md
├── LICENSE
├── Ultimanite.sln
└── Ultimanite
├── Ultimanite.vcxproj
├── Ultimanite.vcxproj.filters
├── dllmain.cpp
├── enums.h
├── framework.h
├── gameplay.h
├── httplib.h
├── packages.config
├── patterns.h
├── script.h
├── script_wrappers.h
├── sdk.h
├── source
├── duk_config.h
├── duk_source_meta.json
├── duktape.c
└── duktape.h
├── structs.h
├── ue4.h
├── util.h
└── xorstr.hpp
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Nuget personal access tokens and Credentials
210 | nuget.config
211 |
212 | # Microsoft Azure Build Output
213 | csx/
214 | *.build.csdef
215 |
216 | # Microsoft Azure Emulator
217 | ecf/
218 | rcf/
219 |
220 | # Windows Store app package directories and files
221 | AppPackages/
222 | BundleArtifacts/
223 | Package.StoreAssociation.xml
224 | _pkginfo.txt
225 | *.appx
226 | *.appxbundle
227 | *.appxupload
228 |
229 | # Visual Studio cache files
230 | # files ending in .cache can be ignored
231 | *.[Cc]ache
232 | # but keep track of directories ending in .cache
233 | !?*.[Cc]ache/
234 |
235 | # Others
236 | ClientBin/
237 | ~$*
238 | *~
239 | *.dbmdl
240 | *.dbproj.schemaview
241 | *.jfm
242 | *.pfx
243 | *.publishsettings
244 | orleans.codegen.cs
245 |
246 | # Including strong name files can present a security risk
247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
248 | #*.snk
249 |
250 | # Since there are multiple workflows, uncomment next line to ignore bower_components
251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
252 | #bower_components/
253 |
254 | # RIA/Silverlight projects
255 | Generated_Code/
256 |
257 | # Backup & report files from converting an old project file
258 | # to a newer Visual Studio version. Backup files are not needed,
259 | # because we have git ;-)
260 | _UpgradeReport_Files/
261 | Backup*/
262 | UpgradeLog*.XML
263 | UpgradeLog*.htm
264 | ServiceFabricBackup/
265 | *.rptproj.bak
266 |
267 | # SQL Server files
268 | *.mdf
269 | *.ldf
270 | *.ndf
271 |
272 | # Business Intelligence projects
273 | *.rdl.data
274 | *.bim.layout
275 | *.bim_*.settings
276 | *.rptproj.rsuser
277 | *- [Bb]ackup.rdl
278 | *- [Bb]ackup ([0-9]).rdl
279 | *- [Bb]ackup ([0-9][0-9]).rdl
280 |
281 | # Microsoft Fakes
282 | FakesAssemblies/
283 |
284 | # GhostDoc plugin setting file
285 | *.GhostDoc.xml
286 |
287 | # Node.js Tools for Visual Studio
288 | .ntvs_analysis.dat
289 | node_modules/
290 |
291 | # Visual Studio 6 build log
292 | *.plg
293 |
294 | # Visual Studio 6 workspace options file
295 | *.opt
296 |
297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
298 | *.vbw
299 |
300 | # Visual Studio LightSwitch build output
301 | **/*.HTMLClient/GeneratedArtifacts
302 | **/*.DesktopClient/GeneratedArtifacts
303 | **/*.DesktopClient/ModelManifest.xml
304 | **/*.Server/GeneratedArtifacts
305 | **/*.Server/ModelManifest.xml
306 | _Pvt_Extensions
307 |
308 | # Paket dependency manager
309 | .paket/paket.exe
310 | paket-files/
311 |
312 | # FAKE - F# Make
313 | .fake/
314 |
315 | # CodeRush personal settings
316 | .cr/personal
317 |
318 | # Python Tools for Visual Studio (PTVS)
319 | __pycache__/
320 | *.pyc
321 |
322 | # Cake - Uncomment if you are using it
323 | # tools/**
324 | # !tools/packages.config
325 |
326 | # Tabs Studio
327 | *.tss
328 |
329 | # Telerik's JustMock configuration file
330 | *.jmconfig
331 |
332 | # BizTalk build output
333 | *.btp.cs
334 | *.btm.cs
335 | *.odx.cs
336 | *.xsd.cs
337 |
338 | # OpenCover UI analysis results
339 | OpenCover/
340 |
341 | # Azure Stream Analytics local run output
342 | ASALocalRun/
343 |
344 | # MSBuild Binary and Structured Log
345 | *.binlog
346 |
347 | # NVidia Nsight GPU debugger configuration file
348 | *.nvuser
349 |
350 | # MFractors (Xamarin productivity tool) working folder
351 | .mfractor/
352 |
353 | # Local History for Visual Studio
354 | .localhistory/
355 |
356 | # BeatPulse healthcheck temp database
357 | healthchecksdb
358 |
359 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
360 | MigrationBackup/
361 |
362 | # Ionide (cross platform F# VS Code tools) working folder
363 | .ionide/
364 |
365 | # Fody - auto-generated XML schema
366 | FodyWeavers.xsd
367 |
368 | # VS Code files for those working on multiple tools
369 | .vscode/*
370 | !.vscode/settings.json
371 | !.vscode/tasks.json
372 | !.vscode/launch.json
373 | !.vscode/extensions.json
374 | *.code-workspace
375 |
376 | # Local History for Visual Studio Code
377 | .history/
378 |
379 | # Windows Installer files from build outputs
380 | *.cab
381 | *.msi
382 | *.msix
383 | *.msm
384 | *.msp
385 |
386 | # JetBrains Rider
387 | .idea/
388 | *.sln.iml
--------------------------------------------------------------------------------
/Contributing.md:
--------------------------------------------------------------------------------
1 | # Ultimanite Coding Style and Guidlines
2 |
3 | # Main sections
4 | - [C++ coding style and formatting](#cpp-coding-style-and-formatting)
5 | - [C++ code-specific guidelines](#cpp-code-specific-guidelines)
6 |
7 | # C++ coding style and formatting
8 |
9 | Summary:
10 |
11 | - [General](#cpp-style-general)
12 | - [Naming](#cpp-style-naming)
13 | - [Conditionals](#cpp-style-conditionals)
14 | - [Classes and structs](#cpp-style-classes-and-structs)
15 | - [UE4](#cpp-code-ue4)
16 |
17 | ## General
18 | - Try to limit lines of code to a maximum of 100 characters.
19 | - Note that this does not mean you should try and use all 100 characters every time you have the chance. Typically with well formatted code, you normally shouldn't hit a line count of anything over 80 or 90 characters.
20 | - The indentation style we use is 2 spaces per level.
21 | - The opening brace for namespaces, classes, functions, enums, structs, unions, conditionals, and loops go on the next line.
22 | - With array initializer lists and lambda expressions it is OK to keep the brace on the same line.
23 | - References and pointers have the ampersand or asterisk against the type name, not the variable name. Example: `int* var`, not `int *var`.
24 | - Use multi-line comments (`/* Comment text */`) for multi-lines and parameters, use single-line comments (`// Comment text`) otherwise.
25 | - Always make sure you are doing whatever you are doing under the correct file context, make sure to read everything and check for duplications.
26 |
27 | ## Naming
28 | - All variables, class, enum, function, and struct names should be in upper CamelCase. If the name contains an abbreviation uppercase it.
29 | - `class SomeClassName`
30 | - `enum IPCCommandType`
31 | - All compile time constants should be fully uppercased. With constants that have more than one word in them, use an underscore to separate them.
32 | - `constexpr double PI = 3.14159;`
33 | - `constexpr int MAX_PATH = 260;`
34 | - Please do not use [Hungarian notation](http://en.wikipedia.org/wiki/Hungarian_notation) prefixes with variables. The only exceptions to this are the variable prefixes below.
35 | - Global variables – `g`
36 | - Class variables – `m`
37 | - Static variables – `s`
38 | - Keep every context in a namespace, keep every context in a seprated file if possible.
39 | ## Conditionals
40 | - Do not leave `else` or `else if` conditions dangling unless the `if` condition lacks braces.
41 | - Yes:
42 |
43 | ```c++
44 | if (condition)
45 | {
46 | // code
47 | }
48 | else
49 | {
50 | // code
51 | }
52 | ```
53 | - Acceptable:
54 |
55 | ```c++
56 | if (condition)
57 | // code line
58 | else
59 | // code line
60 | ```
61 | - No:
62 |
63 | ```c++
64 | if (condition)
65 | {
66 | // code
67 | }
68 | else
69 | // code line
70 | ```
71 |
72 |
73 | ## Classes and structs
74 | - If making a [POD](http://en.wikipedia.org/wiki/Plain_Old_Data_Structures) type, use a `struct` for this. Use a `class` otherwise.
75 | - Class layout should be in the order, `private`, `protected`, and then `public`.
76 | - If one or more of these sections are not needed, then simply don't include them.
77 | - For each of the above specified access levels, the contents of each should follow this given order: constructor, destructor, operator overloads, functions, then variables.
78 | - When defining the variables, define `static` variables before the non-static ones.
79 |
80 | ```c++
81 | class ExampleClass : public SomeParent
82 | {
83 | public:
84 | ExampleClass(int x, int y);
85 |
86 | int GetX() const;
87 | int GetY() const;
88 |
89 | protected:
90 | virtual void SomeProtectedFunction() = 0;
91 | static float SomeVariable;
92 |
93 | private:
94 | int m_x;
95 | int m_y;
96 | };
97 | ```
98 |
99 | # C++ code-specific guidelines
100 |
101 | Summary:
102 |
103 | - [General](#cpp-code-general)
104 | - [Headers](#cpp-code-headers)
105 | - [Loops](#cpp-code-loops)
106 | - [Functions](#cpp-code-functions)
107 | - [Classes and Structs](#cpp-code-classes-and-structs)
108 |
109 | ## General
110 | - The codebase currently uses C++20 (Latest).
111 | - Use the [nullptr](http://en.cppreference.com/w/cpp/language/nullptr) type over the macro `NULL`.
112 | - If a [range-based for loop](http://en.cppreference.com/w/cpp/language/range-for) can be used instead of container iterators, use it.
113 | - Obviously, try not to use `goto` unless you have a *really* good reason for it.
114 | - If a compiler warning is found, please try and fix it.
115 | - Try to avoid using raw pointers (pointers allocated with `new`) as much as possible. There are cases where using a raw pointer is unavoidable, and in these situations it is OK to use them. An example of this is functions from a C library that require them. In cases where it is avoidable, the STL usually has a means to solve this (`vector`, `unique_ptr`, etc).
116 | - Do not use the `auto` keyword everywhere. While it's nice that the type can be determined by the compiler, it cannot be resolved at 'readtime' by the developer as easily. Use auto only in cases where it is obvious what the type being assigned is (note: 'obvious' means not having to open other files or reading the header file). Some situations where it is appropriate to use `auto` is when iterating over a `std::map` container in a foreach loop, or to shorten the length of container iterator variable declarations.
117 | - Do not use `using namespace [x];` in headers. Try not to use it at all if you can.
118 | - The preferred form of the increment and decrement operator in for-loops is prefix-form (e.g. `++var`).
119 |
120 | ## Headers
121 | - All needed headers should be included in framework header, include any new header files in the framework header.
122 | - If you find duplicate includes of a certain header, remove it.
123 | - Each of the above header sections should also be in importance order.
124 | - This project uses `#pragma once` as header guards.
125 |
126 | ## Loops
127 | - If an infinite loop is required, do not use `for (;;)`, use `while (true)`.
128 | - Empty-bodied loops should use braces after their header, not a semicolon.
129 | - Yes: `while (condition) {}`
130 | - No: `while (condition);`
131 | - For do-while loops, place 'while' on the same line as the closing brackets
132 |
133 | ```c++
134 | do
135 | {
136 | // code
137 | } while (false);
138 | ```
139 |
140 | ## Functions
141 | - If a function parameter is a pointer or reference and its value or data isn't intended to be changed, please mark that parameter as `const`.
142 | - Functions that specifically modify their parameters should have the respective parameter(s) marked as a pointer so that the variables being modified are syntaxically obvious.
143 | - What not to do:
144 |
145 | ```c++
146 | template
147 | inline void Clamp(T& val, const T& min, const T& max)
148 | {
149 | if (val < min)
150 | val = min;
151 | else if (val > max)
152 | val = max;
153 | }
154 | ```
155 |
156 | Example call: `Clamp(var, 1000, 5000);`
157 |
158 | - What to do:
159 |
160 | ```c++
161 | template
162 | inline void Clamp(T* val, const T& min, const T& max)
163 | {
164 | if (*val < min)
165 | *val = min;
166 | else if (*val > max)
167 | *val = max;
168 | }
169 | ```
170 |
171 | Example call: `Clamp(&var, 1000, 5000);`
172 | - Otherwise, you can use references.
173 |
174 | - Class member functions that you do not want to be overridden in inheriting classes should be marked with the `final` specifier.
175 |
176 | ```c++
177 | class ClassName : ParentClass
178 | {
179 | public:
180 | void Update() final;
181 | };
182 | ```
183 |
184 | - Overridden member functions that can also be inherited should be marked with the `override` specifier to make it easier to see which functions belong to the parent class.
185 |
186 | ```c++
187 | class ClassName : ParentClass
188 | {
189 | public:
190 | void Update() override;
191 | };
192 | ```
193 |
194 | ## Classes and structs
195 | - Classes and structs that are not intended to be extended through inheritance should be marked with the `final` specifier.
196 |
197 | ```c++
198 | class ClassName final : ParentClass
199 | {
200 | // Class definitions
201 | };
202 | ```
203 |
204 |
205 | ## UE4
206 | - ProcessEvent is the game thread, about 80% of game calles are passed thorugh ProcessEvent, You should be very cautious adding anything to the processevent hook.
207 | - **Donot** use inline functions inside the hook, use static functions instead.
208 | - Force inline if the function is a class member getter.
209 | - If you have to add some blocking code to a ufunction hook inside processevent hook (e.g: Finding alot of objects when `xxxx` is called), then hook `xxxx` **directly** by doing `DetourAttach(&(UFunction->Func), xxxxHook);`.
210 | - Avoid using `GetAsyncKeyState`, Use proper ufunction hook if possible, if not use UE4 input hook, direct input hook.
211 |
212 | - Don't call ProcessEvent directly unless necessary.
213 | - Don't:
214 |
215 | ```c++
216 | static UObject* SwitchLevel = FindObject(L"Function /Script/Engine.PlayerController.SwitchLevel");
217 |
218 | struct {
219 | FString URL = L"...";
220 | } Params;
221 |
222 | ProcessEvent(InController, SwitchLevel, &Prams);
223 | ```
224 |
225 | - Do :
226 | ```c++
227 | static UObject* SwitchLevel = FindObject(L"Function /Script/Engine.PlayerController.SwitchLevel");
228 | auto ret = Controller->Call* RETURN TYPE IF EXISTS */>(SwitchLevel, FString(L"...") /* ACCEPTS ANY NUMBER\TYPE OF PARAMS */);
229 | ```
230 |
231 | - if you are going to use hardcoded offset outside of a full class\struct, please cast the pointer to `uintptr_t` and add the offset to it instead of make a full struct.
232 |
233 | - Check for invalid pointers by doing `UObject.isValid()` or `IsBadReadPtr`, sometimes pointers can be valid but not valid for reading.
234 |
235 | - If you are finding the same object over and over make sure to define the variable as `static`.
236 |
237 | - Avoid allocation, reallocating memory manually unless needed.
238 |
239 | - If FNameToString was used directly, make sure to free the memory.
240 |
241 | - Feel free to copy any needed classes from the sdk, but make sure to implement all classes it needs and not feel it with padding.
242 |
243 | - **Everything** is a wide string, only use normal strings if necessary, all classes has functions for both string types.
244 |
245 | - **Don't** use C Strings unless necessary, use STD strings in normal cases.
246 |
247 | - Avoid copying strings over and over, use references when possible.
248 |
249 | ------
250 |
251 | - Please, try to be as strict as possible applying these guidelines to maintain a stable project shape.
252 | - Keep in mind, Exceptions can be made, you can ask me `kemo#1337` for any help or style tips.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Ultimanite.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31105.61
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ultimanite", "Ultimanite\Ultimanite.vcxproj", "{573E06F0-042C-4EDB-AF95-E6894A481639}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Debug|x64.ActiveCfg = Debug|x64
17 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Debug|x64.Build.0 = Debug|x64
18 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Debug|x86.ActiveCfg = Debug|Win32
19 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Debug|x86.Build.0 = Debug|Win32
20 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Release|x64.ActiveCfg = Release|x64
21 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Release|x64.Build.0 = Release|x64
22 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Release|x86.ActiveCfg = Release|Win32
23 | {573E06F0-042C-4EDB-AF95-E6894A481639}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {C1804CAD-5AB4-416F-8126-5C57E6E41F5D}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Ultimanite/Ultimanite.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {573e06f0-042c-4edb-af95-e6894a481639}
25 | Ultimanite
26 | 10.0
27 |
28 |
29 |
30 | DynamicLibrary
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | DynamicLibrary
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | DynamicLibrary
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | DynamicLibrary
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | $(SolutionDir)\bin
76 |
77 |
78 | false
79 | $(SolutionDir)\bin
80 |
81 |
82 | true
83 | $(SolutionDir)\bin
84 | $(IncludePath)
85 |
86 |
87 | false
88 | $(SolutionDir)\bin
89 | $(IncludePath)
90 |
91 |
92 | true
93 |
94 |
95 | true
96 |
97 |
98 | true
99 |
100 |
101 | true
102 |
103 |
104 |
105 | Level3
106 | true
107 | WIN32;_DEBUG;ULTIMANITE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
108 | true
109 | Use
110 | pch.h
111 | stdcpplatest
112 | stdc17
113 |
114 |
115 | Windows
116 | true
117 | false
118 |
119 |
120 |
121 |
122 | Level3
123 | true
124 | true
125 | true
126 | WIN32;NDEBUG;ULTIMANITE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
127 | true
128 | Use
129 | pch.h
130 | stdcpplatest
131 | stdc17
132 |
133 |
134 | Windows
135 | true
136 | true
137 | true
138 | false
139 |
140 |
141 |
142 |
143 | Level3
144 | true
145 | _DEBUG;ULTIMANITE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
146 | true
147 | NotUsing
148 | pch.h
149 | stdcpplatest
150 | stdc17
151 |
152 |
153 | Windows
154 | true
155 | false
156 |
157 |
158 |
159 |
160 | Level3
161 | true
162 | true
163 | true
164 | NDEBUG;ULTIMANITE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
165 | true
166 | NotUsing
167 | pch.h
168 | stdcpplatest
169 | stdc17
170 |
171 |
172 | Windows
173 | true
174 | true
175 | true
176 | false
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
208 |
209 |
210 |
211 |
212 |
--------------------------------------------------------------------------------
/Ultimanite/Ultimanite.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Resource Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Header Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 | Header Files
58 |
59 |
60 | Header Files
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Ultimanite/dllmain.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include "framework.h"
20 | #include "gameplay.h"
21 | #include "patterns.h"
22 |
23 | void Setup()
24 | {
25 | Util::SetupConsole();
26 |
27 | EEngineVersion CurrentVersion = EEngineVersion::None;
28 |
29 | auto GObjectsAddress = Util::FindPattern(UE_4_20_GOBJECTS);
30 | auto ToStringAddress = Util::FindPattern(UE_4_20_FNAME_TOSTRING);
31 | auto GetFirstPlayerControllerAddress = Util::FindPattern(UE_4_20_GETFIRSTPLAYERCONTROLLER);
32 | auto SpawnActorFromClassAddress = Util::FindPattern(UE_4_20_SPAWNACTORFROMCLASS);
33 | auto LoadObjectAddress = Util::FindPattern(UE_4_20_LOADOBJECT);
34 | auto ConstructObjectAddress = Util::FindPattern(UE_4_20_CONSTRUCTOBJECT);
35 | auto FreeAddress = Util::FindPattern(UE_4_20_FREE);
36 |
37 | if (GObjectsAddress && ToStringAddress && GetFirstPlayerControllerAddress && SpawnActorFromClassAddress && ConstructObjectAddress && FreeAddress)
38 | {
39 | if (!LoadObjectAddress)
40 | {
41 | LoadObjectAddress = Util::FindPattern("4C 89 4C 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 48 8B EC 48 83 EC 78 33 C0");
42 | CurrentVersion = EEngineVersion::UE_4_20;
43 | }
44 | else
45 | {
46 | CurrentVersion = EEngineVersion::UE_4_20;
47 | }
48 |
49 | }
50 |
51 | // not able to find any version yet, lets try again
52 | if (CurrentVersion == EEngineVersion::None)
53 | {
54 | GObjectsAddress = Util::FindPattern(UE_4_21_GOBJECTS);
55 | ToStringAddress = Util::FindPattern(UE_4_21_FNAME_TOSTRING);
56 | GetFirstPlayerControllerAddress = Util::FindPattern(UE_4_21_GETFIRSTPLAYERCONTROLLER);
57 | SpawnActorFromClassAddress = Util::FindPattern(UE_4_21_SPAWNACTORFROMCLASS);
58 | LoadObjectAddress = Util::FindPattern(UE_4_21_LOADOBJECT);
59 | ConstructObjectAddress = Util::FindPattern(UE_4_21_CONSTRUCTOBJECT);
60 | FreeAddress = Util::FindPattern(UE_4_21_FREE);
61 |
62 | if (GObjectsAddress && ToStringAddress && GetFirstPlayerControllerAddress && SpawnActorFromClassAddress && LoadObjectAddress && ConstructObjectAddress && FreeAddress)
63 | {
64 | CurrentVersion = EEngineVersion::UE_4_21;
65 | }
66 | }
67 |
68 | // not able to find any version yet, lets try again
69 | if (CurrentVersion == EEngineVersion::None)
70 | {
71 | GObjectsAddress = Util::FindPattern(UE_4_22_GOBJECTS);
72 | ToStringAddress = Util::FindPattern(UE_4_22_FNAME_TOSTRING);
73 | GetFirstPlayerControllerAddress = Util::FindPattern(UE_4_22_GETFIRSTPLAYERCONTROLLER);
74 | SpawnActorFromClassAddress = Util::FindPattern(UE_4_22_SPAWNACTORFROMCLASS);
75 | LoadObjectAddress = Util::FindPattern(UE_4_22_LOADOBJECT);
76 | ConstructObjectAddress = Util::FindPattern(UE_4_22_CONSTRUCTOBJECT);
77 | FreeAddress = Util::FindPattern(UE_4_22_FREE);
78 |
79 | if (GObjectsAddress && ToStringAddress && GetFirstPlayerControllerAddress && SpawnActorFromClassAddress && LoadObjectAddress && ConstructObjectAddress && FreeAddress)
80 | {
81 | CurrentVersion = EEngineVersion::UE_4_22;
82 | }
83 | }
84 |
85 | if (CurrentVersion == EEngineVersion::None)
86 | {
87 | printf("Unsupported Engine version!\n");
88 | return;
89 | }
90 |
91 | auto ObjectsOffset = *(int32_t*)(GObjectsAddress + 3);
92 | auto FinalObjectsAddress = GObjectsAddress + 7 + ObjectsOffset;
93 |
94 | if (CurrentVersion >= EEngineVersion::UE_4_21)
95 | {
96 | // support recent version of GObjects
97 | GlobalObjects = decltype(GlobalObjects)(FinalObjectsAddress);
98 | }
99 | else
100 | {
101 | // support legacy version of GObjects
102 | ObjObjects = decltype(ObjObjects)(FinalObjectsAddress);
103 | }
104 |
105 | FNameToString = decltype(FNameToString)(ToStringAddress);
106 | GetFirstPlayerController = decltype(GetFirstPlayerController)(GetFirstPlayerControllerAddress);
107 | SpawnActor = decltype(SpawnActor)(SpawnActorFromClassAddress);
108 | StaticConstructObjectInternal = decltype(StaticConstructObjectInternal)(ConstructObjectAddress);
109 | StaticLoadObjectInternal = decltype(StaticLoadObjectInternal)(LoadObjectAddress);
110 | FreeInternal = decltype(FreeInternal)(FreeAddress);
111 |
112 | auto CurrentEngineVersion = std::stof(RuntimeOptions::GetFortniteVersion());
113 |
114 | if (7.4 <= CurrentEngineVersion && !strstr(RuntimeOptions::GetFortniteVersion().c_str(), "8"))
115 | {
116 | ProcessEvent = decltype(ProcessEvent)(FindObject(L"FortEngine_")->VTableObject[0x41]);
117 | }
118 | else
119 | {
120 | ProcessEvent = decltype(ProcessEvent)(FindObject(L"FortEngine_")->VTableObject[0x40]);
121 | }
122 |
123 | // we are ready to enter a game
124 | Game::Setup();
125 | }
126 |
127 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
128 | {
129 | if (reason == DLL_PROCESS_ATTACH)
130 | {
131 | Setup();
132 | }
133 |
134 | return TRUE;
135 | }
136 |
--------------------------------------------------------------------------------
/Ultimanite/enums.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | enum EObjectFlags
22 | {
23 | RF_NoFlags = 0x00000000,
24 | RF_Public = 0x00000001,
25 | RF_Standalone = 0x00000002,
26 | RF_MarkAsNative = 0x00000004,
27 | RF_Transactional = 0x00000008,
28 | RF_ClassDefaultObject = 0x00000010,
29 | RF_ArchetypeObject = 0x00000020,
30 | RF_Transient = 0x00000040,
31 | RF_MarkAsRootSet = 0x00000080,
32 | RF_TagGarbageTemp = 0x00000100,
33 | RF_NeedInitialization = 0x00000200,
34 | RF_NeedLoad = 0x00000400,
35 | RF_KeepForCooker = 0x00000800,
36 | RF_NeedPostLoad = 0x00001000,
37 | RF_NeedPostLoadSubobjects = 0x00002000,
38 | RF_NewerVersionExists = 0x00004000,
39 | RF_BeginDestroyed = 0x00008000,
40 | RF_FinishDestroyed = 0x00010000,
41 | RF_BeingRegenerated = 0x00020000,
42 | RF_DefaultSubObject = 0x00040000,
43 | RF_WasLoaded = 0x00080000,
44 | RF_TextExportTransient = 0x00100000,
45 | RF_LoadCompleted = 0x00200000,
46 | RF_InheritableComponentTemplate = 0x00400000,
47 | RF_DuplicateTransient = 0x00800000,
48 | RF_StrongRefOnFrame = 0x01000000,
49 | RF_NonPIEDuplicateTransient = 0x02000000,
50 | RF_Dynamic = 0x04000000,
51 | RF_WillBeLoaded = 0x08000000,
52 | };
53 |
54 | enum class ESpawnActorNameMode : uint8_t
55 | {
56 | Required_Fatal,
57 | Required_ErrorAndReturnNull,
58 | Required_ReturnNull,
59 | Requested
60 | };
61 |
62 | enum class ESpawnActorCollisionHandlingMethod : uint8_t
63 | {
64 | Undefined = 0,
65 | AlwaysSpawn = 1,
66 | AdjustIfPossibleButAlwaysSpawn = 2,
67 | AdjustIfPossibleButDontSpawnIfColliding = 3,
68 | DontSpawnIfColliding = 4,
69 | ESpawnActorCollisionHandlingMethod_MAX = 5
70 | };
71 |
72 | enum class EAthenaGamePhase : uint8_t
73 | {
74 | None = 0,
75 | Setup = 1,
76 | Warmup = 2,
77 | Aircraft = 3,
78 | SafeZones = 4,
79 | EndGame = 5,
80 | Count = 6,
81 | EAthenaGamePhase_MAX = 7
82 | };
83 |
84 | enum class EFortCustomPartType : uint8_t
85 | {
86 | Head = 0,
87 | Body = 1,
88 | Hat = 2,
89 | Backpack = 3,
90 | Charm = 4,
91 | Face = 5,
92 | NumTypes = 6,
93 | EFortCustomPartType_MAX = 7
94 | };
95 |
96 | enum class ENetRole : uint8_t
97 | {
98 | ROLE_None = 0,
99 | ROLE_SimulatedProxy = 1,
100 | ROLE_AutonomousProxy = 2,
101 | ROLE_Authority = 3,
102 | ROLE_MAX = 4
103 | };
104 |
--------------------------------------------------------------------------------
/Ultimanite/framework.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #define JM_XORSTR_DISABLE_AVX_INTRINSICS //OLD CPU SUPPORT
22 |
23 | #define CPPHTTPLIB_OPENSSL_SUPPORT
24 |
25 | #include "httplib.h"
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | #include "source/duktape.h"
37 | #include "xorstr.hpp"
38 | #define _(str) xorstr_(str)
39 |
40 | //always the last
41 | #include "enums.h"
42 | #include "util.h"
43 | #include "structs.h"
44 | #include "ue4.h"
45 | #include "sdk.h"
46 | #include "script.h"
--------------------------------------------------------------------------------
/Ultimanite/gameplay.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "framework.h"
22 |
23 | namespace Game
24 | {
25 | inline bool bReady = false;
26 | inline bool bDroppedLoadingScreen = false;
27 |
28 | static void SpawnPickupAtLocation(UObject* ItemDefinition, int Count, FVector Location)
29 | {
30 | auto FortPickupAthena = SpawnActorEasy(GetWorld(), FindObject(L"Class /Script/FortniteGame.FortPickupAthena"), Location, {});
31 |
32 | auto EntryCount = reinterpret_cast(__int64(FortPickupAthena) + __int64(Offsets::PrimaryPickupItemEntryOffset) + __int64(Offsets::CountOffset));
33 | auto EntryItemDefinition = reinterpret_cast(__int64(FortPickupAthena) + __int64(Offsets::PrimaryPickupItemEntryOffset) + __int64(Offsets::ItemDefinitionOffset));
34 |
35 | *EntryCount = Count;
36 | *EntryItemDefinition = ItemDefinition;
37 |
38 | Pickup::OnRep_PrimaryPickupItemEntry(FortPickupAthena);
39 | Pickup::TossPickup(FortPickupAthena, Location, Globals::Pawn, 6, true);
40 | }
41 |
42 | static bool IsMatchingGuid(FGuid A, FGuid B)
43 | {
44 | return A.A == B.A && A.B == B.B && A.C == B.C && A.D == B.D;
45 | }
46 |
47 | static void EquipInventoryItem(FGuid Guid)
48 | {
49 | auto ItemInstances = reinterpret_cast*>(__int64(Globals::FortInventory) + __int64(Offsets::InventoryOffset) + __int64(Offsets::ItemInstancesOffset));
50 |
51 | for (int i = 0; i < ItemInstances->Num(); i++)
52 | {
53 | auto CurrentItemInstance = ItemInstances->operator[](i);
54 |
55 | // Does the GUID in the inventory match with the one we are trying to equip
56 | if (IsMatchingGuid(Player::GetGuid(CurrentItemInstance), Guid))
57 | {
58 | // if the GUIDs match, equip the weapon
59 | if (!7.4 <= std::stof(RuntimeOptions::GetFortniteVersion()))
60 | {
61 | Player::EquipWeaponByDefinition(Globals::Pawn, Player::GetItemDefinition(CurrentItemInstance), Guid);
62 | }
63 | else
64 | {
65 | Player::EquipWeaponDefinition(Globals::Pawn, Player::GetItemDefinition(CurrentItemInstance), Guid);
66 | }
67 |
68 | }
69 | }
70 | }
71 |
72 | static void HandlePickup(void* Params)
73 | {
74 | struct ServerHandlePickupParams
75 | {
76 | UObject* Pickup;
77 | float InFlyTime;
78 | FVector InStartDirection;
79 | bool bPlayPickupSound;
80 | };
81 |
82 | auto CurrentParams = (ServerHandlePickupParams*)Params;
83 |
84 | auto ItemInstances = reinterpret_cast*>(__int64(Globals::FortInventory) + __int64(Offsets::InventoryOffset) + __int64(Offsets::ItemInstancesOffset));
85 |
86 | if (CurrentParams->Pickup != nullptr)
87 | {
88 | // get world item definition from item entry
89 | UObject** WorldItemDefinition = reinterpret_cast(__int64(CurrentParams->Pickup) + __int64(Offsets::PrimaryPickupItemEntryOffset) + __int64(Offsets::ItemDefinitionOffset));
90 | TArray QuickbarSlots = *reinterpret_cast*>(reinterpret_cast(Globals::Quickbar) + Offsets::PrimaryQuickbarOffset + Offsets::SlotsOffset);
91 |
92 | for (int i = 0; i < QuickbarSlots.Num(); i++)
93 | {
94 | if (QuickbarSlots[i].Items.Data == 0)
95 | {
96 | if (i >= 6)
97 | {
98 | // no space left in inventory, we should replace the current focused quickbar with this new pickup.
99 | int* CurrentFocusedSlot = reinterpret_cast(__int64(Globals::Quickbar) + __int64(Offsets::PrimaryQuickbarOffset) + __int64(Offsets::CurrentFocusedSlotOffset));
100 |
101 | // do not replace pickaxe
102 | if (*CurrentFocusedSlot == 0)
103 | {
104 | continue;
105 | }
106 |
107 | i = *CurrentFocusedSlot;
108 |
109 | FGuid CurrentFocusedGUID = QuickbarSlots[*CurrentFocusedSlot].Items[0];
110 |
111 | // loop through item entries and see which item matches the current focused slot GUID
112 | for (int j = 0; i < ItemInstances->Num(); j++)
113 | {
114 | auto ItemInstance = ItemInstances->operator[](j);
115 |
116 | auto ItemEntryDefinition = reinterpret_cast(__int64(ItemInstance) + __int64(Offsets::ItemEntryOffset) + __int64(Offsets::ItemDefinitionOffset));
117 | auto ItemEntryGuid = reinterpret_cast(__int64(ItemInstance) + __int64(Offsets::ItemEntryOffset) + __int64(Offsets::ItemGuidOffset));
118 |
119 | if (IsMatchingGuid(CurrentFocusedGUID, *ItemEntryGuid))
120 | {
121 | // spawn the item we are replacing as a pickup
122 | SpawnPickupAtLocation(*ItemEntryDefinition, 1, AActor::GetLocation(Globals::Pawn));
123 | }
124 | }
125 |
126 | // empty current slot
127 | Player::EmptySlot(Globals::Quickbar, *CurrentFocusedSlot);
128 | }
129 |
130 | // give player item
131 | Inventory::AddItemToInventoryWithUpdate(*WorldItemDefinition, EFortQuickBars::Primary, i, 1);
132 |
133 | // destroy pickup in world
134 | AActor::Destroy(CurrentParams->Pickup);
135 |
136 | break;
137 | }
138 | }
139 | }
140 | }
141 |
142 | static void HandleInventoryDrop(void* Params)
143 | {
144 | struct ServerAttemptInventoryDropParams
145 | {
146 | FGuid ItemGuid;
147 | int Count;
148 | };
149 |
150 | auto PawnLocation = AActor::GetLocation(Globals::Pawn);
151 |
152 | auto ItemInstances = reinterpret_cast*>(__int64(Globals::FortInventory) + __int64(Offsets::InventoryOffset) + __int64(Offsets::ItemInstancesOffset));
153 | auto RequestedGuid = ((ServerAttemptInventoryDropParams*)Params)->ItemGuid;
154 |
155 | auto QuickbarSlots = *reinterpret_cast*>(__int64(Globals::Quickbar) + __int64(Offsets::PrimaryQuickbarOffset) + __int64(Offsets::SlotsOffset));
156 |
157 | for (int i = 0; i < QuickbarSlots.Num(); i++)
158 | {
159 | if (QuickbarSlots[i].Items.Data != nullptr)
160 | {
161 | if (IsMatchingGuid(QuickbarSlots[i].Items[0], RequestedGuid))
162 | {
163 | // remove item we are dropping from quickbars
164 | Player::EmptySlot(Globals::Quickbar, i);
165 |
166 | // update inventory due to quickbars being updated
167 | Inventory::UpdateInventory();
168 | }
169 | }
170 | }
171 |
172 | for (int i = 0; i < ItemInstances->Num(); i++)
173 | {
174 | auto CurrentItemInstance = ItemInstances->operator[](i);
175 | auto CurrentGuid = Player::GetGuid(CurrentItemInstance);
176 |
177 | if (IsMatchingGuid(CurrentGuid, RequestedGuid))
178 | {
179 | // we know this weapon is the one we want, fetch item definition from ItemEntry
180 | auto ItemDefinition = reinterpret_cast(__int64(CurrentItemInstance) + __int64(Offsets::ItemEntryOffset) + __int64(Offsets::ItemDefinitionOffset));
181 |
182 | if (ItemDefinition)
183 | {
184 | // spawn item we dropped as a pickup
185 | SpawnPickupAtLocation(*ItemDefinition, 1, PawnLocation);
186 | }
187 | }
188 | }
189 | }
190 |
191 | static void LoadMatch()
192 | {
193 | Globals::Controller = GetFirstPlayerController(GetWorld());
194 | Globals::GameState = FindObject(L"Athena_GameState_C /Game/Athena/Maps/Athena_Terrain.Athena_Terrain.PersistentLevel.Athena_GameState_C");
195 | Globals::GameMode = FindObject(L"Athena_GameMode_C /Game/Athena/Maps/Athena_Terrain.Athena_Terrain.PersistentLevel.Athena_GameMode_C");
196 |
197 | Globals::Pawn = SpawnActorEasy(GetWorld(), FindObject(L"BlueprintGeneratedClass /Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"), FVector{0, 0, 5000}, {});
198 |
199 | Player::K2_TeleportTo(Globals::Pawn, FVector{-280, 400, 5000}, {});
200 |
201 | Globals::PlayerState = *reinterpret_cast(reinterpret_cast(Globals::Controller) + Offsets::PlayerStateOffset);
202 |
203 | UObject* CheatManager = StaticConstructObjectInternal(FindObject(L"Class /Script/Engine.CheatManager"), Globals::Controller, 0, 0, 0, 0, 0, 0, 0);
204 |
205 | *reinterpret_cast(__int64(Globals::Controller) + __int64(Offsets::CheatManagerOffset)) = CheatManager;
206 |
207 | Globals::ChestsSound = FindObject(L"SoundCue /Game/Sounds/Foley_Loot/Containers/Treasure_Chest/Tiered_Chest_Open_T01_Cue.Tiered_Chest_Open_T01_Cue");
208 | Globals::AmmoBoxSound = FindObject(L"SoundCue /Game/Sounds/Foley_Loot/Containers/Toolbox/Toolbox_SearchEnd_Cue.Toolbox_SearchEnd_Cue");
209 |
210 | UObject* FortEngine = FindObject(L"FortEngine /Engine/Transient.FortEngine_");
211 |
212 | UObject* GameViewport = *reinterpret_cast(__int64(FortEngine) + __int64(Offsets::GameViewportOffset));
213 | UObject** CurrentConsole = reinterpret_cast(__int64(GameViewport) + __int64(Offsets::ViewportConsoleOffset));
214 | UObject* NewConsole = StaticConstructObjectInternal(FindObject(L"Class /Script/Engine.Console"), GameViewport, 0, 0, 0, 0, 0, 0, 0);
215 |
216 | // asign console to game viewport
217 | *CurrentConsole = NewConsole;
218 |
219 | // required so inventory does not get filled up quickly
220 | *reinterpret_cast(__int64(Globals::Controller) + __int64(Offsets::OverriddenBackpackSizeOffset)) = 999;
221 |
222 | uint8_t* ControllerBitField = reinterpret_cast(__int64(Globals::Controller) + __int64(Offsets::bInfiniteAmmo));
223 |
224 | // bInfiniteAmmo
225 | ControllerBitField[0] = 1;
226 |
227 | Player::Possess(Globals::Controller, Globals::Pawn);
228 |
229 | // some builds do not have GetGameVersion, we will assume that they use StartMatch
230 | if (RuntimeOptions::GetFortniteVersion().c_str() != "Unknown")
231 | {
232 | // builds that require GamePhase
233 | if (strstr(RuntimeOptions::GetFortniteVersion().c_str(), "4") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "6") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "7"))
234 | {
235 | EAthenaGamePhase* CurrentGamePhase = reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::GamePhaseOffset));
236 | *CurrentGamePhase = EAthenaGamePhase::Aircraft;
237 |
238 | GameState::OnRep_GamePhase(Globals::GameState, EAthenaGamePhase::None);
239 | }
240 |
241 | // builds that require StartMatch
242 | if (strstr(RuntimeOptions::GetFortniteVersion().c_str(), "3") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "5") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "8") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "9") || strstr(RuntimeOptions::GetFortniteVersion().c_str(), "10"))
243 | {
244 | GameMode::StartMatch(Globals::GameMode);
245 | }
246 | }
247 | else
248 | {
249 | GameMode::StartMatch(Globals::GameMode);
250 | }
251 |
252 | //SHOWING HIDDEN POIs
253 | if (strstr(RuntimeOptions::GetFortniteVersion().c_str(), "6."))
254 | {
255 | Player::ShowBuildingFoundation(FindObject(L"LF_Athena_POI_15x15_C /Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_FloatingIsland"), EDynamicFoundationType::Static);
256 | Player::ShowBuildingFoundation(FindObject(L"LF_Athena_POI_75x75_C /Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Lake1"), EDynamicFoundationType::Static);
257 | }
258 | if ((strstr(RuntimeOptions::GetFortniteVersion().c_str(), "7.")))
259 | {
260 | Player::ShowBuildingFoundation(FindObject(L"LF_Athena_POI_25x25_C /Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Athena_POI_25x36"), EDynamicFoundationType::Static);
261 | }
262 | if ((strstr(RuntimeOptions::GetFortniteVersion().c_str(), "8.")))
263 | {
264 | Player::ShowBuildingFoundation(FindObject(L"LF_Athena_POI_50x50_C /Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Athena_POI_50x53_Volcano"), EDynamicFoundationType::Static);
265 | }
266 |
267 | Player::ServerReadyToStartMatch(Globals::Controller);
268 |
269 | UObject* HeadCharacterPart = FindObject(_(L"CustomCharacterPart /Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1"));
270 | UObject* BodyCharacterPart = FindObject(_(L"CustomCharacterPart /Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01"));
271 |
272 | if (HeadCharacterPart && BodyCharacterPart)
273 | {
274 | Player::ServerChoosePart(Globals::Pawn, EFortCustomPartType::Body, BodyCharacterPart);
275 | Player::ServerChoosePart(Globals::Pawn, EFortCustomPartType::Head, HeadCharacterPart);
276 |
277 | ProcessEvent(Globals::PlayerState, FindObject(L"Function /Script/FortniteGame.FortPlayerState.OnRep_CharacterParts"), nullptr);
278 | }
279 |
280 | Kismet::Say(L"Welcome to Lunar");
281 | }
282 |
283 | static UObject* BuildingActorLast;
284 | static UObject* LastClass;
285 |
286 | static bool bIsStarted;
287 |
288 | namespace Hooks
289 | {
290 | void* ProcessEventDetour(UObject* Object, UObject* Function, void* Params)
291 | {
292 | auto ObjectName = Object->GetFullName();
293 | auto FunctionName = Function->GetFullName();
294 |
295 | if (wcsstr(FunctionName.c_str(), L"OnSetPlayButtonText") ||
296 | Function->GetName().find(L"BP_PlayButton") != std::wstring::npos)
297 | {
298 | if (!bIsStarted)
299 | {
300 | auto PlayerController = GetFirstPlayerController(GetWorld());
301 |
302 | if (PlayerController)
303 | {
304 | static UObject* SwitchLevel = FindObject(L"Function /Script/Engine.PlayerController.SwitchLevel");
305 | PlayerController->Call(SwitchLevel, FString(L"Athena_Terrain?Game=/Game/Athena/Athena_GameMode.Athena_GameMode_C"));
306 | }
307 | bIsStarted = true;
308 | }
309 | }
310 |
311 | // called when we load into a level
312 | if (wcsstr(FunctionName.c_str(), L"ReadyToStartMatch"))
313 | {
314 | if (!bReady)
315 | {
316 | bReady = true;
317 |
318 | // At this point, we are in the loading screen. Start loading into Athena_Terrain.
319 | LoadMatch();
320 | }
321 | }
322 |
323 | // called when an item is dropped from the inventory
324 | if (wcsstr(FunctionName.c_str(), L"ServerAttemptInventoryDrop"))
325 | {
326 | HandleInventoryDrop(Params);
327 | }
328 |
329 | // called when a player picks up a pickup
330 | if (wcsstr(FunctionName.c_str(), L"ServerHandlePickup"))
331 | {
332 | HandlePickup(Params);
333 | }
334 |
335 | // called when we select an item in inventory
336 | if (wcsstr(FunctionName.c_str(), L"ServerExecuteInventoryItem"))
337 | {
338 | EquipInventoryItem(*(FGuid*)Params);
339 | }
340 |
341 | if (wcsstr(FunctionName.c_str(), L"ServerCreateBuilding"))
342 | {
343 | auto CurrentBuildableClass = *reinterpret_cast(__int64(Globals::Controller) + Offsets::CurrentBuildableClassOffset);
344 | auto LastPreviewLocation = *reinterpret_cast(__int64(Globals::Controller) + Offsets::LastBuildLocationOffset);
345 | auto LastPreviewRotation = *reinterpret_cast(__int64(Globals::Controller) + Offsets::LastBuildRotationOffset);
346 | auto BuildingActor = SpawnActorEasy(GetWorld(), CurrentBuildableClass, LastPreviewLocation, LastPreviewRotation);
347 | Building::InitializeBuildingActor(BuildingActor);
348 | }
349 |
350 | if (wcsstr(FunctionName.c_str(), L"ServerAttemptInteract"))
351 | {
352 | struct ServerAttemptInteract
353 | {
354 | UObject* ReceivingActor;
355 | UObject* InteractComponent;
356 | byte InteractType;
357 | };
358 |
359 | auto CurrentParams = (ServerAttemptInteract*)Params;
360 |
361 | if (CurrentParams->ReceivingActor->GetFullName().starts_with(L"Tiered_"))
362 | {
363 | struct BitField
364 | {
365 | char bAlwaysShowContainer : 1; // 0xeb9(0x01)
366 | char bAlwaysMaintainLoot : 1; // 0xeb9(0x01)
367 | char bDestroyContainerOnSearch : 1; // 0xeb9(0x01)
368 | char bAlreadySearched : 1; // 0xeb9(0x01)
369 | };
370 |
371 | auto ContainerBitField = reinterpret_cast(__int64(CurrentParams->ReceivingActor) + __int64(Offsets::bAlreadySearchedOffset));
372 | ContainerBitField->bAlreadySearched = true;
373 | Player::OnRep_bAlreadySearched(CurrentParams->ReceivingActor);
374 |
375 | auto ContainerLocation = AActor::GetLocation(CurrentParams->ReceivingActor);
376 |
377 | if (CurrentParams->ReceivingActor->GetFullName().starts_with(L"Tiered_Chest"))
378 | {
379 | Player::ClientPlaySoundAtLocation(Globals::Controller, Globals::ChestsSound, ContainerLocation, 1, 1);
380 | }
381 | else if (CurrentParams->ReceivingActor->GetFullName().starts_with(L"Tiered_Ammo"))
382 | {
383 | Player::ClientPlaySoundAtLocation(Globals::Controller, Globals::AmmoBoxSound, ContainerLocation, 1, 1);
384 | }
385 | }
386 | else if (Globals::InviteToilet && CurrentParams->ReceivingActor == Globals::InviteToilet)
387 | {
388 | system(_("start https://discord.gg/lunarfn"));
389 | }
390 | }
391 |
392 | if (wcsstr(FunctionName.c_str(), L"ServerAttemptExitVehicle"))
393 | {
394 | UObject* Vehicle = Player::GetVehicle();
395 |
396 | *reinterpret_cast(__int64(Globals::Pawn) + __int64(Offsets::RoleOffset)) = ENetRole::ROLE_Authority;
397 | *reinterpret_cast(__int64(Vehicle) + __int64(Offsets::RoleOffset)) = ENetRole::ROLE_Authority;
398 | }
399 |
400 |
401 | if (Globals::InviteToilet && Object == Globals::InviteToilet && wcsstr(FunctionName.c_str(), L"BlueprintCanInteract") && bDroppedLoadingScreen)
402 | {
403 | struct params
404 | {
405 | UObject* InteractingPawn;
406 | bool ret;
407 | };
408 |
409 | static_cast(Params)->ret = true;
410 | return nullptr;
411 | }
412 |
413 | if (Globals::BotPawn && Object == Globals::BotPawn && wcsstr(FunctionName.c_str(), L"Tick") && bDroppedLoadingScreen)
414 | {
415 | auto Target = Globals::BotTarget - AActor::GetLocation(Globals::BotPawn);
416 |
417 | if (AActor::GetLocation(Globals::BotPawn) != Target)
418 | {
419 | Player::SetControlRotation(Globals::BotController, Target.ToRotator());
420 | AActor::K2_SetActorRotation(Globals::BotPawn, Target.ToRotator());
421 | Player::AddMovementInput(Globals::BotPawn, Target);
422 | }
423 | }
424 |
425 | if (Object == Globals::Pawn && wcsstr(FunctionName.c_str(), L"Tick") && bDroppedLoadingScreen)
426 | {
427 | if (!strstr(RuntimeOptions::GetFortniteVersion().c_str(), "3."))
428 | {
429 | *reinterpret_cast(__int64(Globals::Pawn) + __int64(Offsets::RoleOffset)) = (Player::IsInVehicle() ? ENetRole::ROLE_AutonomousProxy : ENetRole::ROLE_Authority);
430 |
431 | UObject* Vehicle = Player::GetVehicle();
432 |
433 | if (Vehicle)
434 | {
435 | *reinterpret_cast(__int64(Vehicle) + __int64(Offsets::RoleOffset)) = ENetRole::ROLE_AutonomousProxy;
436 | }
437 | }
438 |
439 | static bool bHasExecuted;
440 |
441 | if (GetAsyncKeyState(VK_F7))
442 | {
443 | if (!bHasExecuted)
444 | {
445 | bHasExecuted = !bHasExecuted;
446 |
447 | //DEBUG CODE
448 |
449 | CreateThread(nullptr, 0, reinterpret_cast(&UScript::F7), nullptr, 0, nullptr);
450 | }
451 | }
452 | else
453 | {
454 | bHasExecuted = false;
455 | }
456 |
457 | static bool bHasPressedRButton;
458 | if (Building::IsInBuildMode() && !strstr(RuntimeOptions::GetFortniteVersion().c_str(), "3."))
459 | {
460 | Globals::bCanBuild = *reinterpret_cast(Globals::BuildingOffset + 0x20);
461 | Globals::_bCanBuild = *reinterpret_cast(Globals::BuildingOffset + 0x28);
462 |
463 | if (bDroppedLoadingScreen && GetAsyncKeyState(VK_LBUTTON) & 0x8000 && Globals::_bCanBuild && !Globals::bCanBuild)
464 | {
465 | auto CurrentBuildableClass = *reinterpret_cast(__int64(Globals::Controller) + Offsets::CurrentBuildableClassOffset);
466 | auto LastPreviewLocation = *reinterpret_cast(__int64(Globals::Controller) + Offsets::LastBuildLocationOffset);
467 | auto LastPreviewRotation = *reinterpret_cast(__int64(Globals::Controller) + Offsets::LastBuildRotationOffset);
468 |
469 | if (BuildingActorLast && LastClass && !Util::IsBadReadPtr(BuildingActorLast) && !Util::IsBadReadPtr(LastClass))
470 | {
471 | auto CurrentLoc = AActor::GetLocation(BuildingActorLast);
472 | if (!Util::IsBadReadPtr(&CurrentLoc.X) && !Util::IsBadReadPtr(&CurrentLoc.Z) && !Util::IsBadReadPtr(&CurrentLoc.Z) && !Util::IsBadReadPtr(&LastPreviewLocation.X) && !Util::IsBadReadPtr(&LastPreviewLocation.Z) && !Util::IsBadReadPtr(&LastPreviewLocation.Z) && !Util::IsBadReadPtr(CurrentBuildableClass))
473 | {
474 | if (CurrentLoc.X == LastPreviewLocation.X && CurrentLoc.Y == LastPreviewLocation.Y && CurrentLoc.Z == LastPreviewLocation.Z && LastClass == CurrentBuildableClass)
475 | {
476 | return ProcessEvent(Object, Function, Params);
477 | }
478 | }
479 | }
480 |
481 | auto BuildingActor = SpawnActorEasy(GetWorld(), CurrentBuildableClass, LastPreviewLocation, LastPreviewRotation);
482 | BuildingActorLast = BuildingActor;
483 | LastClass = CurrentBuildableClass;
484 | Building::InitializeBuildingActor(BuildingActor);
485 | }
486 | }
487 | }
488 |
489 | if (wcsstr(FunctionName.c_str(), L"ServerLoadingScreenDropped"))
490 | {
491 | struct ToSlateBrush
492 | {
493 | FSlateBrush Brush;
494 | };
495 |
496 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::MinimapBackgroundBrushOffset))->ObjectResource = StaticLoadObjectEasy(FindObject(L"Class /Script/Engine.Texture2D"), L"/Game/Athena/HUD/MiniMap/MiniMapAthena.MiniMapAthena");
497 |
498 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::MinimapSafeZoneBrushOffset))->Brush = {}; // MinimapCircleBrush
499 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::MinimapCircleBrushOffset))->Brush = {}; // MinimapCircleBrush
500 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::MinimapNextCircleBrushOffset))->Brush = {}; // MinimapCircleBrush
501 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::FullMapCircleBrushOffset))->Brush = {}; // MinimapCircleBrush
502 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::FullMapNextCircleBrushOffset))->Brush = {}; // MinimapCircleBrush
503 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::MinimapSafeZoneBrushOffset))->Brush = {}; // MinimapCircleBrush
504 |
505 | auto CurrentFortVersion = Globals::FortniteVersion;
506 |
507 | if (strstr(RuntimeOptions::GetFortniteVersion().c_str(), "6.21"))
508 | {
509 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::FloatingIslandBrushOffset))->Brush = {}; // FloatingIslandBrush
510 | reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::FloatingIslandBrushActivatedOffset))->Brush = {}; // FloatingIslandBrushActivated
511 | }
512 |
513 | // setup duktape
514 | UScript::InitBindings();
515 |
516 | TArray FortHLODSMActors = GameplayStatics::GetAllActorsOfClass(FindObject(L"Class /Script/FortniteGame.FortHLODSMActor"));
517 |
518 | // destroy all FortHLODSMactor instances to remove HLODs
519 | for (int i = 0; i < FortHLODSMActors.Num(); i++)
520 | {
521 | AActor::Destroy(FortHLODSMActors[i]);
522 | }
523 |
524 | auto NetDebugUI = FindObject(L"NetDebugUI_C /Engine/Transient.FortEngine_0.FortGameInstance_0.AthenaHUD_C_0.WidgetTree_0.NetDebugContainer.WidgetTree_0.NetDebugUI");
525 |
526 | if (NetDebugUI)
527 | {
528 | // hide net debug UI in-game
529 | Widget::RemoveFromViewport(NetDebugUI);
530 | }
531 |
532 | // enable main menu in-game
533 | auto bHasServerFinishedLoading = reinterpret_cast(reinterpret_cast(Globals::Controller) + Offsets::bHasServerFinishedLoadingOffset);
534 | *bHasServerFinishedLoading = true;
535 |
536 | Player::ServerSetClientHasFinishedLoading(Globals::Controller);
537 |
538 | // used to show username in top left
539 | PlayerState::OnRep_SquadId();
540 |
541 | auto Text1 = TextActor::Spawn({150, 40, 2900}, {0, 180, 0});
542 |
543 | TextActor::SetText(Text1, _(L"Welcome to Lunar!\nThis project was made by kemo, mix, danii, sizzy and kyiro."));
544 |
545 | httplib::SSLClient cli("discord.com");
546 |
547 | if (auto res = cli.Get(_("/invite/lunarfn")))
548 | {
549 | if (res->status == 200)
550 | {
551 | auto content = res->body;
552 | (content.erase(content.find("members"), content.length())).erase(0, content.find("|") + 2);
553 |
554 | auto message = _("Current Lunar server members: ") + content + _("\nJoin using the toilet below!");
555 |
556 | auto Text2 = TextActor::Spawn({-150, -200, 3000}, {0, 120, 0});
557 |
558 | TextActor::SetText(Text2, std::wstring(message.begin(), message.end()).c_str());
559 |
560 | Globals::InviteToilet = SpawnActorEasy(GetWorld(), FindObject(L"BlueprintGeneratedClass /Game/Athena/BuildingActors/Props/Building/ActorBlueprints/Containers/Athena_Prop_Bathroom_Toilet_01.Athena_Prop_Bathroom_Toilet_01_C"), {200, -170, 2800}, {0, 0, 0});
561 | }
562 | }
563 |
564 |
565 | DWORD QuickbarOffset = FindOffset(L"ObjectProperty /Script/FortniteGame.FortPlayerController.QuickBars");
566 | Globals::FortInventory = reinterpret_cast(__int64(Globals::Controller) + __int64(Offsets::WorldInventoryOffset))->Inventory;
567 |
568 | if (QuickbarOffset != 0)
569 | {
570 | Globals::Quickbar = SpawnActorEasy(GetWorld(), FindObject(L"Class /Script/FortniteGame.FortQuickBars"), FVector{-122398, -103873.02, 3962.51}, {});
571 | reinterpret_cast(__int64(Globals::Controller) + __int64(QuickbarOffset))->QuickBar = Globals::Quickbar;
572 | }
573 | else
574 | {
575 | QuickbarOffset = FindOffset(L"ObjectProperty /Script/FortniteGame.FortPlayerController.ClientQuickBars");
576 | Globals::Quickbar = reinterpret_cast(__int64(Globals::Controller) + __int64(QuickbarOffset))->QuickBar;
577 | }
578 |
579 |
580 | // set owner of quickbar to current controller
581 | Player::SetOwner(Globals::Quickbar, Globals::Controller);
582 |
583 | // give gameplay abilities
584 | UObject** AbilitySystemComponent = reinterpret_cast(__int64(Globals::Pawn) + __int64(Offsets::AbilitySystemComponentOffset));
585 |
586 | if (AbilitySystemComponent)
587 | {
588 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"Class /Script/FortniteGame.FortGameplayAbility_Sprint"));
589 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"Class /Script/FortniteGame.FortGameplayAbility_Jump"));
590 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"BlueprintGeneratedClass /Game/Abilities/Player/Generic/Traits/DefaultPlayer/GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C"));
591 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"BlueprintGeneratedClass /Game/Abilities/Player/Generic/Traits/DefaultPlayer/GA_DefaultPlayer_InteractUse.GA_DefaultPlayer_InteractUse_C"));
592 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"BlueprintGeneratedClass /Game/Athena/DrivableVehicles/GA_AthenaEnterVehicle.GA_AthenaEnterVehicle_C"));
593 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"BlueprintGeneratedClass /Game/Athena/DrivableVehicles/GA_AthenaExitVehicle.GA_AthenaExitVehicle_C"));
594 | Player::GrantGameplayAbility(Globals::Pawn, FindObject(L"BlueprintGeneratedClass /Game/Athena/DrivableVehicles/GA_AthenaInVehicle.GA_AthenaInVehicle_C"));
595 | }
596 |
597 | Inventory::AddItemToInventoryWithUpdate(FindObject(_(L"FortWeaponMeleeItemDefinition /Game/Athena/Items/Weapons/WID_Harvest_Pickaxe_Athena_C_T01.WID_Harvest_Pickaxe_Athena_C_T01")), EFortQuickBars::Primary, 0, 1);
598 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortBuildingItemDefinition /Game/Items/Weapons/BuildingTools/BuildingItemData_Wall.BuildingItemData_Wall"), EFortQuickBars::Secondary, 0, 1);
599 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortBuildingItemDefinition /Game/Items/Weapons/BuildingTools/BuildingItemData_Floor.BuildingItemData_Floor"), EFortQuickBars::Secondary, 1, 1);
600 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortBuildingItemDefinition /Game/Items/Weapons/BuildingTools/BuildingItemData_Stair_W.BuildingItemData_Stair_W"), EFortQuickBars::Secondary, 2, 1);
601 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortBuildingItemDefinition /Game/Items/Weapons/BuildingTools/BuildingItemData_RoofS.BuildingItemData_RoofS"), EFortQuickBars::Secondary, 3, 1);
602 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortResourceItemDefinition /Game/Items/ResourcePickups/WoodItemData.WoodItemData"), EFortQuickBars::Secondary, 0, 999);
603 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortResourceItemDefinition /Game/Items/ResourcePickups/StoneItemData.StoneItemData"), EFortQuickBars::Secondary, 0, 999);
604 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortResourceItemDefinition /Game/Items/ResourcePickups/MetalItemData.MetalItemData"), EFortQuickBars::Secondary, 0, 999);
605 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortAmmoItemDefinition /Game/Athena/Items/Ammo/AthenaAmmoDataRockets.AthenaAmmoDataRockets"), EFortQuickBars::Secondary, 0, 999);
606 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortAmmoItemDefinition /Game/Items/Ammo/AthenaAmmoDataShells.AthenaAmmoDataShells"), EFortQuickBars::Secondary, 0, 999);
607 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortAmmoItemDefinition /Game/Items/Ammo/AthenaAmmoDataBulletsMedium.AthenaAmmoDataBulletsMedium"), EFortQuickBars::Secondary, 0, 999);
608 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortAmmoItemDefinition /Game/Items/Ammo/AthenaAmmoDataBulletsLight.AthenaAmmoDataBulletsLight"), EFortQuickBars::Secondary, 0, 999);
609 | Inventory::AddItemToInventoryWithUpdate(FindObject(L"FortAmmoItemDefinition /Game/Items/Ammo/AthenaAmmoDataBulletsHeavy.AthenaAmmoDataBulletsHeavy"), EFortQuickBars::Secondary, 0, 999);
610 |
611 | CreateThread(nullptr, 0, reinterpret_cast(&UScript::ExecuteStartupScript), nullptr, 0, nullptr);
612 | bDroppedLoadingScreen = true;
613 |
614 | EAthenaGamePhase* CurrentGamePhase = reinterpret_cast(__int64(Globals::GameState) + __int64(Offsets::GamePhaseOffset));
615 | *CurrentGamePhase = EAthenaGamePhase::Aircraft;
616 |
617 | GameState::OnRep_GamePhase(Globals::GameState, EAthenaGamePhase::None);
618 | }
619 |
620 | if (wcsstr(FunctionName.c_str(), L"CheatScript"))
621 | {
622 | FString* ScriptNameF = (FString*)Params;
623 |
624 | if (!ScriptNameF->IsValid())
625 | {
626 | return nullptr;
627 | }
628 |
629 | std::wstring ScriptNameW = ScriptNameF->ToWString();
630 | std::wstring argW;
631 | std::string arg;
632 |
633 | if (ScriptNameW.find(L" ") != std::wstring::npos) argW = ScriptNameW.substr(ScriptNameW.find(L" ") + 1);
634 | std::string a(argW.begin(), argW.end());
635 | arg = a;
636 |
637 | if (wcsstr(ScriptNameW.c_str(), L"test"))
638 | {
639 | if (!argW.empty())
640 | {
641 | Kismet::Say(argW.c_str());
642 | }
643 | else
644 | {
645 | Kismet::Say(L"No Args");
646 | }
647 | }
648 | if (wcsstr(ScriptNameW.c_str(), L"SpawnActor"))
649 | {
650 | static UObject* Class = StaticLoadObjectEasy(FindObject(L"Class /Script/Engine.BlueprintGeneratedClass", true), argW.c_str());
651 | // prevent collision issues
652 | FVector ActorLocation = AActor::GetLocation(Globals::Pawn);
653 | ActorLocation.X += 500;
654 | if (Class)
655 | {
656 | SpawnActorEasy(GetWorld(), Class, ActorLocation, FRotator{0, 0, 0});
657 | Kismet::Say(L"Actor Spawned!");
658 | }
659 | else
660 | {
661 | Kismet::Say(L"Class Not Found!");
662 | }
663 | }
664 | if (wcsstr(ScriptNameW.c_str(), L"SpawnPickup"))
665 | {
666 | int ObjectCount = GlobalObjects ? GlobalObjects->ObjectCount : ObjObjects->NumElements;
667 |
668 | for (int i = 0; i < ObjectCount; i++)
669 | {
670 | auto Object = FindObjectById(i);
671 |
672 | if (Object == nullptr)
673 | {
674 | continue;
675 | }
676 |
677 | if (Object->GetFullName().find(argW) != std::wstring::npos)
678 | {
679 | if (Object->GetFullName().find(L"ItemDefinition") != std::wstring::npos)
680 | {
681 | FVector ActorLocation = AActor::GetLocation(Globals::Pawn);
682 | SpawnPickupAtLocation(Object, 1, ActorLocation);
683 | return 0;
684 | }
685 | }
686 | }
687 | Kismet::Say(L"Item Definition Was not found!");
688 | }
689 |
690 | return nullptr;
691 | }
692 |
693 | return ProcessEvent(Object, Function, Params);
694 | }
695 | }
696 |
697 |
698 | void (*Build)(__int64 A, __int64* B, __int64 C) = nullptr;
699 |
700 |
701 | void BuildExec(__int64 A, __int64* B, __int64 C)
702 | {
703 | Globals::BuildingOffset = A;
704 |
705 | DetourTransactionBegin();
706 | DetourUpdateThread(GetCurrentThread());
707 |
708 | DetourDetach(&(void*&)Build, BuildExec);
709 |
710 | DetourTransactionCommit();
711 | }
712 |
713 |
714 | void Setup()
715 | {
716 | DetourTransactionBegin();
717 | DetourUpdateThread(GetCurrentThread());
718 |
719 | DetourAttach(&(void*&)ProcessEvent, Hooks::ProcessEventDetour);
720 |
721 | DetourTransactionCommit();
722 |
723 | SetupOffsets();
724 |
725 | Build = decltype(Build)(Util::FindPattern(_("48 89 5C 24 ? 57 48 83 EC 30 48 8B FA 48 8B D9 48 83 E9 80 49 8B D0")));
726 |
727 | DetourTransactionBegin();
728 | DetourUpdateThread(GetCurrentThread());
729 |
730 | DetourAttach(&(void*&)Build, BuildExec);
731 |
732 | DetourTransactionCommit();
733 | }
734 | }
735 |
--------------------------------------------------------------------------------
/Ultimanite/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Ultimanite/patterns.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | // From 2.5-CL-3889387 to 4.5-CL-4166199.
22 | #define UE_4_20_GOBJECTS _("48 8B 05 ? ? ? ? 48 8D 1C C8 81 4B ? ? ? ? ? 49 63 76 30")
23 | #define UE_4_20_FNAME_TOSTRING _("48 89 5C 24 ? 57 48 83 EC 40 83 79 04 00 48 8B DA 48 8B F9")
24 | #define UE_4_20_GETFIRSTPLAYERCONTROLLER _("83 B9 ? ? ? ? ? 7E ? 48 8B 89 ? ? ? ? E9")
25 | #define UE_4_20_SPAWNACTORFROMCLASS _("40 53 56 57 48 83 EC 70 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 0F 28 1D ? ? ? ? 0F 57 D2 48 8B B4 24 ? ? ? ? 0F 28 CB")
26 | #define UE_4_20_CONSTRUCTOBJECT _("4C 89 44 24 ? 53 55 56 57 41 54 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ?")
27 | #define UE_4_20_LOADOBJECT _("4C 89 4C 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 33 D2")
28 | #define UE_4_20_GETROW _("48 89 5C 24 ? 48 89 74 24 ? 48 89 54 24 ? 57 48 83 EC 60 48 83 79 ? ? 41 0F B6 F9 49 8B F0 48 8B D9 75 6C 80 3D ? ? ? ? ? 0F 82 ? ? ? ? 45 33 C0 48 8D 54 24 ? E8 ? ? ? ? 83 78 08 00 74 05 48 8B 18 EB 07")
29 | #define UE_4_20_FREE _("48 85 C9 74 1D 4C 8B 05 ? ? ? ? 4D 85 C0")
30 |
31 | // From Season 5 to Season 6.
32 | #define UE_4_21_GOBJECTS _("48 8B 05 ? ? ? ? 48 8B 0C C8 48 8D 04 D1 EB 03 48 8B ? 81 48 08 ? ? ? 40 49")
33 | #define UE_4_21_FNAME_TOSTRING _("48 89 5C 24 ? 57 48 83 EC 30 83 79 04 00 48 8B DA 48 8B F9")
34 | #define UE_4_21_GETFIRSTPLAYERCONTROLLER _("83 B9 ? ? ? ? ? 7E ? 48 8B 89 ? ? ? ? E9")
35 | #define UE_4_21_SPAWNACTORFROMCLASS _("40 53 56 57 48 83 EC 70 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 0F 28 1D ? ? ? ? 0F 57 D2 48 8B B4 24 ? ? ? ? 0F 28 CB")
36 | #define UE_4_21_CONSTRUCTOBJECT _("48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 44 8B A5 ? ? ? ? 48 8D 05 ? ? ? ?")
37 | #define UE_4_21_LOADOBJECT _("4C 89 4C 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 78 45 33 F6")
38 | #define UE_4_21_FREE _("48 85 C9 74 2E 53 48 83 EC 20 48 8B D9")
39 |
40 | // Season 7 (Tested 7.3 and 7.4)
41 | #define UE_4_22_GOBJECTS _("48 8B 05 ? ? ? ? 48 8B 0C C8 48 8D 04 D1 EB 03 48 8B ? 81 48 08 ? ? ? 40 49")
42 | #define UE_4_22_FNAME_TOSTRING _("48 89 5C 24 ? 57 48 83 EC 30 83 79 04 00 48 8B DA 48 8B F9")
43 | #define UE_4_22_GETFIRSTPLAYERCONTROLLER _("83 B9 ? ? ? ? ? 7E ? 48 8B 89 ? ? ? ? E9")
44 | #define UE_4_22_SPAWNACTORFROMCLASS _("40 53 56 57 48 83 EC 70 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 0F 28 1D ? ? ? ? 0F 57 D2 48 8B B4 24 ? ? ? ? 0F 28 CB")
45 | #define UE_4_22_CONSTRUCTOBJECT _("48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 44 8B A5 ? ? ? ? 48 8D 05 ? ? ? ?")
46 | #define UE_4_22_LOADOBJECT _("4C 89 4C 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 78 45 33 F6")
47 | #define UE_4_22_FREE _("48 85 C9 74 2E 53 48 83 EC 20 48 8B D9")
48 |
49 | // 8.51
50 | #define UE_4_23_GOBJECTS _("48 8B 05 ? ? ? ? 48 8B 0C C8 48 8D 04 D1 EB 03 48 8B ? 81 48 08 ? ? ? 40 49")
51 | #define UE_4_23_FNAME_TOSTRING _("48 89 5C 24 ? 57 48 83 EC 30 83 79 04 00 48 8B DA 48 8B F9")
52 | #define UE_4_23_GETFIRSTPLAYERCONTROLLER _("83 B9 ? ? ? ? ? 7E ? 48 8B 89 ? ? ? ? E9")
53 | #define UE_4_23_SPAWNACTORFROMCLASS _("40 53 56 57 48 83 EC 70 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 0F 28 1D ? ? ? ? 0F 57 D2 48 8B B4 24 ? ? ? ? 0F 28 CB")
54 | #define UE_4_23_CONSTRUCTOBJECT _("48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 44 8B A5 ? ? ? ? 48 8D 05 ? ? ? ?")
55 | #define UE_4_23_LOADOBJECT _("4C 89 4C 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 78 45 33 F6")
56 | #define UE_4_23_FREE _("48 85 C9 74 2E 53 48 83 EC 20 48 8B D9")
--------------------------------------------------------------------------------
/Ultimanite/script.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "script_wrappers.h"
21 |
22 | namespace UScript
23 | {
24 | static void error_handler(void* udata, const char* msg) {
25 | (void)udata;
26 | std::string message = "*** FATAL ERROR: ";
27 | message.append(msg ? msg : "NO MESSAGE");
28 | std::wstring messageW(message.begin(), message.end());
29 |
30 | printf("\n%s\n\n", message.c_str());
31 | Kismet::Say(messageW.c_str());
32 | return;
33 | }
34 |
35 | static void eval(std::string code) {
36 | duk_eval_string_noresult(Globals::DukContext, code.c_str());
37 | return;
38 | }
39 |
40 | static void ExecuteStartupScript()
41 | {
42 | auto content = Util::readAllText(Util::GetRuntimePath() + "\\uscripts\\startup.js");
43 |
44 | if (content.empty()) return;
45 |
46 | duk_eval_string_noresult(Globals::DukContext, content.c_str());
47 |
48 | return;
49 | }
50 |
51 | static void F7()
52 | {
53 | auto content = Util::readAllText(Util::GetRuntimePath() + "\\uscripts\\f7.js");
54 |
55 | if (content.empty()) return;
56 |
57 | duk_eval_string_noresult(Globals::DukContext, content.c_str());
58 |
59 | return;
60 | }
61 |
62 | static void InitBindings()
63 | {
64 | duk_context* ctx = duk_create_heap(NULL, NULL, NULL, NULL, error_handler);
65 |
66 | Globals::DukContext = ctx;
67 |
68 | duk_push_c_function(ctx, duk_findobject, DUK_VARARGS); //DOC
69 | duk_put_global_string(ctx, "UFindObject");
70 |
71 | duk_push_c_function(ctx, duk_spawnactor, DUK_VARARGS); //DOC
72 | duk_put_global_string(ctx, "USpawnActor");
73 |
74 | duk_push_c_function(ctx, duk_destroyactor, DUK_VARARGS); //DOC
75 | duk_put_global_string(ctx, "UDestroyActor");
76 |
77 | duk_push_c_function(ctx, duk_additemtoinventory, DUK_VARARGS); //DOC
78 | duk_put_global_string(ctx, "UAddItemToInventory");
79 |
80 | duk_push_c_function(ctx, duk_scaleactor, DUK_VARARGS); //DOC
81 | duk_put_global_string(ctx, "UScaleActor");
82 |
83 | duk_push_c_function(ctx, duk_getlocalplayer, DUK_VARARGS); //DOC
84 | duk_put_global_string(ctx, "UGetLocalPlayer");
85 |
86 | duk_push_c_function(ctx, duk_getactorofclass, DUK_VARARGS); //DOC
87 | duk_put_global_string(ctx, "UGetActorOfClass");
88 |
89 | duk_push_c_function(ctx, duk_getactorlocation, DUK_VARARGS); //DOC
90 | duk_put_global_string(ctx, "UGetActorLocation");
91 |
92 | duk_push_c_function(ctx, duk_displayobjectname, DUK_VARARGS); //DOC
93 | duk_put_global_string(ctx, "UDisplayObjectName");
94 |
95 | duk_push_c_function(ctx, duk_teleportactor, DUK_VARARGS); //DOC
96 | duk_put_global_string(ctx, "UTeleportActor");
97 |
98 | duk_push_c_function(ctx, duk_spawnpickupatlocation, DUK_VARARGS); //DOC
99 | duk_put_global_string(ctx, "USpawnPickupAtLocation");
100 |
101 | duk_push_c_function(ctx, duk_spawntextactor, DUK_VARARGS); //DOC
102 | duk_put_global_string(ctx, "USpawnTextActor");
103 |
104 | duk_push_c_function(ctx, duk_settextactortext, DUK_VARARGS); //DOC
105 | duk_put_global_string(ctx, "USetTextActorText");
106 |
107 | duk_push_c_function(ctx, duk_activateability, DUK_VARARGS); //DOC
108 | duk_put_global_string(ctx, _("UActivateAbility"));
109 |
110 | duk_push_c_function(ctx, duk_renderasciiwithactor, DUK_VARARGS); //DOC
111 | duk_put_global_string(ctx, "URenderASCIIWithActor");
112 |
113 | duk_push_c_function(ctx, duk_webclient, DUK_VARARGS); //DOC
114 | duk_put_global_string(ctx, "UWebClient");
115 |
116 | duk_push_c_function(ctx, duk_webclientget, DUK_VARARGS);//DOC
117 | duk_put_global_string(ctx, "UWebClientGet");
118 |
119 | duk_push_c_function(ctx, duk_webclientpost, DUK_VARARGS);//DOC
120 | duk_put_global_string(ctx, "UWebClientPost");
121 |
122 | duk_push_c_function(ctx, duk_spawnbot, DUK_VARARGS); //DOC
123 | duk_put_global_string(ctx, "USpawnBot");
124 |
125 | duk_push_c_function(ctx, duk_movebottotarget, DUK_VARARGS); //DOC
126 | duk_put_global_string(ctx, "UMoveBotToTarget");
127 |
128 | duk_push_c_function(ctx, duk_setplayermaxhealth, DUK_VARARGS); //DOC
129 | duk_put_global_string(ctx, "USetPlayerMaxHealth");
130 |
131 | duk_push_c_function(ctx, duk_setplayerhealth, DUK_VARARGS); //DOC
132 | duk_put_global_string(ctx, "USetPlayerHealth");
133 |
134 | duk_push_c_function(ctx, duk_setplayermaxshield, DUK_VARARGS); //DOC
135 | duk_put_global_string(ctx, "USetPlayerMaxShield");
136 |
137 | duk_push_c_function(ctx, duk_setplayershield, DUK_VARARGS); //DOC
138 | duk_put_global_string(ctx, "USetPlayerShield");
139 |
140 | duk_push_c_function(ctx, duk_executeconsolecommand, DUK_VARARGS); //DOC
141 | duk_put_global_string(ctx, "UExecuteConsoleCommand");
142 |
143 | duk_push_c_function(ctx, duk_readfileasstring, DUK_VARARGS); //DOC
144 | duk_put_global_string(ctx, "UReadFileAsString");
145 |
146 | duk_push_c_function(ctx, duk_getgamepath, DUK_VARARGS); //DOC
147 | duk_put_global_string(ctx, "UGetGamePath");
148 |
149 | duk_push_c_function(ctx, duk_print, DUK_VARARGS); //DOC
150 | duk_put_global_string(ctx, "UPrint");
151 |
152 | duk_push_c_function(ctx, duk_jump, DUK_VARARGS); //DOC
153 | duk_put_global_string(ctx, "UJump");
154 |
155 | /*duk_push_c_function(ctx, duk_triggerwin, DUK_VARARGS);
156 | duk_put_global_string(ctx, "UTriggerWin");
157 |
158 | duk_push_c_function(ctx, duk_processeventhook, DUK_VARARGS);
159 | duk_put_global_string(ctx, "UProcessEventHook");*/
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/Ultimanite/script_wrappers.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "framework.h"
21 |
22 | //void UDisplayObjectName(ObjectPointer);
23 | static duk_ret_t duk_displayobjectname(duk_context* ctx)
24 | {
25 | int ArgsLength = duk_get_top(ctx);
26 | if (ArgsLength < 1)
27 | {
28 | MessageBox(nullptr, L"This function takes 1 arguments!.", L"UDisplayObjectName", 0);
29 | return DUK_RET_TYPE_ERROR;
30 | }
31 |
32 | auto object = (UObject*)duk_get_pointer(ctx, 0);
33 |
34 | if (!object || Util::IsBadReadPtr(object))
35 | {
36 | MessageBox(nullptr, L"Object is null.", L"UDisplayObjectName", 0);
37 | return DUK_RET_TYPE_ERROR;
38 | }
39 |
40 | auto objectNameW = object->GetFullName();
41 |
42 | MessageBoxW(nullptr, objectNameW.c_str(), L"UDisplayObjectName", MB_OK);
43 |
44 | return 0;
45 | }
46 |
47 | //UObject* UFindObject("OBJECT FULLNAME");
48 | static duk_ret_t duk_findobject(duk_context* ctx)
49 | {
50 | int ArgsLength = duk_get_top(ctx);
51 | if (ArgsLength != 1)
52 | {
53 | MessageBox(nullptr, L"This function takes 1 arguments!.", L"UFindObject", 0);
54 | return DUK_RET_TYPE_ERROR;
55 | }
56 |
57 | std::string objectName = duk_get_string(ctx, 0);
58 |
59 | std::wstring objectNameW(objectName.begin(), objectName.end());
60 |
61 | auto object = FindObject(objectNameW);
62 |
63 | if (!object || Util::IsBadReadPtr(object))
64 | {
65 | MessageBox(nullptr, L"Object cannot be found.", L"UFindObject", 0);
66 | return DUK_RET_TYPE_ERROR;
67 | }
68 |
69 | duk_push_pointer(ctx, object);
70 |
71 | return 1; //one return value
72 | }
73 |
74 | //UObject* USpawnActor(ClassObject, [X, Y, Z], [Pitch, Yaw, Roll]);
75 | static duk_ret_t duk_spawnactor(duk_context* ctx)
76 | {
77 | int ArgsLength = duk_get_top(ctx);
78 | if (ArgsLength < 3)
79 | {
80 | MessageBox(nullptr, L"This function takes 3 arguments!.", L"USpawnActor", 0);
81 | return DUK_RET_TYPE_ERROR;
82 | }
83 |
84 | auto classObject = duk_get_pointer(ctx, 0);
85 |
86 | if (!classObject || Util::IsBadReadPtr(classObject))
87 | {
88 | MessageBox(nullptr, L"Actor class was not found, mostly a wrong name.", L"USpawnActor", 0);
89 | return DUK_RET_TYPE_ERROR;
90 | }
91 |
92 | auto locationArraySize = duk_get_length(ctx, 1);
93 |
94 | auto rotationArraySize = duk_get_length(ctx, 2);
95 |
96 | if (rotationArraySize == 3 && locationArraySize == 3)
97 | {
98 | duk_get_prop_index(ctx, 1, 0);
99 | auto x = duk_get_int(ctx, -1);
100 |
101 | duk_get_prop_index(ctx, 1, 1);
102 | auto y = duk_get_int(ctx, -1);
103 |
104 | duk_get_prop_index(ctx, 1, 2);
105 | auto z = duk_get_int(ctx, -1);
106 |
107 | duk_get_prop_index(ctx, 2, 0);
108 | auto pitch = duk_get_int(ctx, -1);
109 |
110 | duk_get_prop_index(ctx, 2, 1);
111 | auto yaw = duk_get_int(ctx, -1);
112 |
113 | duk_get_prop_index(ctx, 2, 2);
114 | auto roll = duk_get_int(ctx, -1);
115 |
116 | FVector Location{x, y, z};
117 | FRotator Rotation{pitch, yaw, roll};
118 |
119 | auto actor = SpawnActorEasy(GetWorld(), (UObject*)classObject, Location, Rotation);
120 |
121 | if (!actor || Util::IsBadReadPtr(actor))
122 | {
123 | MessageBox(nullptr, L"Failed to spawn actor.", L"USpawnActor", 0);
124 | return DUK_RET_TYPE_ERROR;
125 | }
126 |
127 | duk_push_pointer(ctx, actor);
128 | }
129 | else
130 | {
131 | MessageBox(nullptr, L"Location/Rotations is not correct.", L"USpawnActor", 0);
132 | return DUK_RET_TYPE_ERROR;
133 | }
134 |
135 | return 1;
136 | }
137 |
138 | //void UDestroyActor(ObjectPointer);
139 | static duk_ret_t duk_destroyactor(duk_context* ctx)
140 | {
141 | int ArgsLength = duk_get_top(ctx);
142 | if (ArgsLength < 1)
143 | {
144 | MessageBox(nullptr, L"This function takes 1 arguments!.", L"UDestroyActor", 0);
145 | return DUK_RET_TYPE_ERROR;
146 | }
147 |
148 | auto object = (UObject*)duk_get_pointer(ctx, 0);
149 |
150 | if (!object || Util::IsBadReadPtr(object))
151 | {
152 | MessageBox(nullptr, L"Object is null.", L"UDestroyActor", 0);
153 | return DUK_RET_TYPE_ERROR;
154 | }
155 |
156 | AActor::Destroy(object);
157 |
158 | return 0;
159 | }
160 |
161 | //UObject* UGetActorOfClass(actorClass, index);
162 | static duk_ret_t duk_getactorofclass(duk_context* ctx)
163 | {
164 | int ArgsLength = duk_get_top(ctx);
165 | if (ArgsLength < 2)
166 | {
167 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UGetActorOfClass", 0);
168 | return DUK_RET_TYPE_ERROR;
169 | }
170 |
171 | auto classObject = (UObject*)duk_get_pointer(ctx, 0);
172 |
173 | if (!classObject || Util::IsBadReadPtr(classObject))
174 | {
175 | MessageBox(nullptr, L"Actor class was not found.", L"UGetActorOfClass", 0);
176 | return DUK_RET_TYPE_ERROR;
177 | }
178 |
179 | auto index = duk_get_int(ctx, 1);
180 |
181 | auto actor = GameplayStatics::GetAllActorsOfClass(classObject)[index];
182 |
183 | if (!actor || Util::IsBadReadPtr(actor))
184 | {
185 | MessageBox(nullptr, L"Actor object is null!.", L"UGetActorOfClass", 0);
186 | return DUK_RET_TYPE_ERROR;
187 | }
188 |
189 | duk_push_pointer(ctx, actor);
190 |
191 | return 1;
192 | }
193 |
194 | //UObject* UGetLocalPlayer();
195 | static duk_ret_t duk_getlocalplayer(duk_context* ctx)
196 | {
197 | int ArgsLength = duk_get_top(ctx);
198 | if (ArgsLength < 0)
199 | {
200 | MessageBox(nullptr, L"This function takes 0 arguments!.", L"UGetLocalPlayer", 0);
201 | return DUK_RET_TYPE_ERROR;
202 | }
203 |
204 | duk_push_pointer(ctx, Globals::Pawn);
205 |
206 | return 1;
207 | }
208 |
209 | //void UScaleActor(ActorObjectPointer, [x, y, z]);
210 | static duk_ret_t duk_scaleactor(duk_context* ctx)
211 | {
212 | int ArgsLength = duk_get_top(ctx);
213 | if (ArgsLength != 2)
214 | {
215 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UScaleActor", 0);
216 | return DUK_RET_TYPE_ERROR;
217 | }
218 |
219 | UObject* actorObject = (UObject*)duk_get_pointer(ctx, 0);
220 |
221 | if (!actorObject || Util::IsBadReadPtr(actorObject))
222 | {
223 | MessageBox(nullptr, L"Object was not found.", L"UScaleActor", 0);
224 | return DUK_RET_TYPE_ERROR;
225 | }
226 |
227 | auto arraySize = duk_get_length(ctx, 1);
228 |
229 | if (arraySize == 3)
230 | {
231 | duk_get_prop_index(ctx, 1, 0);
232 | auto x = static_cast(duk_get_int(ctx, -1));
233 |
234 | duk_get_prop_index(ctx, 1, 1);
235 | auto y = static_cast(duk_get_int(ctx, -1));
236 |
237 | duk_get_prop_index(ctx, 1, 2);
238 | auto z = static_cast(duk_get_int(ctx, -1));
239 |
240 | AActor::SetActorScale3D(actorObject, FVector{ x, y, z });
241 | }
242 | else
243 | {
244 | MessageBox(nullptr, L"Scale is not correct.", L"UScaleActor", 0);
245 | return DUK_RET_TYPE_ERROR;
246 | }
247 |
248 | return 0;
249 | }
250 |
251 | //void UTeleportActor(objectPointer, [X, Y, Z], [Pitch, Yaw, Roll]);
252 | static duk_ret_t duk_teleportactor(duk_context* ctx)
253 | {
254 | int ArgsLength = duk_get_top(ctx);
255 | if (ArgsLength < 3)
256 | {
257 | MessageBox(nullptr, L"This function takes 3 arguments!.", L"UTeleportActor", 0);
258 | return DUK_RET_TYPE_ERROR;
259 | }
260 |
261 | auto actor = duk_get_pointer(ctx, 0);
262 |
263 | if (!actor || Util::IsBadReadPtr(actor))
264 | {
265 | MessageBox(nullptr, L"Actor was not found.", L"UTeleportActor", 0);
266 | return DUK_RET_TYPE_ERROR;
267 | }
268 |
269 | auto locationArraySize = duk_get_length(ctx, 1);
270 |
271 | auto rotationArraySize = duk_get_length(ctx, 2);
272 |
273 | if (rotationArraySize == 3 && locationArraySize == 3)
274 | {
275 | duk_get_prop_index(ctx, 1, 0);
276 | auto x = duk_get_int(ctx, -1);
277 |
278 | duk_get_prop_index(ctx, 1, 1);
279 | auto y = duk_get_int(ctx, -1);
280 |
281 | duk_get_prop_index(ctx, 1, 2);
282 | auto z = duk_get_int(ctx, -1);
283 |
284 | duk_get_prop_index(ctx, 2, 0);
285 | auto pitch = duk_get_int(ctx, -1);
286 |
287 | duk_get_prop_index(ctx, 2, 1);
288 | auto yaw = duk_get_int(ctx, -1);
289 |
290 | duk_get_prop_index(ctx, 2, 2);
291 | auto roll = duk_get_int(ctx, -1);
292 |
293 | FVector Location{x, y, z};
294 | FRotator Rotation{pitch, yaw, roll};
295 |
296 | struct Params
297 | {
298 | FVector DestLocation;
299 | FRotator DestRotation;
300 | };
301 |
302 | Params params;
303 |
304 | params.DestLocation = Location;
305 | params.DestRotation = Rotation;
306 |
307 | auto func = FindObject(L"Function /Script/Engine.Actor.K2_TeleportTo");
308 |
309 | ProcessEvent(actor, func, ¶ms);
310 | }
311 | else
312 | {
313 | MessageBox(nullptr, L"Location/Rotations is not correct.", L"UTeleportActor", 0);
314 | return DUK_RET_TYPE_ERROR;
315 | }
316 |
317 | return 0;
318 | }
319 |
320 | //void UAddItemToInventory(weaponObject, slot);
321 | static duk_ret_t duk_additemtoinventory(duk_context* ctx)
322 | {
323 | int ArgsLength = duk_get_top(ctx);
324 | if (ArgsLength != 2)
325 | {
326 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UAddItemToInventory", 0);
327 | return DUK_RET_TYPE_ERROR;
328 | }
329 |
330 | UObject* weaponObject = (UObject*)duk_get_pointer(ctx, 0);
331 |
332 | if (!weaponObject || Util::IsBadReadPtr(weaponObject))
333 | {
334 | MessageBox(nullptr, L"Weapons object was not found, mostly a wrong name.", L"UAddItemToInventory", 0);
335 | return DUK_RET_TYPE_ERROR;
336 | }
337 |
338 | auto slot = duk_get_int(ctx, 1);
339 |
340 | //MessageBoxW(nullptr, weaponObject->GetFullName().c_str(), L"OK", 0);
341 | //MessageBoxW(nullptr, std::to_wstring(slot).c_str(), L"OK", 0);
342 |
343 | Inventory::AddItemToInventoryWithUpdate(weaponObject, EFortQuickBars::Primary, slot, 1);
344 |
345 | return 0;
346 | }
347 |
348 | //void USpawnPickupAtLocation(weaponObject, x, y, z);
349 | static duk_ret_t duk_spawnpickupatlocation(duk_context* ctx)
350 | {
351 | int ArgsLength = duk_get_top(ctx);
352 | if (ArgsLength != 4)
353 | {
354 | MessageBox(nullptr, L"This function takes 4 arguments!.", L"USpawnPickupAtLocation", 0);
355 | return DUK_RET_TYPE_ERROR;
356 | }
357 |
358 | UObject* object = (UObject*)duk_get_pointer(ctx, 0);
359 |
360 | if (!object || Util::IsBadReadPtr(object))
361 | {
362 | MessageBox(nullptr, L"Weapon object is null.", L"USpawnPickupAtLocation", 0);
363 | return DUK_RET_TYPE_ERROR;
364 | }
365 |
366 | auto x = static_cast(duk_get_int(ctx, 1));
367 | auto y = static_cast(duk_get_int(ctx, 2));
368 | auto z = static_cast(duk_get_int(ctx, 3));
369 |
370 | Pickup::SpawnPickupAtLocation(object, 1, {x, y, z});
371 |
372 | return 0;
373 | }
374 |
375 | //int UGetActorLocation(actorPointer, index);
376 | static duk_ret_t duk_getactorlocation(duk_context* ctx)
377 | {
378 | int ArgsLength = duk_get_top(ctx);
379 | if (ArgsLength != 2)
380 | {
381 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UGetActorLocation", 0);
382 | return DUK_RET_TYPE_ERROR;
383 | }
384 |
385 | UObject* actorObject = (UObject*)duk_get_pointer(ctx, 0);
386 |
387 | if (!actorObject || Util::IsBadReadPtr(actorObject))
388 | {
389 | MessageBox(nullptr, L"Object was not found.", L"UGetActorLocation", 0);
390 | return DUK_RET_TYPE_ERROR;
391 | }
392 |
393 | auto index = duk_get_int(ctx, 1);
394 |
395 | //TODO: return an array or json.
396 | auto location = AActor::GetLocation(actorObject);
397 |
398 | switch (index)
399 | {
400 | case 1: //X
401 | {
402 | duk_push_int(ctx, location.X);
403 | //printf("Return X: %f\n", location.X);
404 | break;
405 | }
406 | case 2: //Y
407 | {
408 | duk_push_int(ctx, location.Y);
409 | //printf("Return Y: %f\n", location.Y);
410 | break;
411 | }
412 | case 3: //Z
413 | {
414 | duk_push_int(ctx, location.Z);
415 | //printf("Return Z: %f\n", location.Z);
416 | break;
417 | }
418 | default: duk_push_int(ctx, location.X);
419 | }
420 |
421 | return 1; //one return value
422 | }
423 |
424 | //UObject* USpawnTextActor([X, Y, Z], [Pitch, Yaw, Roll]);
425 | static duk_ret_t duk_spawntextactor(duk_context* ctx)
426 | {
427 | int ArgsLength = duk_get_top(ctx);
428 | if (ArgsLength < 2)
429 | {
430 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USpawnTextActor", 0);
431 | return DUK_RET_TYPE_ERROR;
432 | }
433 |
434 | auto locationArraySize = duk_get_length(ctx, 0);
435 |
436 | auto rotationArraySize = duk_get_length(ctx, 1);
437 |
438 | if (rotationArraySize == 3 && locationArraySize == 3)
439 | {
440 | duk_get_prop_index(ctx, 0, 0);
441 | auto x = duk_get_int(ctx, -1);
442 |
443 | duk_get_prop_index(ctx, 0, 1);
444 | auto y = duk_get_int(ctx, -1);
445 |
446 | duk_get_prop_index(ctx, 0, 2);
447 | auto z = duk_get_int(ctx, -1);
448 |
449 | duk_get_prop_index(ctx, 1, 0);
450 | auto pitch = duk_get_int(ctx, -1);
451 |
452 | duk_get_prop_index(ctx, 1, 1);
453 | auto yaw = duk_get_int(ctx, -1);
454 |
455 | duk_get_prop_index(ctx, 1, 2);
456 | auto roll = duk_get_int(ctx, -1);
457 |
458 | FVector Location{x, y, z};
459 | FRotator Rotation{pitch, yaw, roll};
460 |
461 | auto actor = TextActor::Spawn(Location, Rotation);
462 |
463 | if (!actor || Util::IsBadReadPtr(actor))
464 | {
465 | MessageBox(nullptr, L"Failed to spawn actor.", L"USpawnTextActor", 0);
466 | return DUK_RET_TYPE_ERROR;
467 | }
468 |
469 | duk_push_pointer(ctx, actor);
470 | }
471 | else
472 | {
473 | MessageBox(nullptr, L"Location/Rotations is not correct.", L"USpawnTextActor", 0);
474 | return DUK_RET_TYPE_ERROR;
475 | }
476 |
477 |
478 | return 1;
479 | }
480 |
481 | //void USetTextActorText(actorPointer, "New text");
482 | static duk_ret_t duk_settextactortext(duk_context* ctx)
483 | {
484 | int ArgsLength = duk_get_top(ctx);
485 | if (ArgsLength < 2)
486 | {
487 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USetTextActorText", 0);
488 | return DUK_RET_TYPE_ERROR;
489 | }
490 |
491 | UObject* actorObject = (UObject*)duk_get_pointer(ctx, 0);
492 |
493 | if (!actorObject || Util::IsBadReadPtr(actorObject))
494 | {
495 | MessageBox(nullptr, L"Actor pointer is not valid.", L"USetTextActorText", 0);
496 | return DUK_RET_TYPE_ERROR;
497 | }
498 |
499 | std::string text = duk_get_string(ctx, 1);
500 |
501 | std::wstring textW(text.begin(), text.end());
502 |
503 | TextActor::SetText(actorObject, textW.c_str());
504 |
505 | return 0;
506 | }
507 |
508 | //void UActivateAbility(abilityClass);
509 | static duk_ret_t duk_activateability(duk_context* ctx)
510 | {
511 | int ArgsLength = duk_get_top(ctx);
512 | if (ArgsLength < 1)
513 | {
514 | MessageBox(nullptr, _(L"This function takes 1 arguments!."), _(L"UActivateAbility"), 0);
515 | return DUK_RET_TYPE_ERROR;
516 | }
517 |
518 | UObject* abilityClass = (UObject*)duk_get_pointer(ctx, 0);
519 |
520 | if (!abilityClass || Util::IsBadReadPtr(abilityClass))
521 | {
522 | MessageBox(nullptr, _(L"Ability class pointer is not valid."), _(L"UActivateAbility"), 0);
523 | return DUK_RET_TYPE_ERROR;
524 | }
525 |
526 | Player::GrantGameplayAbility(Globals::Pawn, abilityClass);
527 |
528 | return 0;
529 | }
530 |
531 | //void URenderASCIIWithActor(objectPointer, ASCIIMap, lineLength, itemWidth, itemWidth, [X, Y, Z], [Pitch, Yaw, Roll]);
532 | static duk_ret_t duk_renderasciiwithactor(duk_context* ctx)
533 | {
534 | int ArgsLength = duk_get_top(ctx);
535 | if (ArgsLength < 6)
536 | {
537 | MessageBox(nullptr, L"This function takes 6 arguments!.", L"URenderASCIIWithActor", 0);
538 | return DUK_RET_TYPE_ERROR;
539 | }
540 |
541 | auto actor = (UObject*)duk_get_pointer(ctx, 0);
542 |
543 | if (!actor || Util::IsBadReadPtr(actor))
544 | {
545 | MessageBox(nullptr, L"Actor class is invalid.", L"URenderASCIIWithActor", 0);
546 | return DUK_RET_TYPE_ERROR;
547 | }
548 |
549 | std::string map = duk_get_string(ctx, 1);
550 |
551 | int lineLength = duk_get_int(ctx, 2);
552 |
553 | float actorWidth = duk_get_int(ctx, 3);
554 |
555 | float actorHeight = duk_get_int(ctx, 4);
556 |
557 | auto locationArraySize = duk_get_length(ctx, 5);
558 |
559 | auto rotationArraySize = duk_get_length(ctx, 6);
560 |
561 | if (rotationArraySize == 3 && locationArraySize == 3)
562 | {
563 | duk_get_prop_index(ctx, 5, 0);
564 | auto x = duk_get_int(ctx, -1);
565 |
566 | duk_get_prop_index(ctx, 5, 1);
567 | auto y = duk_get_int(ctx, -1);
568 |
569 | duk_get_prop_index(ctx, 5, 2);
570 | auto z = duk_get_int(ctx, -1);
571 |
572 | duk_get_prop_index(ctx, 6, 0);
573 | auto pitch = duk_get_int(ctx, -1);
574 |
575 | duk_get_prop_index(ctx, 6, 1);
576 | auto yaw = duk_get_int(ctx, -1);
577 |
578 | duk_get_prop_index(ctx, 6, 2);
579 | auto roll = duk_get_int(ctx, -1);
580 |
581 | FVector Location{x, y, z};
582 | FRotator Rotation{pitch, yaw, roll};
583 |
584 | //printf("%s", map.c_str());
585 |
586 | //printf("x: %f, y: %f, z: %f\n", Location.X, Location.Y, Location.Y);
587 |
588 | Render::MapWithActor(actor, map, actorWidth, actorHeight, lineLength, Location, Rotation);
589 | }
590 | else
591 | {
592 | MessageBox(nullptr, L"Location/Rotations is not correct.", L"URenderASCIIWithActor", 0);
593 | return DUK_RET_TYPE_ERROR;
594 | }
595 |
596 | return 0;
597 | }
598 |
599 | //WebClientPointer UWebClient("Host");
600 | static duk_ret_t duk_webclient(duk_context* ctx)
601 | {
602 | int ArgsLength = duk_get_top(ctx);
603 | if (ArgsLength != 1)
604 | {
605 | MessageBox(nullptr, L"This function takes 1 arguments!.", L"UWebClient", 0);
606 | return DUK_RET_TYPE_ERROR;
607 | }
608 |
609 | std::string host = duk_get_string(ctx, 0);
610 |
611 | if (!host.empty())
612 | {
613 | static httplib::SSLClient cli(host);
614 |
615 | duk_push_pointer(ctx, &cli);
616 | }
617 | else
618 | {
619 | MessageBox(nullptr, L"Host name cannot be empty!.", L"UWebClient", 0);
620 | return DUK_RET_TYPE_ERROR;
621 | }
622 |
623 | return 1; //one return value
624 | }
625 |
626 | //MISSING: A function to add headers, bodys etc etc.
627 |
628 | //String UWebClientGet(Client, "Path");
629 | static duk_ret_t duk_webclientget(duk_context* ctx)
630 | {
631 | int ArgsLength = duk_get_top(ctx);
632 | if (ArgsLength != 2)
633 | {
634 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UWebClientGet", 0);
635 | return DUK_RET_TYPE_ERROR;
636 | }
637 |
638 | auto cli = (httplib::SSLClient*)duk_get_pointer(ctx, 0);
639 |
640 | if (!cli || Util::IsBadReadPtr(cli))
641 | {
642 | MessageBox(nullptr, L"Client is invalid.", L"UWebClientGet", 0);
643 | return DUK_RET_TYPE_ERROR;
644 | }
645 |
646 | std::string path = duk_get_string(ctx, 1);
647 |
648 | if (!path.empty())
649 | {
650 | if (auto res = (*cli).Get(path.c_str()))
651 | {
652 | if (res->status == 200)
653 | {
654 | duk_push_string(ctx, res->body.c_str());
655 | }
656 | }
657 | }
658 | else
659 | {
660 | MessageBox(nullptr, L"Path cannot be empty!.", L"UWebClientGet", 0);
661 | return DUK_RET_TYPE_ERROR;
662 | }
663 |
664 | return 1; //one return value
665 | }
666 |
667 | //String UWebClientPost(Client, "Path", "Body", "Content-Type");
668 | static duk_ret_t duk_webclientpost(duk_context* ctx)
669 | {
670 | int ArgsLength = duk_get_top(ctx);
671 | if (ArgsLength != 4)
672 | {
673 | MessageBox(nullptr, L"This function takes 4 arguments!.", L"UWebClientPost", 0);
674 | return DUK_RET_TYPE_ERROR;
675 | }
676 |
677 | auto cli = (httplib::SSLClient*)duk_get_pointer(ctx, 0);
678 |
679 | if (!cli || Util::IsBadReadPtr(cli))
680 | {
681 | MessageBox(nullptr, L"Client is invalid.", L"UWebClientPost", 0);
682 | return DUK_RET_TYPE_ERROR;
683 | }
684 |
685 | std::string path = duk_get_string(ctx, 1);
686 | std::string body = duk_get_string(ctx, 2);
687 | std::string type = duk_get_string(ctx, 3);
688 |
689 | if (!path.empty())
690 | {
691 | if (auto res = (*cli).Post(path.c_str(), body.c_str(), type.c_str()))
692 | {
693 | if (res->status == 200)
694 | {
695 | duk_push_string(ctx, res->body.c_str());
696 | }
697 | }
698 | }
699 | else
700 | {
701 | MessageBox(nullptr, L"Path cannot be empty!.", L"UWebClientPost", 0);
702 | return DUK_RET_TYPE_ERROR;
703 | }
704 |
705 | return 1; //one return value
706 | }
707 |
708 | /*
709 | //void UTriggerWin();
710 | static duk_ret_t duk_triggerwin(duk_context* ctx)
711 | {
712 | Player::TriggerWin();
713 | return 0;
714 | }*/
715 |
716 | /*
717 | //void UProcessEventHook("EVENT", function() {});
718 | static duk_ret_t duk_processeventhook(duk_context* ctx)
719 | {
720 | int ArgsLength = duk_get_top(ctx);
721 | if (ArgsLength != 2)
722 | {
723 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"UProcessEventHook", 0);
724 | return DUK_RET_TYPE_ERROR;
725 | }
726 |
727 | std::string event = duk_get_string(ctx, 0);
728 | std::wstring eventW(event.begin(), event.end());
729 |
730 | duk_require_function(ctx, 1);
731 | duk_dup(ctx, 1);
732 | duk_put_global_string(ctx, event.c_str());
733 |
734 | Globals::ProcessEventHooks.push_back(eventW);
735 |
736 | return 0;
737 | }*/
738 |
739 | //void USpawnBot([X, Y, Z], [Pitch, Yaw, Roll]);
740 | static duk_ret_t duk_spawnbot(duk_context* ctx)
741 | {
742 | int ArgsLength = duk_get_top(ctx);
743 | if (ArgsLength < 2)
744 | {
745 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USpawnBot", 0);
746 | return DUK_RET_TYPE_ERROR;
747 | }
748 |
749 | auto locationArraySize = duk_get_length(ctx, 0);
750 |
751 | auto rotationArraySize = duk_get_length(ctx, 1);
752 |
753 | if (rotationArraySize == 3 && locationArraySize == 3)
754 | {
755 | duk_get_prop_index(ctx, 0, 0);
756 | auto x = duk_get_int(ctx, -1);
757 |
758 | duk_get_prop_index(ctx, 0, 1);
759 | auto y = duk_get_int(ctx, -1);
760 |
761 | duk_get_prop_index(ctx, 0, 2);
762 | auto z = duk_get_int(ctx, -1);
763 |
764 | duk_get_prop_index(ctx, 1, 0);
765 | auto pitch = duk_get_int(ctx, -1);
766 |
767 | duk_get_prop_index(ctx, 1, 1);
768 | auto yaw = duk_get_int(ctx, -1);
769 |
770 | duk_get_prop_index(ctx, 1, 2);
771 | auto roll = duk_get_int(ctx, -1);
772 |
773 | FVector Location{x, y, z};
774 | FRotator Rotation{pitch, yaw, roll};
775 |
776 | if (!Globals::BotController)
777 | {
778 | Globals::BotController = SpawnActorEasy(GetWorld(), FindObject(_(L"Class /Script/FortniteGame.AthenaAIController")), FVector{0, 0, 10000}, {});
779 |
780 | Globals::BotPawn = SpawnActorEasy(GetWorld(), FindObject(L"BlueprintGeneratedClass /Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"), Location, Rotation);
781 |
782 | auto botPlayerState = SpawnActorEasy(GetWorld(), FindObject(L"Class /Script/FortniteGame.FortPlayerStateAthena"), FVector{0, 0, 2792}, {});
783 |
784 | if (Globals::BotPawn)
785 | {
786 | Player::Possess(Globals::BotController, Globals::BotPawn);
787 | Player::SetMaxHealth(Globals::BotPawn, 100);
788 | Player::SetHealth(Globals::BotPawn, 100);
789 | }
790 | else
791 | {
792 | MessageBox(nullptr, L"Couldn't spawn a bot pawn.", L"USpawnBot", 0);
793 | return DUK_RET_TYPE_ERROR;
794 | }
795 |
796 | auto PlayerStatePawn = reinterpret_cast(reinterpret_cast(Globals::BotPawn) + Offsets::PlayerStatePawnOffset);
797 | auto PlayerStateController = reinterpret_cast(reinterpret_cast(Globals::BotController) + Offsets::PlayerStateOffset);
798 |
799 | *PlayerStatePawn = botPlayerState;
800 | *PlayerStateController = botPlayerState;
801 |
802 | ProcessEvent(Globals::BotPawn, FindObject(L"Function /Script/Engine.Pawn.OnRep_PlayerState"), nullptr);
803 | ProcessEvent(Globals::BotController, FindObject(L"Function /Script/Engine.Controller.OnRep_PlayerState"), nullptr);
804 |
805 | auto sk = FindObject(L"SkeletalMesh /Game/Characters/Survivors/Female/Small/F_SML_Starter_01/Meshes/F_SML_Starter_Epic.F_SML_Starter_Epic");
806 | if (sk)
807 | {
808 | Player::SetSkeletalMesh(Globals::BotPawn, sk);
809 | }
810 |
811 | //TODO: figure out why char parts doesn't show
812 | /*
813 | UObject* HeadCharacterPart = FindObject(L"CustomCharacterPart /Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1");
814 | UObject* BodyCharacterPart = FindObject(L"CustomCharacterPart /Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01");
815 |
816 | Player::ServerChoosePart(botPawn, EFortCustomPartType::Body, BodyCharacterPart);
817 | Player::ServerChoosePart(botPawn, EFortCustomPartType::Head, HeadCharacterPart);
818 |
819 | ProcessEvent(botPlayerState, FindObject(L"Function /Script/FortniteGame.FortPlayerState.OnRep_CharacterParts"), nullptr);
820 | */
821 |
822 | duk_push_pointer(ctx, Globals::BotPawn);
823 | }
824 | }
825 | else
826 | {
827 | MessageBox(nullptr, L"Location/Rotations is not correct.", L"USpawnBot", 0);
828 | return DUK_RET_TYPE_ERROR;
829 | }
830 |
831 | return 1;
832 | }
833 |
834 | //void UMoveBotToTarget(playerPawnPointer, X, Y, Z);
835 | static duk_ret_t duk_movebottotarget(duk_context* ctx)
836 | {
837 | int ArgsLength = duk_get_top(ctx);
838 | if (ArgsLength < 4)
839 | {
840 | MessageBox(nullptr, L"This function takes 4 arguments!.", L"UMoveBotToTarget", 0);
841 | return DUK_RET_TYPE_ERROR;
842 | }
843 |
844 | auto pawn = (UObject*)duk_get_pointer(ctx, 0);
845 |
846 | if (!pawn || Util::IsBadReadPtr(pawn))
847 | {
848 | MessageBox(nullptr, L"Pawn pointer is invalid.", L"UMoveBotToTarget", 0);
849 | return DUK_RET_TYPE_ERROR;
850 | }
851 |
852 |
853 | auto x = static_cast(duk_get_int(ctx, 1));
854 | auto y = static_cast(duk_get_int(ctx, 2));
855 | auto z = static_cast(duk_get_int(ctx, 3));
856 |
857 | FVector Location{x, y, z};
858 |
859 | if (Globals::BotController)
860 | {
861 | Globals::BotTarget = Location;
862 | }
863 |
864 | return 0;
865 | }
866 |
867 | //void USetPlayerMaxHealth(playerPawnPointer, newMaxHealth);
868 | static duk_ret_t duk_setplayermaxhealth(duk_context* ctx)
869 | {
870 | int ArgsLength = duk_get_top(ctx);
871 | if (ArgsLength < 2)
872 | {
873 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USetPlayerMaxHealth", 0);
874 | return DUK_RET_TYPE_ERROR;
875 | }
876 |
877 | UObject* playerPawnPointer = (UObject*)duk_get_pointer(ctx, 0);
878 |
879 | if (!playerPawnPointer || Util::IsBadReadPtr(playerPawnPointer))
880 | {
881 | MessageBox(nullptr, L"Player pawn pointer is not valid.", L"USetPlayerMaxHealth", 0);
882 | return DUK_RET_TYPE_ERROR;
883 | }
884 |
885 | auto newMaxHealth = duk_get_int(ctx, 1);
886 |
887 | Player::SetMaxHealth(playerPawnPointer, newMaxHealth);
888 |
889 | return 0;
890 | }
891 |
892 | //void USetPlayerHealth(playerPawnPointer, newHealth);
893 | static duk_ret_t duk_setplayerhealth(duk_context* ctx)
894 | {
895 | int ArgsLength = duk_get_top(ctx);
896 | if (ArgsLength < 2)
897 | {
898 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USetPlayerHealth", 0);
899 | return DUK_RET_TYPE_ERROR;
900 | }
901 |
902 | UObject* playerPawnPointer = (UObject*)duk_get_pointer(ctx, 0);
903 |
904 | if (!playerPawnPointer || Util::IsBadReadPtr(playerPawnPointer))
905 | {
906 | MessageBox(nullptr, L"Player pawn pointer is not valid.", L"USetPlayerHealth", 0);
907 | return DUK_RET_TYPE_ERROR;
908 | }
909 |
910 | auto newHealth = duk_get_int(ctx, 1);
911 |
912 | Player::SetHealth(playerPawnPointer, newHealth);
913 |
914 | return 0;
915 | }
916 |
917 | //void USetPlayerMaxShield(playerPawnPointer, newHealth);
918 | static duk_ret_t duk_setplayermaxshield(duk_context* ctx)
919 | {
920 | int ArgsLength = duk_get_top(ctx);
921 | if (ArgsLength < 2)
922 | {
923 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USetPlayerMaxShield", 0);
924 | return DUK_RET_TYPE_ERROR;
925 | }
926 |
927 | UObject* playerPawnPointer = (UObject*)duk_get_pointer(ctx, 0);
928 |
929 | if (!playerPawnPointer || Util::IsBadReadPtr(playerPawnPointer))
930 | {
931 | MessageBox(nullptr, L"Player pawn pointer is not valid.", L"USetPlayerMaxShield", 0);
932 | return DUK_RET_TYPE_ERROR;
933 | }
934 |
935 | auto newHealth = duk_get_int(ctx, 1);
936 |
937 | Player::SetMaxShield(playerPawnPointer, newHealth);
938 |
939 | return 0;
940 | }
941 |
942 | //void USetPlayerShield(playerPawnPointer, newHealth);
943 | static duk_ret_t duk_setplayershield(duk_context* ctx)
944 | {
945 | int ArgsLength = duk_get_top(ctx);
946 | if (ArgsLength < 2)
947 | {
948 | MessageBox(nullptr, L"This function takes 2 arguments!.", L"USetPlayerShield", 0);
949 | return DUK_RET_TYPE_ERROR;
950 | }
951 |
952 | UObject* playerPawnPointer = (UObject*)duk_get_pointer(ctx, 0);
953 |
954 | if (!playerPawnPointer || Util::IsBadReadPtr(playerPawnPointer))
955 | {
956 | MessageBox(nullptr, L"Player pawn pointer is not valid.", L"USetPlayerShield", 0);
957 | return DUK_RET_TYPE_ERROR;
958 | }
959 |
960 | auto newHealth = duk_get_int(ctx, 1);
961 |
962 | Player::SetShield(playerPawnPointer, newHealth);
963 |
964 | return 0;
965 | }
966 |
967 | //void UExecuteConsoleCommand("Command");
968 | static duk_ret_t duk_executeconsolecommand(duk_context* ctx)
969 | {
970 | int ArgsLength = duk_get_top(ctx);
971 | if (ArgsLength != 1)
972 | {
973 | MessageBox(nullptr, L"This function takes 1 argument!.", L"UExecuteConsoleCommand", 0);
974 | return DUK_RET_TYPE_ERROR;
975 | }
976 |
977 | std::string cmd = duk_get_string(ctx, 0);
978 |
979 | if (!cmd.empty())
980 | {
981 | std::wstring cmdW(cmd.begin(), cmd.end());
982 | Kismet::ExecuteConsoleCommand(cmdW.c_str());
983 | }
984 | else
985 | {
986 | MessageBox(nullptr, L"Commnad cannot be empty!.", L"UExecuteConsoleCommand", 0);
987 | return DUK_RET_TYPE_ERROR;
988 | }
989 |
990 | return 0;
991 | }
992 |
993 | //String UGetGamePath();
994 | static duk_ret_t duk_getgamepath(duk_context* ctx)
995 | {
996 | int ArgsLength = duk_get_top(ctx);
997 | if (ArgsLength != 0)
998 | {
999 | MessageBox(nullptr, L"This function takes 0 arguments!.", L"UGetGamePath", 0);
1000 | return DUK_RET_TYPE_ERROR;
1001 | }
1002 |
1003 | duk_push_string(ctx, Util::GetRuntimePath().c_str());
1004 |
1005 | return 1;
1006 | }
1007 |
1008 | //String UReadFileAsString("Path");
1009 | static duk_ret_t duk_readfileasstring(duk_context* ctx)
1010 | {
1011 | int ArgsLength = duk_get_top(ctx);
1012 | if (ArgsLength != 1)
1013 | {
1014 | MessageBox(nullptr, L"This function takes 1 argument!.", L"UReadFileAsString", 0);
1015 | return DUK_RET_TYPE_ERROR;
1016 | }
1017 |
1018 | std::string path = duk_get_string(ctx, 0);
1019 |
1020 | if (!path.empty())
1021 | {
1022 | duk_push_string(ctx, Util::readAllText(path).c_str());
1023 | }
1024 | else
1025 | {
1026 | MessageBox(nullptr, L"Path cannot be empty!.", L"UReadFileAsString", 0);
1027 | return DUK_RET_TYPE_ERROR;
1028 | }
1029 |
1030 | return 1;
1031 | }
1032 |
1033 | //void UPrint("Hello World!");
1034 | static duk_ret_t duk_print(duk_context* ctx)
1035 | {
1036 | int ArgsLength = duk_get_top(ctx);
1037 | if (ArgsLength != 1)
1038 | {
1039 | MessageBox(nullptr, L"This function takes 1 argument!.", L"UPrint", 0);
1040 | return DUK_RET_TYPE_ERROR;
1041 | }
1042 |
1043 | std::string msg = duk_get_string(ctx, 0);
1044 | std::wstring msgW(msg.begin(), msg.end());
1045 |
1046 | printf("%s\n", msg.c_str());
1047 | Kismet::Say(msgW.c_str());
1048 |
1049 | return 0;
1050 | }
1051 |
1052 | //void UJump(playerPawnPointer);
1053 | static duk_ret_t duk_jump(duk_context* ctx)
1054 | {
1055 | int ArgsLength = duk_get_top(ctx);
1056 | if (ArgsLength != 1)
1057 | {
1058 | MessageBox(nullptr, L"This function takes 1 argument!.", L"UJump", 0);
1059 | return DUK_RET_TYPE_ERROR;
1060 | }
1061 |
1062 | auto pawn = (UObject*)duk_get_pointer(ctx, 0);
1063 |
1064 | if (!pawn || Util::IsBadReadPtr(pawn))
1065 | {
1066 | MessageBox(nullptr, L"Pawn pointer is invalid.", L"UJump", 0);
1067 | return DUK_RET_TYPE_ERROR;
1068 | }
1069 |
1070 | Player::Jump(pawn);
1071 |
1072 | return 0;
1073 | }
--------------------------------------------------------------------------------
/Ultimanite/structs.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "framework.h"
21 | #define PI (3.1415926535897932f)
22 |
23 | class StructMaker
24 | {
25 | public:
26 | void* structPtr = nullptr;
27 | private:
28 | size_t totalSize = 0;
29 | size_t padding = 0;
30 |
31 | template
32 | void add(T Src)
33 | {
34 | constexpr auto Size = sizeof(T);
35 |
36 | totalSize += Size;
37 |
38 | structPtr = realloc(structPtr, totalSize);
39 | if (structPtr) memcpy((void*)(reinterpret_cast(structPtr) + padding), &Src, Size);
40 |
41 | //printf("Size: %d, totalSize: %d, paddint: %d\n", Size, totalSize, padding);
42 |
43 | padding += Size;
44 | }
45 |
46 | template
47 | constexpr void* Create() const
48 | {
49 | return (void*)((uintptr_t)structPtr + padding);
50 | }
51 |
52 | public:
53 | template
54 | void* Create(T retValue, Rest ... params)
55 | {
56 | add(retValue);
57 |
58 | return Create<>(params...);
59 | }
60 | };
61 |
62 | template
63 | struct TArray
64 | {
65 | friend struct FString;
66 |
67 | public:
68 | T* Data;
69 | int32_t Count;
70 | int32_t Max;
71 |
72 | inline TArray()
73 | {
74 | Data = nullptr;
75 | Count = Max = 0;
76 | };
77 |
78 | inline int Num() const
79 | {
80 | return Count;
81 | };
82 |
83 | inline T& operator[](int i)
84 | {
85 | return Data[i];
86 | };
87 |
88 | inline const T& operator[](int i) const
89 | {
90 | return Data[i];
91 | };
92 |
93 | inline bool IsValidIndex(int i) const
94 | {
95 | return i < Num();
96 | }
97 |
98 | inline void Add(T InputData)
99 | {
100 | Data = (T*)realloc(Data, sizeof(T) * (Count + 1));
101 | Data[Count++] = InputData;
102 | Max = Count;
103 | };
104 | };
105 |
106 | struct FString : private TArray
107 | {
108 | FString()
109 | {
110 | };
111 |
112 | FString(const wchar_t* other)
113 | {
114 | Max = Count = *other ? std::wcslen(other) + 1 : 0;
115 |
116 | if (Count)
117 | {
118 | Data = const_cast(other);
119 | }
120 | }
121 |
122 | bool IsValid() const
123 | {
124 | return Data != nullptr;
125 | }
126 |
127 | const wchar_t* ToWString() const
128 | {
129 | return Data;
130 | }
131 |
132 | std::string ToString() const
133 | {
134 | auto length = std::wcslen(Data);
135 |
136 | std::string str(length, '\0');
137 |
138 | std::use_facet>(std::locale()).narrow(Data, Data + length, '?', &str[0]);
139 |
140 | return str;
141 | }
142 | };
143 |
144 | struct FGuid
145 | {
146 | int A;
147 | int B;
148 | int C;
149 | int D;
150 | };
151 |
152 | struct FName;
153 |
154 |
155 | inline void (*FreeInternal)(void*);
156 | void (*FNameToString)(FName* pThis, FString& out);
157 |
158 | struct FName
159 | {
160 | uint32_t ComparisonIndex;
161 | uint32_t DisplayIndex;
162 |
163 | FName() = default;
164 |
165 | explicit FName(int64_t name)
166 | {
167 | DisplayIndex = (name & 0xFFFFFFFF00000000LL) >> 32;
168 | ComparisonIndex = (name & 0xFFFFFFFFLL);
169 | };
170 |
171 | FName(uint32_t comparisonIndex, uint32_t displayIndex) : ComparisonIndex(comparisonIndex),
172 | DisplayIndex(displayIndex)
173 | {
174 | }
175 |
176 | auto ToString()
177 | {
178 | FString temp;
179 | FNameToString(this, temp);
180 |
181 | std::wstring ret(temp.ToWString());
182 |
183 | FreeInternal((void*)temp.ToWString());
184 |
185 | return ret;
186 | }
187 | };
188 |
189 | void* (*ProcessEvent)(void* Object, void* Function, void* Params);
190 |
191 | // This stays the same throughout all Fortnite builds so far, no need to change.
192 | struct UObject
193 | {
194 | void** VTableObject;
195 | DWORD ObjectFlags;
196 | DWORD InternalIndex;
197 | UObject* Class;
198 | FName NamePrivate;
199 | UObject* Outer;
200 |
201 | bool IsA(UObject* cmp) const
202 | {
203 | if (this->Class == cmp)
204 | {
205 | return true;
206 | }
207 | return false;
208 | }
209 |
210 | std::wstring GetName()
211 | {
212 | return NamePrivate.ToString();
213 | }
214 |
215 | std::string GetNameA()
216 | {
217 | auto NameW = NamePrivate.ToString();
218 | return std::string(NameW.begin(), NameW.end());
219 | }
220 |
221 | std::wstring GetFullName()
222 | {
223 | std::wstring temp;
224 |
225 | for (auto outer = Outer; outer; outer = outer->Outer)
226 | {
227 | temp = outer->GetName() + L"." + temp;
228 | }
229 |
230 | temp = reinterpret_cast(Class)->GetName() + L" " + temp + this->GetName();
231 | return temp;
232 | }
233 |
234 | FName GetFName() const
235 | {
236 | return *reinterpret_cast(this + 0x18);
237 | }
238 |
239 | bool isValid() const
240 | {
241 | return !Util::IsBadReadPtr((void*)this);
242 | }
243 |
244 |
245 | //TODO: fix return values!
246 | template
247 | inline ReturnType Call(UObject* function, First&& firstParam, Rest&&... params)
248 | {
249 | ReturnType RetInstance{};
250 |
251 | auto caller = new StructMaker();
252 |
253 | auto ret = *(ReturnType*)caller->Create(std::forward(firstParam), std::forward(params)...,
254 | RetInstance);
255 |
256 | ProcessEvent(this, function, caller->structPtr);
257 |
258 | return ret;
259 | }
260 | };
261 |
262 | struct UField : UObject
263 | {
264 | UField* Next;
265 | };
266 |
267 | struct UProperty : UField
268 | {
269 | uint32_t ArrayDim; // 0x30
270 | uint32_t ElementSize; // 0x34
271 | uint64_t PropertyFlags; // 0x38
272 | char pad_40[4]; // 0x40
273 | uint32_t Offset; // 0x44
274 | char pad_48[0x70 - 0x30 - 0x18];
275 | };
276 |
277 | struct UStruct : UField
278 | {
279 | UStruct* Super; // 0x30
280 | struct UProperty* Children; // 0x38
281 | uint32_t Size; // 0x40
282 | char pad_44[0x88 - 0x30 - 0x14];
283 | };
284 | struct UFunction : UStruct
285 | {
286 | uint32_t FunctionFlags;
287 | char pad[28]; // 0x8C
288 | void* Func; // 0xB0
289 | };
290 |
291 | struct FRotator
292 | {
293 | float Pitch;
294 | float Yaw;
295 | float Roll;
296 | };
297 |
298 | struct FVector
299 | {
300 | float X;
301 | float Y;
302 | float Z;
303 |
304 | auto operator-(FVector A)
305 | {
306 | return FVector { this->X - A.X, this->Y - A.Y, this->Z - A.Z };
307 | }
308 |
309 | auto operator+(FVector A)
310 | {
311 | return FVector { this->X + A.X, this->Y + A.Y, this->Z + A.Z };
312 | }
313 |
314 | auto operator==(FVector A)
315 | {
316 | return (this->X == A.X && this->Y == A.Y && this->Z == A.Z);
317 | }
318 |
319 | auto operator!=(FVector A)
320 | {
321 | return (this->X != A.X && this->Y != A.Y && this->Z != A.Z);
322 | }
323 |
324 | auto ToRotator()
325 | {
326 | FRotator R;
327 | R.Yaw = atan2(Y, X) * (180.f / PI);
328 |
329 | R.Pitch = 0; //atan2(Z, sqrt(X * X + Y * Y)) * (180.f / PI);
330 |
331 | R.Roll = 0;
332 | return R;
333 | }
334 | };
335 |
336 | struct FVector2D
337 | {
338 | float X;
339 | float Y;
340 |
341 | inline FVector2D()
342 | : X(0), Y(0)
343 | {
344 | }
345 |
346 | inline FVector2D(float x, float y)
347 | : X(x),
348 | Y(y)
349 | {
350 | }
351 | };
352 |
353 | // This stays the same throughout all of Fortnite, no need to change.
354 | struct FUObjectItem
355 | {
356 | UObject* Object;
357 | DWORD Flags;
358 | DWORD ClusterIndex;
359 | DWORD SerialNumber;
360 | DWORD SerialNumber2;
361 | };
362 |
363 | // This struct is used on 4.20 and below. Not used on any future builds.
364 | // We will call it TUObjectArray to prevent conflict.
365 | struct TUObjectArray
366 | {
367 | uint8_t* Objects;
368 | uint32_t MaxElements;
369 | uint32_t NumElements;
370 | };
371 |
372 | // This struct is used on 4.21 and above.
373 | struct TUObjectArrayNew
374 | {
375 | FUObjectItem* Objects[9];
376 | };
377 |
378 | struct GObjects
379 | {
380 | TUObjectArrayNew* ObjectArray;
381 | BYTE _padding_0[0xC];
382 | DWORD ObjectCount;
383 | };
384 |
385 | struct FWeakObjectPtr
386 | {
387 | public:
388 | inline bool SerialNumbersMatch(FUObjectItem* ObjectItem) const
389 | {
390 | return ObjectItem->SerialNumber == ObjectSerialNumber;
391 | }
392 |
393 | bool IsValid() const;
394 |
395 | UObject* Get() const;
396 |
397 | int32_t ObjectIndex;
398 | int32_t ObjectSerialNumber;
399 | };
400 |
401 | template
402 | struct TWeakObjectPtr : public TWeakObjectPtrBase
403 | {
404 | public:
405 | inline T* Get() const
406 | {
407 | return (T*)TWeakObjectPtrBase::Get();
408 | }
409 |
410 | inline T& operator*() const
411 | {
412 | return *Get();
413 | }
414 |
415 | inline T* operator->() const
416 | {
417 | return Get();
418 | }
419 |
420 | inline bool IsValid() const
421 | {
422 | return TWeakObjectPtrBase::IsValid();
423 | }
424 | };
425 |
426 | template
427 | class TPersistentObjectPtr
428 | {
429 | public:
430 | FWeakObjectPtr WeakPtr;
431 | int32_t TagAtLastTest;
432 | TObjectID ObjectID;
433 | };
434 |
435 | struct FSoftObjectPath
436 | {
437 | FName AssetPathName;
438 | FString SubPathString;
439 | };
440 |
441 | class FSoftObjectPtr : public TPersistentObjectPtr
442 | {
443 |
444 | };
445 |
446 | template
447 | class TSoftObjectPtr : FSoftObjectPtr
448 | {
449 |
450 | };
451 |
452 | struct FKey {
453 | struct FName KeyName; // 0x00(0x08)
454 | char UnknownData_8[0x10]; // 0x08(0x10)
455 | };
456 |
457 | struct FText
458 | {
459 | char data[0x18];
460 | };
461 |
462 | struct FActorSpawnParameters
463 | {
464 | FActorSpawnParameters() : Name(), Template(nullptr), Owner(nullptr), Instigator(nullptr), OverrideLevel(nullptr),
465 | SpawnCollisionHandlingOverride(), bRemoteOwned(0), bNoFail(0),
466 | bDeferConstruction(0),
467 | bAllowDuringConstructionScript(0),
468 | NameMode(),
469 | ObjectFlags()
470 | {
471 | }
472 | ;
473 |
474 | FName Name;
475 | UObject* Template;
476 | UObject* Owner;
477 | UObject* Instigator;
478 | UObject* OverrideLevel;
479 | ESpawnActorCollisionHandlingMethod SpawnCollisionHandlingOverride;
480 |
481 | private:
482 | uint8_t bRemoteOwned : 1;
483 |
484 | public:
485 | bool IsRemoteOwned() const { return bRemoteOwned; }
486 |
487 | uint8_t bNoFail : 1;
488 | uint8_t bDeferConstruction : 1;
489 | uint8_t bAllowDuringConstructionScript : 1;
490 | ESpawnActorNameMode NameMode;
491 | EObjectFlags ObjectFlags;
492 | };
493 |
494 | template
495 | class TEnumAsByte
496 | {
497 | public:
498 | inline TEnumAsByte()
499 | {
500 | }
501 |
502 | inline TEnumAsByte(TEnum _value)
503 | : value(static_cast(_value))
504 | {
505 | }
506 |
507 | explicit inline TEnumAsByte(int32_t _value)
508 | : value(static_cast(_value))
509 | {
510 | }
511 |
512 | explicit inline TEnumAsByte(uint8_t _value)
513 | : value(_value)
514 | {
515 | }
516 |
517 | inline operator TEnum() const
518 | {
519 | return (TEnum)value;
520 | }
521 |
522 | inline TEnum GetValue() const
523 | {
524 | return (TEnum)value;
525 | }
526 |
527 | private:
528 | uint8_t value;
529 | };
530 |
531 | struct FActiveGameplayEffectHandle
532 | {
533 | int Handle; // 0x00(0x04)
534 | bool bPassedFiltersAndWasExecuted; // 0x04(0x01)
535 | char UnknownData_5[0x3]; // 0x05(0x03)
536 | };
537 |
538 | struct FGameplayEffectContextHandle
539 | {
540 | char UnknownData_0[0x30]; // 0x00(0x18)
541 | };
542 |
543 | struct FGameplayAbilitySpecDef
544 | {
545 | UObject* Ability;
546 | unsigned char Unk00[0x90];
547 | };
548 |
549 | struct FLinearColor {
550 | float R;
551 | float G;
552 | float B;
553 | float A;
554 | };
555 |
556 | enum class EFortResourceType : uint8_t
557 | {
558 | Wood = 0,
559 | Stone = 1,
560 | Metal = 2,
561 | Permanite = 3,
562 | None = 4,
563 | EFortResourceType_MAX = 5
564 | };
--------------------------------------------------------------------------------
/Ultimanite/ue4.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "framework.h"
21 |
22 | // Used on UE version 4.20 and lower.
23 | inline TUObjectArray* ObjObjects;
24 |
25 | // Used on UE version 4.21 and higher.
26 | inline GObjects* GlobalObjects;
27 |
28 |
29 | inline UObject* (*GetFirstPlayerController)(UObject* World);
30 |
31 | inline UObject* (*SpawnActor)(UObject* World, UObject* Class, FVector* Position, FRotator* Rotation, const FActorSpawnParameters& SpawnParameters);
32 |
33 | static UObject* (*StaticConstructObjectInternal)(void*, void*, void*, int, unsigned int, void*, bool, void*, bool);
34 |
35 | static UObject* (*StaticLoadObjectInternal)(UObject* ObjectClass, UObject* InOuter, const TCHAR* InName, const TCHAR* Filename, uint32_t LoadFlags, UObject* Sandbox, bool bAllowObjectReconciliation);
36 |
37 | inline void (*TickPlayerInput)(const UObject* PlayerController, const float DeltaSeconds, const bool bGamePaused);
38 |
39 | enum class EEngineVersion : uint8_t
40 | {
41 | UE_4_20 = 0,
42 | UE_4_21 = 1,
43 | UE_4_22 = 2,
44 | None = 3
45 | };
46 |
47 | inline void NumChunks(int* start, int* end)
48 | {
49 | int cStart = 0, cEnd = 0;
50 |
51 | if (!cEnd)
52 | {
53 | while (1)
54 | {
55 | if (GlobalObjects->ObjectArray->Objects[cStart] == 0)
56 | {
57 | cStart++;
58 | }
59 | else
60 | {
61 | break;
62 | }
63 | }
64 |
65 | cEnd = cStart;
66 | while (1)
67 | {
68 | if (GlobalObjects->ObjectArray->Objects[cEnd] == 0)
69 | {
70 | break;
71 | }
72 | else
73 | {
74 | cEnd++;
75 | }
76 | }
77 | }
78 |
79 | *start = cStart;
80 | *end = cEnd;
81 | }
82 |
83 |
84 |
85 | static UObject* FindObjectById(uint32_t Id)
86 | {
87 | if (GlobalObjects)
88 | {
89 | // we are on ue 4.21+
90 | int cStart = 0, cEnd = 0;
91 | int chunkIndex = 0, chunkSize = 0xFFFF, chunkPos;
92 | FUObjectItem* Object;
93 |
94 | NumChunks(&cStart, &cEnd);
95 |
96 | chunkIndex = Id / chunkSize;
97 | if (chunkSize * chunkIndex != 0 &&
98 | chunkSize * chunkIndex == Id)
99 | {
100 | chunkIndex--;
101 | }
102 |
103 | chunkPos = cStart + chunkIndex;
104 | if (chunkPos < cEnd)
105 | {
106 | Object = GlobalObjects->ObjectArray->Objects[chunkPos] + (Id - chunkSize * chunkIndex);
107 |
108 | if (!Object) { return NULL; }
109 |
110 | return Object->Object;
111 | }
112 | }
113 | else
114 | {
115 | // we are on ue 4.20 on lower
116 | auto Offset = 24 * Id;
117 | return *(UObject**)(ObjObjects->Objects + Offset);
118 | }
119 |
120 | return nullptr;
121 | }
122 |
123 | template static T FindObject(std::wstring ObjectToFind, bool IsEqual = false)
124 | {
125 | int ObjectCount = GlobalObjects ? GlobalObjects->ObjectCount : ObjObjects->NumElements;
126 |
127 | for (int i = 0; i < ObjectCount; i++)
128 | {
129 | auto Object = FindObjectById(i);
130 |
131 | if (Object == nullptr)
132 | {
133 | continue;
134 | }
135 |
136 | if (IsEqual)
137 | {
138 | if (Object->GetFullName() == ObjectToFind)
139 | {
140 | return (T)Object;
141 | }
142 | }
143 | else
144 | {
145 | if (wcsstr(Object->GetFullName().c_str(), ObjectToFind.c_str()))
146 | {
147 | return (T)Object;
148 | }
149 | }
150 | }
151 |
152 | return nullptr;
153 | }
154 |
155 | static DWORD FindOffset(std::wstring OffsetToFind)
156 | {
157 | auto Object = FindObject(OffsetToFind, true);
158 |
159 | if (Object)
160 | {
161 | return *(uint32_t*)(__int64(Object) + 0x44);
162 | }
163 |
164 | return 0;
165 | }
166 |
167 | inline void DumpObjects()
168 | {
169 | std::wofstream DumpFile("dump_objects_log.txt");
170 |
171 | int ObjectCount = GlobalObjects ? GlobalObjects->ObjectCount : ObjObjects->NumElements;
172 |
173 | for (int i = 0; i < ObjectCount; i++)
174 | {
175 | auto Object = FindObjectById(i);
176 |
177 | if (Object == nullptr)
178 | {
179 | continue;
180 | }
181 |
182 | DumpFile << Object->GetFullName() << std::endl;
183 | }
184 | }
185 |
186 | static UObject* GetWorld()
187 | {
188 | static auto FortEngine = FindObject(L"FortEngine_");
189 | static auto GameViewportOffset = FindOffset(L"ObjectProperty /Script/Engine.Engine.GameViewport");
190 | static auto WorldOffset = FindOffset(L"ObjectProperty /Script/Engine.GameViewportClient.World");
191 |
192 | UObject* GameViewport = *reinterpret_cast(__int64(FortEngine) + __int64(GameViewportOffset));
193 | UObject** World = reinterpret_cast(__int64(GameViewport) + __int64(WorldOffset));
194 |
195 | return *World;
196 | }
197 |
198 | static UObject* SpawnActorEasy(UObject* WorldContextObject, UObject* Actor, FVector Location, FRotator ParamRotation)
199 | {
200 | FRotator Rotation = ParamRotation;
201 | return SpawnActor(WorldContextObject, Actor, &Location, &Rotation, FActorSpawnParameters());
202 | }
203 |
204 | static UObject* StaticLoadObjectEasy(UObject* ObjectClass, const wchar_t* InPath)
205 | {
206 | return StaticLoadObjectInternal(ObjectClass, nullptr, InPath, nullptr, 0, nullptr, false);
207 | }
208 |
--------------------------------------------------------------------------------
/Ultimanite/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | Lunar / Ultimanite
3 | Copyright (C) 2021 Daniele Giompaolo
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "framework.h"
21 |
22 | #define RELATIVE_ADDRESS(address, size) ((PBYTE)((UINT_PTR)(address) + *(PINT)((UINT_PTR)(address) + ((size) - sizeof(INT))) + (size)))
23 |
24 | namespace Util
25 | {
26 | static __forceinline void SetupConsole()
27 | {
28 | AllocConsole();
29 |
30 | FILE* pFile;
31 | freopen_s(&pFile, "CONOUT$", "w", stdout);
32 | }
33 |
34 | static __forceinline bool IsBadReadPtr(void* p)
35 | {
36 | MEMORY_BASIC_INFORMATION mbi;
37 | if (VirtualQuery(p, &mbi, sizeof(mbi)))
38 | {
39 | DWORD mask = (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
40 | bool b = !(mbi.Protect & mask);
41 | if (mbi.Protect & (PAGE_GUARD | PAGE_NOACCESS)) b = true;
42 |
43 | return b;
44 | }
45 | return true;
46 | }
47 |
48 | static __forceinline std::string readAllText(const std::string& path)
49 | {
50 | std::ifstream input_file(path);
51 | if (!input_file.is_open()) return std::string();
52 |
53 | return std::string((std::istreambuf_iterator(input_file)), std::istreambuf_iterator());
54 | }
55 |
56 | static __forceinline std::string GetRuntimePath()
57 | {
58 | char result[MAX_PATH];
59 | std::string path(result, GetModuleFileNameA(nullptr, result, MAX_PATH));
60 | size_t pos = path.find_last_of("\\/");
61 | return (std::string::npos == pos) ? "" : path.substr(0, pos);
62 | }
63 |
64 | static __forceinline uintptr_t FindPattern(const char* signature, bool bRelative = false, uint32_t offset = 0)
65 | {
66 | uintptr_t base_address = reinterpret_cast(GetModuleHandle(NULL));
67 | static auto patternToByte = [](const char* pattern)
68 | {
69 | auto bytes = std::vector{};
70 | const auto start = const_cast(pattern);
71 | const auto end = const_cast(pattern) + strlen(pattern);
72 |
73 | for (auto current = start; current < end; ++current)
74 | {
75 | if (*current == '?')
76 | {
77 | ++current;
78 | if (*current == '?') ++current;
79 | bytes.push_back(-1);
80 | }
81 | else { bytes.push_back(strtoul(current, ¤t, 16)); }
82 | }
83 | return bytes;
84 | };
85 |
86 | const auto dosHeader = (PIMAGE_DOS_HEADER)base_address;
87 | const auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)base_address + dosHeader->e_lfanew);
88 |
89 | const auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
90 | auto patternBytes = patternToByte(signature);
91 | const auto scanBytes = reinterpret_cast(base_address);
92 |
93 | const auto s = patternBytes.size();
94 | const auto d = patternBytes.data();
95 |
96 | for (auto i = 0ul; i < sizeOfImage - s; ++i)
97 | {
98 | bool found = true;
99 | for (auto j = 0ul; j < s; ++j)
100 | {
101 | if (scanBytes[i + j] != d[j] && d[j] != -1)
102 | {
103 | found = false;
104 | break;
105 | }
106 | }
107 | if (found)
108 | {
109 | uintptr_t address = reinterpret_cast(&scanBytes[i]);
110 | if (bRelative)
111 | {
112 | address = ((address + offset + 4) + *(int32_t*)(address + offset));
113 | return address;
114 | }
115 | return address;
116 | }
117 | }
118 | return NULL;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Ultimanite/xorstr.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 - 2021 Justas Masiulis
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef JM_XORSTR_HPP
18 | #define JM_XORSTR_HPP
19 |
20 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__)
21 | #include
22 | #elif defined(_M_X64) || defined(__amd64__) || defined(_M_IX86) || defined(__i386__)
23 | #include
24 | #else
25 | #error Unsupported platform
26 | #endif
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #define xorstr(str) ::jm::xor_string([]() { return str; }, std::integral_constant{}, std::make_index_sequence<::jm::detail::_buffer_size()>{})
34 | #define xorstr_(str) xorstr(str).crypt_get()
35 |
36 | #ifdef _MSC_VER
37 | #define XORSTR_FORCEINLINE __forceinline
38 | #else
39 | #define XORSTR_FORCEINLINE __attribute__((always_inline)) inline
40 | #endif
41 |
42 | #if defined(__clang__) || defined(__GNUC__)
43 | #define JM_XORSTR_LOAD_FROM_REG(x) ::jm::detail::load_from_reg(x)
44 | #else
45 | #define JM_XORSTR_LOAD_FROM_REG(x) (x)
46 | #endif
47 |
48 | namespace jm {
49 |
50 | namespace detail {
51 |
52 | template
53 | XORSTR_FORCEINLINE constexpr std::size_t _buffer_size()
54 | {
55 | return ((Size / 16) + (Size % 16 != 0)) * 2;
56 | }
57 |
58 | template
59 | XORSTR_FORCEINLINE constexpr std::uint32_t key4() noexcept
60 | {
61 | std::uint32_t value = Seed;
62 | for(char c : __TIME__)
63 | value = static_cast((value ^ c) * 16777619ull);
64 | return value;
65 | }
66 |
67 | template
68 | XORSTR_FORCEINLINE constexpr std::uint64_t key8()
69 | {
70 | constexpr auto first_part = key4<2166136261 + S>();
71 | constexpr auto second_part = key4();
72 | return (static_cast(first_part) << 32) | second_part;
73 | }
74 |
75 | // loads up to 8 characters of string into uint64 and xors it with the key
76 | template
77 | XORSTR_FORCEINLINE constexpr std::uint64_t
78 | load_xored_str8(std::uint64_t key, std::size_t idx, const CharT* str) noexcept
79 | {
80 | using cast_type = typename std::make_unsigned::type;
81 | constexpr auto value_size = sizeof(CharT);
82 | constexpr auto idx_offset = 8 / value_size;
83 |
84 | std::uint64_t value = key;
85 | for(std::size_t i = 0; i < idx_offset && i + idx * idx_offset < N; ++i)
86 | value ^=
87 | (std::uint64_t{ static_cast(str[i + idx * idx_offset]) }
88 | << ((i % idx_offset) * 8 * value_size));
89 |
90 | return value;
91 | }
92 |
93 | // forces compiler to use registers instead of stuffing constants in rdata
94 | XORSTR_FORCEINLINE std::uint64_t load_from_reg(std::uint64_t value) noexcept
95 | {
96 | #if defined(__clang__) || defined(__GNUC__)
97 | asm("" : "=r"(value) : "0"(value) :);
98 | #endif
99 | return value;
100 | }
101 |
102 | template
103 | struct uint64_v {
104 | constexpr static std::uint64_t value = V;
105 | };
106 |
107 | } // namespace detail
108 |
109 | template
110 | class xor_string;
111 |
112 | template
113 | class xor_string, std::index_sequence> {
114 | #ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS
115 | constexpr static inline std::uint64_t alignment = ((Size > 16) ? 32 : 16);
116 | #else
117 | constexpr static inline std::uint64_t alignment = 16;
118 | #endif
119 |
120 | alignas(alignment) std::uint64_t _storage[sizeof...(Keys)];
121 |
122 | public:
123 | using value_type = CharT;
124 | using size_type = std::size_t;
125 | using pointer = CharT*;
126 | using const_pointer = const CharT*;
127 |
128 | template
129 | XORSTR_FORCEINLINE xor_string(L l, std::integral_constant, std::index_sequence) noexcept
130 | : _storage{ JM_XORSTR_LOAD_FROM_REG(detail::uint64_v(Keys, Indices, l())>::value)... }
131 | {}
132 |
133 | XORSTR_FORCEINLINE constexpr size_type size() const noexcept
134 | {
135 | return Size - 1;
136 | }
137 |
138 | XORSTR_FORCEINLINE void crypt() noexcept
139 | {
140 | // everything is inlined by hand because a certain compiler with a certain linker is _very_ slow
141 | #if defined(__clang__)
142 | alignas(alignment)
143 | std::uint64_t arr[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... };
144 | std::uint64_t* keys =
145 | (std::uint64_t*)JM_XORSTR_LOAD_FROM_REG((std::uint64_t)arr);
146 | #else
147 | alignas(alignment) std::uint64_t keys[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... };
148 | #endif
149 |
150 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__)
151 | #if defined(__clang__)
152 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v(
153 | reinterpret_cast(_storage) + Indices * 2,
154 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51),
155 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)),
156 | 51)), ...);
157 | #else // GCC, MSVC
158 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64(
159 | reinterpret_cast(_storage) + Indices * 2,
160 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2),
161 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...);
162 | #endif
163 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS)
164 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256(
165 | reinterpret_cast<__m256i*>(_storage) + Indices,
166 | _mm256_xor_si256(
167 | _mm256_load_si256(reinterpret_cast(_storage) + Indices),
168 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...);
169 |
170 | if constexpr(sizeof(_storage) % 32 != 0)
171 | _mm_store_si128(
172 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2),
173 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)),
174 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2))));
175 | #else
176 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128(
177 | reinterpret_cast<__m128i*>(_storage) + Indices,
178 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices),
179 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...);
180 | #endif
181 | }
182 |
183 | XORSTR_FORCEINLINE const_pointer get() const noexcept
184 | {
185 | return reinterpret_cast(_storage);
186 | }
187 |
188 | XORSTR_FORCEINLINE pointer get() noexcept
189 | {
190 | return reinterpret_cast(_storage);
191 | }
192 |
193 | XORSTR_FORCEINLINE pointer crypt_get() noexcept
194 | {
195 | // crypt() is inlined by hand because a certain compiler with a certain linker is _very_ slow
196 | #if defined(__clang__)
197 | alignas(alignment)
198 | std::uint64_t arr[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... };
199 | std::uint64_t* keys =
200 | (std::uint64_t*)JM_XORSTR_LOAD_FROM_REG((std::uint64_t)arr);
201 | #else
202 | alignas(alignment) std::uint64_t keys[]{ JM_XORSTR_LOAD_FROM_REG(Keys)... };
203 | #endif
204 |
205 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__)
206 | #if defined(__clang__)
207 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v(
208 | reinterpret_cast(_storage) + Indices * 2,
209 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51),
210 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)),
211 | 51)), ...);
212 | #else // GCC, MSVC
213 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64(
214 | reinterpret_cast(_storage) + Indices * 2,
215 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2),
216 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...);
217 | #endif
218 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS)
219 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256(
220 | reinterpret_cast<__m256i*>(_storage) + Indices,
221 | _mm256_xor_si256(
222 | _mm256_load_si256(reinterpret_cast(_storage) + Indices),
223 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...);
224 |
225 | if constexpr(sizeof(_storage) % 32 != 0)
226 | _mm_store_si128(
227 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2),
228 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)),
229 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2))));
230 | #else
231 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128(
232 | reinterpret_cast<__m128i*>(_storage) + Indices,
233 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices),
234 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...);
235 | #endif
236 |
237 | return (pointer)(_storage);
238 | }
239 | };
240 |
241 | template
242 | xor_string(L l, std::integral_constant, std::index_sequence) -> xor_string<
243 | std::remove_const_t>,
244 | Size,
245 | std::integer_sequence()...>,
246 | std::index_sequence>;
247 |
248 | } // namespace jm
249 |
250 | #endif // include guard
251 |
--------------------------------------------------------------------------------