forked from Ox18/cheatmatrix-gunbound
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMSysUtils.pas
More file actions
167 lines (147 loc) · 3.63 KB
/
CMSysUtils.pas
File metadata and controls
167 lines (147 loc) · 3.63 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
unit CMSysUtils;
interface
//uses windows;
function CM_CopyMemory(destino: PByte; origem: PByte; qnt: integer): Boolean;
function CM_ZeroMemory(destino: PByte; qnt: integer): Boolean;
function CM_LowerCase(valor: AnsiString): AnsiString;
function CM_IntToStr(valor: integer): AnsiString;
function CM_StrToint(valor: AnsiString): integer;
function CM_StrReplace(texto: AnsiString; de: AnsiString; para: AnsiString; ignorecase: boolean = true): AnsiString;
function CM_DupString(valor: AnsiString; qnt: integer): AnsiString;
function CM_Trim(valor: AnsiString): AnsiString;
implementation
function CM_CopyMemory(destino: PByte; origem: PByte; qnt: integer): Boolean;
var i: integer;
begin
//{$I VMProtectBegin.inc}
result := false;
for i := 0 to qnt-1 do
begin
PByte(cardinal(destino)+i)^ := PByte(cardinal(origem)+i)^;
end;
//{$I VMProtectEnd.inc}
end;
function CM_ZeroMemory(destino: PByte; qnt: integer): Boolean;
var i: integer;
begin
//{$I VMProtectBegin.inc}
result := false;
for i := 0 to qnt-1 do
begin
PByte(cardinal(destino)+i)^ := 0;
end;
//{$I VMProtectEnd.inc}
end;
function CM_LowerCase(valor: AnsiString): AnsiString;
var i: integer;
c: byte;
begin
//{$I VMProtectBegin.inc}
result := '';
for i := 1 to length(valor) do
begin
result := result + valor[i];
c := ord(valor[i]);
if (c >= 65) and (c < 90) then
result[i] := AnsiChar(ord(result[i]) + 32);
end;
//{$I VMProtectEnd.inc}
end;
function CM_IntToStr(valor: integer): AnsiString;
var i: integer;
begin
//{$I VMProtectBegin.inc}
result := '';
while valor > 0 do
begin
i := (valor mod 10);
valor := valor div 10;
result := result + AnsiChar(48 + i);
end;
if result = '' then result := '0';
//{$I VMProtectEnd.inc}
end;
function CM_StrToint(valor: AnsiString): integer;
var i: integer;
c: byte;
begin
//{$I VMProtectBegin.inc}
result := 0;
for i := 1 to length(valor) do
begin
c := ord(valor[i]);
if(c >= 48) and (c <= 57) then
result := ((result * 10) + (c - 48))
else
break;
end;
//{$I VMProtectEnd.inc}
end;
function CM_StrReplace(texto: AnsiString; de: AnsiString; para: AnsiString; ignorecase: boolean = true): AnsiString;
var i,j: integer;
valor: AnsiString;
begin
//{$I VMProtectBegin.inc}
if (ignorecase) then
valor := de
else
valor := CM_LowerCase(de);
j := 0;
result := texto;
while( pos(de, texto) > 0 ) do
begin
i := pos(de, texto);
j := j + i;
delete(result, j, length(de));
insert(para, result, j);
texto := copy(texto, i+length(de), length(texto));
j := j + length(para) - 1;
end;
//{$I VMProtectEnd.inc}
end;
function CM_DupString(valor: AnsiString; qnt: integer): AnsiString;
var i: integer;
begin
//{$I VMProtectBegin.inc}
result := '';
for i := 1 to qnt do
begin
result := result + valor;
end;
//{$I VMProtectEnd.inc}
end;
function CM_Trim(valor: AnsiString): AnsiString;
var i: integer;
flag: boolean;
begin
//{$I VMProtectBegin.inc}
result := '';
flag := false;
for i := 1 to length(valor) do
begin
if ord(valor[i]) < 32 then
continue
else
flag := true;
if flag then
begin
result := copy(valor, i, length(valor));
break;
end;
end;
flag := false;
for i := length(valor) downto 1 do
begin
if ord(valor[i]) < 32 then
continue
else
flag := true;
if flag then
begin
result := copy(result, 1, i);
break;
end;
end;
//{$I VMProtectEnd.inc}
end;
end.