ReactOS  0.4.14-dev-342-gdc047f9
SaferIdentifyLevel.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPLv2+ - See COPYING in the top level directory
4  * PURPOSE: Test for SaferIdentifyLevel
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 #include <winsafer.h>
11 
12 #define SaferIdentifyLevel(c, p, h, r) SaferIdentifyLevel(c, (PSAFER_CODE_PROPERTIES)(p), h, r)
13 
15 {
16  BOOL ret;
17  DWORD error;
18  SAFER_LEVEL_HANDLE handle;
20 
21  StartSeh()
22  SetLastError(0xbadbad00);
24  error = GetLastError();
25  ok(ret == FALSE, "ret = %d\n", ret);
26  ok(error == ERROR_NOACCESS, "error = %lu\n", error);
28 
29  StartSeh()
32 
33  StartSeh()
34  ZeroMemory(props, sizeof(props));
35  SetLastError(0xbadbad00);
37  error = GetLastError();
38  ok(ret == FALSE, "ret = %d\n", ret);
39  ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
41 
42  StartSeh()
43  ZeroMemory(props, sizeof(props));
44  SetLastError(0xbadbad00);
46  error = GetLastError();
47  ok(ret == FALSE, "ret = %d\n", ret);
48  ok(error == ERROR_NOACCESS, "error = %lu\n", error);
50 
51  StartSeh()
53  ZeroMemory(props, sizeof(props));
54  SetLastError(0xbadbad00);
56  error = GetLastError();
57  ok(ret == FALSE, "ret = %d\n", ret);
58  ok(handle == InvalidPointer, "handle = %p\n", handle);
59  ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
60  if (handle && handle != InvalidPointer)
63 
64  /* Struct sizes */
65  StartSeh()
67  ZeroMemory(props, sizeof(props));
68  props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V1);
69  SetLastError(0xbadbad00);
71  error = GetLastError();
72  ok(ret == TRUE, "ret = %d\n", ret);
73  ok(handle != NULL && handle != INVALID_HANDLE_VALUE && handle != InvalidPointer, "handle = %p\n", handle);
74  ok(error == 0xbadbad00, "error = %lu\n", error);
75  if (handle && handle != InvalidPointer)
76  {
78  ok(ret == TRUE, "ret = %d\n", ret);
79  }
81 
82  StartSeh()
84  ZeroMemory(props, sizeof(props));
85  props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V2);
86  SetLastError(0xbadbad00);
88  error = GetLastError();
89  ok(ret == FALSE, "ret = %d\n", ret);
90  ok(handle == InvalidPointer, "handle = %p\n", handle);
91  ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
92  if (handle && handle != InvalidPointer)
95 
96  /* Test SaferCloseLevel too */
97  StartSeh()
99  error = GetLastError();
100  ok(ret == FALSE, "ret = %d\n", ret);
101  ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
103 
104  StartSeh()
106  error = GetLastError();
107  ok(ret == FALSE, "ret = %d\n", ret);
108  ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
110 
111  StartSeh()
113  error = GetLastError();
114  ok(ret == FALSE, "ret = %d\n", ret);
115  ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
117 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_BAD_LENGTH
Definition: winerror.h:127
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define StartSeh()
Definition: _sntprintf.h:16
#define ERROR_NOACCESS
Definition: winerror.h:578
BOOL WINAPI SaferCloseLevel(_In_ SAFER_LEVEL_HANDLE hLevelHandle)
Definition: safer.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define InvalidPointer
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define SaferIdentifyLevel(c, p, h, r)
int ret
#define VOID
Definition: acefi.h:82
struct _SAFER_CODE_PROPERTIES_V1 SAFER_CODE_PROPERTIES_V1
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR props[]
Definition: wbemdisp.c:288
struct _SAFER_CODE_PROPERTIES_V2 SAFER_CODE_PROPERTIES_V2
return STATUS_SUCCESS
Definition: btrfs.c:2938
START_TEST(SaferIdentifyLevel)
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17