mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
- restructure syscall code, add edi to RosSyscall clobber list
- more NtGdiGetRandomRgn tests - more TEST -> RTEST svn path=/trunk/; revision=28232
This commit is contained in:
parent
ac4a0d249c
commit
8f82a2f3ed
6 changed files with 103 additions and 84 deletions
|
@ -8,15 +8,15 @@ Test_CreatePen(PTESTINFO pti)
|
|||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
hPen = CreatePen(PS_DASHDOT, 5, RGB(1,2,3));
|
||||
TEST(hPen);
|
||||
RTEST(hPen);
|
||||
|
||||
/* Test if we have a PEN */
|
||||
TEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN);
|
||||
RTEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN);
|
||||
|
||||
GetObject(hPen, sizeof(logpen), &logpen);
|
||||
TEST(logpen.lopnStyle == PS_DASHDOT);
|
||||
TEST(logpen.lopnWidth.x == 5);
|
||||
TEST(logpen.lopnColor == RGB(1,2,3));
|
||||
RTEST(logpen.lopnStyle == PS_DASHDOT);
|
||||
RTEST(logpen.lopnWidth.x == 5);
|
||||
RTEST(logpen.lopnColor == RGB(1,2,3));
|
||||
DeleteObject(hPen);
|
||||
|
||||
/* PS_GEOMETRIC | PS_DASHDOT = 0x00001011 will become PS_SOLID */
|
||||
|
|
|
@ -258,24 +258,24 @@ Test_ExtPen(PTESTINFO pti)
|
|||
TEST(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, 0, &extlogpen) == 0);
|
||||
TEST(GetObject(hPen, 4, &extlogpen) == 0);
|
||||
RTEST(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
RTEST(GetObject(hPen, 0, &extlogpen) == 0);
|
||||
RTEST(GetObject(hPen, 4, &extlogpen) == 0);
|
||||
|
||||
/* Nothing should be filled */
|
||||
TEST(extlogpen.elpPenStyle == 0x77777777);
|
||||
TEST(extlogpen.elpWidth == 0x77777777);
|
||||
RTEST(extlogpen.elpPenStyle == 0x77777777);
|
||||
RTEST(extlogpen.elpWidth == 0x77777777);
|
||||
|
||||
TEST(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0);
|
||||
TEST(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
TEST(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
RTEST(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
RTEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
RTEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0);
|
||||
RTEST(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
RTEST(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
|
||||
|
||||
/* test if the fields are filled correctly */
|
||||
TEST(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH));
|
||||
TEST(extlogpen.elpWidth == 5);
|
||||
TEST(extlogpen.elpBrushStyle == 0);
|
||||
RTEST(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH));
|
||||
RTEST(extlogpen.elpWidth == 5);
|
||||
RTEST(extlogpen.elpBrushStyle == 0);
|
||||
RTEST(extlogpen.elpColor == RGB(1,2,3));
|
||||
RTEST(extlogpen.elpHatch == 22);
|
||||
RTEST(extlogpen.elpNumEntries == 0);
|
||||
|
|
|
@ -5,10 +5,10 @@ Test_GetStockObject(PTESTINFO pti)
|
|||
{
|
||||
/* Test limits and error */
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(GetStockObject(0) != NULL);
|
||||
RTEST(GetStockObject(0) != NULL);
|
||||
TEST(GetStockObject(21) != NULL);
|
||||
TEST(GetStockObject(-1) == NULL);
|
||||
TEST(GetStockObject(9) == NULL);
|
||||
RTEST(GetStockObject(-1) == NULL);
|
||||
RTEST(GetStockObject(9) == NULL);
|
||||
RTEST(GetStockObject(22) == NULL);
|
||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
|
|
|
@ -31,43 +31,63 @@ Test_NtGdiGetRandomRgn(PTESTINFO pti)
|
|||
hrgn = CreateRectRgn(0,0,0,0);
|
||||
hrgn2 = CreateRectRgn(3,3,10,10);
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(NtGdiGetRandomRgn(0, hrgn, 0) == -1);
|
||||
TEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
RTEST(NtGdiGetRandomRgn(0, hrgn, 0) == -1);
|
||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
TEST(NtGdiGetRandomRgn(hDC, 0, 0) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, (HRGN)-5, 0) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 0) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 0);
|
||||
RTEST(NtGdiGetRandomRgn((HDC)2345, hrgn, 1) == -1);
|
||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
RTEST(NtGdiGetRandomRgn((HDC)2345, hrgn, 10) == -1);
|
||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
RTEST(NtGdiGetRandomRgn((HDC)2345, (HRGN)10, 10) == -1);
|
||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
RTEST(NtGdiGetRandomRgn((HDC)2345, 0, 1) == -1);
|
||||
RTEST(GetLastError() == ERROR_INVALID_HANDLE);
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, 0, 0) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, 0, 1) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, (HRGN)-5, 0) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, (HRGN)-5, 1) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 0) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 2) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 3) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 4) == 1);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 5) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 10) == 0);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, -10) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 3) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 4) == 1);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 5) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 10) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, -10) == 0);
|
||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
SelectClipRgn(hDC, hrgn2);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 1);
|
||||
TEST(CombineRgn(hrgn, hrgn, hrgn, RGN_OR) == SIMPLEREGION);
|
||||
TEST(CombineRgn(hrgn, hrgn, hrgn2, RGN_XOR) == NULLREGION);
|
||||
TEST(NtGdiGetRandomRgn(hDC, 0, 1) == -1);
|
||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 1);
|
||||
RTEST(CombineRgn(hrgn, hrgn, hrgn, RGN_OR) == SIMPLEREGION);
|
||||
RTEST(CombineRgn(hrgn, hrgn, hrgn2, RGN_XOR) == NULLREGION);
|
||||
|
||||
SetRectRgn(hrgn2,0,0,0,0);
|
||||
SelectClipRgn(hDC, hrgn2);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 1);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 1);
|
||||
|
||||
TEST(CombineRgn(hrgn2, hrgn, hrgn2, RGN_XOR) == NULLREGION);
|
||||
TEST(CombineRgn(hrgn2, hrgn, hrgn, RGN_OR) == NULLREGION);
|
||||
RTEST(CombineRgn(hrgn2, hrgn, hrgn2, RGN_XOR) == NULLREGION);
|
||||
RTEST(CombineRgn(hrgn2, hrgn, hrgn, RGN_OR) == NULLREGION);
|
||||
|
||||
SelectClipRgn(hDC, NULL);
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 0);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 1) == 0);
|
||||
|
||||
|
||||
TEST(NtGdiGetRandomRgn(hDC, hrgn, 4) == 1);
|
||||
RTEST(NtGdiGetRandomRgn(hDC, hrgn, 4) == 1);
|
||||
|
||||
RTEST(GetLastError() == ERROR_SUCCESS);
|
||||
|
||||
DeleteDC(hDC);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
|
|
|
@ -49,37 +49,6 @@ InitOsVersion()
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
RosSyscall(LPWSTR lpszFunction, int cParams, void* pParams, DWORD* pResult)
|
||||
{
|
||||
DWORD ret;
|
||||
char szFunctionName[MAX_PATH];
|
||||
int ParamSize = cParams * 4;
|
||||
|
||||
sprintf(szFunctionName, "%ls", lpszFunction);
|
||||
FARPROC proc = (FARPROC)GetProcAddress(g_hModule, szFunctionName);
|
||||
if (!proc)
|
||||
{
|
||||
printf("Couldn't find proc: %s\n", szFunctionName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"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
|
||||
: "=a" (ret)
|
||||
: "c" (cParams), "a" (ParamSize), "S"(pParams), "d"(proc)
|
||||
);
|
||||
|
||||
*pResult = ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PSYSCALL_ENTRY
|
||||
GetSyscallEntry(LPWSTR lpszFunction)
|
||||
{
|
||||
|
@ -95,31 +64,60 @@ GetSyscallEntry(LPWSTR lpszFunction)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
WinSyscall(LPWSTR pszFunction, void* pParams, void* pResult)
|
||||
static DWORD STDCALL
|
||||
WinSyscall(INT nSyscalNum, PVOID pFirstParam)
|
||||
{
|
||||
DWORD ret;
|
||||
asm volatile ("int $0x2e\n" : "=a"(ret): "a" (nSyscalNum), "d" (pFirstParam));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DWORD STDCALL
|
||||
RosSyscall(FARPROC proc, UINT cParams, PVOID pFirstParam)
|
||||
{
|
||||
PSYSCALL_ENTRY pEntry = GetSyscallEntry(pszFunction);
|
||||
DWORD ret;
|
||||
|
||||
asm volatile ("int $0x2e\n" : "=a"(ret): "a" (pEntry->nSyscallNum), "d" (pParams));\
|
||||
*((DWORD*)pResult) = ret;
|
||||
return FALSE;
|
||||
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)
|
||||
{
|
||||
DWORD dwRet = 0;
|
||||
|
||||
if (g_nOs == OS_REACTOS)
|
||||
if (g_nOs == OS_REACTOS)
|
||||
{
|
||||
RosSyscall(pszFunction, cParams, pParams, &dwRet);
|
||||
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 RosSyscall(proc, cParams, pParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
WinSyscall(pszFunction, pParams, &dwRet);
|
||||
PSYSCALL_ENTRY pEntry = GetSyscallEntry(pszFunction);
|
||||
return WinSyscall(pEntry->nSyscallNum, pParams);
|
||||
}
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <win32k/callback.h>
|
||||
#include <win32k/ntusrtyp.h>
|
||||
#include <win32k/ntgdityp.h>
|
||||
#include <win32k/ntgdihdl.h>
|
||||
|
||||
#define OS_UNSUPPORTED 0
|
||||
#define OS_REACTOS 1
|
||||
|
|
Loading…
Reference in a new issue