ReactOS 0.4.16-dev-292-gbbdcc14
RtlDeleteAce.c File Reference
#include "precomp.h"
Include dependency graph for RtlDeleteAce.c:

Go to the source code of this file.

Functions

static PACL MakeAcl (_In_ ULONG AceCount,...)
 
 START_TEST (RtlDeleteAce)
 

Function Documentation

◆ MakeAcl()

static PACL MakeAcl ( _In_ ULONG  AceCount,
  ... 
)
static

Definition at line 12 of file RtlDeleteAce.c.

15{
16 PACL Acl;
17 PACE_HEADER AceHeader;
18 ULONG AclSize;
19 ULONG AceSizes[10];
20 ULONG i;
22
23 ASSERT(AceCount <= RTL_NUMBER_OF(AceSizes));
24 AclSize = sizeof(ACL);
25 va_start(Args, AceCount);
26 for (i = 0; i < AceCount; i++)
27 {
28 AceSizes[i] = va_arg(Args, int);
29 AclSize += AceSizes[i];
30 }
31 va_end(Args);
32
33 Acl = AllocateGuarded(AclSize);
34 if (!Acl)
35 {
36 skip("Failed to allocate %lu bytes\n", AclSize);
37 return NULL;
38 }
39
41 Acl->Sbz1 = 0;
42 Acl->AclSize = AclSize;
43 Acl->AceCount = AceCount;
44 Acl->Sbz2 = 0;
45
46 AceHeader = (PACE_HEADER)(Acl + 1);
47 for (i = 0; i < AceCount; i++)
48 {
49 AceHeader->AceType = 0;
50 AceHeader->AceFlags = 0;
51 AceHeader->AceSize = AceSizes[i];
52 AceHeader = (PACE_HEADER)((PCHAR)AceHeader + AceHeader->AceSize);
53 }
54
55 return Acl;
56}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
char ** Args
Definition: acdebug.h:353
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
static PVOID AllocateGuarded(_In_ SIZE_T SizeRequested)
Definition: apitest_guard.h:10
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
struct _ACL ACL
struct _ACE_HEADER * PACE_HEADER
USHORT AceSize
Definition: ms-dtyp.idl:212
UCHAR AceFlags
Definition: ms-dtyp.idl:211
UCHAR AceType
Definition: ms-dtyp.idl:210
USHORT Sbz2
Definition: ms-dtyp.idl:298
UCHAR Sbz1
Definition: ms-dtyp.idl:295
USHORT AceCount
Definition: ms-dtyp.idl:297
USHORT AclSize
Definition: ms-dtyp.idl:296
UCHAR AclRevision
Definition: ms-dtyp.idl:294
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define ACL_REVISION
Definition: setypes.h:39

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( RtlDeleteAce  )

Definition at line 58 of file RtlDeleteAce.c.

59{
60 PACL Acl;
62 ULONG AceSize;
63 PISID Sid;
65 int i;
66
67 Acl = MakeAcl(0);
68 if (Acl)
69 {
70 ok(RtlValidAcl(Acl), "Acl is invalid\n");
71
72 /* There is no first ACE -- should stay untouched */
73 Status = RtlDeleteAce(Acl, 0);
74 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
75 ok(Acl->AclSize == sizeof(ACL), "AclSize = %u\n", Acl->AclSize);
76 ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount);
77
78 /* Index -1 -- should stay untouched */
79 Status = RtlDeleteAce(Acl, 0xFFFFFFFF);
80 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
81 FreeGuarded(Acl);
82 }
83
84 AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority);
85 Acl = MakeAcl(1, (int)AceSize);
86 if (Acl)
87 {
88 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
89 Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
90 Sid = (PISID)&Ace->SidStart;
94
95 ok(RtlValidAcl(Acl), "Acl is invalid\n");
96
97 /* Out of bounds delete -- should stay untouched */
98 Status = RtlDeleteAce(Acl, 1);
99 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
100 ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize);
101 ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount);
102 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
103
104 /* Index -1 -- should stay untouched */
105 Status = RtlDeleteAce(Acl, 0xFFFFFFFF);
106 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
107 ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize);
108 ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount);
109 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
110
111 /* Delete the first (and only) ACE */
112 Status = RtlDeleteAce(Acl, 0);
113 ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
114 ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize);
115 ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount);
116 ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize);
117 FreeGuarded(Acl);
118 }
119
120 AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority[1]);
121 Acl = MakeAcl(4, (int)AceSize, (int)AceSize + 4, (int)AceSize + 8, (int)AceSize + 12);
122 if (Acl)
123 {
124 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
125 for (i = 0; i < 4; i++)
126 {
127 Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
128 Sid = (PISID)&Ace->SidStart;
132 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
133 }
134
135 ok(RtlValidAcl(Acl), "Acl is invalid\n");
136
137 /* Out of bounds delete -- should stay untouched */
138 Status = RtlDeleteAce(Acl, 4);
139 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
140 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
141 ok(Acl->AceCount == 4, "AceCount = %u\n", Acl->AceCount);
142 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
143 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
144 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
145 ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize);
146 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
147 ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize);
148 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
149 ok(Ace->Header.AceSize == AceSize + 12, "AceSize = %u\n", Ace->Header.AceSize);
150
151 /* Index -1 -- should stay untouched */
152 Status = RtlDeleteAce(Acl, 0xFFFFFFFF);
153 ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status);
154 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
155 ok(Acl->AceCount == 4, "AceCount = %u\n", Acl->AceCount);
156 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
157 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
158 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
159 ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize);
160 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
161 ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize);
162 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
163 ok(Ace->Header.AceSize == AceSize + 12, "AceSize = %u\n", Ace->Header.AceSize);
164
165 /* Delete the last ACE */
166 Status = RtlDeleteAce(Acl, 3);
167 ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
168 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
169 ok(Acl->AceCount == 3, "AceCount = %u\n", Acl->AceCount);
170 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
171 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
172 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
173 ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize);
174 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
175 ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize);
176 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
177 ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize);
178
179 /* Delete the second ACE */
180 Status = RtlDeleteAce(Acl, 1);
181 ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
182 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
183 ok(Acl->AceCount == 2, "AceCount = %u\n", Acl->AceCount);
184 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
185 ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize);
186 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
187 ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize);
188 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
189 ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize);
190
191 /* Delete the first ACE */
192 Status = RtlDeleteAce(Acl, 0);
193 ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
194 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
195 ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount);
196 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
197 ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize);
198 Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize);
199 ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize);
200
201 /* Delete the remaining ACE */
202 Status = RtlDeleteAce(Acl, 0);
203 ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
204 ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize);
205 ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount);
206 Ace = (PACCESS_ALLOWED_ACE)(Acl + 1);
207 ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize);
208
209 FreeGuarded(Acl);
210 }
211}
static PACL MakeAcl(_In_ ULONG AceCount,...)
Definition: RtlDeleteAce.c:12
static VOID FreeGuarded(_In_ PVOID Pointer)
Definition: apitest_guard.h:45
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
@ Ace
Definition: card.h:12
Status
Definition: gdiplustypes.h:25
struct _ACCESS_ALLOWED_ACE * PACCESS_ALLOWED_ACE
NTSYSAPI BOOLEAN NTAPI RtlValidAcl(PACL Acl)
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1145
NTSYSAPI NTSTATUS NTAPI RtlDeleteAce(PACL Acl, ULONG AceIndex)
#define STATUS_SUCCESS
Definition: shellext.h:65
BYTE Revision
Definition: ms-dtyp.idl:199
BYTE SubAuthorityCount
Definition: ms-dtyp.idl:200
SID_IDENTIFIER_AUTHORITY IdentifierAuthority
Definition: ms-dtyp.idl:201
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ACCESS_ALLOWED_ACE_TYPE
Definition: setypes.h:717
struct _SID * PISID
#define SID_REVISION
Definition: setypes.h:481