|
发表于 2020-8-3 04:30:36
|
显示全部楼层
您的建議以上經過一些測試和更改後才有效! 我也在read.pudn中找到了另一個類似的代碼並且可以正常工作。
兩種確定的解決方案如下:
1º
- typedef struct _SERVICE_DESCRIPTOR_TABLE
- {
- PULONG ServiceTable;
- PULONG puCounterTable;
- ULONG uTableSize;
- PUCHAR pbArgumentTable;
- } SERVICE_DESCRIPTOR_TABLE, *PSERVICE_DESCRIPTOR_TABLE;
- extern "C" NTKERNELAPI SERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTable;
- //--------------------------- DriverEntry() -----------------------------
- PUCHAR p = NULL;
- PSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTableWIN32K = NULL;
- for (p = (PUCHAR)&KeServiceDescriptorTable - PAGE_SIZE; p < (PUCHAR)&KeServiceDescriptorTable + PAGE_SIZE; p++)
- {
- if (p != (PUCHAR)&KeServiceDescriptorTable)
- {
- if (memcmp(p, &KeServiceDescriptorTable, sizeof(SERVICE_DESCRIPTOR_TABLE)) == 0)
- {
- KeServiceDescriptorTableWIN32K = (PSERVICE_DESCRIPTOR_TABLE)p;
- break;
- }
- }
- }
- if (KeServiceDescriptorTableWIN32K)
- {
- DbgPrint("KeServiceDescriptorTableWIN32K address = %X found! \n", KeServiceDescriptorTableWIN32K);
- DbgPrint("KeServiceDescriptorTableWIN32K entries: %d \n", KeServiceDescriptorTableWIN32K[1].uTableSize);
- }
- else
- DbgPrint("Error: Can't get KeServiceDescriptorTableWIN32K Address! \n");
复制代码
2º
- BOOLEAN FindShadowTable()
- {
- PSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTableShadow = NULL;
- ULONG Sdt = (ULONG)&KeServiceDescriptorTable;
- DbgPrint("KeServiceDescriptorTable = %X \n", Sdt);
- for (ULONG Shadow = Sdt - PAGE_SIZE; Shadow < Sdt + PAGE_SIZE; Shadow += sizeof(SERVICE_DESCRIPTOR_TABLE))
- {
- if (MmIsAddressValid((PVOID)Shadow))
- {
- PSERVICE_DESCRIPTOR_TABLE ShadowPtr = (PSERVICE_DESCRIPTOR_TABLE)Shadow;
- if (ShadowPtr != (PSERVICE_DESCRIPTOR_TABLE)&KeServiceDescriptorTable &&
- ShadowPtr->ServiceTable == KeServiceDescriptorTable.ServiceTable &&
- ShadowPtr->pbArgumentTable == KeServiceDescriptorTable.pbArgumentTable &&
- ShadowPtr->uTableSize == KeServiceDescriptorTable.uTableSize)
- {
- KeServiceDescriptorTableShadow = ShadowPtr;
- DbgPrint("KeServiceDescriptorTableShadow = %X \n", KeServiceDescriptorTableShadow);
- DbgPrint("KeServiceDescriptorTableShadow entries: %d \n", KeServiceDescriptorTableShadow[1].uTableSize);
- return TRUE;
- }
- }
- }
- return FALSE;
- }
复制代码
|
|