MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / AntiRootkitDeviceControl

Function AntiRootkitDeviceControl

Anti-Rootkit/ARK.cpp:331–1434  ·  view source on GitHub ↗

�ڴ�����������ʱ���ں��е��ڴ������޵ģ�Ҫע���ֹ��������� 1.���ƻ������ij���

Source from the content-addressed store, hash-verified

329// �ڴ�����������ʱ���ں��е��ڴ������޵ģ�Ҫע���ֹ���������
330// 1.���ƻ������ij���
331_Use_decl_annotations_
332NTSTATUS AntiRootkitDeviceControl(PDEVICE_OBJECT, PIRP Irp) {
333 // get our IO_STACK_LOCATION
334 auto status = STATUS_INVALID_DEVICE_REQUEST;
335 const auto& dic = IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl;
336 ULONG len = 0;
337
338 switch (dic.IoControlCode) {
339 case IOCTL_ARK_GET_SHADOW_SERVICE_TABLE:
340 {
341 if (Irp->AssociatedIrp.SystemBuffer == nullptr) {
342 status = STATUS_INVALID_PARAMETER;
343 break;
344 }
345 if (dic.InputBufferLength < sizeof(void*)) {
346 status = STATUS_BUFFER_TOO_SMALL;
347 break;
348 }
349 void* p = *(PULONG*)Irp->AssociatedIrp.SystemBuffer;
350 if (!MmIsAddressValid(p))
351 break;
352 SystemServiceTable* pSystemServiceTable = (SystemServiceTable*)p;
353 // �������������ij���
354 if (dic.OutputBufferLength < sizeof(PULONG)) {
355 status = STATUS_BUFFER_TOO_SMALL;
356 break;
357 }
358 pSystemServiceTable += 1;
359 khook::_win32kTable = pSystemServiceTable;
360 *(PULONG*)Irp->AssociatedIrp.SystemBuffer = pSystemServiceTable->ServiceTableBase;
361 len = sizeof(PULONG);
362 status = STATUS_SUCCESS;
363 break;
364 }
365
366 case IOCTL_ARK_GET_SSDT_API_ADDR:
367 {
368 if (Irp->AssociatedIrp.SystemBuffer == nullptr) {
369 status = STATUS_INVALID_PARAMETER;
370 break;
371 }
372 if (dic.InputBufferLength < sizeof(ULONG)) {
373 status = STATUS_BUFFER_TOO_SMALL;
374 break;
375 }
376 // �������������ij���
377 if (dic.OutputBufferLength < sizeof(void*)) {
378 status = STATUS_BUFFER_TOO_SMALL;
379 break;
380 }
381
382 PVOID address;
383 ULONG number = *(ULONG*)Irp->AssociatedIrp.SystemBuffer;
384 bool success = khook::GetApiAddress(number,&address);
385 if (success) {
386 *(PVOID*)Irp->AssociatedIrp.SystemBuffer = address;
387 len = sizeof(address);
388 status = STATUS_SUCCESS;

Callers

nothing calls this directly

Calls 12

EnumSystemNotifyFunction · 0.85
LogInfoFunction · 0.85
GetObCallbackCountFunction · 0.85
EnumObCallbackNotifyFunction · 0.85
RtlInitUnicodeStringFunction · 0.85
LogErrorFunction · 0.85
RemoveSystemNotifyFunction · 0.85
EnumRegistryNotifyFunction · 0.85
EnumMiniFilterOperationsFunction · 0.85
RemoveMiniFilterFunction · 0.85
CompleteIrpFunction · 0.85
InitializeMethod · 0.80

Tested by

no test coverage detected