4 HMODULE g_hModule
= NULL
;
5 PGDI_TABLE_ENTRY GdiHandleTable
;
8 IntSyscall(FARPROC proc
, UINT cParams
, PVOID pFirstParam
)
14 "pushfl;" // Save flags
16 "shl $2, %%eax;" // Calculate param size
17 "subl %%eax, %%esp;" // Calculate new stack pos
18 "movl %%esp, %%edi;" // Destination is stackpointer
19 "cld;" // Clear direction flag
20 "rep movsd;" // Copy params to the stack
21 "call *%%edx;" // Call function
22 "popfl;" // Restore flags
24 : "S" (pFirstParam
), "c" (cParams
), "d"(proc
)
32 Syscall(LPWSTR pszFunction
, int cParams
, void* pParams
)
34 char szFunctionName
[MAX_PATH
];
36 sprintf(szFunctionName
, "%ls", pszFunction
);
37 FARPROC proc
= (FARPROC
)GetProcAddress(g_hModule
, szFunctionName
);
40 printf("Couldn't find proc: %s\n", szFunctionName
);
44 return IntSyscall(proc
, cParams
, pParams
);
48 IsFunctionPresent(LPWSTR lpszFunction
)
50 char szFunctionName
[MAX_PATH
];
51 sprintf(szFunctionName
, "%ls", lpszFunction
);
52 return (GetProcAddress(g_hModule
, szFunctionName
) != NULL
);
56 WinMain(HINSTANCE hInstance
,
57 HINSTANCE hPrevInstance
,
61 g_hInstance
= hInstance
;
62 GDIQUERYPROC GdiQueryHandleTable
;
64 printf("Win32k native API test\n");
66 /* Convert to gui thread */
67 // IsGUIThread(TRUE); <- does not exists on win2k
69 g_hModule
= LoadLibraryW(L
"w32kdll.dll");
72 printf("w32kdll.dll not found!\n");
76 GdiQueryHandleTable
= (GDIQUERYPROC
)GetProcAddress(GetModuleHandleW(L
"GDI32.DLL"), "GdiQueryTable");
77 if(!GdiQueryHandleTable
)
81 GdiHandleTable
= GdiQueryHandleTable();
89 return TestMain(L
"w32knapi", L
"win32k.sys Nt-Api");