ReactOS 0.4.15-dev-8231-g29a56f3
RtlRangeList.c File Reference
#include <kmt_test.h>
#include <ndk/rtlfuncs.h>
Include dependency graph for RtlRangeList.c:

Go to the source code of this file.

Macros

#define expect_range_entries(RangeList, NumRanges, Ranges)    ExpectRangeEntryList(__FILE__, __LINE__, RangeList, NumRanges, Ranges)
 
#define is_range_available(RangeList, Start, End, pAvail)
 

Functions

static NTSTATUS RtlAddRangeWrapper (_Inout_ PRTL_RANGE_LIST RangeList, _In_ const RTL_RANGE *Range, _In_ ULONG Flags)
 
static void ExpectRange (_In_ PCSTR File, _In_ INT Line, _In_ ULONG Index, _In_ const RTL_RANGE *ActualRange, _In_ const RTL_RANGE *ExpectedRange)
 
static void ExpectRangeEntryList (_In_ PCSTR File, _In_ INT Line, _In_ RTL_RANGE_LIST *RangeList, _In_ ULONG NumRanges, _In_reads_(NumRanges) const RTL_RANGE *Ranges)
 
static void TestStartGreaterThanEnd (_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
 
static void TestStartEqualsEnd (_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
 
static void TestSharedFlag (_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
 
static void TestIsAvailable (_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
 
 START_TEST (RtlRangeList)
 

Variables

static UCHAR MyUserData1
 
static UCHAR MyUserData2
 
static UCHAR MyOwner1
 
static UCHAR MyOwner2
 

Macro Definition Documentation

◆ expect_range_entries

#define expect_range_entries (   RangeList,
  NumRanges,
  Ranges 
)     ExpectRangeEntryList(__FILE__, __LINE__, RangeList, NumRanges, Ranges)

Definition at line 135 of file RtlRangeList.c.

◆ is_range_available

#define is_range_available (   RangeList,
  Start,
  End,
  pAvail 
)
Value:
RtlIsRangeAvailable(RangeList, \
Start, \
End, \
0, \
0, \
NULL, \
NULL, \
pAvail)
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI RtlIsRangeAvailable(_In_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ ULONG Flags, _In_ UCHAR AttributeAvailableMask, _In_opt_ PVOID Context, _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback, _Out_ PBOOLEAN Available)
@ Start
Definition: partlist.h:33

Function Documentation

◆ ExpectRange()

static void ExpectRange ( _In_ PCSTR  File,
_In_ INT  Line,
_In_ ULONG  Index,
_In_ const RTL_RANGE ActualRange,
_In_ const RTL_RANGE ExpectedRange 
)
static

Definition at line 33 of file RtlRangeList.c.

39{
40 CHAR FileAndLine[128];
41 RtlStringCbPrintfA(FileAndLine, sizeof(FileAndLine), "%s:%d", File, Line);
42
43 KmtOk(ActualRange->Start == ExpectedRange->Start, FileAndLine,
44 "[%lu] Start = 0x%I64x, expected 0x%I64x\n", Index, ActualRange->Start, ExpectedRange->Start);
45 KmtOk(ActualRange->End == ExpectedRange->End, FileAndLine,
46 "[%lu] End = 0x%I64x, expected 0x%I64x\n", Index, ActualRange->End, ExpectedRange->End);
47 KmtOk(ActualRange->UserData == ExpectedRange->UserData, FileAndLine,
48 "[%lu] UserData = %p, expected %p\n", Index, ActualRange->UserData, ExpectedRange->UserData);
49 KmtOk(ActualRange->Owner == ExpectedRange->Owner, FileAndLine,
50 "[%lu] Owner = %p, expected %p\n", Index, ActualRange->Owner, ExpectedRange->Owner);
51 KmtOk(ActualRange->Attributes == ExpectedRange->Attributes, FileAndLine,
52 "[%lu] Attributes = 0x%x, expected 0x%x\n", Index, ActualRange->Attributes, ExpectedRange->Attributes);
53 KmtOk(ActualRange->Flags == ExpectedRange->Flags, FileAndLine,
54 "[%lu] Flags = 0x%x, expected 0x%x\n", Index, ActualRange->Flags, ExpectedRange->Flags);
55}
Definition: File.h:16
BOOLEAN BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
Definition: ncftp.h:79
_In_ WDFCOLLECTION _In_ ULONG Index
char CHAR
Definition: xmlstorage.h:175

Referenced by ExpectRangeEntryList().

◆ ExpectRangeEntryList()

static void ExpectRangeEntryList ( _In_ PCSTR  File,
_In_ INT  Line,
_In_ RTL_RANGE_LIST RangeList,
_In_ ULONG  NumRanges,
_In_reads_(NumRanges) const RTL_RANGE Ranges 
)
static

Definition at line 59 of file RtlRangeList.c.

65{
67 ULONG i;
70 CHAR FileAndLine[128];
71 RtlStringCbPrintfA(FileAndLine, sizeof(FileAndLine), "%s:%d", File, Line);
72
73 RtlFillMemory(&Iterator, sizeof(Iterator), 0x55);
75 Status = RtlGetFirstRange(RangeList, &Iterator, &Range);
76#ifdef _WIN64
77 /* Padding at the end is uninitialized */
79 KmtOk((&Iterator.Stamp)[1] == 0x55555555, FileAndLine,
80 "Padding is 0x%lx\n", (&Iterator.Stamp)[1]);
81#endif
82
83 for (i = 0; i < NumRanges; i++)
84 {
85 if (!KmtSkip(NT_SUCCESS(Status), FileAndLine, "Range does not have %lu element(s)\n", i + 1))
86 {
87 ExpectRange(File, Line, i, Range, &Ranges[i]);
88
89 /* Validate iterator */
90 KmtOk(Iterator.RangeListHead == &RangeList->ListHead, FileAndLine,
91 "[%lu] Iterator.RangeListHead = %p, expected %p\n", i, Iterator.RangeListHead, &RangeList->ListHead);
92 KmtOk(Iterator.MergedHead == NULL, FileAndLine,
93 "[%lu] Iterator.MergedHead = %p\n", i, Iterator.MergedHead);
94 KmtOk(Iterator.Current == Range, FileAndLine,
95 "[%lu] Iterator.Current = %p, expected %p\n", i, Iterator.Current, Range);
96 KmtOk(Iterator.Stamp == RangeList->Stamp, FileAndLine,
97 "[%lu] Iterator.Stamp = %lu, expected %lu\n", i, Iterator.Stamp, RangeList->Stamp);
98 }
99
102 }
103
104 /* Final iteration status */
105 KmtOk(Status == STATUS_NO_MORE_ENTRIES, FileAndLine,
106 "Status = 0x%lx after enumeration\n", Status);
107 KmtOk(Range == NULL, FileAndLine,
108 "[%lu] Range = %p\n", i, Range);
109 KmtOk(Iterator.RangeListHead == &RangeList->ListHead, FileAndLine,
110 "[%lu] Iterator.RangeListHead = %p, expected %p\n", i, Iterator.RangeListHead, &RangeList->ListHead);
111 KmtOk(Iterator.MergedHead == NULL, FileAndLine,
112 "[%lu] Iterator.MergedHead = %p\n", i, Iterator.MergedHead);
113 KmtOk(Iterator.Current == NULL, FileAndLine,
114 "[%lu] Iterator.Current = %p\n", i, Iterator.Current);
115 KmtOk(Iterator.Stamp == RangeList->Stamp, FileAndLine,
116 "[%lu] Iterator.Stamp = %lu, expected %lu\n", i, Iterator.Stamp, RangeList->Stamp);
117
118 /* Try one more iteration */
121 KmtOk(Status == STATUS_NO_MORE_ENTRIES, FileAndLine,
122 "Status = 0x%lx after enumeration\n", Status);
123 KmtOk(Range == NULL, FileAndLine,
124 "[%lu] Range = %p\n", i, Range);
125 KmtOk(Iterator.RangeListHead == &RangeList->ListHead, FileAndLine,
126 "[%lu] Iterator.RangeListHead = %p, expected %p\n", i, Iterator.RangeListHead, &RangeList->ListHead);
127 KmtOk(Iterator.MergedHead == NULL, FileAndLine,
128 "[%lu] Iterator.MergedHead = %p\n", i, Iterator.MergedHead);
129 KmtOk(Iterator.Current == NULL, FileAndLine,
130 "[%lu] Iterator.Current = %p\n", i, Iterator.Current);
131 KmtOk(Iterator.Stamp == RangeList->Stamp, FileAndLine,
132 "[%lu] Iterator.Stamp = %lu, expected %lu\n", i, Iterator.Stamp, RangeList->Stamp);
133}
static void ExpectRange(_In_ PCSTR File, _In_ INT Line, _In_ ULONG Index, _In_ const RTL_RANGE *ActualRange, _In_ const RTL_RANGE *ExpectedRange)
Definition: RtlRangeList.c:33
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
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 RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define C_ASSERT(e)
Definition: intsafe.h:73
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
#define KmtInvalidPointer
Definition: kmt_test.h:280
NTSYSAPI NTSTATUS NTAPI RtlGetNextRange(_Inout_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range, _In_ BOOLEAN MoveForwards)
NTSYSAPI NTSTATUS NTAPI RtlGetFirstRange(_In_ PRTL_RANGE_LIST RangeList, _Out_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range)
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:672
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
struct tagRange Range
Definition: range.c:39
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656

◆ RtlAddRangeWrapper()

static NTSTATUS RtlAddRangeWrapper ( _Inout_ PRTL_RANGE_LIST  RangeList,
_In_ const RTL_RANGE Range,
_In_ ULONG  Flags 
)
static

Definition at line 17 of file RtlRangeList.c.

21{
22 return RtlAddRange(RangeList,
23 Range->Start,
24 Range->End,
25 Range->Attributes,
26 Flags,
27 Range->UserData,
28 Range->Owner);
29}
NTSYSAPI NTSTATUS NTAPI RtlAddRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ UCHAR Attributes, _In_ ULONG Flags, _In_opt_ PVOID UserData, _In_opt_ PVOID Owner)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by START_TEST(), TestSharedFlag(), TestStartEqualsEnd(), and TestStartGreaterThanEnd().

◆ START_TEST()

START_TEST ( RtlRangeList  )

Definition at line 412 of file RtlRangeList.c.

413{
415 RTL_RANGE_LIST RangeList;
416 RTL_RANGE Ranges[5];
417 ULONG Stamp;
418
419 RtlFillMemory(&RangeList, sizeof(RangeList), 0x55);
420 RtlInitializeRangeList(&RangeList);
421 ok(IsListEmpty(&RangeList.ListHead),
422 "RangeList.ListHead %p %p %p, expected empty\n",
423 &RangeList.ListHead, RangeList.ListHead.Flink, RangeList.ListHead.Blink);
424 ok_eq_ulong(RangeList.Flags, 0UL);
425 ok_eq_ulong(RangeList.Count, 0UL);
426 ok_eq_ulong(RangeList.Stamp, 0UL);
427#ifdef _WIN64
428 /* Padding at the end is uninitialized */
429 C_ASSERT(sizeof(RangeList) == RTL_SIZEOF_THROUGH_FIELD(RTL_RANGE_LIST, Stamp) + sizeof(ULONG));
430 ok_eq_ulong((&RangeList.Stamp)[1], 0x55555555UL);
431#endif
432
433 /* Add a simple range */
434 Ranges[0].Start = 0x100;
435 Ranges[0].End = 0x200;
436 Ranges[0].Attributes = 1;
437 Ranges[0].Flags = 0;
438 Ranges[0].UserData = &MyUserData1;
439 Ranges[0].Owner = &MyOwner1;
440 Status = RtlAddRangeWrapper(&RangeList, &Ranges[0], 0);
442 ok_eq_ulong(RangeList.Flags, 0UL);
443 ok_eq_ulong(RangeList.Count, 1UL);
444 ok_eq_ulong(RangeList.Stamp, 1UL);
445 expect_range_entries(&RangeList, 1, &Ranges[0]);
446
447 /*
448 * Individual tests.
449 * These should always leave the list with our single start entry.
450 * Stamp may change between tests.
451 */
452 TestStartGreaterThanEnd(&RangeList, Ranges);
453 TestStartEqualsEnd(&RangeList, Ranges);
454 TestSharedFlag(&RangeList, Ranges);
455 TestIsAvailable(&RangeList, Ranges);
456
457 Stamp = RangeList.Stamp;
458
459 /* Free it and check the result */
460 RtlFreeRangeList(&RangeList);
461 ok_eq_ulong(RangeList.Flags, 0UL);
462 ok_eq_ulong(RangeList.Count, 0UL);
463 ok_eq_ulong(RangeList.Stamp, Stamp);
464 expect_range_entries(&RangeList, 0, NULL);
465}
static NTSTATUS RtlAddRangeWrapper(_Inout_ PRTL_RANGE_LIST RangeList, _In_ const RTL_RANGE *Range, _In_ ULONG Flags)
Definition: RtlRangeList.c:17
static UCHAR MyUserData1
Definition: RtlRangeList.c:11
static void TestStartEqualsEnd(_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
Definition: RtlRangeList.c:168
static UCHAR MyOwner1
Definition: RtlRangeList.c:12
#define expect_range_entries(RangeList, NumRanges, Ranges)
Definition: RtlRangeList.c:135
static void TestStartGreaterThanEnd(_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
Definition: RtlRangeList.c:141
static void TestIsAvailable(_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
Definition: RtlRangeList.c:238
static void TestSharedFlag(_Inout_ PRTL_RANGE_LIST RangeList, _Inout_ PRTL_RANGE Ranges)
Definition: RtlRangeList.c:203
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
NTSYSAPI VOID NTAPI RtlInitializeRangeList(_Out_ PRTL_RANGE_LIST RangeList)
NTSYSAPI VOID NTAPI RtlFreeRangeList(_In_ PRTL_RANGE_LIST RangeList)
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY ListHead
Definition: rtltypes.h:1461
ULONGLONG End
Definition: rtltypes.h:1470
ULONGLONG Start
Definition: rtltypes.h:1469
UCHAR Attributes
Definition: rtltypes.h:1473
PVOID UserData
Definition: rtltypes.h:1471
PVOID Owner
Definition: rtltypes.h:1472
UCHAR Flags
Definition: rtltypes.h:1474
#define UL
Definition: tui.h:165

◆ TestIsAvailable()

static void TestIsAvailable ( _Inout_ PRTL_RANGE_LIST  RangeList,
_Inout_ PRTL_RANGE  Ranges 
)
static

Definition at line 238 of file RtlRangeList.c.

241{
243 BOOLEAN Available;
244 ULONG StartStamp = RangeList->Stamp;
245
246#define is_range_available(RangeList, Start, End, pAvail) \
247 RtlIsRangeAvailable(RangeList, \
248 Start, \
249 End, \
250 0, \
251 0, \
252 NULL, \
253 NULL, \
254 pAvail)
255
256 /* Single item range before Start */
257 Status = is_range_available(RangeList,
258 Ranges[0].Start - 1,
259 Ranges[0].Start - 1,
260 &Available);
262 ok_eq_bool(Available, TRUE);
263
264 /* Single item range at Start */
265 Status = is_range_available(RangeList,
266 Ranges[0].Start,
267 Ranges[0].Start,
268 &Available);
270 ok_eq_bool(Available, FALSE);
271
272 /* Single item range at End */
273 Status = is_range_available(RangeList,
274 Ranges[0].End,
275 Ranges[0].End,
276 &Available);
278 ok_eq_bool(Available, FALSE);
279
280 /* Single item range after End */
281 Status = is_range_available(RangeList,
282 Ranges[0].End + 1,
283 Ranges[0].End + 1,
284 &Available);
286 ok_eq_bool(Available, TRUE);
287
288 /* Range ending before Start */
289 Status = is_range_available(RangeList,
290 0x0,
291 Ranges[0].Start - 1,
292 &Available);
294 ok_eq_bool(Available, TRUE);
295
296 /* Range ending at Start */
297 Status = is_range_available(RangeList,
298 0x0,
299 Ranges[0].Start,
300 &Available);
302 ok_eq_bool(Available, FALSE);
303
304 /* Range ending in the middle */
305 Status = is_range_available(RangeList,
306 0x0,
307 (Ranges[0].Start + Ranges[0].End) / 2,
308 &Available);
310 ok_eq_bool(Available, FALSE);
311
312 /* Range going all the way through */
313 Status = is_range_available(RangeList,
314 0x0,
315 Ranges[0].End + 0x100,
316 &Available);
318 ok_eq_bool(Available, FALSE);
319
320 /* Range starting in the middle */
321 Status = is_range_available(RangeList,
322 (Ranges[0].Start + Ranges[0].End) / 2,
323 Ranges[0].End + 0x100,
324 &Available);
326 ok_eq_bool(Available, FALSE);
327
328 /* Range starting at End */
329 Status = is_range_available(RangeList,
330 Ranges[0].End,
331 Ranges[0].End + 0x100,
332 &Available);
334 ok_eq_bool(Available, FALSE);
335
336 /* Range starting after End */
337 Status = is_range_available(RangeList,
338 Ranges[0].End + 1,
339 Ranges[0].End + 0x100,
340 &Available);
342 ok_eq_bool(Available, TRUE);
343
344 /* Start > End, at start */
345 Status = is_range_available(RangeList,
346 Ranges[0].Start,
347 Ranges[0].Start - 1,
348 &Available);
350 ok_eq_bool(Available, TRUE);
351
352 /* Start > End, at start */
353 Status = is_range_available(RangeList,
354 Ranges[0].Start + 1,
355 Ranges[0].Start,
356 &Available);
358 ok_eq_bool(Available, FALSE);
359
360 /* Start > End, at end */
361 Status = is_range_available(RangeList,
362 Ranges[0].End + 1,
363 Ranges[0].End,
364 &Available);
366 ok_eq_bool(Available, TRUE);
367
368 /* Start > End, at end */
369 Status = is_range_available(RangeList,
370 Ranges[0].End,
371 Ranges[0].End - 1,
372 &Available);
374 ok_eq_bool(Available, FALSE);
375
376 /* Start > End, through the range */
377 Status = is_range_available(RangeList,
378 Ranges[0].End + 1,
379 Ranges[0].Start - 1,
380 &Available);
382 ok_eq_bool(Available, TRUE);
383
384 /* AttributesAvailableMask will make our range available */
385 Status = RtlIsRangeAvailable(RangeList,
386 0x0,
387 Ranges[0].End + 0x100,
388 0,
389 Ranges[0].Attributes,
390 NULL,
391 NULL,
392 &Available);
394 ok_eq_bool(Available, TRUE);
395
396 /* AttributesAvailableMask with additional bits */
397 Status = RtlIsRangeAvailable(RangeList,
398 0x0,
399 Ranges[0].End + 0x100,
400 0,
401 0xFF,
402 NULL,
403 NULL,
404 &Available);
406 ok_eq_bool(Available, TRUE);
407
408 ok_eq_ulong(RangeList->Stamp, StartStamp);
409}
unsigned char BOOLEAN
#define is_range_available(RangeList, Start, End, pAvail)
#define ok_eq_bool(value, expected)
Definition: apitest.h:80
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by START_TEST().

◆ TestSharedFlag()

static void TestSharedFlag ( _Inout_ PRTL_RANGE_LIST  RangeList,
_Inout_ PRTL_RANGE  Ranges 
)
static

Definition at line 203 of file RtlRangeList.c.

206{
208 ULONG StartStamp = RangeList->Stamp;
209
210 Ranges[1].Start = 0x300;
211 Ranges[1].End = 0x400;
212 Ranges[1].Attributes = 2;
213 Ranges[1].Flags = RTL_RANGE_SHARED;
214 Ranges[1].UserData = &MyUserData2;
215 Ranges[1].Owner = &MyOwner2;
216
217 /* Pass in the shared flag */
218 Status = RtlAddRangeWrapper(RangeList, &Ranges[1], RTL_RANGE_LIST_ADD_SHARED);
220
221 /* List now has two entries */
222 ok_eq_ulong(RangeList->Flags, 0UL);
223 ok_eq_ulong(RangeList->Count, 2UL);
224 ok_eq_ulong(RangeList->Stamp, StartStamp + 1);
225 expect_range_entries(RangeList, 2, &Ranges[0]);
226
227 /* Delete our new entry -- List goes back to one entry */
228 Status = RtlDeleteRange(RangeList, Ranges[1].Start, Ranges[1].End, Ranges[1].Owner);
230 ok_eq_ulong(RangeList->Flags, 0UL);
231 ok_eq_ulong(RangeList->Count, 1UL);
232 ok_eq_ulong(RangeList->Stamp, StartStamp + 2);
233 expect_range_entries(RangeList, 1, &Ranges[0]);
234}
static UCHAR MyOwner2
Definition: RtlRangeList.c:12
static UCHAR MyUserData2
Definition: RtlRangeList.c:11
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1597
NTSYSAPI NTSTATUS NTAPI RtlDeleteRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ PVOID Owner)
#define RTL_RANGE_LIST_ADD_SHARED
Definition: rtltypes.h:82
#define RTL_RANGE_SHARED
Definition: rtltypes.h:84

Referenced by START_TEST().

◆ TestStartEqualsEnd()

static void TestStartEqualsEnd ( _Inout_ PRTL_RANGE_LIST  RangeList,
_Inout_ PRTL_RANGE  Ranges 
)
static

Definition at line 168 of file RtlRangeList.c.

171{
173 ULONG StartStamp = RangeList->Stamp;
174
175 Ranges[1].Start = 0x300;
176 Ranges[1].End = 0x300;
177 Ranges[1].Attributes = 0xff;
178 Ranges[1].Flags = 0;
179 Ranges[1].UserData = &MyUserData2;
180 Ranges[1].Owner = &MyOwner2;
181
182 /* Start == End is valid */
183 Status = RtlAddRangeWrapper(RangeList, &Ranges[1], 0);
185
186 /* List now has two entries */
187 ok_eq_ulong(RangeList->Flags, 0UL);
188 ok_eq_ulong(RangeList->Count, 2UL);
189 ok_eq_ulong(RangeList->Stamp, StartStamp + 1);
190 expect_range_entries(RangeList, 2, &Ranges[0]);
191
192 /* Delete our new entry -- List goes back to one entry */
193 Status = RtlDeleteRange(RangeList, Ranges[1].Start, Ranges[1].End, Ranges[1].Owner);
195 ok_eq_ulong(RangeList->Flags, 0UL);
196 ok_eq_ulong(RangeList->Count, 1UL);
197 ok_eq_ulong(RangeList->Stamp, StartStamp + 2);
198 expect_range_entries(RangeList, 1, &Ranges[0]);
199}

Referenced by START_TEST().

◆ TestStartGreaterThanEnd()

static void TestStartGreaterThanEnd ( _Inout_ PRTL_RANGE_LIST  RangeList,
_Inout_ PRTL_RANGE  Ranges 
)
static

Definition at line 141 of file RtlRangeList.c.

144{
146 ULONG StartStamp = RangeList->Stamp;
147
148 Ranges[1].Start = 0x300;
149 Ranges[1].End = 0x2ff;
150 Ranges[1].Attributes = 2;
151 Ranges[1].Flags = 0;
152 Ranges[1].UserData = &MyUserData2;
153 Ranges[1].Owner = &MyOwner2;
154
155 /* Start > End bails out early with invalid parameter */
156 Status = RtlAddRangeWrapper(RangeList, &Ranges[1], 0);
158
159 /* List should be unchanged */
160 ok_eq_ulong(RangeList->Flags, 0UL);
161 ok_eq_ulong(RangeList->Count, 1UL);
162 ok_eq_ulong(RangeList->Stamp, StartStamp);
163 expect_range_entries(RangeList, 1, &Ranges[0]);
164}
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by START_TEST().

Variable Documentation

◆ MyOwner1

UCHAR MyOwner1
static

Definition at line 12 of file RtlRangeList.c.

Referenced by START_TEST().

◆ MyOwner2

UCHAR MyOwner2
static

Definition at line 12 of file RtlRangeList.c.

Referenced by TestSharedFlag(), TestStartEqualsEnd(), and TestStartGreaterThanEnd().

◆ MyUserData1

UCHAR MyUserData1
static

Definition at line 11 of file RtlRangeList.c.

Referenced by START_TEST().

◆ MyUserData2

UCHAR MyUserData2
static

Definition at line 11 of file RtlRangeList.c.

Referenced by TestSharedFlag(), TestStartEqualsEnd(), and TestStartGreaterThanEnd().