-
Notifications
You must be signed in to change notification settings - Fork 7
/
SDK.h
1030 lines (809 loc) · 25 KB
/
SDK.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#define RVA(addr, size) ((uintptr_t)((UINT_PTR)(addr) + *(PINT)((UINT_PTR)(addr) + ((size) - sizeof(INT))) + (size)))
#define M_PI 3.14159265358979323846264338327950288419716939937510
#define _CRT_SECURE_NO_WARNINGS
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#define MAX_VERTEX_BUFFER 512 * 1024
#define MAX_INDEX_BUFFER 128 * 1024
#define NK_INCLUDE_STANDARD_IO
#define NK_INCLUDE_STANDARD_VARARGS
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#define NK_D3D11_IMPLEMENTATION
#define NK_IMPLEMENTATION
#include "imgui/imgui.h"
#include "imgui/imgui_impl_dx11.h"
#include "imgui/imgui_internal.h"
#include "vector3d.h"
#include "Defines.h"
#include "Offsets.h"
#include "lazyimporter.h"
#include "xor.h"
#include <windows.h>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <time.h>
#include <math.h>
#include <D3D11.h>
#include <codecvt>
#include <Psapi.h>
#include <list>
#include <wchar.h>
#include <tchar.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <ostream>
#include <regex>
#include <winuser.h>
#include <WinReg.h>
#include <winternl.h>
#include <TlHelp32.h>
#include <random>
#include <ctime>
#include <urlmon.h>
#pragma comment(lib, "Psapi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "ntdll.lib")
float FOVAngle;
uintptr_t UWorld;
uintptr_t BoneMatrix;
uintptr_t FreeFn;
uintptr_t ProjectWorldToScreen;
uintptr_t LineOfS;
uintptr_t GetNameByIndex;
Vector3 CamLoc;
Vector3 CamRot;
namespace detail
{
extern "C" void* _spoofer_stub();
template <typename Ret, typename... Args>
static inline auto shellcode_stub_helper(
const void* shell,
Args... args
) -> Ret
{
auto fn = (Ret(*)(Args...))(shell);
return fn(args...);
}
template <std::size_t Argc, typename>
struct argument_remapper
{
template<
typename Ret,
typename First,
typename Second,
typename Third,
typename Fourth,
typename... Pack
>
static auto do_call(const void* shell, void* shell_param, First first, Second second,
Third third, Fourth fourth, Pack... pack) -> Ret
{
return shellcode_stub_helper< Ret, First, Second, Third, Fourth, void*, void*, Pack... >(shell, first, second, third, fourth, shell_param, nullptr, pack...);
}
};
template <std::size_t Argc>
struct argument_remapper<Argc, std::enable_if_t<Argc <= 4>>
{
template<
typename Ret,
typename First = void*,
typename Second = void*,
typename Third = void*,
typename Fourth = void*
>
static auto do_call(
const void* shell,
void* shell_param,
First first = First{},
Second second = Second{},
Third third = Third{},
Fourth fourth = Fourth{}
) -> Ret
{
return shellcode_stub_helper<
Ret,
First,
Second,
Third,
Fourth,
void*,
void*
>(
shell,
first,
second,
third,
fourth,
shell_param,
nullptr
);
}
};
}
uintptr_t Iamgayaddr = (uintptr_t)LI_FN(GetModuleHandleA)(xorstr("FortniteClient-Win64-Shipping.exe"));
template <typename Ret, typename... Args>
static inline auto SpoofCall(Ret(*fn)(Args...), Args... args) -> Ret
{
static const void* jmprbx = nullptr;
if (!jmprbx) {
const auto ntdll = reinterpret_cast<const unsigned char*>(Iamgayaddr);
const auto dos = reinterpret_cast<const IMAGE_DOS_HEADER*>(ntdll);
const auto nt = reinterpret_cast<const IMAGE_NT_HEADERS*>(ntdll + dos->e_lfanew);
const auto sections = IMAGE_FIRST_SECTION(nt);
const auto num_sections = nt->FileHeader.NumberOfSections;
constexpr char section_name[5]{ '.', 't', 'e', 'x', 't' };
const auto section = std::find_if(sections, sections + num_sections, [&](const auto& s) {
return std::equal(s.Name, s.Name + 5, section_name);
});
constexpr unsigned char instr_bytes[2]{ 0xFF, 0x26 };
const auto va = ntdll + section->VirtualAddress;
jmprbx = std::search(va, va + section->Misc.VirtualSize, instr_bytes, instr_bytes + 2);
}
struct shell_params
{
const void* trampoline;
void* function;
void* rdx;
};
shell_params p
{
jmprbx,
reinterpret_cast<void*>(fn)
};
using mapper = detail::argument_remapper<sizeof...(Args), void>;
return mapper::template do_call<Ret, Args...>((const void*)&detail::_spoofer_stub, &p, args...);
}
namespace SpoofRuntime {
inline float acosf_(float x)
{
return SpoofCall(acosf, x);
}
inline float atan2f_(float x, float y)
{
return SpoofCall(atan2f, x, y);
}
inline float sqrtf_(float x)
{
union { float f; uint32_t i; } z = { x };
z.i = 0x5f3759df - (z.i >> 1);
z.f *= (1.5f - (x * 0.5f * z.f * z.f));
z.i = 0x7EEEEEEE - z.i;
return z.f;
}
double powf_(double x, int y)
{
double temp;
if (y == 0)
return 1;
temp = powf_(x, y / 2);
if ((y % 2) == 0) {
return temp * temp;
}
else {
if (y > 0)
return x * temp * temp;
else
return (temp * temp) / x;
}
}
inline float cosf_(float x)
{
return SpoofCall(cosf, x);
}
inline float sinf_(float x)
{
return SpoofCall(sinf, x);
}
}
BOOL valid_pointer(DWORD64 address)
{
if (!IsBadWritePtr((LPVOID)address, (UINT_PTR)8)) return TRUE;
else return FALSE;
}
template<typename ReadT>
ReadT read(DWORD_PTR address, const ReadT& def = ReadT())
{
if (valid_pointer(address)) {
return *(ReadT*)(address);
}
}
template<typename WriteT>
bool write(DWORD_PTR address, WriteT value, const WriteT& def = WriteT())
{
if (valid_pointer(address)) {
*(WriteT*)(address) = value;
return true;
}
return false;
}
uintptr_t PlayerController;
uintptr_t LocalPawn;
#define get_array_size(array) (sizeof(array) / sizeof(array[0]))
int random_int(int min, int max)
{
int range = max - min;
static bool seed = false;
if (!seed)
{
srand((unsigned int)time(0));
seed = true;
}
return rand() % range + min;
}
float distance(int x1, int y1, int x2, int y2)
{
return (int)SpoofRuntime::sqrtf_((int)SpoofRuntime::powf_(x2 - x1, 2) +
(int)SpoofRuntime::powf_(y2 - y1, 2) * 1.0);
}
namespace SDK
{
namespace Structs
{
struct FMatrix
{
float M[4][4];
};
static FMatrix* myMatrix = new FMatrix();
typedef struct {
float X, Y, Z;
} FVector;
struct FVector2D
{
FVector2D() : x(0.f), y(0.f)
{
}
FVector2D(float _x, float _y) : x(_x), y(_y)
{
}
~FVector2D()
{
}
float x, y;
};
template<class T>
struct TArray
{
friend struct FString;
public:
inline TArray()
{
Data = nullptr;
Count = Max = 0;
};
inline int Num() const
{
return Count;
};
inline T& operator[](int i)
{
return Data[i];
};
inline const T& operator[](int i) const
{
return Data[i];
};
inline bool IsValidIndex(int i) const
{
return i < Num();
}
private:
T* Data;
int32_t Count;
int32_t Max;
};
class FText {
private:
char _padding_[0x28];
PWCHAR Name;
DWORD Length;
public:
inline PWCHAR c_wstr() {
return Name;
}
inline char* c_str()
{
char sBuff[255];
wcstombs((char*)sBuff, (const wchar_t*)this->Name, sizeof(sBuff));
return sBuff;
}
};
struct FString : private TArray<wchar_t>
{
inline FString()
{
};
FString(const wchar_t* other)
{
Max = Count = *other ? std::wcslen(other) + 1 : 0;
if (Count)
{
Data = const_cast<wchar_t*>(other);
}
};
inline bool IsValid() const
{
return Data != nullptr;
}
inline const wchar_t* c_str() const
{
return Data;
}
std::string ToString() const
{
auto length = std::wcslen(Data);
std::string str(length, '\0');
std::use_facet<std::ctype<wchar_t>>(std::locale()).narrow(Data, Data + length, '?', &str[0]);
return str;
}
};
}
//Functions
//typedef bool(__fastcall* WorldToScreen_t)(std::uint64_t PlayerController, Vector3 vWorldPos, Vector3* vScreenPos, char);
//WorldToScreen_t fnWorldToScreen;
namespace Classes
{
class APlayerCameraManager
{
public:
static float GetFOVAngle(uintptr_t PlayerCameraManager)
{
auto GetFOVAngle = reinterpret_cast<float(*)(UINT64, char*)>(*(ULONG_PTR*)(*(ULONG_PTR*)PlayerCameraManager + 0x740));
return SpoofCall(GetFOVAngle, (ULONG_PTR)PlayerCameraManager, (char*)0);
}
static Vector3 GetCameraLocation(uintptr_t PlayerCameraManager)
{
auto GetCameraLocation = reinterpret_cast<Vector3(*)(UINT64, char*)>(*(ULONG_PTR*)(*(ULONG_PTR*)PlayerCameraManager + 0x788));
return SpoofCall(GetCameraLocation, (ULONG_PTR)PlayerCameraManager, (char*)0);
}
static Vector3 GetCameraRotation(uintptr_t PlayerCameraManager)
{
auto GetCameraRotation = reinterpret_cast<Vector3(*)(UINT64, char*)>(*(ULONG_PTR*)(*(ULONG_PTR*)PlayerCameraManager + 0x710));
return SpoofCall(GetCameraRotation, (ULONG_PTR)PlayerCameraManager, (char*)0);
}
static BOOLEAN LineOfSightTo(PVOID PlayerController, PVOID Actor, Vector3* ViewPoint) {
auto LOSTo = reinterpret_cast<bool(__fastcall*)(PVOID PlayerController, PVOID Actor, Vector3 * ViewPoint)>(LineOfS);
return SpoofCall(LOSTo, PlayerController, Actor, ViewPoint);
}
static bool GetPlayerViewPoint(uintptr_t PlayerController, Vector3* vCameraPos, Vector3* vCameraRot)
{
if (!PlayerController) return false;
static uintptr_t pGetPlayerViewPoint = 0;
if (!pGetPlayerViewPoint)
{
uintptr_t VTable = *(uintptr_t*)PlayerController;
if (!VTable) return false;
pGetPlayerViewPoint = *(uintptr_t*)(VTable + 0x788);
if (!pGetPlayerViewPoint) return false;
}
auto GetPlayerViewPoint = reinterpret_cast<void(__fastcall*)(uintptr_t, Vector3*, Vector3*)>(pGetPlayerViewPoint);
SpoofCall(GetPlayerViewPoint, (uintptr_t)PlayerController, vCameraPos, vCameraRot);
return true;
}
};
class UObject
{
public:
static void FreeObjName(__int64 address)
{
auto func = reinterpret_cast<__int64(__fastcall*)(__int64 a1)>(FreeFn);
SpoofCall(func, address);
}
static const char* GetObjectName(uintptr_t Object)
{
if (Object == NULL)
return ("");
auto fGetObjName = reinterpret_cast<SDK::Structs::FString * (__fastcall*)(int* index, SDK::Structs::FString * res)>(GetNameByIndex);
//auto heheh = reinterpret_cast<SDK::Structs::FString * (__fastcall*)(int* index, SDK::Structs::FString * res)>(GetNameByIndex);
int index = *(int*)(Object + 0x18);
SDK::Structs::FString result;
SpoofCall(fGetObjName, &index, &result);
if (result.c_str() == NULL)
return ("");
auto result_str = result.ToString();
if (result.c_str() != NULL)
FreeObjName((__int64)result.c_str());
return result_str.c_str();
}
};
class USkeletalMeshComponent
{
public:
static bool GetBoneLocation(uintptr_t CurrentActor, int id, Vector3* out)
{
uintptr_t mesh = read<uintptr_t>(CurrentActor + StaticOffsets::Mesh);
if (!mesh) return false;
auto fGetBoneMatrix = ((Structs::FMatrix * (__fastcall*)(uintptr_t, Structs::FMatrix*, int))(BoneMatrix));
SpoofCall(fGetBoneMatrix, mesh, Structs::myMatrix, id);
out->x = Structs::myMatrix->M[3][0];
out->y = Structs::myMatrix->M[3][1];
out->z = Structs::myMatrix->M[3][2];
return true;
}
static Vector3 GetBoneDebug(uintptr_t CurrentActor, int id)
{
uintptr_t mesh = read<uintptr_t>(CurrentActor + StaticOffsets::Mesh);
if (!mesh) return Vector3(0, 0, 0);
auto fGetBoneMatrix = ((Structs::FMatrix * (__fastcall*)(uintptr_t, Structs::FMatrix*, int))(BoneMatrix));
SpoofCall(fGetBoneMatrix, mesh, Structs::myMatrix, id);
Vector3 out;
out.x = Structs::myMatrix->M[3][0];
out.y = Structs::myMatrix->M[3][1];
out.z = Structs::myMatrix->M[3][2];
return out;
}
};
class AController
{
public:
static bool WorldToScreen(Vector3 WorldLocation, Vector3* out)
{
//if (!fnWorldToScreen) {
// fnWorldToScreen = reinterpret_cast<WorldToScreen_t>(ProjectWorldToScreen);
//}
auto WorldToScreen = reinterpret_cast<bool(__fastcall*)(uintptr_t pPlayerController, Vector3 vWorldPos, Vector3 * vScreenPosOut, char)>(ProjectWorldToScreen);
SpoofCall(WorldToScreen, (uintptr_t)PlayerController, WorldLocation, out, (char)0);
return true;
}
static void SetControlRotation(Vector3 NewRotation, bool bResetCamera = false)
{
auto SetControlRotation_ = (*(void(__fastcall**)(uintptr_t Controller, Vector3 NewRotation, bool bResetCamera))(*(uintptr_t*)PlayerController + 0x6F8));
SpoofCall(SetControlRotation_, PlayerController, NewRotation, bResetCamera);
}
};
}
namespace Utils
{
double GetCrossDistance(double x1, double y1, double x2, double y2)
{
return SpoofRuntime::sqrtf_(SpoofRuntime::powf_((float)(x1 - x2), (float)2) + SpoofRuntime::powf_((float)(y1 - y2), (float)2));
}
inline float GetDistLength(Vector3 from, Vector3 to)
{
return float(SpoofRuntime::sqrtf_(SpoofRuntime::powf_(to.x - from.x, 2.0) + SpoofRuntime::powf_(to.y - from.y, 2.0) + SpoofRuntime::powf_(to.z - from.z, 2.0)));
}
Vector3 AimbotPrediction(float bulletVelocity, float bulletGravity, float targetDistance, Vector3 targetPosition, Vector3 targetVelocity) {
Vector3 recalculated = targetPosition;
float gravity = fabs(bulletGravity);
float time = targetDistance / fabs(bulletVelocity);
float bulletDrop = (gravity / 250) * time * time;
recalculated.z += bulletDrop * 120;
recalculated.x += time * (targetVelocity.x);
recalculated.y += time * (targetVelocity.y);
recalculated.z += time * (targetVelocity.z);
return recalculated;
}
bool CheckInScreen(uintptr_t CurrentActor, int Width, int Height) {
Vector3 Pos;
Classes::USkeletalMeshComponent::GetBoneLocation(CurrentActor, 66, &Pos);
Classes::AController::WorldToScreen(Pos, &Pos);
if (CurrentActor)
{
if (((Pos.x <= 0 or Pos.x > Width) and (Pos.y <= 0 or Pos.y > Height)) or ((Pos.x <= 0 or Pos.x > Width) or (Pos.y <= 0 or Pos.y > Height))) {
return false;
}
else {
return true;
}
}
}
bool CheckItemInScreen(uintptr_t CurrentActor, int Width, int Height) {
Vector3 Pos;
//MessageBoxA(NULL, "Before RootComponent", "", MB_OK);
uintptr_t RootComponent = read<uintptr_t>(CurrentActor + StaticOffsets::RootComponent);
//std::cout << "TheOmegaLul: " << RootComponent << "\n";
//MessageBoxA(NULL, "Before RelativeLocation", "", MB_OK);
//if (!RootComponent) return false;
Vector3 RelativeLocation = read<Vector3>(RootComponent + StaticOffsets::RelativeLocation);
//MessageBoxA(NULL, "Before WorldToScreen", "", MB_OK);
Classes::AController::WorldToScreen(RelativeLocation, &Pos);
if (CurrentActor)
{
//MessageBoxA(NULL, "Before THE OMEGALUL IF", "", MB_OK);
if (((Pos.x <= 0 or Pos.x > Width) and (Pos.y <= 0 or Pos.y > Height)) or ((Pos.x <= 0 or Pos.x > Width) or (Pos.y <= 0 or Pos.y > Height))) {
return false;
}
else {
return true;
}
}
}
bool CheckIfInFOV(uintptr_t CurrentActor, float& max)
{
Vector3 Pos;
Classes::USkeletalMeshComponent::GetBoneLocation(CurrentActor, Settings::aimbone, &Pos);
Classes::AController::WorldToScreen(Pos, &Pos);
if (CurrentActor)
{
float Dist = GetCrossDistance(Pos.x, Pos.y, (Renderer_Defines::Width / 2), (Renderer_Defines::Height / 2));
if (Dist < max)
{
float Radius = (Settings::FovCircle_Value * Renderer_Defines::Width / FOVAngle) / 2;
if (Pos.x <= ((Renderer_Defines::Width / 2) + Radius) &&
Pos.x >= ((Renderer_Defines::Width / 2) - Radius) &&
Pos.y <= ((Renderer_Defines::Height / 2) + Radius) &&
Pos.y >= ((Renderer_Defines::Height / 2) - Radius))
{
max = Dist;
return true;
}
return false;
}
}
return false;
}
Vector3 CalculateNewRotation(uintptr_t CurrentActor, Vector3 LocalRelativeLocation, bool prediction)
{
Vector3 RetVector = { 0,0,0 };
Vector3 rootHead;
Vector3 Headbox;
Classes::USkeletalMeshComponent::GetBoneLocation(CurrentActor, Settings::aimbone, &rootHead);
Classes::AController::WorldToScreen(Vector3(rootHead.x, rootHead.y, rootHead.z + 20), &Headbox);
Vector3 calculated;
if (prediction) {
float distance = Utils::GetDistLength(LocalRelativeLocation, Headbox) / 250;
uint64_t CurrentActorRootComponent = read<uint64_t>(CurrentActor + 0x130);
Vector3 vellocity = read<Vector3>(CurrentActorRootComponent + 0x140);
Vector3 Predicted = Utils::AimbotPrediction(30000, -504, distance, rootHead, vellocity);
calculated = Predicted;
}
else {
calculated = rootHead;
}
if (calculated.x == 0 && calculated.y == 0) return Vector3(0, 0, 0);
Vector3 VectorPos = calculated - CamLoc;
float distance = VectorPos.Length();
RetVector.x = -((SpoofRuntime::acosf_(VectorPos.z / distance) * (float)(180.0f / M_PI)) - 90.f);
RetVector.y = SpoofRuntime::atan2f_(VectorPos.y, VectorPos.x) * (float)(180.0f / M_PI);
return RetVector;
}
Vector3 SmoothAngles(Vector3 rot1, Vector3 rot2)
{
Vector3 ret;
auto currentRotation = rot1;
ret.x = (rot2.x - rot1.x) / Settings::smooth + rot1.x;
ret.y = (rot2.y - rot1.y) / Settings::smooth + rot1.y;
return ret;
}
}
}
namespace Scanners
{
uintptr_t PatternScan(uintptr_t pModuleBaseAddress, const char* sSignature, size_t nSelectResultIndex = 0);
uintptr_t PatternScan(const char* sSignature, size_t nSelectResultIndex = 0);
uintptr_t PatternScan(uintptr_t pModuleBaseAddress, const char* sSignature, size_t nSelectResultIndex)
{
static auto patternToByte = [](const char* pattern)
{
auto bytes = std::vector<int>{};
const auto start = const_cast<char*>(pattern);
const auto end = const_cast<char*>(pattern) + strlen(pattern);
for (auto current = start; current < end; ++current)
{
if (*current == '?')
{
++current;
if (*current == '?')
++current;
bytes.push_back(-1);
}
else
bytes.push_back(strtoul(current, ¤t, 16));
}
return bytes;
};
const auto dosHeader = (PIMAGE_DOS_HEADER)pModuleBaseAddress;
const auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)pModuleBaseAddress + dosHeader->e_lfanew);
const auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
auto patternBytes = patternToByte(sSignature);
const auto scanBytes = reinterpret_cast<std::uint8_t*>(pModuleBaseAddress);
const auto s = patternBytes.size();
const auto d = patternBytes.data();
size_t nFoundResults = 0;
for (auto i = 0ul; i < sizeOfImage - s; ++i)
{
bool found = true;
for (auto j = 0ul; j < s; ++j)
{
if (scanBytes[i + j] != d[j] && d[j] != -1)
{
found = false;
break;
}
}
if (found)
{
if (nSelectResultIndex != 0)
{
if (nFoundResults < nSelectResultIndex)
{
nFoundResults++;
found = false;
}
else
return reinterpret_cast<uintptr_t>(&scanBytes[i]);
}
else
return reinterpret_cast<uintptr_t>(&scanBytes[i]);
}
}
return NULL;
}
uintptr_t PatternScan(const char* sSignature, size_t nSelectResultIndex)
{
static bool bIsSetted = false;
static MODULEINFO info = { 0 };
if (!bIsSetted)
{
GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &info, sizeof(info));
bIsSetted = true;
}
return PatternScan((uintptr_t)info.lpBaseOfDll, sSignature, nSelectResultIndex);
}
}
namespace MemoryHelper {
uintptr_t PatternScanW(uintptr_t pModuleBaseAddress, const char* sSignature, size_t nSelectResultIndex = 0)
{
static auto patternToByte = [](const char* pattern)
{
auto bytes = std::vector<int>{};
const auto start = const_cast<char*>(pattern);
const auto end = const_cast<char*>(pattern) + SpoofCall(strlen, pattern);
for (auto current = start; current < end; ++current)
{
if (*current == '?')
{
++current;
if (*current == '?')
++current;
bytes.push_back(-1);
}
else
bytes.push_back(strtoul(current, ¤t, 16));
}
return bytes;
};
const auto dosHeader = (PIMAGE_DOS_HEADER)pModuleBaseAddress;
const auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)pModuleBaseAddress + dosHeader->e_lfanew);
const auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
auto patternBytes = patternToByte(sSignature);
const auto scanBytes = reinterpret_cast<std::uint8_t*>(pModuleBaseAddress);
const auto s = patternBytes.size();
const auto d = patternBytes.data();
size_t nFoundResults = 0;
for (auto i = 0ul; i < sizeOfImage - s; ++i)
{
bool found = true;
for (auto j = 0ul; j < s; ++j)
{
if (scanBytes[i + j] != d[j] && d[j] != -1)
{
found = false;
break;
}
}
if (found)
{
if (nSelectResultIndex != 0)
{
if (nFoundResults < nSelectResultIndex)
{
nFoundResults++;
found = false;
}
else
return reinterpret_cast<uintptr_t>(&scanBytes[i]);
}
else
return reinterpret_cast<uintptr_t>(&scanBytes[i]);
}
}
return NULL;
}
uintptr_t PatternScan(const char* sSignature, size_t nSelectResultIndex = 0)
{
static bool bIsSetted = false;
static MODULEINFO info = { 0 };
if (!bIsSetted)
{
LI_FN(GetModuleInformation)(LI_FN(GetCurrentProcess)(), LI_FN(GetModuleHandleA)(xorstr("FortniteClient-Win64-Shipping.exe")), &info, sizeof(info));
bIsSetted = true;
}
return SpoofCall(PatternScanW, (uintptr_t)info.lpBaseOfDll, sSignature, nSelectResultIndex);
}
}
namespace ObsHelper {
uintptr_t GetObsModule()
{
std::string module = ("graphics-hook64.dll");
return (uintptr_t)GetModuleHandleA(module.c_str());
}
void InsertHook(__int64 addr, __int64 func, __int64* orig)
{
static uintptr_t hook_addr;
if (!hook_addr)
hook_addr = Scanners::PatternScan(GetObsModule(), xorstr("FF 15 ? ? ? ? 48 8B 16 48 8B CE FF 52 10 48"));
auto hook = ((__int64(__fastcall*)(__int64 addr, __int64 func, __int64* orig, __int64 smthng))(hook_addr));
hook((__int64)addr, (__int64)func, orig, (__int64)1);
}
short GetAsyncKeyState(const int vKey)
{
static uintptr_t addrGetAsyncKeyState = NULL;
if (!addrGetAsyncKeyState)
{
addrGetAsyncKeyState = Scanners::PatternScan(GetObsModule(),
xorstr("FF 15 ? ? ? ? 48 8B 16 48 8B CE FF 52 10 48"));
}
if (!addrGetAsyncKeyState)
return false;
using GetAsyncKeyState_t = short(__fastcall*)(int);
auto fnGetAyncKeyState = (GetAsyncKeyState_t)addrGetAsyncKeyState;
return fnGetAyncKeyState(vKey);
}
short SetCursorPos(int x, int y)
{
static uintptr_t addrSetCursorPos = NULL;
if (!addrSetCursorPos)
{
addrSetCursorPos = Scanners::PatternScan(GetObsModule(),
xorstr(""));
}
if (!addrSetCursorPos)
return false;
using SetCursorPos_t = short(__fastcall*)(int, int);
auto fnSetCursorPos = (SetCursorPos_t)addrSetCursorPos;
return fnSetCursorPos(x, y);
}
bool GetCursorPos(LPPOINT lpPoint)
{
static uintptr_t addrGetCursorPos = NULL;
if (!addrGetCursorPos)
{
addrGetCursorPos = Scanners::PatternScan(GetObsModule(),
xorstr(""));
}
if (!addrGetCursorPos)
return false;
using GetCursorPos_t = short(__fastcall*)(LPPOINT);
auto fnGetCursorPos = (GetCursorPos_t)addrGetCursorPos;
return fnGetCursorPos(lpPoint);
}
HCURSOR SetCursor(HCURSOR hCursor)
{
static uintptr_t addrSetCursor = NULL;
if (!addrSetCursor)
{
addrSetCursor = Scanners::PatternScan(GetObsModule(),
xorstr(""));
}
if (!addrSetCursor)