4 HMODULE g_hModule
= NULL
;
5 PGDI_TABLE_ENTRY GdiHandleTable
;
11 PTEB pTeb
= NtCurrentTeb();
12 PPEB pPeb
= pTeb
->ProcessEnvironmentBlock
;
13 return pPeb
->GdiSharedHandleTable
;
17 IntSyscall(FARPROC proc
, UINT cParams
, PVOID pFirstParam
)
23 "pushfl;" // Save flags
25 "shl $2, %%eax;" // Calculate param size
26 "subl %%eax, %%esp;" // Calculate new stack pos
27 "movl %%esp, %%edi;" // Destination is stackpointer
28 "cld;" // Clear direction flag
29 "rep movsd;" // Copy params to the stack
30 "call *%%edx;" // Call function
31 "popfl;" // Restore flags
33 : "S" (pFirstParam
), "c" (cParams
), "d"(proc
)
41 Syscall(LPWSTR pszFunction
, int cParams
, void* pParams
)
43 char szFunctionName
[MAX_PATH
];
45 sprintf(szFunctionName
, "%ls", pszFunction
);
46 FARPROC proc
= (FARPROC
)GetProcAddress(g_hModule
, szFunctionName
);
49 printf("Couldn't find proc: %s\n", szFunctionName
);
53 return IntSyscall(proc
, cParams
, pParams
);
57 IsFunctionPresent(LPWSTR lpszFunction
)
59 char szFunctionName
[MAX_PATH
];
60 sprintf(szFunctionName
, "%ls", lpszFunction
);
61 return (GetProcAddress(g_hModule
, szFunctionName
) != NULL
);
65 WinMain(HINSTANCE hInstance
,
66 HINSTANCE hPrevInstance
,
70 g_hInstance
= hInstance
;
72 printf("Win32k native API test\n");
74 /* Convert to gui thread */
75 // IsGUIThread(TRUE); <- does not exists on win2k
78 printf("g_OsIdx = %d\n", g_OsIdx
);
80 g_hModule
= LoadLibraryW(L
"w32kdll.dll");
83 printf("w32kdll.dll not found!\n");
87 GdiHandleTable
= MyGdiQueryTable();
90 FreeLibrary(g_hModule
);
91 printf("GdiHandleTable not found!\n");
97 return TestMain(L
"w32knapi", L
"win32k.sys Nt-Api");