4 HMODULE g_hModule
= NULL
;
7 IntSyscall(FARPROC proc
, UINT cParams
, PVOID pFirstParam
)
13 "pushfl;" // Save flags
15 "shl $2, %%eax;" // Calculate param size
16 "subl %%eax, %%esp;" // Calculate new stack pos
17 "movl %%esp, %%edi;" // Destination is stackpointer
18 "cld;" // Clear direction flag
19 "rep movsd;" // Copy params to the stack
20 "call *%%edx;" // Call function
21 "popfl;" // Restore flags
23 : "S" (pFirstParam
), "c" (cParams
), "d"(proc
)
31 Syscall(LPWSTR pszFunction
, int cParams
, void* pParams
)
33 char szFunctionName
[MAX_PATH
];
35 sprintf(szFunctionName
, "%ls", pszFunction
);
36 FARPROC proc
= (FARPROC
)GetProcAddress(g_hModule
, szFunctionName
);
39 printf("Couldn't find proc: %s\n", szFunctionName
);
43 return IntSyscall(proc
, cParams
, pParams
);
47 IsFunctionPresent(LPWSTR lpszFunction
)
49 char szFunctionName
[MAX_PATH
];
50 sprintf(szFunctionName
, "%ls", lpszFunction
);
51 return (GetProcAddress(g_hModule
, szFunctionName
) != NULL
);
55 WinMain(HINSTANCE hInstance
,
56 HINSTANCE hPrevInstance
,
60 g_hInstance
= hInstance
;
62 printf("Win32k native API test\n");
64 /* Convert to gui thread */
65 // IsGUIThread(TRUE); <- does not exists on win2k
67 g_hModule
= LoadLibraryW(L
"w32kdll.dll");
70 printf("w32kdll.dll not found!\n");
76 return TestMain(L
"w32knapi", L
"win32k.sys Nt-Api");