forked from Ox18/cheatmatrix-gunbound
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCmPlugins.pas
More file actions
815 lines (713 loc) · 17.8 KB
/
CmPlugins.pas
File metadata and controls
815 lines (713 loc) · 17.8 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
unit CmPlugins;
interface
uses windows, classes, messages, Utils, controls, common,
SplashScreen, graphics, functions, constantes;
const
fSep = '|ØH®¼Ã|';
vSep = '|©À½¥£|';
type
PSwLine = ^TSwLine;
TSwLine = packed record
Field: AnsiString;
Value: AnsiString;
end;
{
TSwField = class
private
fValue: tSwLine;
public
Function AsString: AnsiString;
Function AsPointer: PAnsiChar;
Function AsInteger: Integer;
Function AsBoolean: Boolean;
end;
}
PPluginMemoryDataRecord = ^TPluginMemoryDataRecord;
TPluginMemoryDataRecord = record
PacketID: integer;
Ponteiro: cardinal;
Offset: cardinal;
Range: cardinal;
Size: cardinal;
Endereco: cardinal;
Valor: PAnsiChar;
end;
PPluginMemoryData = ^TPluginMemoryData;
TPluginMemoryData = class(TList)
constructor Create;
private
fcount: integer;
function GetItem(index: integer): TPluginMemoryDataRecord;
procedure SetItem(index: integer; const Value: TPluginMemoryDataRecord);
public
Hack: ShortString;
Processo: ShortString;
VersaoJogo: PAnsiChar;
Property Item[index: integer]: TPluginMemoryDataRecord read GetItem write SetItem;
Procedure Add(Valor: TPluginMemoryDataRecord);
end;
PPluginRegData = ^TPluginRegData;
TPluginRegData = class(TList)
constructor Create;
private
function GetItem(index: integer): TPluginMemoryData;
procedure SetItem(index: integer; const Value: TPluginMemoryData);
public
Property Item[index: integer]: TPluginMemoryData read GetItem write SetItem;
function Add(const Valor: TPluginMemoryData): integer; overload;
Function IndexOf(Hack: ShortString): integer;
end;
//
// Menssagem
//
{ TSwMessage = Class
constructor Create;
private
fValue: TList;
public
Procedure Clear;
Procedure Add(Field: AnsiString; Value: AnsiString);
Function ToText: AnsiString;
Procedure LoadFrom(Value: AnsiString);
Function FieldByName(Name: AnsiString): TSwField;
end;
TPluginMsgType = (MT_Close);
TPluginMsg = packed record
Tipo: TPluginMsgType;
Valor: AnsiString;
end; }
//
// Dados de um Plugin
//
TPgRec = record
PutInList: Boolean;
PluginHandle: HMODULE;
WindowHandle: THandle;
Registered: Boolean;
Tipo: integer; // THackType;
Status: integer; // TImageStatus;
Offset: Pointer;
Codigo: DWORD;
Nome: PAnsiChar;
Nick: PAnsiChar;
Game: PAnsiChar;
FileName: PAnsiChar;
Key: PAnsiChar;
NULO: PAnsiChar;
end;
PPgRec = ^TPgRec;
PPlugin = ^TPlugin;
TPlugin = class
// private
public
// Vars: TPgRec;
PutInList: Boolean;
PluginHandle: HMODULE;
WindowHandle: THandle;
Registered: Boolean;
Tipo: integer; // THackType;
Status: integer; // TImageStatus;
Offset: Pointer;
Codigo: DWORD;
Nome: PAnsiChar;
VersaoJogo: PAnsiChar;
Game: PAnsiChar;
FileName: PAnsiChar;
Key: PAnsiChar;
Function SendMsg(Valor: integer): PChar;
Procedure Show;
Procedure Hide;
Function Visible: Boolean;
Procedure Close;
constructor Create;
end;
//
// Lista de Plugins
//
TPluginList = class
constructor Create(AOwner: THandle);
private
fPlugins: TList;
fIndex: integer;
Function GetPlugin(Index: integer): TPlugin;
Procedure SetPlugin(Index: integer; Plugin: TPlugin);
Function LoadPlugin(PathAnsi: AnsiString): TPlugin;
Procedure SetAtual(Plugin: TPlugin);
function GetAtual: TPlugin;
public
Owner: THandle;
Property PluginIndex: integer read fIndex;
Property Plugins[index: integer]: TPlugin read GetPlugin write SetPlugin;
Property Plugin: TPlugin read GetAtual write SetAtual;
Function GetFromNick(Nick: AnsiString): integer;
Function GetAll(ClearBefore: Boolean = false): integer;
Function Count: integer;
Procedure Add(Plugin: TPlugin);
Procedure Delete(Index: integer);
Procedure DeleteFull(Plugin: TPlugin);
Function Seek(Index: integer): Boolean;
Function Next: Boolean;
Function Prev: Boolean;
Function Eof: Boolean;
Procedure Clear;
Procedure Reset;
end;
TOffsetUnit = record
Nome: AnsiString;
Code: AnsiString;
Data: TPluginMemoryDataRecord;
end;
TProcesso = record
Nome: String;
Indice: integer;
Injetado: Boolean;
end;
var
listaGrupoItemsMemoria: TPluginRegData;
arrayProcessos: array of TProcesso;
entradasRegistro: TStringList;
listaProcessos: TStringList;
// OffsetList: array of TOffsetUnit;
Function CompleteNumber(Numero: AnsiString): AnsiString;
implementation
uses SysUtils;
{ TPlugin }
Function CompleteNumber(Numero: AnsiString): AnsiString;
var
s: AnsiString;
i, j: integer;
begin
result := Numero;
j := length(result);
s := '';
for i := 1 to (8 - j) do
s := s + '0';
result := result + s;
{ while length(IntToStr(Numero)) < 10 do
Numero := Numero*10;
while length(IntToStr(Numero)) > 10 do
Numero := Numero div 10;
result := Numero; }
end;
//
// Fecha o Plugin
//
procedure TPlugin.Close;
begin
SendMsg(integer(MT_Close));
try
FreeLibrary(PluginHandle);
except
on e: exception do
end;
end;
//
// Cria o Plugin
//
constructor TPlugin.Create;
begin
//
end;
//
// Envia Msg para o Plugin
//
procedure TPlugin.Hide;
begin
SendMsg(integer(MT_Hide));
end;
Function TPlugin.SendMsg(Valor: integer): PChar;
var
Func: function(Valor: integer): PChar; stdcall;
Address: Pointer;
Ms: TMemoryStream;
begin
//
Address := GetProcAddress(PluginHandle, 'm5');
if Address = nil then
result := '';
@Func := Address;
result := Func(Valor);
//
end;
{ TPluginList }
//
// Adiciona um Plugin
//
procedure TPluginList.Add(Plugin: TPlugin);
var
P: PPlugin;
begin
//
P := new(PPlugin);
P^ := Plugin;
if fPlugins = nil then
fPlugins := TList.Create;
fPlugins.Add(P);
//
end;
//
// Limpa a Lista de Plugins
//
procedure TPluginList.Clear;
begin
fPlugins.Clear;
end;
//
// Cria a Lista de Plugins
//
function TPluginList.Count: integer;
begin
result := fPlugins.Count;
end;
constructor TPluginList.Create(AOwner: THandle);
begin
Owner := AOwner;
fPlugins := TList.Create;
fIndex := 0;
end;
//
// Deleta um Plugin
//
procedure TPluginList.Delete(Index: integer);
begin
fPlugins.Delete(index);
end;
//
// Deleta um Plugin
//
procedure TPluginList.DeleteFull(Plugin: TPlugin);
var
P: PPlugin;
begin
P := new(PPlugin);
P^ := Plugin;
fPlugins.Remove(P);
end;
//
// Fim da lista de Plugins?
//
function TPluginList.Eof: Boolean;
begin
result := false;
if (fIndex >= fPlugins.Count) or (fIndex < 0) then
result := true;
end;
//
// Retorna um Plugin da lista
//
Function TPluginList.GetAll(ClearBefore: Boolean = false): integer;
var
i: integer;
SearchResult: TSearchRec;
Plugin: TPlugin;
Dir: AnsiString;
Indice: integer;
begin
//
if ClearBefore then
Clear;
for i := 0 to length(PluginsLiberados) - 1 do
begin
if not FileExists(ExtractFilePath(ParamStr(0)) + PluginsLiberados[i]) then
continue;
Plugin := LoadPlugin(ExtractFilePath(ParamStr(0)) + PluginsLiberados[i]);
if Plugin <> nil then
if trim(Plugin.Nome) <> '' then
Indice := listaGrupoItemsMemoria.IndexOf(md5(IntToStr(Plugin.Codigo) { +trim(Plugin.Nome) } ));
if Indice >= 0 { InList( md5( trim(IntToStr(CompleteNumber(Plugin.Codigo)))+trim(Plugin.Nick)) , listaGrupoItemsMemoria) } then
begin
Plugin.VersaoJogo := listaGrupoItemsMemoria.GetItem(Indice).VersaoJogo;
if Splash <> nil then
if Splash.Visible then
begin
ChangeSplash(AnsiString('Carregando ' + ExtractFileName(CMPchar(Plugin.FileName))));
Delay(10);
end;
Add(Plugin);
Inc(result);
end;
end;
//
end;
function TPluginList.GetPlugin(Index: integer): TPlugin;
begin
result := TPlugin(fPlugins.Items[Index]^);
end;
//
// Plugin atual
//
function TPluginList.GetAtual: TPlugin;
begin
result := Plugins[fIndex];
end;
//
// Carrega um Plugin
//
function TPluginList.LoadPlugin(PathAnsi: AnsiString): TPlugin;
type
PStream = ^TStream;
var
Loc: cardinal;
Address, _Address: Pointer;
Dll: Function(Chave: PAnsiChar; AOwner: THandle; Color: TColor): PPgRec; stdcall;
m2: Procedure(Valor: TPluginMemoryDataRecord); stdcall;
m3: Function: Boolean; stdcall;
m4: Procedure(id: integer; Valor: cardinal); stdcall;
Key: AnsiString;
t: PPgRec;
SID: ShortString;
i, j, k, n: integer;
b: Boolean;
ttv: TPluginMemoryDataRecord;
okey: AnsiString;
Path: String;
PathDLL: PChar;
s: AnsiString;
itemMemoria: TPluginMemoryDataRecord;
const
nums = '0123456789';
begin
Path := String(PathAnsi);
PathDLL := PChar(Path);
if Path = '' then
Exit;
try
if (FileExists(Path)) then
Loc := LoadLibrary(PathDLL);
if Loc = 0 then
begin
MessageBox(0, CMPchar(Constante(0031, false) + ExtractFileName(Path) + ')'), '', 0);
Exit;
end;
result := TPlugin.Create;
Address := GetProcAddress(Loc, PAnsiChar(AnsiString(Constante(0027, false))));
@m4 := GetProcAddress(Loc, PAnsiChar(AnsiString(Constante(0028, false))));
@m2 := GetProcAddress(Loc, PAnsiChar(AnsiString(Constante(0029, false))));
@m3 := GetProcAddress(Loc, PAnsiChar(AnsiString(Constante(0030, false))));
if (Address = nil) or (@m2 = nil) or (@m4 = nil) or (@m3 = nil) then
begin
MessageBoxA(0, PAnsiChar(AnsiString(Constante(0032, false) + ExtractFileName(Path))), '', 0);
Exit;
end;
@Dll := Address;
Key := '';
Randomize;
for i := 1 to 10 do
begin
j := Random(10) + 1;
okey := Key + nums[j];
Key := Key + nums[j];
end;
t := Dll(PAnsiChar(Key), Owner, MatrizColor);
result.PutInList := t.PutInList;
result.Codigo := t.Codigo;
result.PluginHandle := t.PluginHandle;
result.WindowHandle := t.WindowHandle;
result.Registered := t.Registered;
result.Tipo := t.Tipo;
result.Status := t.Status;
result.Offset := t.Offset;
result.Nome := t.Nick;
// result.Nick := t.Nick;
result.Game := t.Game;
result.FileName := t.FileName;
result.Key := t.Key;
SetWindowPos(result.WindowHandle, 0, 0, 0, 570, 360, SWP_DRAWFRAME);
result.PluginHandle := Loc;
SID := '';
for i := 1 to length(okey) do
begin
j := DWORD(okey[i]) - DWORD('0');
SID := SID + AnsiChar($41 + j);
end;
for i := 0 to listaGrupoItemsMemoria.Count - 1 do
begin
s := md5(IntToStr(result.Codigo) { + trim(Result.Nome) } );
if trim(listaGrupoItemsMemoria.Item[i].Hack) = s then
for j := 0 to listaGrupoItemsMemoria.Item[i].Count - 1 do
begin
try
itemMemoria := listaGrupoItemsMemoria.Item[i].Item[j];
n := itemMemoria.PacketID;
if n > 0 then
m2(listaGrupoItemsMemoria.Item[i].Item[j]);
except
on e: exception do
end;
end;
end;
m4(1, cardinal(@PortaSubMatrix));
m4(2, cardinal(@Idioma));
// FixApis(2, cardinal(@CMWriteProcessMemoryB));
// FixApis(3, cardinal(@CMOpenProcessB));
// FixApis(4, cardinal(@CMGetDCB));
// FixApis(5, cardinal(@MatrizInfo));
// FixApis(6, cardinal(@CMVirtualProtectB));
// FixApis(7, cardinal(@CMOpenFileMappingB));
// FixApis(8, cardinal(@CMMapViewOfFileB));
b := m3;
{$IFNDEF DEBUG6}
if (trim(SID) <> trim(result.Key)) or (not b) then
begin
result := nil;
Exit
end;
{$ENDIF}
except
on e: exception do
begin
MessageBox(0, PChar(e.Message), '', 0);
result := nil;
end;
end;
end;
//
// Proximo Plugin da Lista
//
function TPluginList.Next: Boolean;
begin
Inc(fIndex);
result := true;
if fIndex >= fPlugins.Count then
result := false;
end;
//
// Plugin Anterior
//
function TPluginList.Prev: Boolean;
begin
if fIndex - 1 < 0 then
begin
result := false;
Exit;
end;
result := true;
dec(fIndex);
end;
//
// Primeiro Plugin
//
procedure TPluginList.Reset;
begin
fIndex := 0;
end;
//
// Modifica um Plugin
//
procedure TPluginList.SetAtual(Plugin: TPlugin);
begin
Plugins[fIndex] := Plugin;
end;
procedure TPluginList.SetPlugin(Index: integer; Plugin: TPlugin);
var
P: PPlugin;
begin
/// /
P := new(PPlugin);
P^ := Plugin;
fPlugins.Items[Index] := P;
/// /
end;
//
// TSwMessage
(*
//
// Adiciona um campo na Mensagem
//
procedure TSwMessage.Add(Field, Value: AnsiString);
var Msg: PSwLine;
begin
////
Msg := new(PSwLine);
Msg^.Field := Field;
Msg^.Value := Value;
fValue.Add(Msg);
////
end;
//
// Inicializa Mensagem
//
procedure TSwMessage.Clear;
begin
fValue.Clear;
end;
constructor TSwMessage.Create;
begin
fValue := TList.Create;
end;
//
// Campo pelo nome
//
function TSwMessage.FieldByName(Name: AnsiString): TSwField;
var i:integer;
begin
//
result := TSwField.Create;
for i:=0 to fValue.Count-1 do
begin
if LowerCase(TSwLine(fValue.Items[i]^).Field) = LowerCase(Name) then
begin
Result.fValue := TSwLine(fValue.Items[i]^);
end;
end;
//
end;
//
// Carrega uma mensagem
//
procedure TSwMessage.LoadFrom(Value: AnsiString);
var Texto: AnsiString;
SepLen: integer;
SepPos: integer;
Field: AnsiString;
Result: PSwLine;
begin
//
Texto := Value;
SepLen := Length(fSep);
while pos(fSep, Texto)>0 do
begin
SepPos := pos(fSep, Texto);
Texto := Copy(Texto, SepPos+SepLen, length(Texto)-(SepPos+SepLen)+1);
if pos(vSep, Texto) > 0 then
begin
Field := copy(Texto, 1, pos(vSep,Texto)-1);
Value := copy(Texto, pos(vSep,Texto)+SepLen , pos(fSep,Texto)-(pos(vSep,Texto)+SepLen));
Result := new(PSwLine);
Result^.Field := Field;
Result^.Value := Value;
fValue.Add(Result);
end;
end;
//
end;
//
// Prepara mensagem para enviar
//
function TSwMessage.ToText: AnsiString;
var i:integer;
begin
result := '';
for i:=0 to fValue.Count-1 do
begin
result := result + fSep + TSwLine(fValue[i]^).Field + vSep + TSwLine(fValue[i]^).Value;
end;
result := result + fSep;
end;
//
// TSwField
function TSwField.AsBoolean: Boolean;
begin
result := StrToBool(fValue.Value);
end;
function TSwField.AsInteger: Integer;
begin
result := StrToInt(fValue.Value);
end;
function TSwField.AsPointer: PAnsiChar;
begin
result := PAnsiChar(fValue.Value);
end;
function TSwField.AsString: AnsiString;
begin
result := fValue.Value;
end;
*)
function TPluginList.GetFromNick(Nick: AnsiString): integer;
var
i: integer;
begin
i := pos('(', Nick);
if (i > 0) then
Nick := trim(copy(Nick, 1, i - 1));
result := -1;
for i := 0 to Count - 1 do
begin
if trim(LowerCase(TPlugin(fPlugins.Items[i]^).Nome)) = trim(LowerCase(Nick)) then
begin
result := i;
Exit;
end;
end;
/// /
end;
procedure TPlugin.Show;
begin
SendMsg(integer(MT_Show));
end;
function TPlugin.Visible: Boolean;
begin
//
result := Boolean(SendMsg(integer(MT_Visible)));
//
end;
function TPluginList.Seek(Index: integer): Boolean;
begin
if (Index < Count) and (Index >= 0) then
begin
fIndex := index;
result := true;
end
else
result := false;
end;
//
// TPluginMemoryData
procedure TPluginMemoryData.Add(Valor: TPluginMemoryDataRecord);
var
P: PPluginMemoryDataRecord;
x: TList;
begin
P := new(PPluginMemoryDataRecord);
P^ := Valor;
inherited Add(P);
end;
constructor TPluginMemoryData.Create;
begin
inherited Create;
end;
function TPluginMemoryData.GetItem(index: integer): TPluginMemoryDataRecord;
begin
result := TPluginMemoryDataRecord(Items[index]^);
end;
procedure TPluginMemoryData.SetItem(index: integer; const Value: TPluginMemoryDataRecord);
begin
TPluginMemoryDataRecord(Items[index]^) := Value;
end;
//
// TPluginRegData
function TPluginRegData.Add(const Valor: TPluginMemoryData): integer;
var
P: PPluginMemoryData;
begin
P := new(PPluginMemoryData);
P^ := Valor;
inherited Add(P);
end;
constructor TPluginRegData.Create;
begin
inherited Create;
end;
function TPluginRegData.GetItem(index: integer): TPluginMemoryData;
begin
result := TPluginMemoryData(Items[index]^);
end;
function TPluginRegData.IndexOf(Hack: ShortString): integer;
var
i: integer;
begin
result := -1;
for i := 0 to Count - 1 do
begin
if LowerCase(trim(TPluginMemoryData(Items[i]^).Hack)) = LowerCase(trim(Hack)) then
begin
result := i;
Exit;
end;
end;
end;
procedure TPluginRegData.SetItem(index: integer; const Value: TPluginMemoryData);
begin
TPluginMemoryData(Items[index]^) := Value;
end;
end.