[KMTESTS:MM]

Make MmMapLockedPagesSpecifyCache a bit more robust. Based on Thomas' suggestions

svn path=/trunk/; revision=74955
This commit is contained in:
Pierre Schweitzer 2017-06-08 06:44:48 +00:00
parent eb6360d80f
commit 453fae7f31

View file

@ -110,6 +110,9 @@ TestMessageHandler(
ok_eq_size(InLength, sizeof(QUERY_BUFFER)); ok_eq_size(InLength, sizeof(QUERY_BUFFER));
ok_eq_size(*OutLength, sizeof(QUERY_BUFFER)); ok_eq_size(*OutLength, sizeof(QUERY_BUFFER));
ok_eq_pointer(CurrentMdl, NULL); ok_eq_pointer(CurrentMdl, NULL);
TestCleanEverything();
ok(ExGetPreviousMode() == UserMode, "Not comming from umode!\n"); ok(ExGetPreviousMode() == UserMode, "Not comming from umode!\n");
if (!skip(Buffer && InLength >= sizeof(QUERY_BUFFER) && *OutLength >= sizeof(QUERY_BUFFER), "Cannot read/write from/to buffer!\n")) if (!skip(Buffer && InLength >= sizeof(QUERY_BUFFER) && *OutLength >= sizeof(QUERY_BUFFER), "Cannot read/write from/to buffer!\n"))
{ {
@ -120,16 +123,18 @@ TestMessageHandler(
QueryBuffer = Buffer; QueryBuffer = Buffer;
CacheType = (QueryBuffer->Cached ? MmCached : MmNonCached); CacheType = (QueryBuffer->Cached ? MmCached : MmNonCached);
Length = QueryBuffer->Length; Length = QueryBuffer->Length;
CurrentUser = NULL;
ok(Length > 0, "Null size!\n"); ok(Length > 0, "Null size!\n");
if (!skip(Length > 0, "Null size!\n"))
{
CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, 'MLPC'); CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, 'MLPC');
ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n"); ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n");
CurrentUser = NULL;
if (!skip(CurrentBuffer != NULL, "ExAllocatePool failed!\n")) if (!skip(CurrentBuffer != NULL, "ExAllocatePool failed!\n"))
{ {
CurrentMdl = IoAllocateMdl(CurrentBuffer, Length, FALSE, FALSE, NULL); CurrentMdl = IoAllocateMdl(CurrentBuffer, Length, FALSE, FALSE, NULL);
ok(CurrentMdl != NULL, "IoAllocateMdl failed!\n"); ok(CurrentMdl != NULL, "IoAllocateMdl failed!\n");
if (CurrentMdl) if (!skip(CurrentMdl != NULL, "IoAllocateMdl failed!\n"))
{ {
KIRQL Irql; KIRQL Irql;
@ -170,9 +175,14 @@ TestMessageHandler(
ok_eq_pointer(CurrentUser, NULL); ok_eq_pointer(CurrentUser, NULL);
} }
} }
else
{
ExFreePoolWithTag(CurrentBuffer, 'MLPC');
}
}
} }
QueryBuffer->Buffer = CurrentUser;
QueryBuffer->Buffer = CurrentUser;
*OutLength = sizeof(QUERY_BUFFER); *OutLength = sizeof(QUERY_BUFFER);
} }