- /* Probe and capture the driver name */
- ProbeAndCaptureUnicodeString(&ImageName, PreviousMode, Buffer);
+ /* Probe the string buffer */
+ ProbeForRead(ImageName.Buffer, ImageName.Length, sizeof(WCHAR));
+
+ /* Check if we have the correct name (nothing else is allowed!) */
+ if (!RtlEqualUnicodeString(&ImageName, &Win32kName, FALSE))
+ {
+ _SEH2_YIELD(return STATUS_PRIVILEGE_NOT_HELD);
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+
+ /* Recursively call the function, so that we are from kernel mode */
+ return ZwSetSystemInformation(SystemExtendServiceTableInformation,
+ (PVOID)&Win32kName,
+ sizeof(Win32kName));
+ }