-
Notifications
You must be signed in to change notification settings - Fork 0
/
proc1.asm
553 lines (544 loc) · 18.9 KB
/
proc1.asm
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
;**********************************************************************************************************************************************************
GetDeviceName proc uses ebx esi edi ebp device:DWORD, user_proc:DWORD
LOCAL wvhWin:DWORD
LOCAL buffer[1024]:TCHAR, md5d[16]:BYTE
.if user_proc== 0
return 0
.endif
.if device== GDN_WEBCAM
@@:
invoke GetWebCamName, 0, addr buffer, addr md5d, addr wvhWin
cmp eax, 0
je @F
push wvhWin
lea ebx, md5d
push ebx
lea ebx, buffer
push ebx
push eax
call user_proc
jmp @B
@@:
.elseif device== GDN_MICROPHONE
@@:
invoke GetMicrophoneName, 0, addr buffer
cmp eax, 0
je @F
lea ebx, buffer
push ebx
push eax
call user_proc
jmp @B
@@:
.endif
return 1
GetDeviceName endp
;**********************************************************************************************************************************************************
GetMicrophoneName proc uses ebx esi edi ebp wcNum:DWORD, wcName:DWORD
LOCAL Fetched:DWORD, Moniker:DWORD, PropBag:DWORD, locNum:DWORD
LOCAL md5:MD5_CTX, len_data:DWORD
.IF wcNum> 0
mov maxdevM, 0
mrm locNum, wcNum
dec locNum
.ELSE
mov locNum, 0
.ENDIF
.IF maxdevM== 0
.if ClassEnumM!= 0 && DevEnumM!= 0
mov eax, ClassEnumM
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, ClassEnumM
mov eax, DevEnumM
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, DevEnumM
.endif
invoke CoCreateInstance, addr CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC_SERVER, addr IID_ICreateDevEnum, addr DevEnumM
.IF eax!= 0
return 0
.ENDIF
mov eax, DevEnumM
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).CreateClassEnumerator, DevEnumM, addr CLSID_AudioInputDeviceCategory, addr ClassEnumM, 0
.IF ClassEnumM== 0 || eax!= 0
return 0
.ENDIF
.ENDIF
.if locNum> 0
mov eax, ClassEnumM
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Skip, ClassEnumM, locNum
cmp eax, S_OK
jne endEnumDeviceM
.endif
mov eax, ClassEnumM
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Next, ClassEnumM, 1, addr Moniker, addr Fetched
cmp eax, S_OK
jne endEnumDeviceM
cmp Fetched, 1
jne endEnumDeviceM
mov eax, Moniker
mov ebx, [eax]
invoke (IMoniker PTR [ebx]).BindToStorage, Moniker, 0, 0, addr IID_IPropertyBag, addr PropBag
cmp eax, S_OK
jne endEnumDeviceM
mov vt.vt, VT_BSTR
mov vt.parray, 0
mov eax, PropBag
mov ebx, [eax]
invoke (IPropertyBag PTR [ebx]).Read, PropBag, uc$("FriendlyName"), addr vt, 0
invoke lstrcpy, wcName, vt.parray
invoke SysFreeString, vt.parray
mov eax, PropBag
mov ebx, [eax]
invoke (IPropertyBag PTR [ebx]).Release, PropBag
mov eax, Moniker
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Release, Moniker
.IF wcNum> 0
return -1 ;OK
.ENDIF
inc maxdevM
cmp maxdevM, 101
jae endEnumDeviceM
return maxdevM ;OK
endEnumDeviceM:
.if ClassEnumM!= 0 && DevEnumM!= 0
mov eax, ClassEnumM
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, ClassEnumM
mov eax, DevEnumM
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, DevEnumM
mov ClassEnumM, 0
mov DevEnumM, 0
.endif
invoke lstrcpy, wcName, uc$("No microphone")
mov maxdevM, 0
return 0
GetMicrophoneName endp
;**********************************************************************************************************************************************************
GetWebCamName proc uses ebx esi edi ebp wcNum:DWORD, wcName:DWORD, wcHash:DWORD, wchWin:DWORD
LOCAL Fetched:DWORD, Moniker:DWORD, PropBag:DWORD, locNum:DWORD
LOCAL md5:MD5_CTX, len_data:DWORD
.IF wcNum> 0
mov maxdev, 0
mrm locNum, wcNum
dec locNum
.ELSE
mov locNum, 0
.ENDIF
.IF maxdev== 0
.if ClassEnum!= 0 && DevEnum!= 0
mov eax, ClassEnum
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, ClassEnum
mov eax, DevEnum
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, DevEnum
.endif
invoke CoCreateInstance, addr CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC_SERVER, addr IID_ICreateDevEnum, addr DevEnum
.IF eax!= 0
return 0
.ENDIF
mov eax, DevEnum
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).CreateClassEnumerator, DevEnum, addr CLSID_VideoInputDeviceCategory, addr ClassEnum, 0
.IF ClassEnum== 0 || eax!= 0
return 0
.ENDIF
.ENDIF
.if locNum> 0
mov eax, ClassEnum
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Skip, ClassEnum, locNum
cmp eax, S_OK
jne endEnumDevice
.endif
mov eax, ClassEnum
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Next, ClassEnum, 1, addr Moniker, addr Fetched
cmp eax, S_OK
jne endEnumDevice
cmp Fetched, 1
jne endEnumDevice
mov eax, Moniker
mov ebx, [eax]
invoke (IMoniker PTR [ebx]).BindToStorage, Moniker, 0, 0, addr IID_IPropertyBag, addr PropBag
cmp eax, S_OK
jne endEnumDevice
mov vt.vt, VT_BSTR
mov vt.parray, 0
mov eax, PropBag
mov ebx, [eax]
invoke (IPropertyBag PTR [ebx]).Read, PropBag, uc$("FriendlyName"), addr vt, 0
invoke lstrcpy, wcName, vt.parray
invoke SysFreeString, vt.parray
mov vt.vt, VT_BSTR
mov vt.parray, 0
mov eax, PropBag
mov ebx, [eax]
invoke (IPropertyBag PTR [ebx]).Read, PropBag, uc$("DevicePath"), addr vt, 0
invoke lstrlen, vt.parray
mov len_data, eax
invoke MD5Init, addr md5
invoke MD5Update, addr md5, vt.parray, len_data
invoke MD5Final, addr md5
lea esi, md5.digest
mov edi, wcHash
mov ecx, 4
rep movsd
invoke SysFreeString, vt.parray
mov eax, PropBag
mov ebx, [eax]
invoke (IPropertyBag PTR [ebx]).Release, PropBag
mov eax, Moniker
mov ebx, [eax]
invoke (IEnumMoniker PTR [ebx]).Release, Moniker
.IF wcNum> 0
invoke dd_cmp, addr md5.digest
.if eax> 0
mov ebx, wchWin
mov dword ptr[ebx], eax
.else
mov ebx, wchWin
mov dword ptr[ebx], 0
.endif
return -1 ;OK
.ENDIF
inc maxdev
cmp maxdev, 101
jae endEnumDevice
invoke dd_cmp, addr md5.digest
.if eax> 0
mov ebx, wchWin
mov dword ptr[ebx], eax
.else
mov ebx, wchWin
mov dword ptr[ebx], 0
.endif
return maxdev ;OK
endEnumDevice:
.if ClassEnum!= 0 && DevEnum!= 0
mov eax, ClassEnum
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, ClassEnum
mov eax, DevEnum
mov ebx, [eax]
invoke (ICreateDevEnum PTR [ebx]).Release, DevEnum
mov ClassEnum, 0
mov DevEnum, 0
.endif
mov ebx, wchWin
mov dword ptr[ebx], 0
invoke lstrcpy, wcName, uc$("Is no camera")
mov maxdev, 0
return 0
GetWebCamName endp
;**********************************************************************************************************************************************************
VWFullScreen proc uses ebx esi edi ebp hWin:DWORD, on_off:DWORD
LOCAL hParent:DWORD, wvw:DWORD, wvh:DWORD, wvx:DWORD, wvy:DWORD, rec:RECT, wvStyle:DWORD
invoke GetWindowLong, hWin, 40 ;ðåæèì: 2- ñ ïðîñìîòðîì, 1- áåç ïðîñìîòðà
.IF ax== 1 || eax== 0 ;åñëè áåç ïðîñìîòðà èëè èäåíòèôèêàòîð íå àêòèâåí- ïîëíîýêðàííûé ðåæèì íå èñïîëüçóåòñÿ
return -2
.ENDIF
invoke GetWindowLong, hWin, 80 ;ïîëíîýêðàííûé ðåæèì 1-âêëþ÷åí, 2-âûêëþ÷åí
.IF f_FullScreen> 2 && eax== 2 ;áëîêèðîâàòü ïîëíîýêðàííûé ðåæèì â äðóãèõ îêíàõ åñëè â îäíîì îí óæå àêòèâåí
return 0
.ENDIF
.IF on_off== 1 && eax== 2 ;âêëþ÷åíèå
invoke GetWindowRect, hWin, addr rec
mov eax, rec.right
sub eax, rec.left
mov wvw, eax
mov eax, rec.bottom
sub eax, rec.top
mov wvh, eax
invoke GetParent, hWin
mov hParent, eax
invoke SetWindowLong, hWin, 52, hParent
.if hParent!= 0
invoke ScreenToClient, hParent, addr rec
.endif
invoke SetWindowLong, hWin, 92, rec.left ;x
invoke SetWindowLong, hWin, 96, rec.top ;y
invoke SetWindowLong, hWin, 84, wvw ;øèðèíà
invoke SetWindowLong, hWin, 88, wvh ;âûñîòà
invoke GetSystemMetrics, SM_CXSCREEN
mov wvw, eax
invoke GetSystemMetrics, SM_CYSCREEN
mov wvh, eax
invoke ShowWindow, hWin, SW_HIDE
invoke GetWindowLong, hWin, GWL_STYLE
mov wvStyle, eax
invoke SetWindowLong, hWin, 60, wvStyle
invoke SetWindowLong, hWin, GWL_STYLE, WS_POPUP or WS_CLIPCHILDREN or WS_CLIPSIBLINGS
.if hParent!= 0
invoke SetParent, hWin, 0
.endif
invoke SetWindowPos, hWin, HWND_TOP, 0, 0, wvw, wvh, SWP_SHOWWINDOW
invoke SetForegroundWindow, hWin
invoke SetActiveWindow, hWin
invoke SetWindowLong, hWin, 80, 1
mrm f_FullScreen, hWin
.ELSEIF on_off== 2 && eax== 1 ;âûêëþ÷åíèå
invoke SetWindowLong, hWin, 80, 2
mov f_FullScreen, 2
invoke GetWindowLong, hWin, 84
mov wvw, eax
invoke GetWindowLong, hWin, 88
mov wvh, eax
invoke GetWindowLong, hWin, 92
mov wvx, eax
invoke GetWindowLong, hWin, 96
mov wvy, eax
invoke ShowWindow, hWin, SW_HIDE
invoke GetWindowLong, hWin, 60
or eax, WS_CLIPCHILDREN or WS_CLIPSIBLINGS
invoke SetWindowLong, hWin, GWL_STYLE, eax
invoke GetWindowLong, hWin, 52
mov hParent, eax
.if hParent!= 0
invoke SetParent, hWin, hParent
.endif
invoke SetWindowPos, hWin, HWND_TOP, wvx, wvy, wvw, wvh, SWP_SHOWWINDOW
invoke SetForegroundWindow, hParent
invoke SetActiveWindow, hParent
.ENDIF
return 1
VWFullScreen endp
;**********************************************************************************************************************************************************
StartVideo proc uses ebx esi edi ebp hWin:DWORD, MicrophoneNum:DWORD, fAudioVideo:DWORD, BufferFileName:DWORD
LOCAL buffer[1024]:TCHAR, md5d[16]:BYTE
LOCAL f_control_video:DWORD, new_num:DWORD, wvhWin:DWORD
invoke GetWindowLong, hWin, 48 ;1- ñòîï, 2- ñòàðò, 3- ïàóçà
.if eax== 0
return -2
.elseif eax== 1 || eax== 3
mov f_control_video, eax
.if eax== 1
invoke GetWindowLong, hWin, 0
mov ebx, eax
invoke GetWebCamName, ebx, addr buffer, addr md5d, addr wvhWin
cmp eax, 0
je start_vid_m
invoke cmp_md5, hWin, addr md5d
.if eax== 0
start_vid_m:
invoke GetWebCamName, 0, addr buffer, addr md5d, addr wvhWin
cmp eax, 0
je start_vid_m1
mov new_num, eax
invoke cmp_md5, hWin, addr md5d
cmp eax, 1
jne @F
invoke SetWindowLong, hWin, 0, new_num
jmp start_vid_m2
@@:
jmp start_vid_m
start_vid_m1:
invoke GetWindowText, hWin, addr buffer, 1024
invoke MessageBox, hWin, uc$("Unable to connect to the selected camera."), addr buffer, MB_OK
return 0 ;ê âûáðàííîé êàìåðå ïîäêëþ÷èòüñÿ íå óäàëîñü.
.endif
start_vid_m2:
invoke release_graph, hWin
invoke steep1, hWin, MicrophoneNum
.if eax== 0
return 0 ;ê âûáðàííîé êàìåðå\ìèêðîôîíó ïîäêëþ÷èòüñÿ íå óäàëîñü.
.endif
invoke set_format, hWin
xor eax, eax
xor ebx, ebx
xor ecx, ecx
test fAudioVideo, SV_PREVIEW_AUDIO
jz @F
mov eax, 1
@@:
test fAudioVideo, SV_RECORDING_AUDIO
jz @F
mov ebx, 1
@@:
test fAudioVideo, SV_RECORDING_VIDEO
jz @F
mov ecx, 1
@@:
invoke set_grabber, hWin, eax, ebx, ecx, BufferFileName ;fAudioPreview -eax, fAudioRecording -ebx, fVideoRecording -ecx
.if eax== 0
return 0 ;ê âûáðàííîé êàìåðå ïîäêëþ÷èòüñÿ íå óäàëîñü.
.endif
.endif
invoke GetWindowLong, hWin, 8
mov ebx, [eax]
invoke (IMediaControl PTR [ebx]).Run, eax
.if eax== 1 && f_control_video== 1 ;óñïåøíî
invoke GetWindowLong, hWin, 12
mov ebx, [eax]
invoke (IVideoWindow PTR [ebx]).put_Visible, eax, -1
invoke SetWindowLong, hWin, 48, 2 ;start
.elseif eax== 0 && f_control_video== 3 ;óñïåøíî
invoke SetWindowLong, hWin, 48, 2 ;start
.else
invoke GetWindowLong, hWin, 12
mov ebx, [eax]
invoke (IVideoWindow PTR [ebx]).put_Visible, eax, 0
invoke SetWindowLong, hWin, 48, 1 ;stop
invoke GetWindowText, hWin, addr buffer, 1024
invoke MessageBox, hWin, ucc$("The camera is already in use by another application or system \nperformance is not enough to run."), addr buffer, MB_OK
return 0
.endif
invoke GetWindowLong, hWin, 40; ðåæèì
.if ax== 1 ;áåç ïðîñìîòðà
invoke Sleep, 2500
.endif
.endif
return 1
StartVideo endp
;**********************************************************************************************************************************************************
StopVideo proc uses ebx esi edi ebp hWin:DWORD
invoke GetWindowLong, hWin, 48 ;1- ñòîï, 2- ñòàðò, 3- ïàóçà
.if eax== 0
return -2
.elseif eax== 2 || eax== 3
invoke SetWindowLong, hWin, 48, 1 ;stop
invoke GetWindowLong, hWin, 8
mov ebx, [eax]
invoke (IMediaControl PTR [ebx]).Stop, eax
invoke GetWindowLong, hWin, 12
mov ebx, [eax]
invoke (IVideoWindow PTR [ebx]).put_Visible, eax, 0
.endif
return 1
StopVideo endp
;**********************************************************************************************************************************************************
PauseVideo proc uses ebx esi edi ebp hWin:DWORD
invoke GetWindowLong, hWin, 48 ;1- ñòîï, 2- ñòàðò, 3- ïàóçà
.if eax== 0
return -2
.elseif eax== 2
invoke SetWindowLong, hWin, 48, 3 ;pause
invoke GetWindowLong, hWin, 8
mov ebx, [eax]
invoke (IMediaControl PTR [ebx]).IMCPause, eax
.endif
return 1
PauseVideo endp
;**********************************************************************************************************************************************************
RatioFPU proc uses ebx esi edi ebp rec:DWORD
mov ebx, rec
mov ecx, dword ptr[ebx+8]
mov edx, dword ptr[ebx+12]
;--FPU--
finit
fild dword ptr[ebx+8]
fidiv dword ptr[ebx+12]
fild dword ptr[ebx]
fidiv dword ptr[ebx+4]
fcom
fstsw ax
fwait
sahf
ja fpu_m1
fimul dword ptr[ebx+12]
fist dword ptr[ebx+8]
jmp fpu_m2
fpu_m1:
fidivr dword ptr[ebx+8]
fist dword ptr[ebx+12]
fpu_m2:
fwait
;-------
sub ecx, dword ptr[ebx+8]
shr ecx, 1
mov dword ptr[ebx], ecx
sub edx, dword ptr[ebx+12]
shr edx, 1
mov dword ptr[ebx+4], edx
return ebx
RatioFPU endp
;**********************************************************************************************************************************************************
VWRatio proc uses ebx esi edi ebp hWin:DWORD, f_ratio:DWORD
LOCAL rec:RECT
invoke GetWindowLong, hWin, 40
.if eax== 0 || ax== 1
return 0
.endif
mov ebx, f_ratio
ror eax, 16
mov ax, bx
ror eax, 16
invoke SetWindowLong, hWin, 40, eax
invoke GetClientRect, hWin, addr rec
.IF f_ratio== 1 ;ñîõðàíÿòü ïðîïîðöèþ
invoke GetWindowLong, hWin, 36 ;øèðèíà è âûñîòà âèäåîêàäðà â ïèêñåëÿõ
movzx edx, ax
mov rec.left, edx
shr eax, 16
mov rec.top, eax
invoke RatioFPU, addr rec
.ELSEIF f_ratio== 2 ;ðàñòÿíóòü
mov rec.left, 0
mov rec.top, 0
.ELSE
mov rec.left, 0
mov rec.top, 0
.ENDIF
invoke GetWindowLong, hWin, 12
cmp eax, 0
je @F
mov ebx,[eax]
invoke (IVideoWindow PTR [ebx]).SetWindowPosition, eax, rec.left, rec.top, rec.right, rec.bottom
mov eax, rec.bottom
shl eax, 16
mov ecx, rec.right
mov ax, cx
@@:
ret
VWRatio endp
;**********************************************************************************************************************************************************
cmp_md5 proc hWin:DWORD, md5d:DWORD
invoke GetWindowLong, hWin, 56
mov esi, md5d
mov ecx, 4
@@:
mov ebx, dword ptr[esi]
mov edx, dword ptr[eax]
cmp ebx, edx
jne @F
add esi, 4
add eax, 4
loop @B
return 1 ;OK
@@:
return 0 ;ERROR
cmp_md5 endp
;**********************************************************************************************************************************************************
GetTime proc uses ebx esi edi ebp
LOCAL stmt:SYSTEMTIME
invoke GetLocalTime, addr stmt
movzx ebx, stmt.wDay
invoke lstrcpy, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("-")
movzx ebx, stmt.wMonth
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("-")
movzx ebx, stmt.wYear
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("_")
movzx ebx, stmt.wHour
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("h-")
movzx ebx, stmt.wMinute
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("m-")
movzx ebx, stmt.wSecond
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("s-")
movzx ebx, stmt.wMilliseconds
invoke lstrcat, addr TimeBuffer, ustr$(ebx)
invoke lstrcat, addr TimeBuffer, uc$("ms")
lea eax, TimeBuffer
ret
GetTime endp
;**********************************************************************************************************************************************************