From fbdff437fd072429a9738eddc27f21242cdca0c8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 28 May 2019 11:06:56 +0200 Subject: [PATCH] [NTOS:KE:X64] Implement flushing the GDI batch --- ntoskrnl/ke/amd64/stubs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ntoskrnl/ke/amd64/stubs.c b/ntoskrnl/ke/amd64/stubs.c index c23c02b0849..fee659737b9 100644 --- a/ntoskrnl/ke/amd64/stubs.c +++ b/ntoskrnl/ke/amd64/stubs.c @@ -432,6 +432,28 @@ KiSystemCallHandler( Offset = (ServiceNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK; ServiceNumber &= SERVICE_NUMBER_MASK; + /* Check for win32k system calls */ + if (Offset & SERVICE_TABLE_TEST) + { + ULONG GdiBatchCount; + + /* Read the GDI batch count from the TEB */ + _SEH2_TRY + { + GdiBatchCount = NtCurrentTeb()->GdiBatchCount; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + GdiBatchCount = 0; + } + + /* Flush batch, if there are entries */ + if (GdiBatchCount != 0) + { + KeGdiFlushUserBatch(); + } + } + /* Get descriptor table */ DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset);