178 SehStatus = STATUS_SUCCESS;
181 CurrentUser = MmMapLockedPagesSpecifyCache(CurrentMdl, UserMode, CacheType, QueryBuffer->Buffer, FALSE, NormalPagePriority);
183 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
185 SehStatus = _SEH2_GetExceptionCode();
188 if (QueryBuffer->Status != -1)
190 ok_eq_hex(SehStatus, QueryBuffer->Status);
191 if (NT_SUCCESS(QueryBuffer->Status))
200 QueryBuffer->Status = SehStatus;
204 ExFreePoolWithTag(CurrentBuffer, 'MLPC');
209 QueryBuffer->Buffer = CurrentUser;
210 *OutLength = sizeof(QUERY_BUFFER);
215 case IOCTL_READ_BUFFER:
218 ok_eq_size(InLength, sizeof(READ_BUFFER));
219 ok_eq_size(*OutLength, 0);
220 ok(CurrentMdl != NULL, "MDL is not
in use!\
n");
222 if (!skip(Buffer && InLength >= sizeof(READ_BUFFER), "Cannot
read from buffer!\
n"))
224 PREAD_BUFFER ReadBuffer;
227 if (!skip(ReadBuffer && ReadBuffer->Buffer == CurrentUser, "Cannot
find matching
MDL\
n"))
229 if (ReadBuffer->Buffer != NULL)
232 PULONG KBuffer = MmGetSystemAddressForMdlSafe(CurrentMdl, NormalPagePriority);
234 ok(ReadBuffer->Length % sizeof(ULONG) == 0, "Invalid size: %
d\
n", ReadBuffer->Length);
238 for (i = 0; i < ReadBuffer->Length / sizeof(ULONG); ++i)
240 ok_eq_ulong(KBuffer[i], ReadBuffer->Pattern);
246 TestCleanEverything();
253 TestCleanEverything();
258 DeviceObject, ControlCode, Buffer, InLength, *OutLength);
268 _In_ PDEVICE_OBJECT DeviceObject,
270 _In_ PIO_STACK_LOCATION IoStack)
276 DPRINT("IRP %
x/%
x\
n", IoStack->MajorFunction, IoStack->MinorFunction);
277 ASSERT(IoStack->MajorFunction == IRP_MJ_CLEANUP);
279 Status = STATUS_NOT_SUPPORTED;
280 Irp->IoStatus.Information = 0;
282 if (IoStack->MajorFunction == IRP_MJ_CLEANUP)
284 TestCleanEverything();
285 Status = STATUS_SUCCESS;
288 if (Status == STATUS_PENDING)
290 IoMarkIrpPending(Irp);
291 IoCompleteRequest(Irp, IO_NO_INCREMENT);
292 Status = STATUS_PENDING;
296 Irp->IoStatus.Status = Status;
297 IoCompleteRequest(Irp, IO_NO_INCREMENT);
#define IOCTL_QUERY_BUFFER
static PVOID CurrentBuffer
static KMT_MESSAGE_HANDLER TestMessageHandler
VOID TestCleanEverything(VOID)
VOID TestUnload(IN PDRIVER_OBJECT DriverObject)
NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, IN OUT INT *Flags)
static KMT_IRP_HANDLER TestIrpHandler
static SIZE_T NonCachedLength
static unsigned char bytes[4]
#define ok_eq_pointer(value, expected)
#define ok_eq_hex(value, expected)
#define ok_eq_size(value, expected)
void get(int argc, const char *argv[])
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeGetCurrentIrql()
#define ExGetPreviousMode
GLint GLint GLint GLint GLint x
#define EXCEPTION_EXECUTE_HANDLER
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN ULONG Priority)
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
#define ExFreePoolWithTag(_P, _T)
VOID NTAPI MmFreeNonCachedMemory(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
PVOID NTAPI MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
PULONG MinorVersion OPTIONAL
#define RtlZeroMemory(Destination, Length)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
_Must_inspect_result_ _In_ ULONG Flags
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE CacheType
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE