-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhack.cpp
More file actions
1262 lines (1165 loc) · 54.1 KB
/
hack.cpp
File metadata and controls
1262 lines (1165 loc) · 54.1 KB
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
#include "hack.h"
#include "jwsettings.h"
unsigned int offsets::m_pStudioBones = 0x2C70; // unsigned long long m_pStudioBones;
unsigned int offsets::m_flLowerBodyYawTarget = 0x42A8; // float m_flLowerBodyYawTarget; // 0x42C8
unsigned int offsets::dwViewMatrix = 0x2537374; // 4x4 float matrix //2537334 and 2553C14 on Aug-7-17
unsigned int offsets::m_lifeState = 0x293; // int m_lifeState; // 0x293
unsigned int offsets::m_bIsDefusing = 0x414C; // unsigned char m_bIsDefusing; // 0x416C
unsigned int offsets::m_bIsScoped = 0x4144; // unsigned char m_bIsScoped; // 0x4164
unsigned int offsets::m_bGunGameImmunity = 0x4178; // unsigned char m_bGunGameImmunity; // 0x4178
unsigned int offsets::m_iShotsFired = 0xAB90; // int m_iShotsFired; // 0xAB90 todo: sig scan for it
unsigned int offsets::m_aimPunchAngle = 0x3764; // Vector m_aimPunchAngle; // 0x3764
unsigned int offsets::m_fFlashMaxAlpha = 0xabd4; // flash max alpha 0-255 float value
unsigned int offsets::m_iFOV = 0x3998; // fov when you are doing something other than being normal (scoped, etc.)
unsigned int offsets::m_iFOVStart = 0x399c; // default fov
unsigned int offsets::m_viewPunchAngle = 0x3758; // Vector m_viewPunchAngle; // 0x3758
unsigned int offsets::m_hObserverTarget = 0x3b54; // unsigned long long m_hObserverTarget; // 0x3B54
unsigned int offsets::m_iObserveCamType = 0x3b50; // int 4 1st person, 5 3rd person, 6 free cam
unsigned int offsets::m_bIsSpotted = 0xECD; // todo: sig
unsigned int offsets::m_hActiveWeapon = 0x3628; // todo: sig
unsigned int offsets::m_iWeaponID =
0x3788; // this is wrong name, its actually m_AttributeManager + m_Item + m_iItemDefinitionIndex
unsigned int offsets::m_AttributeManager = 0x34c0; // todo: sig offset from entity to DataTable
unsigned int offsets::m_iItemDefinitionIndex =
0x268; // offset from m_Item (DataTable + 0x60) of DataTable to the weapon's economy ID
int settings::misc::hitmarker_time = 8;
float settings::misc::hitmarker_length = 10;
float settings::misc::hitmarker_width = 1.5;
static int SIX = 6;
static int toggleOn = 5;
static int toggleOff = 4;
bool hack::IsConnected()
{
return isConnected;
}
void hack::readEntities(std::array<EntityInfo, 64>& rentities)
{
std::lock_guard<std::mutex> l(entities_access);
rentities = entities;
}
void hack::writeEntities(std::array<EntityInfo, 64>& wentities)
{
std::lock_guard<std::mutex> l(entities_access);
entities = wentities;
}
std::array<unsigned long, 64> hack::readAllPlayerNamePtrs(unsigned long playerresources_adr)
{
std::array<unsigned long, 64> nameptrs;
playerresources_adr += 0xf78; // todo: variable for this hardcoded offset
csgo.Read((void*)playerresources_adr, &nameptrs, sizeof(unsigned long) * 64);
return nameptrs;
}
std::array<std::string, 64> hack::readAllPlayerNames(unsigned long playerresources_adr)
{
struct iovec local[1];
struct iovec remote[64];
std::array<std::array<char, 64>, 64> names_buf;
std::array<unsigned long, 64> nameptrs;
std::array<std::string, 64> names;
nameptrs = readAllPlayerNamePtrs(playerresources_adr);
for (int i = 0; i < 64; i++) {
remote[i].iov_base = (void*)nameptrs[i];
remote[i].iov_len = sizeof(char) * 64;
}
local[0].iov_base = &names_buf;
local[0].iov_len = sizeof(char) * 64 * 64;
process_vm_readv(csgo.GetPid(), local, 1, remote, 64, 0);
for (int i = 0; i < 64; i++) {
int endindex = 63;
for (int j = 0; j < 64; j++) {
if (names_buf[i][j] == 0) {
endindex = j;
break;
}
}
std::string name(names_buf[i].begin(), endindex);
names[i] = name;
}
return names;
}
std::array<bool, 64> hack::findSpectatorsOfEnt(std::array<EntityInfo, 64> entityInfo, int entID)
{
std::array<bool, 64> spectators;
for (int i = 0; i < 64; i++) {
unsigned long long hObserverTarget = 0;
csgo.Read((void*)entityInfo[i].entityPtr + offsets::m_hObserverTarget, &hObserverTarget, sizeof(long long));
hObserverTarget &= 0xFFF;
if (hObserverTarget == entID && !entityInfo[i].entity.m_bDormant) {
spectators[i] = true;
} else {
spectators[i] = false;
}
}
return spectators;
}
bool hack::getWorldToScreenData(std::array<EntityToScreen, 64>& output, Vector& rcsCross)
{
if (!hack::isConnected) {
return false;
}
int observeCamType = 0;
unsigned long long hObserverTarget = 0;
unsigned long serverDetail = 0;
unsigned long one = 0;
unsigned long two = 0;
unsigned long addressOfViewAngle = 0;
unsigned long playerresources_adr = 0;
int myLife = 0;
QAngle aimpunch;
QAngle viewpunch;
QAngle baseAng;
QAngle myTotalAng;
Vector myActualPos;
std::array<EntityInfo, 64> entitiesForScreen;
hack::readEntities(entitiesForScreen);
unsigned long localPlayer = 0;
Entity myEnt;
Entity specEnt;
FOV_t FOV;
std::array<std::string, 64> names;
std::array<bool, 64> spectators;
if (!csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long))) {
return false;
}
if (localPlayer == 0) {
return false;
}
csgo.Read((void*)hack::addressServerDetail, &serverDetail, sizeof(int));
csgo.Read((void*)hack::basePointerOfViewAngle, &one, sizeof(long));
csgo.Read((void*)one + serverDetail, &two, sizeof(long));
csgo.Read((void*)two + 0x4308, &addressOfViewAngle, sizeof(long));
addressOfViewAngle += 0x8e20;
csgo.Read((void*)(unsigned long)addressOfViewAngle, &(baseAng), sizeof(QAngle));
csgo.Read((void*)localPlayer, &myEnt, sizeof(Entity));
csgo.Read((void*)localPlayer + offsets::m_lifeState, &myLife, sizeof(char));
// cout<<"ang x: "<<myTotalAng.x<<" ang y: "<<myTotalAng.y;
// cout<<" pos.x "<<myActualPos.x<<" pos.y "<<myActualPos.y<<endl;
// cout<<myActualPos.z<<endl;
// cout<<"FOV "<<FOV<<" FOVSTART "<<FOVStart<<endl;
// cout<<"my life "<<myLife<<endl;
csgo.Read((void*)playerresources_ptr, &playerresources_adr, sizeof(int));
csgo.Read((void*)localPlayer + offsets::m_iObserveCamType, &observeCamType, sizeof(int));
names = hack::readAllPlayerNames(playerresources_adr);
if (myLife == LIFE_ALIVE && observeCamType == 0) {
// if we are alive and not spectating someone
csgo.Read((void*)localPlayer + offsets::m_iFOV, &FOV, sizeof(FOV_t));
if (FOV.iFOV == 0 && FOV.iFOVStart != 0) {
FOV.iFOV = FOV.iFOVStart;
}
csgo.Read((void*)localPlayer + offsets::m_aimPunchAngle, &aimpunch, sizeof(QAngle));
csgo.Read((void*)localPlayer + offsets::m_viewPunchAngle, &viewpunch, sizeof(QAngle));
rcsCross = helper::RecoilCrosshair(aimpunch, FOV.iFOV);
specEnt = myEnt;
} else if (observeCamType == 4) {
// if the cam is type 4 which means first person
csgo.Read((void*)localPlayer + offsets::m_hObserverTarget, &hObserverTarget, sizeof(long long));
hObserverTarget &= 0xfff;
if (hObserverTarget == 0xfff) {
// 0xfff is the max and i think its reserved for our ent.
csgo.Read((void*)localPlayer + offsets::m_iFOV, &FOV, sizeof(FOV_t));
if (FOV.iFOV == 0 && FOV.iFOVStart != 0) {
FOV.iFOV = FOV.iFOVStart;
}
csgo.Read((void*)localPlayer + offsets::m_aimPunchAngle, &aimpunch, sizeof(QAngle));
csgo.Read((void*)localPlayer + offsets::m_viewPunchAngle, &viewpunch, sizeof(QAngle));
specEnt = myEnt;
rcsCross = helper::RecoilCrosshair(aimpunch, FOV.iFOV);
} else if (hObserverTarget > 1 && hObserverTarget < 64) {
// if its between 2 and 63 then its most likely valid ent, so set it as the ent we are spectating and use
// it's FOV and aimpunch for calculations
csgo.Read((void*)entitiesForScreen[hObserverTarget].entityPtr + offsets::m_iFOV, &FOV, sizeof(FOV_t));
if (FOV.iFOV == 0 && FOV.iFOVStart != 0) {
FOV.iFOV = FOV.iFOVStart;
}
csgo.Read((void*)entitiesForScreen[hObserverTarget].entityPtr + offsets::m_aimPunchAngle,
&aimpunch,
sizeof(QAngle));
csgo.Read((void*)entitiesForScreen[hObserverTarget].entityPtr + offsets::m_viewPunchAngle,
&viewpunch,
sizeof(QAngle));
specEnt = entitiesForScreen[hObserverTarget].entity;
rcsCross = helper::RecoilCrosshair(aimpunch, FOV.iFOV);
}
} else if (observeCamType == 2 || observeCamType == 1) {
rcsCross = Vector(-99999, -99999, -99999);
return true;
} else {
// if we arent in cam 4 and we arent alive then we are most likely in freecam or third person, therefore we
// don't need the rcsCross and can just use our localplayer's FOV
rcsCross = Vector(-99999, -99999, -99999);
csgo.Read((void*)localPlayer + offsets::m_iFOV, &FOV, sizeof(FOV_t));
if (FOV.iFOV == 0 && FOV.iFOVStart != 0) {
FOV.iFOV = FOV.iFOVStart;
}
csgo.Read((void*)localPlayer + offsets::m_aimPunchAngle, &aimpunch, sizeof(QAngle));
csgo.Read((void*)localPlayer + offsets::m_viewPunchAngle, &viewpunch, sizeof(QAngle));
specEnt = myEnt;
}
spectators = hack::findSpectatorsOfEnt(entitiesForScreen, specEnt.ID);
// add up all the angles
myTotalAng.x = baseAng.x + aimpunch.x + viewpunch.x;
myTotalAng.y = baseAng.y + aimpunch.y + viewpunch.y;
myTotalAng.z = 0;
// get position and account for view offset (crouching or standing)
myActualPos = myEnt.m_vecNetworkOrigin;
myActualPos.z += myEnt.m_vecViewOffset.z;
for (int i = 0; i < 64; i++) {
output[i].name = names[i];
output[i].spectatingMe = spectators[i];
if (entitiesForScreen[i].entity.m_iHealth <= 0 || entitiesForScreen[i].entity.m_bDormant ||
entitiesForScreen[i].entity.ID == specEnt.ID || entitiesForScreen[i].entityPtr == 0) {
continue;
}
// cout<<"found one #"<<i<<endl;
Vector vecScreenOrigin(-99999, -99999, -99999);
Vector vecScreenHeight(-99999, -99999, -99999);
Vector height = entitiesForScreen[i].entity.m_vecAbsOrigin;
/*if(entitiesForScreen[i].entity.m_fFlags&IN_DUCK)
{
height.z+=50;
}
else
{*/
height.z += 74;
//}
vecScreenOrigin =
helper::WorldToScreen(myActualPos, entitiesForScreen[i].entity.m_vecAbsOrigin, myTotalAng, float(FOV.iFOV));
vecScreenHeight = helper::WorldToScreen(myActualPos, height, myTotalAng, float(FOV.iFOV));
if (vecScreenOrigin.x != -99999 && vecScreenHeight.x != -99999) {
output[i].origin = vecScreenOrigin;
output[i].head = vecScreenHeight;
}
uint8_t isScoped = 0;
uint8_t isDefusing = 0;
float lby = 0;
csgo.Read((void*)entitiesForScreen[i].entityPtr + offsets::m_bIsScoped, &isScoped, sizeof(uint8_t));
csgo.Read((void*)entitiesForScreen[i].entityPtr + offsets::m_bIsDefusing, &isDefusing, sizeof(uint8_t));
csgo.Read((void*)entitiesForScreen[i].entityPtr + offsets::m_flLowerBodyYawTarget, &lby, sizeof(float));
output[i].myTeam = myEnt.m_iTeamNum == entitiesForScreen[i].entity.m_iTeamNum;
output[i].scoped = isScoped > 0 ? true : false;
output[i].defusing = isDefusing;
output[i].lby = lby;
output[i].entityInfo = entitiesForScreen[i];
}
return true;
}
bool hack::totalHitsIncreased()
{
unsigned long localPlayer = 0;
int iTotalHits = 0;
csgo.Read((void*)hack::m_addressOfLocalPlayer, &localPlayer, sizeof(unsigned long));
csgo.Read((void*)localPlayer + 0xABA8, &iTotalHits, sizeof(int));
// cout<<"total hits: "<<iTotalHits<<" lastTotal: "<<lastTotalHits<<endl;
if (iTotalHits > hack::lastTotalHits) {
if (iTotalHits >= 255) {
/*int one = 1;
csgo.Write((void*)localPlayer+0xABA8,&one,sizeof(int));
hack::lastTotalHits=1;*/
hack::lastTotalHits = 0;
return false;
// if the iTotalHits is greater than/equal to 255 then it stops updating until next round
} else {
hack::lastTotalHits = iTotalHits;
}
return true;
} else if (iTotalHits >= 255) {
/*int one = 1;
csgo.Write((void*)localPlayer+0xABA8,&one,sizeof(int));
hack::lastTotalHits=1;*/
hack::lastTotalHits = 0;
return false;
// if the iTotalHits is greater than/equal to 255 then it stops updating until next round
} else {
hack::lastTotalHits = iTotalHits;
}
return false;
}
void hack::setupIsConnected()
{
uint8_t isConnected = 0;
// cout<<"hack adriscon: "<<hack::addressIsConnected<<endl;
csgo.Read((void*)hack::addressIsConnected, &isConnected, sizeof(uint8_t));
if (isConnected != 1) {
hack::isConnected = false;
} else {
hack::isConnected = true;
}
}
void hack::aim()
{
if (!hack::isConnected) {
return;
}
unsigned long localPlayer = 0;
unsigned int shotsFired = 0;
csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
if (localPlayer == 0) {
return;
}
csgo.Read((void*)(localPlayer + offsets::m_iShotsFired), &shotsFired, sizeof(int));
if (!hack::ShouldAimAssist || (hack::aimbotMaxBullets != 0 && shotsFired > hack::aimbotMaxBullets) ||
(hack::iWeaponID_lp != -1 && helper::IgnoreWeapon(iWeaponID_lp))) {
int AltTwo = 4;
csgo.Read((void*)m_addressOfAlt2, &AltTwo, sizeof(long));
if (AltTwo == 5) {
csgo.Write((void*)m_addressOfForceAttack, &toggleOn, sizeof(int));
usleep(10000);
} else if (AltTwo == 4) {
csgo.Write((void*)m_addressOfForceAttack, &toggleOff, sizeof(int));
usleep(100);
}
return;
}
QAngle newAngle;
Vector myPos;
Entity myEnt;
QAngle punch;
static QAngle oldPunch;
QAngle punchDelta;
QAngle viewAngle;
QAngle aimDelta;
int AltTwo = 4;
// mem addresses
unsigned int serverDetail = 0;
unsigned long one = 0;
unsigned long two = 0;
unsigned long addressOfViewAngle = 0;
Vector theirPos;
BoneMatrix theirBones;
static bool foundTarget; // true while found a living target (not necessarily in fov)
bool shouldShoot = false; // true if our crosshair is close enough to the enemy and we should shoot
static bool isAiming =
false; // true if mouse was clicked when foundTarget == true. remains true until mouse is released. used to
// determine if we should snap to next target (based on rage mode or legit mode setting)
static bool acquiring = false; // true if mouse clicked but didnt reach target yet. used to finish a shot in
// progress even when mouse is released early.
static bool alreadyShotOnce = false; // true if already shot once (so we can ignore acquiring)
static unsigned int idclosestEnt = 0;
float lowestDistance = -1.0; // used to determine the closest target in the entity loop
std::array<EntityInfo, 64> entitiesCopy;
hack::readEntities(entitiesCopy);
csgo.Read((void*)m_addressOfAlt2, &AltTwo, sizeof(long));
csgo.Read((void*)hack::addressServerDetail, &serverDetail, sizeof(int));
csgo.Read((void*)hack::basePointerOfViewAngle, &one, sizeof(long));
csgo.Read((void*)one + serverDetail, &two, sizeof(long));
csgo.Read((void*)two + 0x4308, &addressOfViewAngle, sizeof(long));
addressOfViewAngle += 0x8e20;
csgo.Read((void*)(unsigned long)addressOfViewAngle, &(viewAngle), sizeof(QAngle));
csgo.Read((void*)(unsigned long)localPlayer, &myEnt, sizeof(Entity));
csgo.Read((void*)(localPlayer + offsets::m_aimPunchAngle), &punch, sizeof(QAngle));
csgo.Read((void*)(localPlayer + offsets::m_iShotsFired), &shotsFired, sizeof(int));
char enemyLifeState = LIFE_DEAD;
enemyLifeState = hack::getLifeState((unsigned long)entitiesCopy[idclosestEnt].entityPtr);
if (enemyLifeState != LIFE_ALIVE ||
idclosestEnt == 0) { // if the enemy we were aiming at is not alive or is the world...
acquiring = false; // stop acquiring the target
foundTarget = false; // no target found
csgo.Read((void*) (localPlayer+0xBBB8), &idclosestEnt, sizeof(idclosestEnt));
}
punchDelta.x = punch.x - oldPunch.x;
punchDelta.y = punch.y - oldPunch.y;
newAngle = viewAngle;
myPos.x = myEnt.m_vecNetworkOrigin.x;
myPos.y = myEnt.m_vecNetworkOrigin.y;
myPos.z = myEnt.m_vecNetworkOrigin.z + myEnt.m_vecViewOffset.z;
if ((!isAiming || ShouldRage) && AltTwo == 5) { // if we aren't aiming or are in rage mode and we are clicking...
idclosestEnt = 0;
// aimbot block
for (int i = 1; i < 64; i++) {
void* entPtr = entitiesCopy[i].entityPtr;
int lifeState = hack::getLifeState((unsigned long)entPtr);
;
if ((shootFriends || ((entitiesCopy[i].entity.m_iTeamNum == 3 && myEnt.m_iTeamNum == 2) ||
(entitiesCopy[i].entity.m_iTeamNum == 2 && myEnt.m_iTeamNum == 3))) &&
(entitiesCopy[i].entity.m_bDormant == 0) && (entitiesCopy[i].entity.m_iHealth > 0) &&
(entitiesCopy[i].entity.ID != myEnt.ID) &&
(lifeState == LIFE_ALIVE)) { // if the ent isn't on our team, if they are not dormant, if their health
// is greater than 0, if they are not us, if they are alive...
void* m_pStudioBones;
int closestBone;
/*float lby;
csgo.Read((void*)entPtr+offsets::m_flLowerBodyYawTarget,&lby,sizeof(float));
//auto b-aim
helper::clampAngle(&entitiesCopy[i].entity.m_angNetworkAngles);
float angleDiff = fabsf(lby-entitiesCopy[i].entity.m_angNetworkAngles.y);
//cout<<"angleDiff "<<angleDiff<<endl;
if(angleDiff>35){
closestBone=6;
}
else{
closestBone = hack::getClosestBone((unsigned long)m_pStudioBones, hack::bones, viewAngle, punch,
myPos);
}*/
csgo.Read((void*)entPtr + offsets::m_pStudioBones, &m_pStudioBones, sizeof(int));
closestBone =
hack::getClosestBone((unsigned long)m_pStudioBones, hack::preferredBones, viewAngle, punch, myPos);
csgo.Read(m_pStudioBones + closestBone * sizeof(BoneMatrix), &theirBones, sizeof(BoneMatrix));
theirPos.x = theirBones.x;
theirPos.y = theirBones.y;
theirPos.z = theirBones.z;
// cout<<"myPos x, y, z "<<myPos.x<<", "<<myPos.y<<", "<<myPos.z<<endl;
if (theirPos.y == 0 && theirPos.x == 0 && theirPos.z == 0) { // if we find invalid data...
continue; // skip this iteration
}
// cout<<"theirPos x, y, z "<<theirPos.x<<", "<<theirPos.y<<", "<<theirPos.z<<endl;
/* failed at creating a resolver
float lby;
csgo.Read((void*)entPtr+offsets::m_flLowerBodyYawTarget,&lby,sizeof(int));
if(true){
hack::resolve(&entitiesCopy[i].entity,&theirPos,lby);
}*/
aimDelta = helper::calcAngle(&myPos, &theirPos);
aimDelta.x -= viewAngle.x + (punch.x * 2); // calculate aimDelta in order to calculate xhair distance.
// aimDelta is angle to the player - (current angle + punch*2)
aimDelta.y -= viewAngle.y + (punch.y * 2);
helper::clampAngle(&aimDelta);
// cout<<"vecabs x "<<entitiesCopy[i].entity.m_vecAbsOrigin.x<<" y
// "<<entitiesCopy[i].entity.m_vecAbsOrigin.y<<" z "<<entitiesCopy[i].entity.m_vecAbsOrigin.z<<endl;
// cout<<"vec x "<<entitiesCopy[i].entity.m_vecOrigin.x<<" y "<<entitiesCopy[i].entity.m_vecOrigin.y<<"
// z "<<entitiesCopy[i].entity.m_vecOrigin.z<<endl; cout<<"networked angles x
// "<<entitiesCopy[i].entity.m_angNetworkAngles.x<<" y "<<entitiesCopy[i].entity.m_angNetworkAngles.y<<"
// z "<<entitiesCopy[i].entity.m_angNetworkAngles.z<<endl; cout<<"lby: "<<lby<<endl; cout<< "aimDelta.x,
// y = "<<aimDelta.x<<", "<<aimDelta.y<<endl;
float xhairDistance = -1;
if (hack::useDistanceBasedFOV) {
xhairDistance = helper::getDistanceFov(&aimDelta, &myPos, &theirPos);
} else {
xhairDistance = helper::getAngleBasedFOV(aimDelta);
}
// cout<< "aimDelta.x, y = "<<aimDelta.x<<", "<<aimDelta.y<<" xhair, entid: "<<xhairDistance<<"
// "<<i<<endl; cout<<lowestDistance<<" <- lowest - cur distance -> "<<xhairDistance<<endl; cout<<" i
// "<<i<<" entID "<<entitiesCopy[i].entity.ID<<endl;
if (xhairDistance != -1 && (xhairDistance <= lowestDistance || lowestDistance == -1.0)) {
lowestDistance = xhairDistance;
idclosestEnt = entitiesCopy[i].entity.ID;
foundTarget = true;
alreadyShotOnce = false;
// cout<<foundTarget<<endl;
}
}
}
}
// cout<<"idclosestEnt "<<idclosestEnt<<endl;
if (foundTarget && idclosestEnt != 0) { // if we have an alive target...
unsigned long m_pStudioBones = 0;
int closestBone = 0;
float shootDistance = 0;
/*float lby;
csgo.Read(entitiesCopy[idclosestEnt].entityPtr+offsets::m_flLowerBodyYawTarget,&lby,sizeof(float));
//auto b-aim
helper::clampAngle(&entitiesCopy[idclosestEnt].entity.m_angNetworkAngles);
float angleDiff = fabsf(lby-entitiesCopy[idclosestEnt].entity.m_angNetworkAngles.y);
cout<<"angleDiff "<<angleDiff<<endl;
cout<<"lby "<<lby<<" entitiesCopy[idclosestEnt].entity.m_angNetworkAngles.y
"<<entitiesCopy[idclosestEnt].entity.m_angNetworkAngles.y<<endl; if(angleDiff>35){ closestBone=6;
}
else{
closestBone = hack::getClosestBone((unsigned long)m_pStudioBones, hack::bones, viewAngle, punch, myPos);
}*/
csgo.Read(entitiesCopy[idclosestEnt].entityPtr + offsets::m_pStudioBones, &m_pStudioBones, sizeof(long));
closestBone =
hack::getClosestBone((unsigned long)m_pStudioBones, hack::preferredBones, viewAngle, punch, myPos);
shootDistance = helper::fShootDistance(closestBone);
// cout<<"closest bone "<<closestBone<<endl;
csgo.Read((void*)m_pStudioBones + closestBone * sizeof(BoneMatrix), &theirBones, sizeof(BoneMatrix));
theirPos.x = theirBones.x;
theirPos.y = theirBones.y;
theirPos.z = theirBones.z;
if (AltTwo == 5 || acquiring) { // if we have a target and we are still clicking alt2, or if we are in the
// process of moving to a target...
/* failed at creating resolver
float lby;
csgo.Read(entitiesCopy[idclosestEnt].entityPtr+offsets::m_flLowerBodyYawTarget,&lby,sizeof(int));
if(true){
hack::resolve(&entitiesCopy[idclosestEnt ].entity,&theirPos,lby);
}*/
aimDelta = helper::calcAngle(&myPos, &theirPos);
aimDelta.x -= viewAngle.x + (punch.x * 2);
aimDelta.y -= viewAngle.y + (punch.y * 2);
helper::clampAngle(&aimDelta);
float xhairDistance = -1;
float angleBasedFOV = -1;
float distanceBasedFOV = -1;
angleBasedFOV = helper::getAngleBasedFOV(aimDelta);
distanceBasedFOV = helper::getDistanceFov(&aimDelta, &myPos, &theirPos);
if (hack::useDistanceBasedFOV) {
xhairDistance = distanceBasedFOV;
} else {
xhairDistance = angleBasedFOV;
}
if ((xhairDistance <= fov || fov == 0) && xhairDistance != -1.0) {
// cout<<"lowestDistance "<<lowestDistance<<endl;
if (!alreadyShotOnce) // if we didnt already shoot, start searching for target
{
acquiring = true;
} else // if we did already shoot we can stop looking for target
{
acquiring = false;
}
newAngle = helper::calcAngle(&myPos, &theirPos);
if (!helper::ShouldNotRCS(iWeaponID_lp)) {
newAngle.x -= punch.x * 2;
newAngle.y -= punch.y * 2;
}
// cout<<"newAngle.x "<<newAngle.x<<" newAngle.y "<<newAngle.y<<endl;
if (distanceBasedFOV < shootDistance) // use distance based fov to calculate accurately whether or not
// we are on target and ready to shoot
{
helper::Smoothing(&viewAngle,
&newAngle,
percentSmoothing / 20); // reduce smoothing because we are already on target
shouldShoot = true;
} else {
helper::Smoothing(&viewAngle, &newAngle, percentSmoothing);
}
isAiming = true;
} else {
shouldShoot = true;
}
} else if (AltTwo == 4) {
isAiming = false;
}
}
// rcs block
if (!isAiming && ShouldRCS) {
if (ShouldRCS) {
if ((punchDelta.y != 0.0 || punchDelta.x != 0.0) && (shotsFired > 1) &&
!helper::ShouldNotRCS(iWeaponID_lp)) {
// seeout<<shotsFired<<endl;
newAngle.x -= punchDelta.x * 2; // new camera angle is the old camera angle minus the change in view
// punch angle *2 (because it works)
newAngle.y -= punchDelta.y * 2;
newAngle.z = 0;
//}
}
}
oldPunch.y = punch.y;
oldPunch.x = punch.x;
oldPunch.z = 0;
}
if (newAngle.x != viewAngle.x || newAngle.y != viewAngle.y) {
hack::setVAng(&newAngle, addressOfViewAngle);
// cout<<"set vang"<<endl;
}
if (foundTarget && idclosestEnt != 0) { // if we found the target and its not the world or unset
if (AltTwo == 5) // if we are actively clicking
{
if (shouldShoot) // if we should shoot
{
csgo.Write((void*)m_addressOfForceAttack, &toggleOn, sizeof(int));
usleep(10000);
alreadyShotOnce = true;
}
} else {
if (!shouldShoot) {
csgo.Write((void*)m_addressOfForceAttack, &toggleOff, sizeof(int));
}
if (acquiring && shouldShoot) // if we are acquiring our target, and we are in range of our target
{
csgo.Write((void*)m_addressOfForceAttack, &toggleOn, sizeof(int));
usleep(40000);
csgo.Write((void*)m_addressOfForceAttack, &toggleOff, sizeof(int));
usleep(10000);
acquiring = false; // set acquiring to false because we reached our target
alreadyShotOnce = true;
}
}
} else { // otherwise just shoot normally
if (AltTwo == 5) {
csgo.Write((void*)m_addressOfForceAttack, &toggleOn, sizeof(int));
usleep(10000);
} else if (AltTwo == 4) {
csgo.Write((void*)m_addressOfForceAttack, &toggleOff, sizeof(int));
isAiming = false;
}
}
}
int hack::getLifeState(unsigned long entityPtr)
{
int lifeState = LIFE_DEAD;
if (entityPtr != 0) {
csgo.Read((void*)entityPtr + offsets::m_lifeState, &lifeState, sizeof(char));
}
return lifeState;
}
int hack::getClosestBone(
unsigned long m_pStudioBonesPtr, std::vector<int>& bones, QAngle& curViewAngle, QAngle& aimPunch, Vector& myPos)
{
std::vector<BoneMatrix> enemyBones;
Vector bonePos;
QAngle aimDelta;
for (int i = 0; i < bones.size(); i++) {
// cout<<"bones iteration #"<<i<<endl;
BoneMatrix boneMatrix;
// cout<<"curbone "<<bones[i]<<endl;
int curBone = bones[i];
csgo.Read((void*)m_pStudioBonesPtr + curBone * sizeof(BoneMatrix), &boneMatrix, sizeof(BoneMatrix));
/*cout<<boneMatrix.x<<" boneMatrix.x"<<endl;
cout<<boneMatrix.y<<" boneMatrix.y"<<endl;
cout<<boneMatrix.z<<" boneMatrix.z"<<endl;*/
enemyBones.push_back(boneMatrix);
}
float closestDistanceToBone = -1.0;
int closestBone = 0;
// cout<<enemyBones.size()<<endl;
for (int i = 0; i < enemyBones.size(); i++) {
if (enemyBones[i].x == 0 && enemyBones[i].y == 0 && enemyBones[i].z == 0) { // if we find invalid data...
continue; // skip this iteration
}
bonePos.x = enemyBones[i].x;
bonePos.y = enemyBones[i].y;
bonePos.z = enemyBones[i].z;
aimDelta = helper::calcAngle(&myPos, &bonePos);
aimDelta.x -= curViewAngle.x + aimPunch.x * 2; // calculate aimDelta in order to calculate xhair distance
aimDelta.y -= curViewAngle.y + aimPunch.y * 2;
helper::clampAngle(&aimDelta);
float distanceToBone = helper::getAngleBasedFOV(aimDelta);
if (distanceToBone <= closestDistanceToBone || closestDistanceToBone == -1.0) {
closestDistanceToBone = distanceToBone;
closestBone = bones[i];
}
}
return closestBone;
}
void hack::setVAng(QAngle* newAngle, unsigned long addressOfViewAngle)
{
helper::clampAngle(newAngle);
csgo.Write((void*)(unsigned long)(addressOfViewAngle), &(*newAngle), sizeof(QAngle));
}
void hack::bhop()
{
unsigned int iAlt1Status = 0;
int m_fFlags = 0;
unsigned long localPlayer = 0;
csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
csgo.Read((void*)(m_addressOfAlt1), &iAlt1Status, sizeof(int));
csgo.Read((void*)(localPlayer + 0x138), &m_fFlags, sizeof(int));
if (ShouldBhop == true) {
// cout<<"\nalt1: "<<iAlt1Status<<" \nonGround: "<<onGround<<endl;
if (iAlt1Status == 5 && (m_fFlags & ON_GROUND)) {
// cout<<"jumping\n:)"<<endl;
csgo.Write((void*)((unsigned long)m_addressOfJump), &SIX, sizeof(int));
/*XFlush(display);
XTestFakeKeyEvent(display, 65, true, 0);
this_thread::sleep_for(chrono::milliseconds(1));
XTestFakeKeyEvent(display, 65, false, 0);*/
}
} else {
if (iAlt1Status == 5) {
// cout<<"jumping\n:)"<<endl;
csgo.Write((void*)((unsigned long)m_addressOfJump), &toggleOn, sizeof(int));
this_thread::sleep_for(chrono::microseconds(500));
} else {
csgo.Write((void*)((unsigned long)m_addressOfJump), &toggleOff, sizeof(int));
this_thread::sleep_for(chrono::microseconds(500));
}
}
}
void hack::noFlash()
{
if (ShouldNoFlash) {
unsigned long localPlayer = 0;
csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
csgo.Write((void*)(localPlayer + offsets::m_fFlashMaxAlpha), &flashMax, sizeof(float));
}
}
void hack::setHands()
{
if (noHands) {
int zero_ = 0;
unsigned long localPlayer = 0;
csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
csgo.Write((void*)(localPlayer + 0x28c), &zero_, sizeof(char));
}
}
void hack::setFov()
{
if (viewFov == 0) {
return;
}
int isScoped = 0;
int iFOV = 0;
int iFOVStart = 0;
static int defaultFOV = DEFAULT_FOV;
unsigned long localPlayer = 0;
csgo.Read((void*)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
csgo.Read((void*)(localPlayer + offsets::m_bIsScoped), &isScoped, sizeof(long));
csgo.Read((void*)localPlayer + offsets::m_iFOV, &iFOV, sizeof(int));
if (isScoped == 0) {
if ((iWeaponID_lp == WEAPON_AUG || iWeaponID_lp == WEAPON_SG556)) {
csgo.Write((void*)(localPlayer + offsets::m_iFOV), &defaultFOV, sizeof(long));
} else if (iFOV != viewFov) {
csgo.Write((void*)(localPlayer + offsets::m_iFOV), &viewFov, sizeof(long));
}
// csgo.Write((void*)(localPlayer+offsets::m_iFOVStart), &viewFov, sizeof(long));
// csgo.Write((void*)(localPlayer+0x399C), &viewFov, sizeof(float));
// csgo.Write((void*)(localPlayer+0x3B14), &viewFov, sizeof(float));
} else if (isScoped > 0 && iFOV == DEFAULT_FOV) {
csgo.Write((void*)(localPlayer + offsets::m_iFOV), &viewFov, sizeof(long));
}
/*else if(isScoped==1){
csgo.Write((void*)(localPlayer+offsets::m_iFOV), &scope1, sizeof(long));
}
else{
csgo.Write((void*)(localPlayer+offsets::m_iFOV), &viewFov, sizeof(long));
}*/
}
bool hack::glow()
{
if (!hack::isConnected) {
return false;
}
struct iovec g_remote[1024], g_local[1024];
struct hack::GlowObjectDefinition_t g_glow[1024];
std::array<EntityInfo, 64> entitiesLocal;
auto colors = JWSettings::getInstance().Colors();
// Reset
bzero(g_remote, sizeof(g_remote));
bzero(g_local, sizeof(g_local));
bzero(g_glow, sizeof(g_glow));
fill(begin(entitiesLocal), end(entitiesLocal), EntityInfo{});
unsigned long localPlayer = 0;
csgo.Read((void *)m_addressOfLocalPlayer, &localPlayer, sizeof(long));
Entity local = {};
if (localPlayer != 0)
{
csgo.Read((void *)(unsigned long)localPlayer, &local, sizeof(Entity));
}
hack::CGlowObjectManager manager;
if (!csgo.Read((void*)m_addressOfGlowPointer, &manager, sizeof(hack::CGlowObjectManager))) {
cout << ("Failed to read glowClassAddress") << endl;
throw 1;
return false;
}
size_t count = manager.m_GlowObjectDefinitions.Count;
void* data_ptr = (void*)manager.m_GlowObjectDefinitions.DataPtr;
if (!csgo.Read(data_ptr, g_glow, sizeof(hack::GlowObjectDefinition_t) * count)) {
cout << ("Failed to read m_GlowObjectDefinitions") << endl;
throw 1;
return false;
}
size_t writeCount = 0;
unsigned int teamNumber = local.m_iTeamNum;
int ActiveWeaponEntID = getActiveWeaponEntityID(localPlayer);
for (unsigned int i = 0; i < count; i++) {
if (g_glow[i].m_pEntity != NULL) {
Entity ent;
if (csgo.Read(g_glow[i].m_pEntity, &ent, sizeof(Entity))) {
if (ent.ID == ActiveWeaponEntID) {
int iWeaponID = 0;
csgo.Read((void*)g_glow[i].m_pEntity + offsets::m_AttributeManager + 0x60 +
offsets::m_iItemDefinitionIndex,
&iWeaponID,
sizeof(int));
if (iWeaponID > WEAPON_NONE && iWeaponID < WEAPON_MAX) {
iWeaponID_lp = iWeaponID;
} else {
iWeaponID_lp = -1;
}
}
if (ent.m_iTeamNum != 2 && ent.m_iTeamNum != 3) {
g_glow[i].m_bRenderWhenOccluded = 1;
g_glow[i].m_bRenderWhenUnoccluded = 0;
continue;
}
if (!glowItems && ent.m_iHealth < 1)
continue;
if (ShouldRadarHack)
{
csgo.Write((void *)((unsigned long)g_glow[i].m_pEntity + offsets::m_bIsSpotted), &spotted, sizeof(unsigned char));
}
if (ent.m_iTeamNum == 2 || ent.m_iTeamNum == 3) {
if (ent.ID <= 64 && ent.ID > 0) {
EntityInfo e;
e.entity = ent;
e.entityPtr = g_glow[i].m_pEntity;
entitiesLocal[ent.ID] = e;
// cout<<"ent #"<<i<<": "<<e.entityPtr<<endl;
}
}
if (g_glow[i].m_bRenderWhenOccluded == 1)
continue;
g_glow[i].m_bRenderWhenOccluded = 1;
g_glow[i].m_bRenderWhenUnoccluded = 0;
if (ent.m_iTeamNum == 2 || ent.m_iTeamNum == 3)
{
g_glow[i].m_nGlowStyle = glowStyle;
g_glow[i].m_bFullBloomRender = glowBloom;
/*cout<<"ent ID " <<ent.ID<<" teamid "<<ent.m_iTeamNum;
cout<<" ent address " <<g_glow[i].m_pEntity<<endl;*/
if (ent.m_iTeamNum != teamNumber || h.shootFriends)
{
g_glow[i].m_flGlowRed = colors[0];
g_glow[i].m_flGlowGreen = colors[1];
g_glow[i].m_flGlowBlue = colors[2];
g_glow[i].m_flGlowAlpha = colors[3];
}
else
{
g_glow[i].m_flGlowRed = colors[8];
g_glow[i].m_flGlowGreen = colors[9];
g_glow[i].m_flGlowBlue = colors[10];
g_glow[i].m_flGlowAlpha = colors[11];
}
}
}
}
if (ShouldGlow) {
size_t bytesToCutOffEnd = sizeof(hack::GlowObjectDefinition_t) - g_glow[i].writeEnd();
size_t bytesToCutOffBegin = (size_t)g_glow[i].writeStart();
size_t totalWriteSize = (sizeof(hack::GlowObjectDefinition_t) - (bytesToCutOffBegin + bytesToCutOffEnd));
g_remote[writeCount].iov_base =
((uint8_t*)data_ptr + (sizeof(hack::GlowObjectDefinition_t) * i)) + bytesToCutOffBegin;
g_local[writeCount].iov_base = ((uint8_t*)&g_glow[i]) + bytesToCutOffBegin;
g_remote[writeCount].iov_len = g_local[writeCount].iov_len = totalWriteSize;
writeCount++;
}
}
process_vm_writev(csgo.GetPid(), g_local, writeCount, g_remote, writeCount, 0);
hack::writeEntities(entitiesLocal);
}
/*void hack::setWindowInfo(){
WindowsMatchingPid match(hack::display,XDefaultRootWindow(hack::display),int(csgo.GetPid()));
const list<Window> &matches = match.result();
for(list<Window>::const_iterator it = matches.begin(); it != matches.end(); it++){
XWindowAttributes attr;
if (::XGetWindowAttributes(hack::display, *it, &attr))
{
esp::windowX = attr.x;
esp::windowY = attr.y;
esp::windowHeight = attr.height;
esp::windowWidth = attr.width;
//cout<<"esp::windowX "<<esp::windowX<<" esp::windowY "<<esp::windowY<<endl;
}
}
}
*/
/*void hack::trigger(){
if(ShouldTrigger&&entityInCrossHair){
/*XFlush(display);
XTestFakeButtonEvent(display, Button1, true, 0);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
XTestFakeButtonEvent(display, Button1, false, 0);
std::this_thread::sleep_for(std::chrono::milliseconds(20));/*
unsigned int attack = 0x5;
unsigned int release = 0x4;
unsigned int shooting;
csgo.Read((void*) (m_addressOfForceAttack), &shooting, sizeof(int));
if(shooting!=attack){
cout<<"we should be shooting"<<endl;
csgo.Write((void*) (m_addressOfForceAttack), &attack, sizeof(int));
std::this_thread::sleep_for(std::chrono::microseconds(10));
csgo.Write((void*) (m_addressOfForceAttack), &release, sizeof(int));
}
}
}
*/
bool hack::checkKeys()
{
if (csgo.IsRunning()) {
XQueryKeymap(display, keys);
for (unsigned i = 0; i < sizeof(keys); ++i) {
if (keys[i] != lastkeys[i]) {
// check which key got changed
for (unsigned j = 0, test = 1; j < 8; ++j, test *= 2) {
// if the key was pressed, and it wasn't before, print this
if ((keys[i] & test) && ((keys[i] & test) != (lastkeys[i] & test))) {
const int code = i * 8 + j;
if (code == keycodeGlow) {
ShouldGlow = !ShouldGlow;
std::cout << "Glow: " << ShouldGlow << endl;
} else if (code == keycodeBhop) {
ShouldBhop = !ShouldBhop;
std::cout << "Bhop: " << ShouldBhop << endl;
} else if (code == keycodeNoFlash) {
ShouldNoFlash = !ShouldNoFlash;
std::cout << "NoFlash: " << ShouldNoFlash << endl;
} else if (code == keycodeRCS) {
ShouldRCS = !ShouldRCS;
cout << "AlwaysRCS: " << ShouldRCS << endl;
} else if (code == keycodeRage) {
ShouldRage = !ShouldRage;
cout << "RAGE: " << ShouldRage << endl;
} else if (code == keycodeESP) {
ShouldESP = !ShouldESP;
cout << "ESP: " << ShouldESP << endl;
} else if (code == keycodeRadarHack) {
ShouldRadarHack = !ShouldRadarHack;
cout << "Radar: " << ShouldRadarHack << endl;
} else if (code == keycodeAim) {
ShouldAimAssist = !ShouldAimAssist;
cout << "Aim: " << ShouldAimAssist << endl;
}
}
}
}
lastkeys[i] = keys[i];
}
return true;
} else {
cout << "CSGO was not found. Returning." << endl;
return false;
}
}
int hack::getActiveWeaponEntityID(unsigned long entityPtr)
{
unsigned int m_hActiveWeapon = 0;
unsigned int ActiveWeapon = 0;
csgo.Read((void*)entityPtr + offsets::m_hActiveWeapon, &m_hActiveWeapon, sizeof(int));
if (m_hActiveWeapon != 0) {
ActiveWeapon = m_hActiveWeapon & 0xFFF;
}
return ActiveWeapon;
}
bool hack::init()
{
if (getuid() != 0)
{
cout << "Cannot start as NON ROOT user.\n";
return false;
}
hack::display = XOpenDisplay(0);
// Detect if a composite manager is running.
// Since some features won't work without it just close out.
char prop_name[20];
snprintf(prop_name, 20, "_NET_WM_CM_S%d", XDefaultScreen(hack::display));
Atom prop_atom = XInternAtom(hack::display, prop_name, False);
if (XGetSelectionOwner(hack::display, prop_atom) == None) {
std::cout << "Cannot start without composite manager running.\n";
return false;
}
JWSettings& s = JWSettings::getInstance();
auto printKeyInfo = [](const std::string& cmd, const std::string& key, int keycode) {
std::cout << cmd << " Toggle = " << key << " Keycode: " << keycode << '\n';
};
// configure our custom settings from settings.cfg
hack::ShouldGlowToggleKey = s.KeyMap.Glow();
keycodeGlow = s.toKeycode(hack::ShouldGlowToggleKey);
printKeyInfo("Glow", hack::ShouldGlowToggleKey, keycodeGlow);