#26 21-03-2009 11:19

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

обьясните как пользоваться дебаггером плз,нич не понимаю там((

Offline

#27 22-03-2009 17:25

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

тишина...

Offline

#28 23-03-2009 04:51

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

@009 - момент не очень удачно выбран. Все, кто мог бы ответить, сейчас лихорадочно правят адреса для нового патча к IV.

Что дает дебаггер. Дебаггер дает возможность остановить программу в произвольной точке (set breakpoint) и посмотреть значения регистров и памяти. Кроме того, можно не запускать/останавливать программу, а выполнять пошагово (отдельные команды или функции).

Ставишь на "интересную команду" breakpoint и запускаешь программу (из-под дебаггера).
Как остановилось, смотришь, что там сейчас в программе делается.
Если непонятен какой-то фрагмент - его можно выполнять покомандно и смотреть, что меняется (step into). Чтобы не смотреть, что происходит в какой-то уже изместной функции - делаешь на нее не step into, а step over (программа останавливается после того, как эта функция отработает).

А дальше, нужно прикидывать что хочется узнать и соотнести это с возможностями дебаггера (например, можно ставить breakpoint не на адрес, а на модификацию памяти по какму-то адресу).

Offline

#29 23-03-2009 08:57

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

Здрасти ещё раз,вот я нашёл процедуру в которой берёт начало весь коннект игрока,там есть 4 места которые идентичны и различаются на 1 цифру и 1 переменную,все они вызывают процедуру sub_43CE90
эти 4 места выполняются не вместе,выполняется 1 изних(какая решает условие),вот эти 4 места:

1
2
3
4
5
6
7
push    1
push    8
lea     eax, [esp+380h+var_36C]
push    eax
lea     ecx, [esp+384h+var_348]
mov     [esp+384h+var_36C], 3
call    sub_43CE90
1
2
3
4
5
6
7
push    1
push    8
lea     ecx, [esp+380h+var_364]
push    ecx
lea     ecx, [esp+384h+var_348]
mov     byte ptr [esp+384h+var_364], 2
call    sub_43CE90
1
2
3
4
5
6
7
push    1
push    8
lea     ecx, [esp+380h+var_36C]
push    ecx
lea     ecx, [esp+384h+var_348]
mov     [esp+384h+var_36C], 1
call    sub_43CE90
1
2
3
4
5
6
7
push    1
push    8
lea     ecx, [esp+380h+var_36C]
push    ecx
lea     ecx, [esp+384h+var_348]
mov     [esp+384h+var_36C], 4
call    sub_43CE90

а вот сам этот sub_43CE90:

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
.text:0043CE90 sub_43CE90      proc near               ; CODE XREF: sub_43CF40+66p
.text:0043CE90                                         ; sub_43CFC0+55p ...
.text:0043CE90
.text:0043CE90 var_4           = dword ptr -4
.text:0043CE90 arg_0           = dword ptr  4
.text:0043CE90 arg_4           = dword ptr  8
.text:0043CE90 arg_8           = byte ptr  0Ch
.text:0043CE90
.text:0043CE90                 push    ecx
.text:0043CE91                 push    ebx
.text:0043CE92                 mov     ebx, [esp+8+arg_4]
.text:0043CE96                 test    ebx, ebx
.text:0043CE98                 push    esi
.text:0043CE99                 mov     esi, ecx
.text:0043CE9B                 jle     loc_43CF2D
.text:0043CEA1                 push    ebp
.text:0043CEA2                 push    edi
.text:0043CEA3                 push    ebx
.text:0043CEA4                 call    sub_43CB80
.text:0043CEA9                 mov     edx, [esi]
.text:0043CEAB                 mov     ebp, [esp+14h+arg_0]
.text:0043CEAF                 and     edx, 7
.text:0043CEB2                 mov     [esp+14h+var_4], edx
.text:0043CEB6
.text:0043CEB6 loc_43CEB6:                             ; CODE XREF: sub_43CE90+99j
.text:0043CEB6                 cmp     ebx, 8
.text:0043CEB9                 mov     al, [ebp+0]
.text:0043CEBC                 jge     short loc_43CECC
.text:0043CEBE                 mov     cl, [esp+14h+arg_8]
.text:0043CEC2                 test    cl, cl
.text:0043CEC4                 jz      short loc_43CECC
.text:0043CEC6                 mov     cl, 8
.text:0043CEC8                 sub     cl, bl
.text:0043CECA                 shl     al, cl
.text:0043CECC
.text:0043CECC loc_43CECC:                             ; CODE XREF: sub_43CE90+2Cj
.text:0043CECC                                         ; sub_43CE90+34j
.text:0043CECC                 mov     ecx, [esi]
.text:0043CECE                 mov     edi, [esi+0Ch]
.text:0043CED1                 sar     ecx, 3
.text:0043CED4                 test    edx, edx
.text:0043CED6                 jnz     short loc_43CEDD
.text:0043CED8                 mov     [ecx+edi], al
.text:0043CEDB                 jmp     short loc_43CF13
.text:0043CEDD ; ---------------------------------------------------------------------------
.text:0043CEDD
.text:0043CEDD loc_43CEDD:                             ; CODE XREF: sub_43CE90+46j
.text:0043CEDD                 add     edi, ecx
.text:0043CEDF                 mov     cl, al
.text:0043CEE1                 mov     byte ptr [esp+14h+arg_4], cl
.text:0043CEE5                 mov     cl, dl
.text:0043CEE7                 mov     dl, al
.text:0043CEE9                 shr     dl, cl
.text:0043CEEB                 or      [edi], dl
.text:0043CEED                 mov     edi, [esp+14h+var_4]
.text:0043CEF1                 mov     ecx, 8
.text:0043CEF6                 sub     ecx, edi
.text:0043CEF8                 cmp     ecx, 8
.text:0043CEFB                 jge     short loc_43CF0F
.text:0043CEFD                 cmp     ecx, ebx
.text:0043CEFF                 jge     short loc_43CF0F
.text:0043CF01                 mov     edx, [esi]
.text:0043CF03                 shl     al, cl
.text:0043CF05                 mov     ecx, [esi+0Ch]
.text:0043CF08                 sar     edx, 3
.text:0043CF0B                 mov     [edx+ecx+1], al
.text:0043CF0F
.text:0043CF0F loc_43CF0F:                             ; CODE XREF: sub_43CE90+6Bj
.text:0043CF0F                                         ; sub_43CE90+6Fj
.text:0043CF0F                 mov     edx, [esp+14h+var_4]
.text:0043CF13
.text:0043CF13 loc_43CF13:                             ; CODE XREF: sub_43CE90+4Bj
.text:0043CF13                 cmp     ebx, 8
.text:0043CF16                 mov     eax, [esi]
.text:0043CF18                 jl      short loc_43CF1F
.text:0043CF1A                 add     eax, 8
.text:0043CF1D                 jmp     short loc_43CF21
.text:0043CF1F ; ---------------------------------------------------------------------------
.text:0043CF1F
.text:0043CF1F loc_43CF1F:                             ; CODE XREF: sub_43CE90+88j
.text:0043CF1F                 add     eax, ebx
.text:0043CF21
.text:0043CF21 loc_43CF21:                             ; CODE XREF: sub_43CE90+8Dj
.text:0043CF21                 sub     ebx, 8
.text:0043CF24                 inc     ebp
.text:0043CF25                 test    ebx, ebx
.text:0043CF27                 mov     [esi], eax
.text:0043CF29                 jg      short loc_43CEB6
.text:0043CF2B                 pop     edi
.text:0043CF2C                 pop     ebp
.text:0043CF2D
.text:0043CF2D loc_43CF2D:                             ; CODE XREF: sub_43CE90+Bj
.text:0043CF2D                 pop     esi
.text:0043CF2E                 pop     ebx
.text:0043CF2F                 pop     ecx
.text:0043CF30                 retn    0Ch
.text:0043CF30 sub_43CE90      endp

Пытался вызвать этот суб на подобии того как он вызывается в первом случае,вот так:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
static cell AMX_NATIVE_CALL n_ConnectBot( AMX* amx, cell* params )
{
    FARPROC con = (FARPROC) 0x43CE90;
    __asm
      {
      push    1
      push    8
      lea     eax, [esp+380h+0x00]
      push    eax
      lea     ecx, [esp+384h+0x00]
      mov     [esp+384h+0x00], 3
      call    con
      }
    logprintf( "Bot connected!" );
    return 1;
}

var'ы заменил 0х00 т.к. в самой начальной процедуре где они указаны вот так:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var_36C= byte ptr -36Ch
var_366= byte ptr -366h
var_365= byte ptr -365h
var_364= dword ptr -364h
var_360= byte ptr -360h
var_35C= dword ptr -35Ch
var_358= dword ptr -358h
var_354= dword ptr -354h
var_350= word ptr -350h
var_34C= dword ptr -34Ch
var_348= byte ptr -348h
var_230= byte ptr -230h
Args= byte ptr -118h
var_14= dword ptr -14h
var_C= dword ptr -0Ch
var_4= dword ptr -4
arg_0= dword ptr  8

НО выдало ошибку:

Инструкция по адресу "0x10011928" обратилась к памяти по адресу "0x00130054".Память не может быть "writen".

т.к. тут уже writen то думаю я на правельном пути...

Last edited by 009 (23-03-2009 09:00)

Offline

#30 23-03-2009 09:10

Seemann
Registered: 07-08-2006
Posts: 2,156

Re: Помогите написать плагин для SA-MP

Регистр esp - это указатель на стек (место в оперативной памяти, где хранятся временные значения при выполнении программы). Когда ты вызываешь n_ConnectBot esp указывает на участок стека, который отведен для твоей программы, а не сампа. Соответственно, esp+384h+0x00 будет указывать на неверные данные (по этому указателю не будет каких-то значений, которые нужны 0x43CE90;). Поэтому при заходе в 0x43CE90 регистры ecx и eax будут содержать неправильные значения, отсюда и все проблемы. Тебе нужно узнать, что лежит по адресу esp+384h+var_ и соответственно прочитать это. Обычно выше в процедуре читается какой-то конкретный адрес например, mov     [esp+384h+var_36C], 0xC60010.

Offline

#31 23-03-2009 10:26

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

@009 - здесь имеет смысл понять, что же происходит в коде на высоком уровне.
А происходит там следующее: функция коннекта вызывается с тремя параметрами. Первы параметр - указатель на int, в котором (в том, на что этот указатель указывает) лежит 3. Второй и третий параметры, соответственно, 8 и 1.

Как это можно сделать легко и просто. Поскольку в регистрах параметры не передаются, это делается вообще без ассемблера.

Сначала объявляем переменную - указатель на функцию.

1
void (__stdcall * _43CE90)(int *, int, int) = (void (__stdcall *)(int *, int, int))0x43CE90;

Обявляем указатель на функцию, которая не возвращает значения, берет три параметра и сама освобождает стек (__stdcall). Присваиваем ей число-адрес функции (предварительно, приведя тип)

После этого, можно делать так:

1
2
int param = 3;
_43CE90 (&param, 8, 1);

Эта конструкция эквивалентна первому приведенному фрагменту.

Offline

#32 23-03-2009 10:50

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

@listener теперь он выдал другую ошибку:

Инструкция по адресу "0x0043cb8b" братилась к памяти по адресу "0x00000000".Память не может быть "read".

Теперь уже чтение памяти...

Offline

#33 23-03-2009 11:24

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

Ага. Слона-то я и не приметил (я про lea ecx, ...)
Эта конструкция означает, что это не __stdcall, а __thiscall.
Соответственно, нужно ему еще одним параметром передать объект.

Поскольку объект лежит на стеке, перед всем этим, должен быть конструктор того, что начинается с var_348.
Пока не будет этого -  подсказать ничего не смогу.

Offline

#34 23-03-2009 11:47

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

вот:

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
.text:0046E9B0
.text:0046E9B0 ; =============== S U B R O U T I N E =======================================
.text:0046E9B0
.text:0046E9B0 ; Attributes: bp-based frame
.text:0046E9B0
.text:0046E9B0 sub_46E9B0      proc near               ; DATA XREF: sub_470BD0+5o
.text:0046E9B0
.text:0046E9B0 var_36C         = byte ptr -36Ch
.text:0046E9B0 var_366         = byte ptr -366h
.text:0046E9B0 var_365         = byte ptr -365h
.text:0046E9B0 var_364         = dword ptr -364h
.text:0046E9B0 var_360         = byte ptr -360h
.text:0046E9B0 var_35C         = dword ptr -35Ch
.text:0046E9B0 var_358         = dword ptr -358h
.text:0046E9B0 var_354         = dword ptr -354h
.text:0046E9B0 var_350         = word ptr -350h
.text:0046E9B0 var_34C         = dword ptr -34Ch
.text:0046E9B0 var_348         = byte ptr -348h
.text:0046E9B0 var_230         = byte ptr -230h
.text:0046E9B0 Args            = byte ptr -118h
.text:0046E9B0 var_14          = dword ptr -14h
.text:0046E9B0 var_C           = dword ptr -0Ch
.text:0046E9B0 var_4           = dword ptr -4
.text:0046E9B0 arg_0           = dword ptr  8
.text:0046E9B0
.text:0046E9B0                 push    ebp
.text:0046E9B1                 mov     ebp, esp
.text:0046E9B3                 and     esp, 0FFFFFFF8h
.text:0046E9B6                 push    0FFFFFFFFh
.text:0046E9B8                 push    offset unknown_libname_119 ; Microsoft VisualC 2-9/net runtime
.text:0046E9BD                 mov     eax, large fs:0
.text:0046E9C3                 push    eax
.text:0046E9C4                 mov     large fs:0, esp
.text:0046E9CB                 sub     esp, 360h
.text:0046E9D1                 mov     eax, dword_4AF3B0
.text:0046E9D6                 mov     ecx, [ebp+arg_0]
.text:0046E9D9                 mov     [esp+36Ch+var_14], eax
.text:0046E9E0                 mov     eax, [ecx+4]
.text:0046E9E3                 push    ebx
.text:0046E9E4                 cdq
.text:0046E9E5                 push    esi
.text:0046E9E6                 and     edx, 7
.text:0046E9E9                 push    edi
.text:0046E9EA                 mov     edi, [ecx]
.text:0046E9EC                 add     eax, edx
.text:0046E9EE                 add     ecx, 8
.text:0046E9F1                 mov     esi, [ecx]
.text:0046E9F3                 mov     bx, [ecx+4]
.text:0046E9F7                 sar     eax, 3
.text:0046E9FA                 push    0               ; char
.text:0046E9FC                 inc     eax
.text:0046E9FD                 push    eax             ; Size
.text:0046E9FE                 push    edi             ; int
.text:0046E9FF                 lea     ecx, [esp+384h+var_230]
.text:0046EA06                 call    sub_43C880
.text:0046EA0B                 xor     edi, edi
.text:0046EA0D                 lea     ecx, [esp+378h+var_348]
.text:0046EA11                 mov     [esp+378h+var_4], edi
.text:0046EA18                 call    sub_43C7F0
.text:0046EA1D                 mov     eax, dword_4B7CCC
.text:0046EA22                 mov     ecx, [eax+4]
.text:0046EA25                 sub     esp, 8
.text:0046EA28                 mov     [esp+380h+var_358], ecx
.text:0046EA2C                 mov     ecx, dword_4B7E1C
.text:0046EA32                 mov     eax, esp
.text:0046EA34                 mov     [esp+380h+var_35C], edi
.text:0046EA38                 mov     edx, [ecx]
.text:0046EA3A                 mov     [eax], esi
.text:0046EA3C                 mov     byte ptr [esp+380h+var_4], 1
.text:0046EA44                 mov     [eax+4], bx
.text:0046EA48                 call    dword ptr [edx+0D8h]
.text:0046EA4E                 mov     ecx, dword_4B7E1C
.text:0046EA54                 mov     edx, [ecx]
.text:0046EA56                 mov     [esp+378h+var_360], al
.text:0046EA5A                 movzx   eax, al
.text:0046EA5D                 push    eax
.text:0046EA5E                 lea     eax, [esp+37Ch+var_354]
.text:0046EA62                 push    eax
.text:0046EA63                 call    dword ptr [edx+0DCh]
.text:0046EA69                 xor     eax, eax
.text:0046EA6B                 push    1
.text:0046EA6D                 mov     ecx, 40h
.text:0046EA72                 lea     edi, [esp+37Ch+Args]
.text:0046EA79                 rep stosd
.text:0046EA7B                 push    20h
.text:0046EA7D                 lea     ecx, [esp+380h+var_34C]
.text:0046EA81                 push    ecx
.text:0046EA82                 lea     ecx, [esp+384h+var_230]
.text:0046EA89                 call    sub_43C9C0
.text:0046EA8E                 push    1
.text:0046EA90                 push    8
.text:0046EA92                 lea     edx, [esp+380h+var_365]
.text:0046EA96                 push    edx
.text:0046EA97                 lea     ecx, [esp+384h+var_230]
.text:0046EA9E                 call    sub_43C9C0
.text:0046EAA3                 push    1
.text:0046EAA5                 push    8
.text:0046EAA7                 lea     eax, [esp+380h+var_366]
.text:0046EAAB                 push    eax
.text:0046EAAC                 lea     ecx, [esp+384h+var_230]
.text:0046EAB3                 call    sub_43C9C0
.text:0046EAB8                 movzx   ecx, [esp+378h+var_366]
.text:0046EABD                 push    ecx
.text:0046EABE                 lea     edx, [esp+37Ch+Args]
.text:0046EAC5                 push    edx
.text:0046EAC6                 lea     ecx, [esp+380h+var_230]
.text:0046EACD                 call    sub_43CD50
.text:0046EAD2                 movzx   eax, [esp+378h+var_366]
.text:0046EAD7                 push    1
.text:0046EAD9                 push    20h
.text:0046EADB                 lea     ecx, [esp+380h+var_35C]
.text:0046EADF                 mov     [esp+eax+380h+Args], 0
.text:0046EAE7                 push    ecx
.text:0046EAE8                 lea     ecx, [esp+384h+var_230]
.text:0046EAEF                 call    sub_43C9C0
.text:0046EAF4                 lea     edx, [esp+378h+var_354]
.text:0046EAF8                 push    edx
.text:0046EAF9                 mov     ecx, offset dword_4AF2D4
.text:0046EAFE                 call    sub_43E100
.text:0046EB03                 test    al, al
.text:0046EB05                 jz      short loc_46EB3A
.text:0046EB07                 push    esi             ; in
.text:0046EB08                 call    ds:inet_ntoa
.text:0046EB0E                 push    eax             ; Args
.text:0046EB0F                 push    offset aDetectedPossib ; "Detected possible bot from (%s)"
.text:0046EB14                 call    sub_46A590
.text:0046EB19                 mov     esi, [esp+380h+var_354]
.text:0046EB1D                 mov     ecx, dword_4B7E1C
.text:0046EB23                 mov     eax, [ecx]
.text:0046EB25                 mov     edx, esp
.text:0046EB27                 mov     [edx], esi
.text:0046EB29                 mov     si, [esp+380h+var_350]
.text:0046EB2E                 mov     [edx+4], si
.text:0046EB32                 call    dword ptr [eax+28h]
.text:0046EB35                 jmp     loc_46ED00
.text:0046EB3A ; ---------------------------------------------------------------------------
.text:0046EB3A
.text:0046EB3A loc_46EB3A:                             ; CODE XREF: sub_46E9B0+155j
.text:0046EB3A                 mov     ecx, dword_4B7E1C
.text:0046EB40                 mov     eax, [ecx]
.text:0046EB42                 sub     esp, 8
.text:0046EB45                 mov     edx, esp
.text:0046EB47                 mov     [edx], esi
.text:0046EB49                 mov     [edx+4], bx
.text:0046EB4D                 call    dword ptr [eax+0F0h]
.text:0046EB53                 test    al, al
.text:0046EB55                 jz      loc_46ECA9
.text:0046EB5B                 cmp     [esp+378h+var_360], 0C8h
.text:0046EB60                 ja      loc_46ECA9
.text:0046EB66                 cmp     [esp+378h+var_34C], 22A2h
.text:0046EB6E                 jnz     loc_46EC71
.text:0046EB74                 mov     eax, [esp+378h+var_35C]
.text:0046EB78                 mov     ecx, dword_4B7CC0
.text:0046EB7E                 xor     eax, 22A2h
.text:0046EB83                 cmp     ecx, eax
.text:0046EB85                 jnz     loc_46EC71
.text:0046EB8B                 mov     edx, dword_4B7CCC
.text:0046EB91                 mov     cl, [esp+378h+var_365]
.text:0046EB95                 cmp     cl, [edx+58h]
.text:0046EB98                 jz      short loc_46EBD5
.text:0046EB9A                 push    1
.text:0046EB9C                 push    8
.text:0046EB9E                 lea     eax, [esp+380h+var_36C]
.text:0046EBA2                 push    eax
.text:0046EBA3                 lea     ecx, [esp+384h+var_348]
.text:0046EBA7                 mov     [esp+384h+var_36C], 3
.text:0046EBAC                 call    sub_43CE90
.text:0046EBB1                 push    0
.text:0046EBB3                 push    0
.text:0046EBB5                 sub     esp, 8
.text:0046EBB8                 mov     eax, esp
.text:0046EBBA                 push    0
.text:0046EBBC                 mov     [eax], esi
.text:0046EBBE                 push    2
.text:0046EBC0                 mov     [eax+4], bx
.text:0046EBC4                 push    1
.text:0046EBC6                 lea     eax, [esp+394h+var_348]
.text:0046EBCA                 push    eax
.text:0046EBCB                 push    offset aAu_1    ; "au"
.text:0046EBD0                 jmp     loc_46ECDF
.text:0046EBD5 ; ---------------------------------------------------------------------------
.text:0046EBD5
.text:0046EBD5 loc_46EBD5:                             ; CODE XREF: sub_46E9B0+1E8j
.text:0046EBD5                 lea     ecx, [esp+378h+Args]
.text:0046EBDC                 push    ecx
.text:0046EBDD                 call    sub_475F90
.text:0046EBE2                 add     esp, 4
.text:0046EBE5                 test    al, al
.text:0046EBE7                 jnz     short loc_46EC39
.text:0046EBE9                 mov     al, [esp+378h+var_366]
.text:0046EBED                 cmp     al, 3
.text:0046EBEF                 jb      short loc_46EC39
.text:0046EBF1                 cmp     al, 10h
.text:0046EBF3                 ja      short loc_46EC39
.text:0046EBF5                 mov     ecx, [esp+378h+var_358]
.text:0046EBF9                 lea     edx, [esp+378h+Args]
.text:0046EC00                 push    edx             ; Str2
.text:0046EC01                 call    sub_4742B0
.text:0046EC06                 test    eax, eax
.text:0046EC08                 jnz     short loc_46EC39
.text:0046EC0A                 mov     edi, dword ptr [esp+378h+var_360]
.text:0046EC0E                 mov     ecx, [esp+378h+var_358]
.text:0046EC12                 lea     eax, [esp+378h+Args]
.text:0046EC19                 push    eax             ; Args
.text:0046EC1A                 push    edi             ; char
.text:0046EC1B                 call    sub_4743C0
.text:0046EC20                 test    eax, eax
.text:0046EC22                 jz      loc_46ECEA
.text:0046EC28                 mov     ecx, dword_4B7CCC
.text:0046EC2E                 push    edi
.text:0046EC2F                 call    sub_46E240
.text:0046EC34                 jmp     loc_46ED00
.text:0046EC39 ; ---------------------------------------------------------------------------
.text:0046EC39
.text:0046EC39 loc_46EC39:                             ; CODE XREF: sub_46E9B0+237j
.text:0046EC39                                         ; sub_46E9B0+23Fj ...
.text:0046EC39                 push    1
.text:0046EC3B                 push    8
.text:0046EC3D                 lea     ecx, [esp+380h+var_364]
.text:0046EC41                 push    ecx
.text:0046EC42                 lea     ecx, [esp+384h+var_348]
.text:0046EC46                 mov     byte ptr [esp+384h+var_364], 2
.text:0046EC4B                 call    sub_43CE90
.text:0046EC50                 push    0
.text:0046EC52                 push    0
.text:0046EC54                 sub     esp, 8
.text:0046EC57                 mov     eax, esp
.text:0046EC59                 push    0
.text:0046EC5B                 mov     [eax], esi
.text:0046EC5D                 push    2
.text:0046EC5F                 mov     [eax+4], bx
.text:0046EC63                 push    1
.text:0046EC65                 lea     eax, [esp+394h+var_348]
.text:0046EC69                 push    eax
.text:0046EC6A                 push    offset aAu_2    ; "au"
.text:0046EC6F                 jmp     short loc_46ECDF
.text:0046EC71 ; ---------------------------------------------------------------------------
.text:0046EC71
.text:0046EC71 loc_46EC71:                             ; CODE XREF: sub_46E9B0+1BEj
.text:0046EC71                                         ; sub_46E9B0+1D5j
.text:0046EC71                 push    1
.text:0046EC73                 push    8
.text:0046EC75                 lea     ecx, [esp+380h+var_36C]
.text:0046EC79                 push    ecx
.text:0046EC7A                 lea     ecx, [esp+384h+var_348]
.text:0046EC7E                 mov     [esp+384h+var_36C], 1
.text:0046EC83                 call    sub_43CE90
.text:0046EC88                 push    0
.text:0046EC8A                 push    0
.text:0046EC8C                 sub     esp, 8
.text:0046EC8F                 mov     eax, esp
.text:0046EC91                 push    0
.text:0046EC93                 mov     [eax], esi
.text:0046EC95                 push    2
.text:0046EC97                 mov     [eax+4], bx
.text:0046EC9B                 push    1
.text:0046EC9D                 lea     eax, [esp+394h+var_348]
.text:0046ECA1                 push    eax
.text:0046ECA2                 push    offset aAu_0    ; "au"
.text:0046ECA7                 jmp     short loc_46ECDF
.text:0046ECA9 ; ---------------------------------------------------------------------------
.text:0046ECA9
.text:0046ECA9 loc_46ECA9:                             ; CODE XREF: sub_46E9B0+1A5j
.text:0046ECA9                                         ; sub_46E9B0+1B0j
.text:0046ECA9                 push    1
.text:0046ECAB                 push    8
.text:0046ECAD                 lea     ecx, [esp+380h+var_36C]
.text:0046ECB1                 push    ecx
.text:0046ECB2                 lea     ecx, [esp+384h+var_348]
.text:0046ECB6                 mov     [esp+384h+var_36C], 4
.text:0046ECBB                 call    sub_43CE90
.text:0046ECC0                 push    0
.text:0046ECC2                 push    0
.text:0046ECC4                 sub     esp, 8
.text:0046ECC7                 mov     eax, esp
.text:0046ECC9                 push    0
.text:0046ECCB                 mov     [eax], esi
.text:0046ECCD                 push    2
.text:0046ECCF                 mov     [eax+4], bx
.text:0046ECD3                 push    1
.text:0046ECD5                 lea     eax, [esp+394h+var_348]
.text:0046ECD9                 push    eax
.text:0046ECDA                 push    offset aAu      ; "au"
.text:0046ECDF
.text:0046ECDF loc_46ECDF:                             ; CODE XREF: sub_46E9B0+220j
.text:0046ECDF                                         ; sub_46E9B0+2BFj ...
.text:0046ECDF                 mov     ecx, dword_4B7E1C
.text:0046ECE5                 mov     edx, [ecx]
.text:0046ECE7                 call    dword ptr [edx+7Ch]
.text:0046ECEA
.text:0046ECEA loc_46ECEA:                             ; CODE XREF: sub_46E9B0+272j
.text:0046ECEA                 mov     ecx, dword_4B7E1C
.text:0046ECF0                 mov     edx, [ecx]
.text:0046ECF2                 sub     esp, 8
.text:0046ECF5                 mov     eax, esp
.text:0046ECF7                 mov     [eax], esi
.text:0046ECF9                 mov     [eax+4], bx
.text:0046ECFD                 call    dword ptr [edx+28h]
.text:0046ED00
.text:0046ED00 loc_46ED00:                             ; CODE XREF: sub_46E9B0+185j
.text:0046ED00                                         ; sub_46E9B0+284j
.text:0046ED00                 lea     ecx, [esp+378h+var_348]
.text:0046ED04                 mov     byte ptr [esp+378h+var_4], 0
.text:0046ED0C                 call    sub_43C900
.text:0046ED11                 lea     ecx, [esp+378h+var_230]
.text:0046ED18                 mov     [esp+378h+var_4], 0FFFFFFFFh
.text:0046ED23                 call    sub_43C900
.text:0046ED28                 mov     ecx, [esp+378h+var_C]
.text:0046ED2F                 mov     large fs:0, ecx
.text:0046ED36                 mov     ecx, [esp+378h+var_14]
.text:0046ED3D                 call    sub_477BD9
.text:0046ED42                 pop     edi
.text:0046ED43                 pop     esi
.text:0046ED44                 pop     ebx
.text:0046ED45                 mov     esp, ebp
.text:0046ED47                 pop     ebp
.text:0046ED48                 retn
.text:0046ED48 sub_46E9B0      endp

Offline

#35 24-03-2009 19:44

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

Здравствуйте все,надеюсь ещё не надоел вопросами...есть исходник VC-MP 0.1c где разработчик тот же(keyman) ,и вот 2 вида добавления игрока(из исходника и из ассемблера):

исходник:

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
BOOL CPlayerPool::New(BYTE bytePlayerID, PCHAR szPlayerName)
{
    m_pPlayers[bytePlayerID] = new CPlayer();
 
    if(m_pPlayers[bytePlayerID])
    {
        strcpy(m_szPlayerName[bytePlayerID],szPlayerName);
        m_pPlayers[bytePlayerID]->SetID(bytePlayerID);
        m_bPlayerSlotState[bytePlayerID] = TRUE;
        m_iPlayerScore[bytePlayerID] = 0;
        m_bIsAnAdmin[bytePlayerID] = FALSE;
 
        // Notify all the other players of a newcommer with
        // a 'ServerJoin' join RPC
        RakNet::BitStream bsSend;
        bsSend.Write(bytePlayerID);
        bsSend.Write(strlen(szPlayerName));
        bsSend.Write(szPlayerName,strlen(szPlayerName));
        pNetGame->GetRakServer()->RPC("ServerJoin",&bsSend,HIGH_PRIORITY,RELIABLE_ORDERED,0,
            pNetGame->GetRakServer()->GetPlayerIDFromIndex(bytePlayerID),TRUE,FALSE);
         
        pRcon->ConsolePrintf("[join] %u %s",bytePlayerID,szPlayerName);
 
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}

Ассемблер:

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
.text:00418C10
.text:00418C10 ; =============== S U B R O U T I N E =======================================
.text:00418C10
.text:00418C10
.text:00418C10 sub_418C10      proc near               ; CODE XREF: .text:00415539p
.text:00418C10
.text:00418C10 var_28          = dword ptr -28h
.text:00418C10 var_20          = byte ptr -20h
.text:00418C10 var_C           = dword ptr -0Ch
.text:00418C10 var_4           = dword ptr -4
.text:00418C10 arg_0           = dword ptr  4
.text:00418C10 arg_4           = dword ptr  8
.text:00418C10
.text:00418C10                 push    0FFFFFFFFh
.text:00418C12                 push    offset SEH_418C10
.text:00418C17                 mov     eax, large fs:0
.text:00418C1D                 push    eax
.text:00418C1E                 mov     large fs:0, esp
.text:00418C25                 sub     esp, 1Ch
.text:00418C28                 push    ebx
.text:00418C29                 push    ebp
.text:00418C2A                 push    esi
.text:00418C2B                 push    edi
.text:00418C2C                 push    187h            ; dwBytes
.text:00418C31                 mov     edi, ecx
.text:00418C33                 call    ??2@YAPAXI@Z    ; operator new(uint)
.text:00418C38                 add     esp, 4
.text:00418C3B                 mov     [esp+38h+var_28], eax
.text:00418C3F                 test    eax, eax
.text:00418C41                 mov     [esp+38h+var_4], 0
.text:00418C49                 jz      short loc_418C54
.text:00418C4B                 mov     ecx, eax
.text:00418C4D                 call    sub_418000
.text:00418C52                 jmp     short loc_418C56
.text:00418C54 ; ---------------------------------------------------------------------------
.text:00418C54
.text:00418C54 loc_418C54:                             ; CODE XREF: sub_418C10+39j
.text:00418C54                 xor     eax, eax
.text:00418C56
.text:00418C56 loc_418C56:                             ; CODE XREF: sub_418C10+42j
.text:00418C56                 test    eax, eax
.text:00418C58                 mov     ebx, [esp+38h+arg_0]
.text:00418C5C                 movzx   esi, bl
.text:00418C5F                 mov     [esp+38h+var_4], 0FFFFFFFFh
.text:00418C67                 mov     [edi+esi*4+190h], eax
.text:00418C6E                 jz      loc_418D82
.text:00418C74                 mov     ebp, [esp+38h+arg_4]
.text:00418C78                 lea     ecx, [esi+20h]
.text:00418C7B                 imul    ecx, 19h
.text:00418C7E                 sub     ecx, ebp
.text:00418C80                 mov     eax, ebp
.text:00418C82                 lea     edx, [ecx+edi]
.text:00418C85
.text:00418C85 loc_418C85:                             ; CODE XREF: sub_418C10+7Dj
.text:00418C85                 mov     cl, [eax]
.text:00418C87                 mov     [edx+eax], cl
.text:00418C8A                 inc     eax
.text:00418C8B                 test    cl, cl
.text:00418C8D                 jnz     short loc_418C85
.text:00418C8F                 mov     eax, [edi+esi*4+190h]
.text:00418C96                 mov     [eax], bl
.text:00418C98                 xor     eax, eax
.text:00418C9A                 lea     ecx, [esp+38h+var_20]
.text:00418C9E                 mov     dword ptr [edi+esi*4], 1
.text:00418CA5                 mov     [edi+esi*4+0CE4h], eax
.text:00418CAC                 mov     [edi+esi*4+0E74h], eax
.text:00418CB3                 call    sub_401D40
.text:00418CB8                 push    ebx
.text:00418CB9                 lea     ecx, [esp+3Ch+var_20]
.text:00418CBD                 mov     [esp+3Ch+var_4], 1
.text:00418CC5                 call    sub_4025D0
.text:00418CCA                 mov     eax, ebp
.text:00418CCC                 lea     edx, [eax+1]
.text:00418CCF                 nop
.text:00418CD0
.text:00418CD0 loc_418CD0:                             ; CODE XREF: sub_418C10+C5j
.text:00418CD0                 mov     cl, [eax]
.text:00418CD2                 inc     eax
.text:00418CD3                 test    cl, cl
.text:00418CD5                 jnz     short loc_418CD0
.text:00418CD7                 sub     eax, edx
.text:00418CD9                 push    eax
.text:00418CDA                 lea     ecx, [esp+3Ch+var_20]
.text:00418CDE                 call    sub_402610
.text:00418CE3                 mov     eax, ebp
.text:00418CE5                 lea     ecx, [eax+1]
.text:00418CE8
.text:00418CE8 loc_418CE8:                             ; CODE XREF: sub_418C10+DDj
.text:00418CE8                 mov     dl, [eax]
.text:00418CEA                 inc     eax
.text:00418CEB                 test    dl, dl
.text:00418CED                 jnz     short loc_418CE8
.text:00418CEF                 sub     eax, ecx
.text:00418CF1                 push    eax
.text:00418CF2                 push    ebp
.text:00418CF3                 lea     ecx, [esp+40h+var_20]
.text:00418CF7                 call    sub_402630
.text:00418CFC                 mov     edx, dword_42E08C
.text:00418D02                 mov     edi, [edx+0Ch]
.text:00418D05                 mov     eax, [edi]
.text:00418D07                 push    esi
.text:00418D08                 lea     ecx, [esp+3Ch+var_28]
.text:00418D0C                 push    ecx
.text:00418D0D                 mov     ecx, edi
.text:00418D0F                 call    dword ptr [eax+0C0h]
.text:00418D15                 mov     ebx, [eax]
.text:00418D17                 mov     ax, [eax+4]
.text:00418D1B                 mov     edx, [edi]
.text:00418D1D                 push    0
.text:00418D1F                 push    1
.text:00418D21                 sub     esp, 8
.text:00418D24                 mov     ecx, esp
.text:00418D26                 push    0
.text:00418D28                 mov     [ecx], ebx
.text:00418D2A                 push    3
.text:00418D2C                 mov     [ecx+4], ax
.text:00418D30                 push    1
.text:00418D32                 lea     ecx, [esp+54h+var_20]
.text:00418D36                 push    ecx
.text:00418D37                 push    offset aServerjoin ; "ServerJoin"
.text:00418D3C                 mov     ecx, edi
.text:00418D3E                 call    dword ptr [edx+78h]
.text:00418D41                 mov     edx, dword_42E088
.text:00418D47                 push    ebp
.text:00418D48                 push    esi             ; Args
.text:00418D49                 push    offset aJoinUS  ; "[join] %u %s"
.text:00418D4E                 push    edx             ; int
.text:00418D4F                 call    sub_419620
.text:00418D54                 add     esp, 10h
.text:00418D57                 lea     ecx, [esp+38h+var_20]
.text:00418D5B                 mov     [esp+38h+var_4], 0FFFFFFFFh
.text:00418D63                 call    sub_401E20
.text:00418D68                 mov     eax, 1
.text:00418D6D                 mov     ecx, [esp+38h+var_C]
.text:00418D71                 mov     large fs:0, ecx
.text:00418D78                 pop     edi
.text:00418D79                 pop     esi
.text:00418D7A                 pop     ebp
.text:00418D7B                 pop     ebx
.text:00418D7C                 add     esp, 28h
.text:00418D7F                 retn    8
.text:00418D82 ; ---------------------------------------------------------------------------
.text:00418D82
.text:00418D82 loc_418D82:                             ; CODE XREF: sub_418C10+5Ej
.text:00418D82                 mov     ecx, [esp+38h+var_C]
.text:00418D86                 pop     edi
.text:00418D87                 pop     esi
.text:00418D88                 pop     ebp
.text:00418D89                 xor     eax, eax
.text:00418D8B                 mov     large fs:0, ecx
.text:00418D92                 pop     ebx
.text:00418D93                 add     esp, 28h
.text:00418D96                 retn    8
.text:00418D96 sub_418C10      endp

при сравнивании ассемблеровских кодов VC-MP и SA-MP нашёл не очень много отличий...и вот вопрос есть:

как выглядят m_pPlayers[bytePlayerID]->SetID(bytePlayerID);
        m_bPlayerSlotState[bytePlayerID] = TRUE;
        m_iPlayerScore[bytePlayerID] = 0;
в ассемблеровском коде?(поняв как выглядят они я смогу отыскать в ассемблеровском коде сампа подобное и забить слот игрока...)

Offline

#36 25-03-2009 08:51

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

bytePlayerID - это arg_0.

; приведение BYTE к DWORD
.text:00418C58                 mov     ebx, [esp+38h+arg_0]
.text:00418C5C                 movzx   esi, bl

; m_pPlayers[bytePlayerID]->SetID(bytePlayerID);
; вернее, в коде это получилось что-то вроде: m_pPlayers[bytePlayerID]->m_bID = bytePlayerID;
; edi = this, 0x190 - смещение m_pPlayers относительно начала объекта, 4 - размер указателя
text:00418C8F                 mov     eax, [edi+esi*4+190h]
.text:00418C96                 mov     [eax], bl

; m_bPlayerSlotState[bytePlayerID] = TRUE;
; смещение m_bPlayerSlotState нулевое, поэтому смещение в объекте, не прибавляется; 4 здесь - размер DWORD
.text:00418C9E                 mov     dword ptr [edi+esi*4], 1

; m_iPlayerScore[bytePlayerID] = 0;
; m_bIsAnAdmin[bytePlayerID] = FALSE;
; оптимизатор легко мог поменять присваивание местами, поэтому стоит посмотреть дальше по коду, какое из смещений m_iPlayerScore, а какое m_bIsAnAdmin
; (скорее всего, m_iPlayerScore по смещению 0xCE4, но на 100% в этом увереным быть нельзя)
.text:00418C98                 xor     eax, eax
; ...
.text:00418CA5                 mov     [edi+esi*4+0CE4h], eax
.text:00418CAC                 mov     [edi+esi*4+0E74h], eax

Last edited by listener (25-03-2009 08:51)

Offline

#37 25-03-2009 09:52

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

спс=)

как и планировал я попытался попробовать по примеру всмп сделать закрытие ида(m_bPlayerSlotState[bytePlayerID] = TRUE;) в самп...вот что кароче получается:

вот код где назодится закрытие id:

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
.text:004743C0 ; int __stdcall sub_4743C0(char, char Args)
.text:004743C0 sub_4743C0      proc near               ; CODE XREF: sub_46E9B0+26Bp
.text:004743C0
.text:004743C0 var_138         = byte ptr -138h
.text:004743C0 in              = in_addr ptr -134h
.text:004743C0 var_12A         = byte ptr -12Ah
.text:004743C0 var_124         = byte ptr -124h
.text:004743C0 var_10          = dword ptr -10h
.text:004743C0 var_C           = dword ptr -0Ch
.text:004743C0 var_4           = dword ptr -4
.text:004743C0 arg_0           = byte ptr  4
.text:004743C0 Args            = byte ptr  8
.text:004743C0
.text:004743C0                 push    0FFFFFFFFh
.text:004743C2                 push    offset unknown_libname_125 ; Microsoft VisualC 2-9/net runtime
.text:004743C7                 mov     eax, large fs:0
.text:004743CD                 push    eax
.text:004743CE                 mov     large fs:0, esp
.text:004743D5                 sub     esp, 12Ch
.text:004743DB                 mov     eax, dword_4AF3B0
.text:004743E0                 push    ebx
.text:004743E1                 mov     bl, [esp+13Ch+arg_0]
.text:004743E8                 cmp     bl, 0C8h
.text:004743EB                 push    ebp
.text:004743EC                 push    esi
.text:004743ED                 mov     [esp+144h+var_10], eax
.text:004743F4                 push    edi
.text:004743F5                 mov     ebp, ecx
.text:004743F7                 ja      loc_4745D4
.text:004743FD                 mov     edi, dword ptr [esp+148h+Args]
.text:00474404                 mov     eax, edi
.text:00474406                 lea     edx, [eax+1]
.text:00474409                 lea     esp, [esp+0]
.text:00474410
.text:00474410 loc_474410:                             ; CODE XREF: sub_4743C0+55j
.text:00474410                 mov     cl, [eax]
.text:00474412                 inc     eax
.text:00474413                 test    cl, cl
.text:00474415                 jnz     short loc_474410
.text:00474417                 sub     eax, edx
.text:00474419                 cmp     eax, 18h
.text:0047441C                 ja      loc_4745D4
.text:00474422                 push    1E9h            ; dwBytes
.text:00474427                 call    ??2@YAPAXI@Z    ; operator new(uint)
.text:0047442C                 add     esp, 4
.text:0047442F                 mov     dword ptr [esp+148h+in.S_un], eax
.text:00474433                 test    eax, eax
.text:00474435                 mov     [esp+148h+var_4], 0
.text:00474440                 jz      short loc_47444B
.text:00474442                 mov     ecx, eax
.text:00474444                 call    sub_471980
.text:00474449                 jmp     short loc_47444D
.text:0047444B ; ---------------------------------------------------------------------------
.text:0047444B
.text:0047444B loc_47444B:                             ; CODE XREF: sub_4743C0+80j
.text:0047444B                 xor     eax, eax
.text:0047444D
.text:0047444D loc_47444D:                             ; CODE XREF: sub_4743C0+89j
.text:0047444D                 test    eax, eax
.text:0047444F                 movzx   esi, bl
.text:00474452                 mov     [esp+148h+var_4], 0FFFFFFFFh
.text:0047445D                 mov     [ebp+esi*4+320h], eax
.text:00474464                 jz      loc_4745D4
.text:0047446A                 lea     ecx, [esi+40h]
.text:0047446D                 imul    ecx, 19h
.text:00474470                 sub     ecx, edi
.text:00474472                 mov     eax, edi
.text:00474474                 lea     edx, [ecx+ebp]
.text:00474477
.text:00474477 loc_474477:                             ; CODE XREF: sub_4743C0+BFj
.text:00474477                 mov     cl, [eax]
.text:00474479                 mov     [edx+eax], cl
.text:0047447C                 inc     eax
.text:0047447D                 test    cl, cl
.text:0047447F                 jnz     short loc_474477
.text:00474481                 mov     eax, [ebp+esi*4+320h]
.text:00474488                 mov     [eax], bl
.text:0047448A                 xor     eax, eax
.text:0047448C                 mov     dword ptr [ebp+esi*4+0], 1
.text:00474494                 mov     [ebp+esi*4+19C8h], eax
.text:0047449B                 mov     [ebp+esi*4+1CE8h], eax
.text:004744A2                 mov     [ebp+esi*4+2328h], eax
.text:004744A9                 lea     ecx, [esp+148h+var_124]
.text:004744AD                 mov     [esi+ebp+2648h], al
.text:004744B4                 call    sub_43C7F0
.text:004744B9                 push    1
.text:004744BB                 push    8
.text:004744BD                 lea     edx, [esp+150h+var_138]
.text:004744C1                 push    edx
.text:004744C2                 lea     ecx, [esp+154h+var_124]
.text:004744C6                 mov     [esp+154h+var_4], 1
.text:004744D1                 mov     [esp+154h+var_138], bl
.text:004744D5                 call    sub_43CE90
.text:004744DA                 mov     eax, edi
.text:004744DC                 lea     ecx, [eax+1]
.text:004744DF                 nop
.text:004744E0
.text:004744E0 loc_4744E0:                             ; CODE XREF: sub_4743C0+125j
.text:004744E0                 mov     dl, [eax]
.text:004744E2                 inc     eax
.text:004744E3                 test    dl, dl
.text:004744E5                 jnz     short loc_4744E0
.text:004744E7                 sub     eax, ecx
.text:004744E9                 push    1
.text:004744EB                 mov     ebx, eax
.text:004744ED                 push    8
.text:004744EF                 lea     eax, [esp+150h+var_138]
.text:004744F3                 push    eax
.text:004744F4                 lea     ecx, [esp+154h+var_124]
.text:004744F8                 mov     [esp+154h+var_138], bl
.text:004744FC                 call    sub_43CE90
.text:00474501                 movzx   ecx, bl
.text:00474504                 push    ecx
.text:00474505                 push    edi
.text:00474506                 lea     ecx, [esp+150h+var_124]
.text:0047450A                 call    sub_43CF40
.text:0047450F                 mov     edx, dword_4B7CCC
.text:00474515                 mov     edi, [edx]
.text:00474517                 mov     eax, [edi]
.text:00474519                 push    esi
.text:0047451A                 lea     ecx, [esp+14Ch+var_12A]
.text:0047451E                 push    ecx
.text:0047451F                 mov     ecx, edi
.text:00474521                 call    dword ptr [eax+0DCh]
.text:00474527                 mov     ebx, [eax]
.text:00474529                 mov     ax, [eax+4]
.text:0047452D                 mov     edx, [edi]
.text:0047452F                 push    0
.text:00474531                 push    1
.text:00474533                 sub     esp, 8
.text:00474536                 mov     ecx, esp
.text:00474538                 push    0
.text:0047453A                 mov     [ecx], ebx
.text:0047453C                 push    2
.text:0047453E                 mov     [ecx+4], ax
.text:00474542                 push    1
.text:00474544                 lea     ecx, [esp+164h+var_124]
.text:00474548                 push    ecx
.text:00474549                 push    offset unk_49BA78
.text:0047454E                 mov     ecx, edi
.text:00474550                 call    dword ptr [edx+7Ch]
.text:00474553                 mov     edx, dword_4B7CCC
.text:00474559                 mov     ecx, [edx]
.text:0047455B                 mov     eax, [ecx]
.text:0047455D                 push    esi
.text:0047455E                 lea     edx, [esp+14Ch+in]
.text:00474562                 push    edx
.text:00474563                 call    dword ptr [eax+0DCh]
.text:00474569                 mov     eax, dword ptr [esp+148h+in.S_un]
.text:0047456D                 push    eax             ; in
.text:0047456E                 call    ds:inet_ntoa
.text:00474574                 mov     ecx, dword ptr [esp+148h+Args]
.text:0047457B                 push    eax
.text:0047457C                 push    esi
.text:0047457D                 push    ecx             ; Args
.text:0047457E                 push    offset aJoinSHasJoined ; "[join] %s has joined the server (%u:%s)"...
.text:00474583                 call    sub_46A590
.text:00474588                 mov     edx, dword_4B7CCC
.text:0047458E                 mov     ecx, [edx+18h]
.text:00474591                 add     esp, 10h
.text:00474594                 push    esi
.text:00474595                 call    sub_457680
.text:0047459A                 mov     eax, dword_4B7CCC
.text:0047459F                 mov     ecx, [eax+14h]
.text:004745A2                 test    ecx, ecx
.text:004745A4                 jz      short loc_4745AC
.text:004745A6                 push    esi
.text:004745A7                 call    sub_459240
.text:004745AC
.text:004745AC loc_4745AC:                             ; CODE XREF: sub_4743C0+1E4j
.text:004745AC                 mov     eax, [ebp+2710h]
.text:004745B2                 inc     eax
.text:004745B3                 lea     ecx, [esp+148h+var_124]
.text:004745B7                 mov     [ebp+2710h], eax
.text:004745BD                 mov     [esp+148h+var_4], 0FFFFFFFFh
.text:004745C8                 call    sub_43C900
.text:004745CD                 mov     eax, 1
.text:004745D2                 jmp     short loc_4745D6
.text:004745D4 ; ---------------------------------------------------------------------------
.text:004745D4
.text:004745D4 loc_4745D4:                             ; CODE XREF: sub_4743C0+37j
.text:004745D4                                         ; sub_4743C0+5Cj ...
.text:004745D4                 xor     eax, eax
.text:004745D6
.text:004745D6 loc_4745D6:                             ; CODE XREF: sub_4743C0+212j
.text:004745D6                 mov     ecx, [esp+148h+var_C]
.text:004745DD                 mov     large fs:0, ecx
.text:004745E4                 mov     ecx, [esp+148h+var_10]
.text:004745EB                 call    sub_477BD9
.text:004745F0                 pop     edi
.text:004745F1                 pop     esi
.text:004745F2                 pop     ebp
.text:004745F3                 pop     ebx
.text:004745F4                 add     esp, 138h
.text:004745FA                 retn    8
.text:004745FA sub_4743C0      endp

и так,я сделал в плагине вот это:

1
2
3
4
5
6
7
8
9
10
11
static cell AMX_NATIVE_CALL n_ConnectBot( AMX* amx, cell* params )
{
    __asm
        {
        mov     bl, [esp+13Ch+0x00]
        cmp     bl, 0C8h
        movzx   esi, bl
        mov     dword ptr [ebp+esi*4+0], 1
        }
    logprintf( "seeeeee" );
}

0х00 я написал т.к. я ид 0 хочу закрыть,делал сначало приведение BYTE к DWORD(надеюсь что это сделал=)),а после этого выставил TRUE на слот 0

сервер даёт такую ошибку:
Инструкция по адресу "0x10011922" обратилась к памяти по адресу "0x0130164".Память не может быть "written".

Offline

#38 25-03-2009 10:17

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

Ужас какой.
А куда ты вообще пытаешься это записать? (что у тебя в ebp? зачем ты сравниваешь bl с 200 и, самое главное, что ты пыташься достичь, прибавляя 0x134 к esp, если у тебя стекового фрейма нет совсем)

Все, что тебе нужно - получить адрес CPlayerPool, с которым ты работаешь (он либо лежит статически, либо хранится в какой-то переменной) - здесь нужно смотреть, что передается приведенным функциям в ecx (смотреть _до_ вызова функции)

дальше - все просто:

1
(DWORD *)(poolAddress+bytePlayerID*4) = 1;

Все остальное за тебя сделает компилятор (в т.ч. и приведения типов).

PS. Стоило бы рассказать, как организована память, что такое стековый фрейм, откуда берутся числа, прибавляемые/вычитаемые из esp и так далее, но прямо сейчас у меня на это нет ни сил, ни времени.

Offline

#39 25-03-2009 11:31

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

нкак этот адрес плин найти,уже пол часа наверно ищу по всякому,и в исходнике плагинаY_less'a лазал,там есть CPlayerPool ток всё заморочено спецально

Offline

#40 25-03-2009 11:34

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

что значит

1
inc     ebp

???

Offline

#41 25-03-2009 11:53

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

(DWORD *)(0x7C802446+0x00*4) = 1;

не компилит,говорит не верный тип
делал так:
(DWORD *)(0x7C802446+0x00*4) = (DWORD *)(1);

пишет left operand must be l-value

Offline

#42 25-03-2009 11:54

Seemann
Registered: 07-08-2006
Posts: 2,156

Re: Помогите написать плагин для SA-MP

009 wrote:

что значит

1
inc     ebp

???

то же самое, что

1
add ebp, 1

значение регистра ebp увеличивается на 1

009 wrote:

(DWORD *)(0x7C802446+0x00*4) = 1;

не компилит,говорит не верный тип
делал так:
(DWORD *)(0x7C802446+0x00*4) = (DWORD *)(1);

пишет left operand must be l-value

попробуй убрать +0x00*4. хотя что-то мне подсказывает, что адрес памяти неверный (7C802446) ..

Last edited by Seemann (25-03-2009 11:56)

Offline

#43 25-03-2009 12:37

listener
From: Vice City
Registered: 09-11-2006
Posts: 616
Website

Re: Помогите написать плагин для SA-MP

Адрес в любом случае неверный.
Похоже на динамически выделенный. Смотри, из какой переменной его получили.

А не компилирует, потому что я звездочку в начале пропустил

1
*(DWORD *)(poolAddress+bytePlayerID*4) = 1;

Offline

#44 25-03-2009 13:28

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

этот адрес я взял из файла crashinfo.txt в который при сбое сервер записывает вот такое:

--------------------------

Exception At Address: 0x10004A6A



Registers:

EAX: 0x00000001    EBX: 0x00000002    ECX: 0x00CDFF20    EDX: 0x7C90E4F4

ESI: 0x7C801AD4    EDI: 0x7C802446    EBP: 0x7C802446    ESP: 0x00CDFF78

EFLAGS: 0x00010202



Stack:

Offline

#45 25-03-2009 13:34

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

что это может значить:

1
.text:0046AE4A                 call    ebp ; Sleep

Offline

#46 25-03-2009 13:55

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

как найти этот адрес плин(((я уже мозг сломал с этим адресом

Offline

#47 26-03-2009 10:00

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

написал письмо одному из разработчиков сампа-Y_Less'у,может помощет...вот копия:

Hello, I and some more Russian programmers we try to make boats for SA-MP in the form of a plug-in (please do not speak "not probably" and "do not spend in vain time", we will not stop working out not having received desirable result), at present we study samp-server.exe through assembler as we are going to do these boats operating memory of a server (some addresses), I the initiator of this working out, though and not the strong programmer. Recently using source codes vc-mp 0.1c and assembler's code vc-mp 0.1c server we have understood as in sa-mp on defined slot the player value is put occupied"(TRUE) in assembler this line looks so:


Code:
mov dword ptr [ebp+esi*4+0], 1

Where edp it CPlayerPool and esi it id the player in format BYTE

You, of course, all it and so know, but I wished to show that we not stupidly set questions, we really work over a plug-in. And which I ask the help from you it is edp (CPlayerPool address without which to execute closing slot it is not obviously possible, and which I cannot find in any way, please help.

Also forgive for my bad English, I used translator PROMT smile

Yours faithfully, 009

вродь норм написано,надеюсь поможет crazy

Offline

#48 26-03-2009 10:19

NC22RUS
Registered: 26-03-2009
Posts: 3

Re: Помогите написать плагин для SA-MP

Извените что вмешиваюсь, но может быть всеже легче будет ковыряться в маленькой dllки sBotа чем в громоздком коде samp server что-то искать smile ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
char* szName = "BOT";
   FARPROC CPlayer__Connect = (FARPROC) 0х4743C0;
   __asm
   {
      mov esi,0x100007F
      mov ebx,0xCA2EE0
      mov ecx,0xCA2EE0
      push szName
      push 200
      call CPlayer__Connect
   }
  return 1;
}

Не знаю по какой причине, но у меня при вызове ф-ции плагином с этим кодом сервер крешится. Ты говоришь у тебя не крешится и бот конектится "нормально"(ну серв хотябы не крешит)? Адрес вроде бы правильно указан

Last edited by NC22RUS (26-03-2009 12:49)

Offline

#49 26-03-2009 13:27

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

дело в том что sBot написан для 0.2.2 версии сампа,а сейчас 0.2Х в которой главный разработчик keyman сделал защиту от sbot т.к. sbot был сделан используя украденные исходники сампа,среди которых имелся исходник сервера...

Offline

#50 26-03-2009 16:51

009
From: Кемерово
Registered: 06-03-2009
Posts: 46
Website

Re: Помогите написать плагин для SA-MP

как сделать слежку за всеми действиями внутри процесса в дебаггере,можете нормально обьяснить?

Offline

Board footer

Powered by FluxBB