| 507 | |
| 508 | |
| 509 | NTSTATUS SearchServiceFromKdbExt(PDRIVER_OBJECT KbdDriverObject, PDEVICE_OBJECT pPortDev) |
| 510 | { |
| 511 | PDEVICE_OBJECT pTargetDeviceObject = NULL; |
| 512 | UCHAR* DeviceExt; |
| 513 | int i = 0; |
| 514 | NTSTATUS status; |
| 515 | PVOID KbdDriverStart; |
| 516 | ULONG KbdDriverSize = 0; |
| 517 | PDEVICE_OBJECT pTmpDev; |
| 518 | UNICODE_STRING kbdDriName; |
| 519 | |
| 520 | KbdDriverStart = KbdDriverObject->DriverStart; |
| 521 | KbdDriverSize = KbdDriverObject->DriverSize; |
| 522 | |
| 523 | status = STATUS_UNSUCCESSFUL; |
| 524 | |
| 525 | RtlInitUnicodeString(&kbdDriName, L"\\Driver\\kbdclass"); |
| 526 | pTmpDev = pPortDev; |
| 527 | while (pTmpDev->AttachedDevice != NULL) |
| 528 | { |
| 529 | KdPrint(("Att: 0x%x", pTmpDev->AttachedDevice)); |
| 530 | KdPrint(("Dri Name : %wZ", &pTmpDev->AttachedDevice->DriverObject->DriverName)); |
| 531 | if (RtlCompareUnicodeString(&pTmpDev->AttachedDevice->DriverObject->DriverName, |
| 532 | &kbdDriName, TRUE) == 0) |
| 533 | { |
| 534 | break; |
| 535 | } |
| 536 | pTmpDev = pTmpDev->AttachedDevice; |
| 537 | } |
| 538 | if (pTmpDev->AttachedDevice == NULL) |
| 539 | { |
| 540 | return status; |
| 541 | } |
| 542 | |
| 543 | pTargetDeviceObject = KbdDriverObject->DeviceObject; |
| 544 | while (pTargetDeviceObject) |
| 545 | { |
| 546 | if (pTmpDev->AttachedDevice != pTargetDeviceObject) |
| 547 | { |
| 548 | pTargetDeviceObject = pTargetDeviceObject->NextDevice; |
| 549 | continue; |
| 550 | } |
| 551 | DeviceExt = (UCHAR*)pTmpDev->DeviceExtension; |
| 552 | g_KoMCallBack.KdbDeviceObject = NULL; |
| 553 | //�����������ҵ��Ķ˿��������豸��չ��ÿһ��ָ�� |
| 554 | for (i = 0; i < 4096; i++, DeviceExt++) |
| 555 | { |
| 556 | PVOID tmp; |
| 557 | if (!MmIsAddressValid(DeviceExt)) |
| 558 | { |
| 559 | break; |
| 560 | } |
| 561 | //�ҵ������д�����ȫ�ֱ����У��������Ƿ��Ѿ������ |
| 562 | //����Ѿ�����˾Ͳ��ü������ˣ�����ֱ���˳� |
| 563 | if (g_KoMCallBack.KdbDeviceObject && g_KoMCallBack.KeyboardClassServiceCallback) |
| 564 | { |
| 565 | status = STATUS_SUCCESS; |
| 566 | break; |
no outgoing calls
no test coverage detected