mirror of
https://github.com/reactos/reactos.git
synced 2024-08-23 11:52:51 +00:00
![Timo Kreuzer](/assets/img/avatar_default.png)
- link to w32kdll instead of implementing all syscalls as stubs. I will remove the rest of the syscall code as soon as our syscall db is more complete - more TEST -> RTEST - update w32kdll_ros.def - add tests for NtGdiEngCreatePalette, NtGdiEnumFontOpen - Add some gdi handle table code to w32knapi - header cleanup svn path=/trunk/; revision=28619
91 lines
2 KiB
C
91 lines
2 KiB
C
#include "w32knapi.h"
|
|
|
|
HINSTANCE g_hInstance;
|
|
HMODULE g_hModule = NULL;
|
|
PGDI_TABLE_ENTRY GdiHandleTable;
|
|
|
|
static DWORD STDCALL
|
|
IntSyscall(FARPROC proc, UINT cParams, PVOID pFirstParam)
|
|
{
|
|
DWORD ret;
|
|
|
|
asm volatile
|
|
(
|
|
"pushfl;" // Save flags
|
|
"movl %%ecx, %%eax;"
|
|
"shl $2, %%eax;" // Calculate param size
|
|
"subl %%eax, %%esp;" // Calculate new stack pos
|
|
"movl %%esp, %%edi;" // Destination is stackpointer
|
|
"cld;" // Clear direction flag
|
|
"rep movsd;" // Copy params to the stack
|
|
"call *%%edx;" // Call function
|
|
"popfl;" // Restore flags
|
|
: "=a" (ret)
|
|
: "S" (pFirstParam), "c" (cParams), "d"(proc)
|
|
: "%edi"
|
|
);
|
|
|
|
return ret;
|
|
}
|
|
|
|
DWORD
|
|
Syscall(LPWSTR pszFunction, int cParams, void* pParams)
|
|
{
|
|
char szFunctionName[MAX_PATH];
|
|
|
|
sprintf(szFunctionName, "%ls", pszFunction);
|
|
FARPROC proc = (FARPROC)GetProcAddress(g_hModule, szFunctionName);
|
|
if (!proc)
|
|
{
|
|
printf("Couldn't find proc: %s\n", szFunctionName);
|
|
return FALSE;
|
|
}
|
|
|
|
return IntSyscall(proc, cParams, pParams);
|
|
}
|
|
|
|
BOOL
|
|
IsFunctionPresent(LPWSTR lpszFunction)
|
|
{
|
|
char szFunctionName[MAX_PATH];
|
|
sprintf(szFunctionName, "%ls", lpszFunction);
|
|
return (GetProcAddress(g_hModule, szFunctionName) != NULL);
|
|
}
|
|
|
|
int APIENTRY
|
|
WinMain(HINSTANCE hInstance,
|
|
HINSTANCE hPrevInstance,
|
|
LPSTR lpCmdLine,
|
|
int nCmdShow)
|
|
{
|
|
g_hInstance = hInstance;
|
|
GDIQUERYPROC GdiQueryHandleTable;
|
|
|
|
printf("Win32k native API test\n");
|
|
|
|
/* Convert to gui thread */
|
|
// IsGUIThread(TRUE); <- does not exists on win2k
|
|
|
|
g_hModule = LoadLibraryW(L"w32kdll.dll");
|
|
if (!g_hModule)
|
|
{
|
|
printf("w32kdll.dll not found!\n");
|
|
return -1;
|
|
}
|
|
|
|
GdiQueryHandleTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"), "GdiQueryTable");
|
|
if(!GdiQueryHandleTable)
|
|
{
|
|
return -1;
|
|
}
|
|
GdiHandleTable = GdiQueryHandleTable();
|
|
if(!GdiHandleTable)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
return TestMain(L"w32knapi", L"win32k.sys Nt-Api");
|
|
}
|