-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(https://www.unknowncheats.me/forum/2369780-post10.html) - DeviceObject no longer leaked - Unload was added (Still unsure about this) - EPROCESS are no longer leaked - Buffers size from userspace are validated - Dereferenced pointers from userspace are sanitized
- Loading branch information
Showing
7 changed files
with
166 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "NTUndocumented.h" | ||
#include "Utility.h" | ||
|
||
NTSTATUS DriverSleep(int ms) | ||
{ | ||
LARGE_INTEGER li; | ||
li.QuadPart = -10000; | ||
|
||
for (int i = 0; i < ms; i++) | ||
{ | ||
KeDelayExecutionThread(KernelMode, FALSE, &li); | ||
return STATUS_SUCCESS; | ||
} | ||
return STATUS_UNSUCCESSFUL; | ||
} | ||
|
||
PVOID SanitizeUserPointer(PVOID pointer, SIZE_T size) | ||
{ | ||
MEMORY_BASIC_INFORMATION memInfo; | ||
|
||
if (NT_SUCCESS(ZwQueryVirtualMemory(ZwCurrentProcess(), pointer, MemoryBasicInformation, &memInfo, sizeof(MEMORY_BASIC_INFORMATION), NULL))) | ||
{ | ||
if (!(((uintptr_t)memInfo.BaseAddress + memInfo.RegionSize) < (((uintptr_t)pointer + size)))) | ||
{ | ||
if (memInfo.State & MEM_COMMIT || !(memInfo.Protect & (PAGE_GUARD | PAGE_NOACCESS))) | ||
{ | ||
if (memInfo.Protect & PAGE_EXECUTE_READWRITE || memInfo.Protect & PAGE_EXECUTE_WRITECOPY || memInfo.Protect & PAGE_READWRITE || memInfo.Protect & PAGE_WRITECOPY) | ||
{ | ||
return pointer; | ||
} | ||
} | ||
} | ||
} | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#include <ntddk.h> | ||
|
||
NTSTATUS DriverSleep(int ms); | ||
|
||
PVOID SanitizeUserPointer(PVOID pointer, SIZE_T size); |