diff options
Diffstat (limited to 'km/src')
| -rw-r--r-- | km/src/nt_namespace/main.c | 2 | ||||
| -rw-r--r-- | km/src/nt_namespace/nt2dos.c | 16 | ||||
| -rw-r--r-- | km/src/simple/device.c | 18 |
3 files changed, 23 insertions, 13 deletions
diff --git a/km/src/nt_namespace/main.c b/km/src/nt_namespace/main.c index a1c08e8..4c7ef74 100644 --- a/km/src/nt_namespace/main.c +++ b/km/src/nt_namespace/main.c @@ -22,6 +22,8 @@ NTSTATUS DriverEntry( { UNREFERENCED_PARAMETER(registry_path); + ExInitializeDriverRuntime(DrvRtPoolNxOptIn); + driver_object->DriverUnload = on_driver_unload; return set_up_devices(driver_object); } diff --git a/km/src/nt_namespace/nt2dos.c b/km/src/nt_namespace/nt2dos.c index d1bdb3d..be2c2f5 100644 --- a/km/src/nt_namespace/nt2dos.c +++ b/km/src/nt_namespace/nt2dos.c @@ -9,6 +9,15 @@ #include "nt2dos.h" +static PVOID allocate(SIZE_T nb) +{ +#if !defined(NTDDI_WIN10) || NTDDI_VERSION < NTDDI_WIN10 + return ExAllocatePoolWithTag(PagedPool, nb, '1l'); +#else + return ExAllocatePoolQuotaZero(PagedPool, nb, '1l'); +#endif +} + static NTSTATUS get_object_name_info( void *object, OBJECT_NAME_INFORMATION **object_name_info) @@ -21,7 +30,7 @@ static NTSTATUS get_object_name_info( if (status != STATUS_INFO_LENGTH_MISMATCH) return status; - *object_name_info = ExAllocatePoolWithTag(PagedPool, nbneeded, '1l'); + *object_name_info = allocate(nbneeded); if (*object_name_info == NULL) return STATUS_INSUFFICIENT_RESOURCES; @@ -92,8 +101,7 @@ NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) if (file_object->Vpb == NULL) { - u_resolved->Buffer = ExAllocatePoolWithTag( - PagedPool, file_name_info->Name.Length, '1l'); + u_resolved->Buffer = allocate(file_name_info->Name.Length); if (u_resolved->Buffer == NULL) { @@ -120,7 +128,7 @@ NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) u_resolved_size = file_name_info->Name.Length - volume_name_info->Name.Length + u_dos_name.Length; - u_resolved->Buffer = ExAllocatePoolWithTag(PagedPool, u_resolved_size, '1l'); + u_resolved->Buffer = allocate(u_resolved_size); if (u_resolved->Buffer == NULL) { diff --git a/km/src/simple/device.c b/km/src/simple/device.c index 859ba67..f632a8d 100644 --- a/km/src/simple/device.c +++ b/km/src/simple/device.c @@ -43,7 +43,7 @@ static NTSTATUS handle_say_hello( return STATUS_SUCCESS; } -static unsigned int i = 42; +static unsigned int num = 42; static NTSTATUS handle_exchange_ints( void *in_buf, @@ -52,20 +52,20 @@ static NTSTATUS handle_exchange_ints( unsigned long out_buf_size, ULONG_PTR *nbwritten) { - unsigned int temp_i; + unsigned int temp_num; - if (in_buf_size != sizeof(temp_i)) + if (in_buf_size != sizeof(temp_num)) return STATUS_INVALID_BUFFER_SIZE; - RtlCopyMemory(&temp_i, in_buf, in_buf_size); - DbgPrint("%08x\n", temp_i); + RtlCopyMemory(&temp_num, in_buf, in_buf_size); + DbgPrint("%08x\n", temp_num); - if (out_buf_size < sizeof(i)) + if (out_buf_size < sizeof(num)) return STATUS_BUFFER_TOO_SMALL; - RtlCopyMemory(out_buf, &i, sizeof(i)); - *nbwritten += sizeof(i); - i = temp_i; + RtlCopyMemory(out_buf, &num, sizeof(num)); + *nbwritten += sizeof(num); + num = temp_num; return STATUS_SUCCESS; } |
