почему эта функция не работает? Код (Text): KbFilter_PnP proc pDeviceObject:PDEVICE_OBJECT, pIrp:PIRP local pDevExt:PFiDO_DEVICE_EXTENSION local event:KEVENT mov eax, pDeviceObject push ebx mov ebx, pIrp push esi push edi mov edi, [eax+28h] mov eax, [ebx+60h] movzx ecx, byte ptr [eax+1] sub ecx, 0 mov pIrp, edi jz short loc_125 dec ecx dec ecx mov edx, ebx jz short loc_EE sub ecx, 15h jz short loc_E1 inc byte ptr [ebx+23h] add eax, 24h mov [ebx+60h], eax loc_D1: mov ecx, [edi+8] call IofCallDriver mov esi, eax jmp loc_1A9 loc_E1: mov byte ptr [edi+0Dh], 1 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h jmp short loc_D1 loc_EE: dec gr mov byte ptr [edi+0Eh], 1 and dword ptr [ebx+18h], 0 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h mov ecx, [edi+8] call IofCallDriver push dword ptr [edi+8] mov esi, eax call IoDetachDevice push pDeviceObject call IoDeleteDevice jmp loc_1A9 loc_125: push 7 pop ecx lea edx, [eax-24h] push 0 mov esi, eax mov edi, edx push 0 lea eax, event rep movsd and byte ptr [edx+3], 0 push eax call KeInitializeEvent mov eax, [ebx+60h] mov edi, pDevExt sub eax, 24h lea ecx, event mov dword ptr [eax+1Ch], offset KbFilter_Complete mov [eax+20h], ecx mov byte ptr [eax+3], 0E0h mov ecx, [edi+8] mov edx, ebx call IofCallDriver mov esi, eax cmp esi, 103h jnz short loc_182 xor eax, eax push eax push eax push eax push eax lea eax, event push eax call KeWaitForSingleObject loc_182: test esi, esi jl short loc_198 cmp dword ptr [ebx+18h], 0 jl short loc_198 and byte ptr [edi+0Eh], 0 and byte ptr [edi+0Dh], 0 mov byte ptr [edi+0Ch], 1 loc_198: and dword ptr [ebx+1Ch], 0 xor dl, dl mov ecx, ebx mov [ebx+18h], esi call IofCompleteRequest loc_1A9: pop edi mov eax, esi pop esi pop ebx ret KbFilter_PnP endp , она же в IDA Код (Text): var_14 = byte ptr -14h var_4 = dword ptr -4 arg_0 = dword ptr 8 arg_4 = dword ptr 0Ch push ebp mov ebp, esp add esp, 0FFFFFFECh mov eax, [ebp+arg_0] push ebx mov ebx, [ebp+arg_4] push esi push edi mov edi, [eax+28h] mov eax, [ebx+60h] movzx ecx, byte ptr [eax+1] sub ecx, 0 mov [ebp+arg_4], edi jz short loc_232 dec ecx dec ecx mov edx, ebx jz short loc_1FD sub ecx, 15h jz short loc_1F0 inc byte ptr [ebx+23h] add eax, 24h ; '$' mov [ebx+60h], eax loc_1E1: ; CODE XREF: KbFilter_PnP(x,x)+4Fj mov ecx, [edi+8] call @IofCallDriver@8 ; IofCallDriver(x,x) mov esi, eax jmp loc_2B2 ; --------------------------------------------------------------------------- loc_1F0: ; CODE XREF: KbFilter_PnP(x,x)+2Aj mov byte ptr [edi+0Dh], 1 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h ; '$' jmp short loc_1E1 ; --------------------------------------------------------------------------- loc_1FD: ; CODE XREF: KbFilter_PnP(x,x)+25j dec gr mov byte ptr [edi+0Eh], 1 and dword ptr [ebx+18h], 0 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h ; '$' mov ecx, [edi+8] call @IofCallDriver@8 ; IofCallDriver(x,x) push dword ptr [edi+8] mov esi, eax call _IoDetachDevice@4 ; IoDetachDevice(x) push [ebp+arg_0] call _IoDeleteDevice@4 ; IoDeleteDevice(x) jmp loc_2B2 ; --------------------------------------------------------------------------- loc_232: ; CODE XREF: KbFilter_PnP(x,x)+1Fj push 7 pop ecx lea edx, [eax-24h] push 0 mov esi, eax mov edi, edx push 0 lea eax, [ebp+var_14] rep movsd and byte ptr [edx+3], 0 push eax call _KeInitializeEvent@12 ; KeInitializeEvent(x,x,x) mov eax, [ebx+60h] mov edi, [ebp+var_4] sub eax, 24h ; '$' lea ecx, [ebp+var_14] mov dword ptr [eax+1Ch], offset _KbFilter_Complete@0 ; KbFilter_Complete() mov [eax+20h], ecx mov byte ptr [eax+3], 0E0h ; 'а' mov ecx, [edi+8] mov edx, ebx call @IofCallDriver@8 ; IofCallDriver(x,x) mov esi, eax cmp esi, 103h jnz short loc_28C xor eax, eax push eax push eax push eax push eax lea eax, [ebp+var_14] push eax call _KeWaitForSingleObject@20 ; KeWaitForSingleObject(x,x,x,x,x) loc_28C: ; CODE XREF: KbFilter_PnP(x,x)+CFj test esi, esi jl short loc_2A2 cmp dword ptr [ebx+18h], 0 jl short loc_2A2 and byte ptr [edi+0Eh], 0 and byte ptr [edi+0Dh], 0 mov byte ptr [edi+0Ch], 1 loc_2A2: ; CODE XREF: KbFilter_PnP(x,x)+E2j ; KbFilter_PnP(x,x)+E8j and dword ptr [ebx+1Ch], 0 xor dl, dl mov ecx, ebx mov [ebx+18h], esi call @IofCompleteRequest@8 ; IofCompleteRequest(x,x) loc_2B2: ; CODE XREF: KbFilter_PnP(x,x)+3Fj ; KbFilter_PnP(x,x)+81j pop edi mov eax, esi pop esi pop ebx leave retn 8 а это работающая функция: Код (Text): KbFilter_PnP proc near var_14= byte ptr -14h var_4= dword ptr -4 arg_0= dword ptr 8 arg_4= dword ptr 0Ch push ebp mov ebp, esp sub esp, 14h mov eax, [ebp+arg_0] push ebx mov ebx, [ebp+arg_4] push esi push edi mov edi, [eax+28h] mov eax, [ebx+60h] movzx ecx, byte ptr [eax+1] sub ecx, 0 mov [ebp+var_4], edi jz short loc_125 dec ecx dec ecx mov edx, ebx jz short loc_EE sub ecx, 15h jz short loc_E1 inc byte ptr [ebx+23h] add eax, 24h mov [ebx+60h], eax loc_D1: mov ecx, [edi+8] call IofCallDriver mov esi, eax jmp loc_1A9 loc_E1: mov byte ptr [edi+0Dh], 1 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h jmp short loc_D1 loc_EE: dec gr mov byte ptr [edi+0Eh], 1 and dword ptr [ebx+18h], 0 inc byte ptr [ebx+23h] add dword ptr [ebx+60h], 24h mov ecx, [edi+8] call IofCallDriver push dword ptr [edi+8] mov esi, eax call IoDetachDevice push [ebp+arg_0] call IoDeleteDevice jmp loc_1A9 loc_125: push 7 pop ecx lea edx, [eax-24h] push 0 mov esi, eax mov edi, edx push 0 lea eax, [ebp+var_14] rep movsd and byte ptr [edx+3], 0 push eax call KeInitializeEvent mov eax, [ebx+60h] mov edi, [ebp+var_4] sub eax, 24h lea ecx, [ebp+var_14] mov dword ptr [eax+1Ch], offset KbFilter_Complete mov [eax+20h], ecx mov byte ptr [eax+3], 0E0h mov ecx, [edi+8] mov edx, ebx call IofCallDriver mov esi, eax cmp esi, 103h jnz short loc_182 xor eax, eax push eax push eax push eax push eax lea eax, [ebp+var_14] push eax call KeWaitForSingleObject loc_182: test esi, esi jl short loc_198 cmp dword ptr [ebx+18h], 0 jl short loc_198 and byte ptr [edi+0Eh], 0 and byte ptr [edi+0Dh], 0 mov byte ptr [edi+0Ch], 1 loc_198: and dword ptr [ebx+1Ch], 0 xor dl, dl mov ecx, ebx mov [ebx+18h], esi call IofCompleteRequest loc_1A9: pop edi mov eax, esi pop esi pop ebx leave retn 8 KbFilter_PnP endp в чём разница? просто я хочу её перевести на MASM, что бы лучше её понимать. Правда, мне на этом форуме когда-то уже пытались перевести её с С http://www.wasm.ru/forum/viewtopic.php?pid=417621#p417621, но к сожалению получилась лажа(
Я написал так: Код (Text): .................... .if [edi].MinorFunction == IRP_MN_START_DEVICE mov ebx, pDeviceObject assume ebx:ptr DEVICE_OBJECT mov ebx, [ebx].DeviceExtension assume ebx:nothing assume ebx:ptr FiDO_DEVICE_EXTENSION IoCopyCurrentIrpStackLocationToNext esi invoke KeInitializeEvent, addr event, NotificationEvent, FALSE IoSetCompletionRoutine esi, KbFilter_Complete, addr event, TRUE, TRUE, TRUE mov eax, pDeviceObject .if eax == KeyDeviceObject invoke killirp, pIrp jmp eehyu .endif mov edx, pIrp mov eax, (DEVICE_OBJECT ptr [eax]).DeviceExtension mov ecx, (FiDO_DEVICE_EXTENSION ptr [eax]).TopOfStack call IofCallDriver mov status, eax cmp eax, STATUS_PENDING je WAIT_DRIVER cmp eax, STATUS_SUCCESS je CHK_SUCCESS jmp EXIT_START_DEVICE_SUB WAIT_DRIVER: invoke KeWaitForSingleObject, addr event, Executive, KernelMode, FALSE, 0 CHK_SUCCESS: cmp [esi].IoStatus.Status, STATUS_SUCCESS je CHANGE_DEV_EXT jmp EXIT_START_DEVICE_SUB CHANGE_DEV_EXT: mov [ebx].Started, TRUE mov [ebx].Removed, FALSE mov [ebx].SurpriseRemoved, FALSE assume ebx:nothing EXIT_START_DEVICE_SUB: push status pop [esi].IoStatus.Status mov [esi].IoStatus.Information, 0 invoke IoCompleteRequest, pIrp, IO_NO_INCREMENT pop esi pop edi pop ebx mov eax, status ret с PS/2 клавой фильтр работает, а вот при подключении USB-клавы получается BSOD. Что ещё надо добавить в этот код?