ReactOS 0.4.16-dev-91-g764881a
misc.cpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL CreateSurface (LPDIRECTDRAWSURFACE7 *pSurface)
 
BOOL Test_Misc (INT *passed, INT *failed)
 

Function Documentation

◆ CreateSurface()

BOOL CreateSurface ( LPDIRECTDRAWSURFACE7 pSurface)

Definition at line 28 of file helper.cpp.

29{
32 HWND hwnd;
33
34 // Create DDraw Object
35 if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
36 {
37 printf("ERROR: Failed to set up ddraw\n");
38 return FALSE;
39 }
40
41 if(!( hwnd = CreateBasicWindow() ))
42 {
43 printf("ERROR: Failed to create window\n");
44 DirectDraw->Release();
45 return FALSE;
46 }
47
48 if (DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) != DD_OK)
49 {
50 printf("ERROR: Could not set cooperative level\n");
51 DirectDraw->Release();
52 return 0;
53 }
54
55 // Creat Surface
56 DDSURFACEDESC2 Desc = { 0 };
57 Desc.dwHeight = 200;
58 Desc.dwWidth = 200;
59 Desc.dwSize = sizeof (DDSURFACEDESC2);
62
63 if(DirectDraw->CreateSurface(&Desc, &Surface, NULL) != DD_OK)
64 {
65 printf("ERROR: Faild to create Surface\n");
66 return FALSE;
67 }
68
69 DirectDraw->Release();
70
71 *pSurface = Surface;
72 return TRUE;
73}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:6
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: freeldr.h:97
HWND CreateBasicWindow(VOID)
Definition: helper.cpp:17
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSCL_NORMAL
Definition: ddraw.h:535
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSD_HEIGHT
Definition: ddraw.h:209
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
DWORD dwCaps
Definition: ddraw.h:732
DWORD dwWidth
Definition: ddraw.h:1155
DWORD dwHeight
Definition: ddraw.h:1154
DDSCAPS2 ddsCaps
Definition: ddraw.h:1188
DWORD dwFlags
Definition: ddraw.h:1153
DWORD dwSize
Definition: ddraw.h:1152
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by Test_Misc().

◆ Test_Misc()

BOOL Test_Misc ( INT passed,
INT failed 
)

Definition at line 3 of file misc.cpp.

4{
6 if(!CreateSurface(&Surface))
7 return FALSE;
8
9 TEST (Surface->Initialize(NULL, NULL) == DDERR_ALREADYINITIALIZED);
10
11 // GetCaps
12 DDSCAPS2 Caps;
13 TEST (Surface->GetCaps((DDSCAPS2*)0xdeadbeef) == DDERR_INVALIDPARAMS);
14 TEST (Surface->GetCaps(&Caps) == DD_OK && Caps.dwCaps == 0x10004040
15 && Caps.dwCaps2 == 0 && Caps.dwCaps3 == 0 && Caps.dwCaps4 == 0); // FIXME: Replace 0x10004040
16
17 // GetDC / ReleaseDC
18 HDC hdc;
19 TEST (Surface->GetDC((HDC*)0xdeadbeef) == DDERR_INVALIDPARAMS);
20 TEST (Surface->ReleaseDC((HDC)0xdeadbeef) == DDERR_NODC);
21 TEST (Surface->ReleaseDC(GetDC(NULL)) == DDERR_NODC);
22
23 TEST (Surface->GetDC(&hdc) == DD_OK);
24 TEST (MoveToEx(hdc, 0, 0, NULL) == TRUE); // validate hdc
25 TEST (Surface->Blt(NULL, NULL, NULL, 0, NULL) == DDERR_SURFACEBUSY); // check lock
26 TEST (Surface->ReleaseDC(hdc) == DD_OK);
27
28 // ChangeUniquenessValue / GetUniquenessValue
30 // FIXME: find out other apis which increases the uniqueness value
31 TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 2);
32 TEST (Surface->Blt(NULL, NULL, NULL, 0, NULL) == DDERR_INVALIDPARAMS); // Even this increases the uniqueness value
33 TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 3);
34 TEST (Surface->ChangeUniquenessValue() == DD_OK);
35 TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 4);
36
37 // GetPixelFormat
39 // FIXME: Produce DDERR_INVALIDSURFACETYPE
40 TEST (Surface->GetPixelFormat((LPDDPIXELFORMAT)0xdeadbeef) == DDERR_INVALIDPARAMS);
41 TEST (Surface->GetPixelFormat(&PixelFormat));
42 PixelFormat.dwSize = sizeof(DDPIXELFORMAT);
43 TEST (Surface->GetPixelFormat(&PixelFormat) == DD_OK && PixelFormat.dwFlags == 0x40); // FIXME: Find out what 0x40 is
44
45 // GetSurfaceDesc / SetSurfaceDesc
46 DDSURFACEDESC2 Desc = {0};
47 // FIXME: Produce DDERR_INVALIDSURFACETYPE
48 TEST (Surface->GetSurfaceDesc((LPDDSURFACEDESC2)0xdeadbeef) == DDERR_INVALIDPARAMS);
49 TEST (Surface->GetSurfaceDesc(&Desc));
50 Desc.dwSize = sizeof(DDSURFACEDESC2);
51 TEST (Surface->GetSurfaceDesc(&Desc) == DD_OK && Desc.dwFlags == 0x100f); // FIXME: Find out what 0x100f is
53 // FIXME: Test SetSurfaceDesc
54
55 // GetDDInterface
56 IUnknown* iface;
57 TEST(Surface->GetDDInterface((LPVOID*)0xdeadbeef) == DDERR_INVALIDPARAMS);
58 TEST(Surface->GetDDInterface((LPVOID*)&iface) == DD_OK && iface);
59 TEST(iface->Release() == 1); // FIXME: Test the interface further
60
61 Surface->Release();
62
63 return TRUE;
64}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned long DWORD
Definition: ntddk_ex.h:95
INT PixelFormat
ULONG Release()
#define TEST(x)
Definition: precomp.h:20
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
#define DDERR_NODC
Definition: ddraw.h:160
struct _DDPIXELFORMAT DDPIXELFORMAT
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define DDERR_SURFACEBUSY
Definition: ddraw.h:119
DWORD dwCaps4
Definition: ddraw.h:737
DWORD dwCaps3
Definition: ddraw.h:734
DWORD dwCaps2
Definition: ddraw.h:733
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1185
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HDC WINAPI GetDC(_In_opt_ HWND)