
Сообщение от mss
stdcall мыши съели ?
что это такое? ( причем тут мышь )

Сообщение от mss
А вот обязательно сплайсингом заморачиваться ?
Подмена точки входа в ф-цию в IAT и EAT проще и не менее надежнее ..
Через таблицу импорта? хммм.... но ведь в результате обращатся я буду к тойже функ-ии и результат будет тотже...

Сообщение от mss
почему не packed record ?
Ну я выложил описание с сайта( как это должно быть )... я пробовал и так и так и через пакет все записи и без него.. результат 1-н -> вылет
Добавлено через 3 минуты
stdcall/winapi[править | править исходный текст]
Применяется при вызове функций WinAPI. Аргументы передаются через стек, справа налево. Очистку стека производит вызываемая подпрограмма.
- это с вики... тоесть надо както по другому параметры передавать? ( ну и получать соответственно ).. хотя на примерах в инете перехвата MessegeBox там все в томже порядке было...
Добавлено через 6 минут
для большей ясности выкладываю полный полный код... проги
Pascal | 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
| library my_dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Windows;
type
TApiPack = packed record
jmp1 : byte;
newF : DWord;
jmp2 : byte;
end;
TTApiPack = ^TApiPack;
TSocket = Cardinal;
TSockAddr = record
case Integer of
0: (
sin_family : Word;
sin_port : Word;
sin_addr : record
case integer of
0: ( S_un_b: packed record
s_b1, s_b2, s_b3, s_b4: byte;
end;
);
1: ( S_un_w: packed record
s_w1, s_w2: Word;
end;
);
2: ( S_addr: Longint )
end;
sin_zero : array [ 0..7 ] of byte
);
1: (
sa_family : Word;
sa_data : array [ 0..13 ] of byte
)
end;
TSendTo = function (
socket : TSocket;
var Buf;
len,
flags : Cardinal;
var addrto : TSockAddr;
tolen : Cardinal
) : Integer;
var
GB_DATA : record
oldFunct,
newFunct : TApiPack;
dataMemory : TTApiPack;
procAddress,
newAddres : Pointer;
OldProtect : Cardinal;
sendTo : TSendTo;
end;
{$R *.res}
procedure outLog ( log : String );
var
f: TextFile;
begin
if FileExists ( 'log_my_dll.log' ) then begin
AssignFile ( f, 'log_my_dll.log' );
Append ( f );
WriteLn ( f, log );
CloseFile ( f );
end else begin
AssignFile ( f, 'log_my_dll.log' );
Rewrite ( f );
WriteLn ( f, log );
CloseFile ( f );
End;
end;
procedure setMemoryPrivileg ();
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, PAGE_EXECUTE_READWRITE, GB_DATA.OldProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure unsetMemoryPrivileg ();
var
newProtect : Cardinal;
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, GB_DATA.OldProtect, newProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure setHookApi ();
begin
GB_data.dataMemory^ := GB_data.newFunct;
end;
procedure unsetHookApi ();
begin
GB_data.dataMemory^ := GB_data.oldFunct;
end;
procedure setHookApiBegin ();
begin
setMemoryPrivileg;
GB_DATA.dataMemory := GB_DATA.procAddress;
@GB_DATA.sendTo := GB_DATA.procAddress;
GB_DATA.oldFunct := GB_data.dataMemory^;
outLog ( 'oldFun = ' + IntToHex ( DWORD ( GB_DATA.procAddress ), 8 ) );
outLog ( 'newFun = ' + IntToHex ( DWORD ( GB_DATA.newAddres ), 8 ) );
GB_DATA.newFunct.jmp1 := $68;
GB_DATA.newFunct.newF := DWORD ( GB_DATA.newAddres );
// GB_DATA.newFunct.newF := DWORD ( GB_DATA.newAddres ) - DWORD ( GB_DATA.procAddress ) - 5;
GB_DATA.newFunct.jmp2 := $C3;
setHookApi;
// jump = $E9 ( 4 byte ) go to $25FF ( 4 byte ) push $68 ( 4 byte ) $C3
end;
function getProcAddress ( name : String; libb : String ) : Pointer;
var
ProcAddress : Pointer;
begin
ProcAddress := Windows.GetProcAddress ( Windows.GetModuleHandle ( PChar ( libb ) ), PChar ( name ) );
if ProcAddress = NiL then begin
outLog ( name + ' не найдена' );
Result := NiL;
end else begin
outLog ( name + ' найдена' );
Result := ProcAddress;
end;
end;
function _sendto (
socket : TSocket;
var Buf;
Len,
Flags : Cardinal;
var AddrTo : TSockAddr;
ToLen : Cardinal
) : Integer; far;
var
res : Integer;
begin
outLog ( 'socket = ' + IntToStr ( socket ) );
outLog ( 'lenBuf = ' + IntToStr ( Len ) );
outLog ( 'flags = ' + IntToStr ( Flags ) );
// outLog ( 'msgSock= ' + IntToStr ( res ) );
{
outLog ( ' port = ' + IntToStr ( AddrTo.sin_port ) );
outLog ( ' ip1 = ' + IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b1 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b2 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b3 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b4 ) ) );
outLog ( ' ip2 = ' + IntToStr ( AddrTo.sin_addr.S_un_w.s_w1 ) + '.' +
IntToStr ( AddrTo.sin_addr.S_un_w.s_w2 ) );
outLog ( ' ip3 = ' + IntToStr ( AddrTo.sin_addr.S_addr ) );
outLog ( ' saData = ' + IntToStr ( ord ( AddrTo.sa_data [ 0 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 1 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 2 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 3 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 4 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 5 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 6 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 7 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 8 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 9 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 10 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 11 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 12 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 13 ] ) ) );
outLog ( ' saZero = ' + IntToStr ( ord ( AddrTo.sin_zero [ 0 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 2 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 3 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 4 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 5 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 6 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 7 ] ) ) );
outLog ( 'sin_family = ' + IntToStr ( AddrTo.sin_family ) );
outLog ( 'sa_family = ' + IntToStr ( AddrTo.sa_family ) );
}
unsetHookApi;
{ вылет всегда на этой фун-ии, без нее игра проста повисает }
res := GB_DATA.sendTo ( socket, Buf, Len, Flags, AddrTo, ToLen );
setHookApi;
Result := 1;
end;
begin
outLog ( '---------------------------------------------------------------------------------------------------------' );
GB_DATA.newAddres := @_sendto;
GB_DATA.procAddress := getProcAddress ( 'sendto', 'ws2_32.dll' );
if not ( GB_DATA.procAddress = NiL ) then
setHookApiBegin ();
end. |
|
Добавлено через 4 минуты
хм и если вывести принимаемые параметры ( до вызова оригинальной сендТо ) то порт практически всегда = 65535... чет такое там а также ип.. он практически всегда 1-н и тотде ( при конекте и обнове сервов тоже один и тотже но дрегой )
Добавлено через 30 минут
о во что получилось.. я поставил после функции stdcall; а было far;
теперь все параметры как надо принмаются ( и длинна и сам буфер( 'yyyygetchallenge steam' ) 1-й пакет конекта на голд сурсе однако при попытке вызвать оригинал происходит вылет....
Добавлено через 1 минуту
Уррррррааааааааааааа
Добавлено через 48 секунд
Получилось... Надо было еще в описание функ-ции добавить stdcall; все как надо перехватывается и отправляется вот обновленый код
Pascal | 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
| library my_dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Windows;
type
TApiPack = packed record
jmp1 : byte;
newF : DWord;
jmp2 : byte;
end;
TTApiPack = ^TApiPack;
TSocket = Cardinal;
TSockAddr = record
case Integer of
0: (
sin_family : Word;
sin_port : Word;
sin_addr : record
case integer of
0: ( S_un_b: packed record
s_b1, s_b2, s_b3, s_b4: byte;
end;
);
1: ( S_un_w: packed record
s_w1, s_w2: Word;
end;
);
2: ( S_addr: Longint )
end;
sin_zero : array [ 0..7 ] of byte
);
1: (
sa_family : Word;
sa_data : array [ 0..13 ] of byte
)
end;
TBuf = Array [ 1..4096 ] of byte;
TSendTo = function (
socket : TSocket;
var Buf : TBuf;
len,
flags : Cardinal;
var addrto : TSockAddr;
tolen : Cardinal
) : Integer; stdcall;
var
GB_DATA : record
oldFunct,
newFunct : TApiPack;
dataMemory : TTApiPack;
procAddress,
newAddres : Pointer;
OldProtect : Cardinal;
sendTo : TSendTo;
end;
{$R *.res}
procedure outLog ( log : String );
var
f: TextFile;
begin
if FileExists ( 'log_my_dll.log' ) then begin
AssignFile ( f, 'log_my_dll.log' );
Append ( f );
WriteLn ( f, log );
CloseFile ( f );
end else begin
AssignFile ( f, 'log_my_dll.log' );
Rewrite ( f );
WriteLn ( f, log );
CloseFile ( f );
End;
end;
procedure setMemoryPrivileg ();
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, PAGE_EXECUTE_READWRITE, GB_DATA.OldProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure unsetMemoryPrivileg ();
var
newProtect : Cardinal;
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, GB_DATA.OldProtect, newProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure setHookApi ();
begin
GB_data.dataMemory^ := GB_data.newFunct;
end;
procedure unsetHookApi ();
begin
GB_data.dataMemory^ := GB_data.oldFunct;
end;
procedure setHookApiBegin ();
begin
setMemoryPrivileg;
GB_DATA.dataMemory := GB_DATA.procAddress;
@GB_DATA.sendTo := GB_DATA.procAddress;
GB_DATA.oldFunct := GB_data.dataMemory^;
outLog ( 'oldFun = ' + IntToHex ( DWORD ( GB_DATA.procAddress ), 8 ) );
outLog ( 'newFun = ' + IntToHex ( DWORD ( GB_DATA.newAddres ), 8 ) );
GB_DATA.newFunct.jmp1 := $68;
GB_DATA.newFunct.newF := DWORD ( GB_DATA.newAddres );
// GB_DATA.newFunct.newF := DWORD ( GB_DATA.newAddres ) - DWORD ( GB_DATA.procAddress ) - 5;
GB_DATA.newFunct.jmp2 := $C3;
setHookApi;
// jump = $E9 ( 4 byte ) go to $25FF ( 4 byte ) push $68 ( 4 byte ) $C3
end;
function getProcAddress ( name : String; libb : String ) : Pointer;
var
ProcAddress : Pointer;
begin
ProcAddress := Windows.GetProcAddress ( Windows.GetModuleHandle ( PChar ( libb ) ), PChar ( name ) );
if ProcAddress = NiL then begin
outLog ( name + ' не найдена' );
Result := NiL;
end else begin
outLog ( name + ' найдена' );
Result := ProcAddress;
end;
end;
function _sendto (
socket : TSocket;
var Buf : TBuf;
Len,
Flags : Cardinal;
var AddrTo : TSockAddr;
ToLen : Cardinal
) : Integer; stdcall;
var
res,
i : Integer;
st : String;
begin
outLog ( 'socket = ' + IntToStr ( socket ) );
outLog ( 'lenBuf = ' + IntToStr ( Len ) );
outLog ( 'flags = ' + IntToStr ( Flags ) );
// outLog ( 'msgSock= ' + IntToStr ( res ) );
{
outLog ( ' port = ' + IntToStr ( AddrTo.sin_port ) );
outLog ( ' ip1 = ' + IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b1 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b2 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b3 ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_addr.S_un_b.s_b4 ) ) );
outLog ( ' ip2 = ' + IntToStr ( AddrTo.sin_addr.S_un_w.s_w1 ) + '.' +
IntToStr ( AddrTo.sin_addr.S_un_w.s_w2 ) );
outLog ( ' ip3 = ' + IntToStr ( AddrTo.sin_addr.S_addr ) );
outLog ( ' saData = ' + IntToStr ( ord ( AddrTo.sa_data [ 0 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 1 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 2 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 3 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 4 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 5 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 6 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 7 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 8 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 9 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 10 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 11 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 12 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sa_data [ 13 ] ) ) );
outLog ( ' saZero = ' + IntToStr ( ord ( AddrTo.sin_zero [ 0 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 2 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 3 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 4 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 5 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 6 ] ) ) + '.' +
IntToStr ( ord ( AddrTo.sin_zero [ 7 ] ) ) );
outLog ( 'sin_family = ' + IntToStr ( AddrTo.sin_family ) );
outLog ( 'sa_family = ' + IntToStr ( AddrTo.sa_family ) );
}
st := '';
for i := 1 to Len - 1 do
st := st + chr ( buf [ i ] );
outLog ( st );
unsetHookApi;
{ вылет всегда на этой фун-ии, без нее игра проста повисает }
res := GB_DATA.sendTo ( socket, Buf, Len, Flags, AddrTo, ToLen );
setHookApi;
Result := 1;
end;
begin
outLog ( '---------------------------------------------------------------------------------------------------------' );
GB_DATA.newAddres := @_sendto;
GB_DATA.procAddress := getProcAddress ( 'sendto', 'ws2_32.dll' );
if not ( GB_DATA.procAddress = NiL ) then
setHookApiBegin ();
end. |
|
Добавлено через 1 минуту
спс mss за подсказку куда хоть копать....
теперь сдлед не главный вопрос..
буфер приходится объявлять так TBuf = Array [ 1..4096 ] of byte;
динамический не работает как мне сделать динамический буфер?
Добавлено через 42 минуты
вот готовый код мб кому пригодится
Pascal | 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
| library my_dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Windows;
type
TApiPack = packed record
jmp1 : byte;
newF : DWord;
end;
TTApiPack = ^TApiPack;
{ размер буфера }
TBuf = Array [ 1..4096 ] of byte;
{ сдесь пишем описание своей функции }
TSockAddr = record
case Integer of
0: (
sin_family : Word;
sin_port : Word;
sin_addr : record
case integer of
0: ( S_un_b: packed record
s_b1, s_b2, s_b3, s_b4: byte;
end;
);
1: ( S_un_w: packed record
s_w1, s_w2: Word;
end;
);
2: ( S_addr: Longint )
end;
sin_zero : array [ 0..7 ] of byte
);
1: (
sa_family : Word;
sa_data : array [ 0..13 ] of byte
)
end;
TSendTo = function (
socket : Cardinal;
var Buf : TBuf;
len,
flags : Cardinal;
var addrto : TSockAddr;
tolen : Cardinal
) : Integer; stdcall;
{ конец описанию своей функции }
var
GB_DATA : record
oldFunct,
newFunct : TApiPack;
dataMemory : TTApiPack;
procAddress,
newAddres : Pointer;
OldProtect : Cardinal;
originalF : TSendTo;
bufer : record
size : DWORD;
buf : TBuf;
end;
end;
{$R *.res}
procedure outLog ( log : String );
var
f: TextFile;
begin
if FileExists ( 'log_my_dll.log' ) then begin
AssignFile ( f, 'log_my_dll.log' );
Append ( f );
WriteLn ( f, log );
CloseFile ( f );
end else begin
AssignFile ( f, 'log_my_dll.log' );
Rewrite ( f );
WriteLn ( f, log );
CloseFile ( f );
End;
end;
procedure setMemoryPrivileg ();
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, PAGE_EXECUTE_READWRITE, GB_DATA.OldProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure unsetMemoryPrivileg ();
var
newProtect : Cardinal;
begin
if not VirtualProtect ( GB_DATA.procAddress, 6, GB_DATA.OldProtect, newProtect ) then begin
outLog ( 'Нет доступа к памяти.' );
exit;
end;
end;
procedure setHookApi ();
begin
GB_data.dataMemory^ := GB_data.newFunct;
end;
procedure unsetHookApi ();
begin
GB_data.dataMemory^ := GB_data.oldFunct;
end;
procedure setHookApiBegin ();
begin
setMemoryPrivileg;
GB_DATA.dataMemory := GB_DATA.procAddress;
@GB_DATA.originalF := GB_DATA.procAddress;
GB_DATA.oldFunct := GB_data.dataMemory^;
GB_DATA.newFunct.jmp1 := $E9;
GB_DATA.newFunct.newF := DWORD ( GB_DATA.newAddres ) - DWORD ( GB_DATA.procAddress ) - 5;
setHookApi;
// jump = $E9 ( 4 byte ) go to $25FF ( 4 byte ) push $68 ( 4 byte ) $C3
end;
procedure setBufer ();
begin
{ сдесь подменяяем отсылаемые данные }
// GB_DATA.bufer.size := 11;
// GB_DATA.bufer.buf := 'bla bla bla';
end;
function getProcAddress ( name : String; libb : String ) : Pointer;
var
ProcAddress : Pointer;
begin
ProcAddress := Windows.GetProcAddress ( Windows.GetModuleHandle ( PChar ( libb ) ), PChar ( name ) );
if ProcAddress = NiL then begin
// outLog ( name + ' не найдена' );
Result := NiL;
end else begin
// outLog ( name + ' найдена' );
Result := ProcAddress;
end;
end;
{ все параметры функции }
function podmenaFunct (
socket : Cardinal;
var Buf : TBuf;
Len,
Flags : Cardinal;
var AddrTo : TSockAddr;
ToLen : Cardinal
) : Integer; stdcall;
{ конец все параметры функции }
begin
GB_DATA.bufer.size := Len;
GB_DATA.bufer.buf := Buf;
setBufer;
unsetHookApi;
Result := GB_DATA.originalF ( socket, GB_DATA.bufer.buf, GB_DATA.bufer.size, Flags, AddrTo, ToLen );
setHookApi;
end;
begin
GB_DATA.newAddres := @podmenaFunct;
{ сдесь свою функ-ию и название дилки }
GB_DATA.procAddress := getProcAddress ( 'sendto', 'ws2_32.dll' );
if not ( GB_DATA.procAddress = NiL ) then
setHookApiBegin ();
end. |
|
Добавлено через 49 секунд
правда есть минус загрузка цп под 50%.... пинг стал 20-25 (а был 4-10 )
0
|