1 /* Unit test suite for Rtl* API functions
3 * Copyright 2003 Thomas Mertes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * We use function pointers here as there is no import library for NTDLL on
26 #include "ntdll_test.h"
29 #ifndef __WINE_WINTERNL_H
31 typedef struct _RTL_HANDLE
33 struct _RTL_HANDLE
* Next
;
36 typedef struct _RTL_HANDLE_TABLE
49 /* avoid #include <winsock2.h> */
51 #ifdef WORDS_BIGENDIAN
52 #define htons(s) ((USHORT)(s))
53 #else /* WORDS_BIGENDIAN */
54 static inline USHORT
__my_ushort_swap(USHORT s
)
56 return (s
>> 8) | (s
<< 8);
58 #define htons(s) __my_ushort_swap(s)
59 #endif /* WORDS_BIGENDIAN */
63 /* Function ptrs for ntdll calls */
64 static HMODULE hntdll
= 0;
65 static SIZE_T (WINAPI
*pRtlCompareMemory
)(LPCVOID
,LPCVOID
,SIZE_T
);
66 static SIZE_T (WINAPI
*pRtlCompareMemoryUlong
)(PULONG
, SIZE_T
, ULONG
);
67 static NTSTATUS (WINAPI
*pRtlDeleteTimer
)(HANDLE
, HANDLE
, HANDLE
);
68 static VOID (WINAPI
*pRtlMoveMemory
)(LPVOID
,LPCVOID
,SIZE_T
);
69 static VOID (WINAPI
*pRtlFillMemory
)(LPVOID
,SIZE_T
,BYTE
);
70 static VOID (WINAPI
*pRtlFillMemoryUlong
)(LPVOID
,SIZE_T
,ULONG
);
71 static VOID (WINAPI
*pRtlZeroMemory
)(LPVOID
,SIZE_T
);
72 static ULONGLONG (WINAPIV
*pRtlUlonglongByteSwap
)(ULONGLONG source
);
73 static ULONG (WINAPI
*pRtlUniform
)(PULONG
);
74 static ULONG (WINAPI
*pRtlRandom
)(PULONG
);
75 static BOOLEAN (WINAPI
*pRtlAreAllAccessesGranted
)(ACCESS_MASK
, ACCESS_MASK
);
76 static BOOLEAN (WINAPI
*pRtlAreAnyAccessesGranted
)(ACCESS_MASK
, ACCESS_MASK
);
77 static DWORD (WINAPI
*pRtlComputeCrc32
)(DWORD
,const BYTE
*,INT
);
78 static void (WINAPI
* pRtlInitializeHandleTable
)(ULONG
, ULONG
, RTL_HANDLE_TABLE
*);
79 static BOOLEAN (WINAPI
* pRtlIsValidIndexHandle
)(const RTL_HANDLE_TABLE
*, ULONG
, RTL_HANDLE
**);
80 static NTSTATUS (WINAPI
* pRtlDestroyHandleTable
)(RTL_HANDLE_TABLE
*);
81 static RTL_HANDLE
* (WINAPI
* pRtlAllocateHandle
)(RTL_HANDLE_TABLE
*, ULONG
*);
82 static BOOLEAN (WINAPI
* pRtlFreeHandle
)(RTL_HANDLE_TABLE
*, RTL_HANDLE
*);
83 static NTSTATUS (WINAPI
*pRtlAllocateAndInitializeSid
)(PSID_IDENTIFIER_AUTHORITY
,BYTE
,DWORD
,DWORD
,DWORD
,DWORD
,DWORD
,DWORD
,DWORD
,DWORD
,PSID
*);
84 static NTSTATUS (WINAPI
*pRtlFreeSid
)(PSID
);
85 static struct _TEB
* (WINAPI
*pNtCurrentTeb
)(void);
86 static DWORD (WINAPI
*pRtlGetThreadErrorMode
)(void);
87 static NTSTATUS (WINAPI
*pRtlSetThreadErrorMode
)(DWORD
, LPDWORD
);
88 static IMAGE_BASE_RELOCATION
*(WINAPI
*pLdrProcessRelocationBlock
)(void*,UINT
,USHORT
*,INT_PTR
);
89 static CHAR
* (WINAPI
*pRtlIpv4AddressToStringA
)(const IN_ADDR
*, LPSTR
);
90 static NTSTATUS (WINAPI
*pRtlIpv4AddressToStringExA
)(const IN_ADDR
*, USHORT
, LPSTR
, PULONG
);
91 static NTSTATUS (WINAPI
*pRtlIpv4StringToAddressA
)(PCSTR
, BOOLEAN
, PCSTR
*, IN_ADDR
*);
92 static NTSTATUS (WINAPI
*pLdrAddRefDll
)(ULONG
, HMODULE
);
93 static NTSTATUS (WINAPI
*pLdrLockLoaderLock
)(ULONG
, ULONG
*, ULONG_PTR
*);
94 static NTSTATUS (WINAPI
*pLdrUnlockLoaderLock
)(ULONG
, ULONG_PTR
);
96 static HMODULE hkernel32
= 0;
97 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
101 static const char* src_src
= "This is a test!"; /* 16 bytes long, incl NUL */
102 static ULONG src_aligned_block
[4];
103 static ULONG dest_aligned_block
[32];
104 static const char *src
= (const char*)src_aligned_block
;
105 static char* dest
= (char*)dest_aligned_block
;
107 static void InitFunctionPtrs(void)
109 hntdll
= LoadLibraryA("ntdll.dll");
110 ok(hntdll
!= 0, "LoadLibrary failed\n");
112 pRtlCompareMemory
= (void *)GetProcAddress(hntdll
, "RtlCompareMemory");
113 pRtlCompareMemoryUlong
= (void *)GetProcAddress(hntdll
, "RtlCompareMemoryUlong");
114 pRtlDeleteTimer
= (void *)GetProcAddress(hntdll
, "RtlDeleteTimer");
115 pRtlMoveMemory
= (void *)GetProcAddress(hntdll
, "RtlMoveMemory");
116 pRtlFillMemory
= (void *)GetProcAddress(hntdll
, "RtlFillMemory");
117 pRtlFillMemoryUlong
= (void *)GetProcAddress(hntdll
, "RtlFillMemoryUlong");
118 pRtlZeroMemory
= (void *)GetProcAddress(hntdll
, "RtlZeroMemory");
119 pRtlUlonglongByteSwap
= (void *)GetProcAddress(hntdll
, "RtlUlonglongByteSwap");
120 pRtlUniform
= (void *)GetProcAddress(hntdll
, "RtlUniform");
121 pRtlRandom
= (void *)GetProcAddress(hntdll
, "RtlRandom");
122 pRtlAreAllAccessesGranted
= (void *)GetProcAddress(hntdll
, "RtlAreAllAccessesGranted");
123 pRtlAreAnyAccessesGranted
= (void *)GetProcAddress(hntdll
, "RtlAreAnyAccessesGranted");
124 pRtlComputeCrc32
= (void *)GetProcAddress(hntdll
, "RtlComputeCrc32");
125 pRtlInitializeHandleTable
= (void *)GetProcAddress(hntdll
, "RtlInitializeHandleTable");
126 pRtlIsValidIndexHandle
= (void *)GetProcAddress(hntdll
, "RtlIsValidIndexHandle");
127 pRtlDestroyHandleTable
= (void *)GetProcAddress(hntdll
, "RtlDestroyHandleTable");
128 pRtlAllocateHandle
= (void *)GetProcAddress(hntdll
, "RtlAllocateHandle");
129 pRtlFreeHandle
= (void *)GetProcAddress(hntdll
, "RtlFreeHandle");
130 pRtlAllocateAndInitializeSid
= (void *)GetProcAddress(hntdll
, "RtlAllocateAndInitializeSid");
131 pRtlFreeSid
= (void *)GetProcAddress(hntdll
, "RtlFreeSid");
132 pNtCurrentTeb
= (void *)GetProcAddress(hntdll
, "NtCurrentTeb");
133 pRtlGetThreadErrorMode
= (void *)GetProcAddress(hntdll
, "RtlGetThreadErrorMode");
134 pRtlSetThreadErrorMode
= (void *)GetProcAddress(hntdll
, "RtlSetThreadErrorMode");
135 pLdrProcessRelocationBlock
= (void *)GetProcAddress(hntdll
, "LdrProcessRelocationBlock");
136 pRtlIpv4AddressToStringA
= (void *)GetProcAddress(hntdll
, "RtlIpv4AddressToStringA");
137 pRtlIpv4AddressToStringExA
= (void *)GetProcAddress(hntdll
, "RtlIpv4AddressToStringExA");
138 pRtlIpv4StringToAddressA
= (void *)GetProcAddress(hntdll
, "RtlIpv4StringToAddressA");
139 pLdrAddRefDll
= (void *)GetProcAddress(hntdll
, "LdrAddRefDll");
140 pLdrLockLoaderLock
= (void *)GetProcAddress(hntdll
, "LdrLockLoaderLock");
141 pLdrUnlockLoaderLock
= (void *)GetProcAddress(hntdll
, "LdrUnlockLoaderLock");
143 hkernel32
= LoadLibraryA("kernel32.dll");
144 ok(hkernel32
!= 0, "LoadLibrary failed\n");
146 pIsWow64Process
= (void *)GetProcAddress(hkernel32
, "IsWow64Process");
148 strcpy((char*)src_aligned_block
, src_src
);
149 ok(strlen(src
) == 15, "Source must be 16 bytes long!\n");
152 #define COMP(str1,str2,cmplen,len) size = pRtlCompareMemory(str1, str2, cmplen); \
153 ok(size == len, "Expected %ld, got %ld\n", size, (SIZE_T)len)
155 static void test_RtlCompareMemory(void)
159 if (!pRtlCompareMemory
)
161 win_skip("RtlCompareMemory is not available\n");
168 COMP(src
,src
,LEN
,LEN
);
170 COMP(src
,dest
,LEN
,0);
173 static void test_RtlCompareMemoryUlong(void)
178 if (!pRtlCompareMemoryUlong
)
180 win_skip("RtlCompareMemoryUlong is not available\n");
188 result
= pRtlCompareMemoryUlong(a
, 0, 0x0123);
189 ok(result
== 0, "RtlCompareMemoryUlong(%p, 0, 0x0123) returns %u, expected 0\n", a
, result
);
190 result
= pRtlCompareMemoryUlong(a
, 3, 0x0123);
191 ok(result
== 0, "RtlCompareMemoryUlong(%p, 3, 0x0123) returns %u, expected 0\n", a
, result
);
192 result
= pRtlCompareMemoryUlong(a
, 4, 0x0123);
193 ok(result
== 4, "RtlCompareMemoryUlong(%p, 4, 0x0123) returns %u, expected 4\n", a
, result
);
194 result
= pRtlCompareMemoryUlong(a
, 5, 0x0123);
195 ok(result
== 4, "RtlCompareMemoryUlong(%p, 5, 0x0123) returns %u, expected 4\n", a
, result
);
196 result
= pRtlCompareMemoryUlong(a
, 7, 0x0123);
197 ok(result
== 4, "RtlCompareMemoryUlong(%p, 7, 0x0123) returns %u, expected 4\n", a
, result
);
198 result
= pRtlCompareMemoryUlong(a
, 8, 0x0123);
199 ok(result
== 4, "RtlCompareMemoryUlong(%p, 8, 0x0123) returns %u, expected 4\n", a
, result
);
200 result
= pRtlCompareMemoryUlong(a
, 9, 0x0123);
201 ok(result
== 4, "RtlCompareMemoryUlong(%p, 9, 0x0123) returns %u, expected 4\n", a
, result
);
202 result
= pRtlCompareMemoryUlong(a
, 4, 0x0127);
203 ok(result
== 0, "RtlCompareMemoryUlong(%p, 4, 0x0127) returns %u, expected 0\n", a
, result
);
204 result
= pRtlCompareMemoryUlong(a
, 4, 0x7123);
205 ok(result
== 0, "RtlCompareMemoryUlong(%p, 4, 0x7123) returns %u, expected 0\n", a
, result
);
206 result
= pRtlCompareMemoryUlong(a
, 16, 0x4567);
207 ok(result
== 0, "RtlCompareMemoryUlong(%p, 16, 0x4567) returns %u, expected 0\n", a
, result
);
210 result
= pRtlCompareMemoryUlong(a
, 3, 0x0123);
211 ok(result
== 0, "RtlCompareMemoryUlong(%p, 3, 0x0123) returns %u, expected 0\n", a
, result
);
212 result
= pRtlCompareMemoryUlong(a
, 4, 0x0123);
213 ok(result
== 4, "RtlCompareMemoryUlong(%p, 4, 0x0123) returns %u, expected 4\n", a
, result
);
214 result
= pRtlCompareMemoryUlong(a
, 5, 0x0123);
215 ok(result
== 4, "RtlCompareMemoryUlong(%p, 5, 0x0123) returns %u, expected 4\n", a
, result
);
216 result
= pRtlCompareMemoryUlong(a
, 7, 0x0123);
217 ok(result
== 4, "RtlCompareMemoryUlong(%p, 7, 0x0123) returns %u, expected 4\n", a
, result
);
218 result
= pRtlCompareMemoryUlong(a
, 8, 0x0123);
219 ok(result
== 8, "RtlCompareMemoryUlong(%p, 8, 0x0123) returns %u, expected 8\n", a
, result
);
220 result
= pRtlCompareMemoryUlong(a
, 9, 0x0123);
221 ok(result
== 8, "RtlCompareMemoryUlong(%p, 9, 0x0123) returns %u, expected 8\n", a
, result
);
224 #define COPY(len) memset(dest,0,sizeof(dest_aligned_block)); pRtlMoveMemory(dest, src, len)
225 #define CMP(str) ok(strcmp(dest,str) == 0, "Expected '%s', got '%s'\n", str, dest)
227 static void test_RtlMoveMemory(void)
231 win_skip("RtlMoveMemory is not available\n");
235 /* Length should be in bytes and not rounded. Use strcmp to ensure we
236 * didn't write past the end (it checks for the final NUL left by memset)
242 COPY(4); CMP("This");
243 COPY(5); CMP("This ");
244 COPY(6); CMP("This i");
245 COPY(7); CMP("This is");
246 COPY(8); CMP("This is ");
247 COPY(9); CMP("This is a");
250 strcpy(dest
, src
); pRtlMoveMemory(dest
, dest
+ 1, strlen(src
) - 1);
251 CMP("his is a test!!");
252 strcpy(dest
, src
); pRtlMoveMemory(dest
+ 1, dest
, strlen(src
));
253 CMP("TThis is a test!");
256 #define FILL(len) memset(dest,0,sizeof(dest_aligned_block)); strcpy(dest, src); pRtlFillMemory(dest,len,'x')
258 static void test_RtlFillMemory(void)
262 win_skip("RtlFillMemory is not available\n");
266 /* Length should be in bytes and not rounded. Use strcmp to ensure we
267 * didn't write past the end (the remainder of the string should match)
269 FILL(0); CMP("This is a test!");
270 FILL(1); CMP("xhis is a test!");
271 FILL(2); CMP("xxis is a test!");
272 FILL(3); CMP("xxxs is a test!");
273 FILL(4); CMP("xxxx is a test!");
274 FILL(5); CMP("xxxxxis a test!");
275 FILL(6); CMP("xxxxxxs a test!");
276 FILL(7); CMP("xxxxxxx a test!");
277 FILL(8); CMP("xxxxxxxxa test!");
278 FILL(9); CMP("xxxxxxxxx test!");
281 #define LFILL(len) memset(dest,0,sizeof(dest_aligned_block)); strcpy(dest, src); pRtlFillMemoryUlong(dest,len,val)
283 static void test_RtlFillMemoryUlong(void)
285 ULONG val
= ('x' << 24) | ('x' << 16) | ('x' << 8) | 'x';
286 if (!pRtlFillMemoryUlong
)
288 win_skip("RtlFillMemoryUlong is not available\n");
292 /* Length should be in bytes and not rounded. Use strcmp to ensure we
293 * didn't write past the end (the remainder of the string should match)
295 LFILL(0); CMP("This is a test!");
296 LFILL(1); CMP("This is a test!");
297 LFILL(2); CMP("This is a test!");
298 LFILL(3); CMP("This is a test!");
299 LFILL(4); CMP("xxxx is a test!");
300 LFILL(5); CMP("xxxx is a test!");
301 LFILL(6); CMP("xxxx is a test!");
302 LFILL(7); CMP("xxxx is a test!");
303 LFILL(8); CMP("xxxxxxxxa test!");
304 LFILL(9); CMP("xxxxxxxxa test!");
307 #define ZERO(len) memset(dest,0,sizeof(dest_aligned_block)); strcpy(dest, src); pRtlZeroMemory(dest,len)
308 #define MCMP(str) ok(memcmp(dest,str,LEN) == 0, "Memcmp failed\n")
310 static void test_RtlZeroMemory(void)
314 win_skip("RtlZeroMemory is not available\n");
318 /* Length should be in bytes and not rounded. */
319 ZERO(0); MCMP("This is a test!");
320 ZERO(1); MCMP("\0his is a test!");
321 ZERO(2); MCMP("\0\0is is a test!");
322 ZERO(3); MCMP("\0\0\0s is a test!");
323 ZERO(4); MCMP("\0\0\0\0 is a test!");
324 ZERO(5); MCMP("\0\0\0\0\0is a test!");
325 ZERO(6); MCMP("\0\0\0\0\0\0s a test!");
326 ZERO(7); MCMP("\0\0\0\0\0\0\0 a test!");
327 ZERO(8); MCMP("\0\0\0\0\0\0\0\0a test!");
328 ZERO(9); MCMP("\0\0\0\0\0\0\0\0\0 test!");
331 static void test_RtlUlonglongByteSwap(void)
335 if ( !pRtlUlonglongByteSwap
)
337 win_skip("RtlUlonglongByteSwap is not available\n");
341 if ( pRtlUlonglongByteSwap( 0 ) != 0 )
343 win_skip("Broken RtlUlonglongByteSwap in win2k\n");
347 result
= pRtlUlonglongByteSwap( ((ULONGLONG
)0x76543210 << 32) | 0x87654321 );
348 ok( (((ULONGLONG
)0x21436587 << 32) | 0x10325476) == result
,
349 "RtlUlonglongByteSwap(0x7654321087654321) returns 0x%x%08x, expected 0x2143658710325476\n",
350 (DWORD
)(result
>> 32), (DWORD
)result
);
354 static void test_RtlUniform(void)
364 win_skip("RtlUniform is not available\n");
369 * According to the documentation RtlUniform is using D.H. Lehmer's 1948
370 * algorithm. This algorithm is:
372 * seed = (seed * const_1 + const_2) % const_3;
374 * According to the documentation the random number is distributed over
375 * [0..MAXLONG]. Therefore const_3 is MAXLONG + 1:
377 * seed = (seed * const_1 + const_2) % (MAXLONG + 1);
379 * Because MAXLONG is 0x7fffffff (and MAXLONG + 1 is 0x80000000) the
380 * algorithm can be expressed without division as:
382 * seed = (seed * const_1 + const_2) & MAXLONG;
384 * To find out const_2 we just call RtlUniform with seed set to 0:
387 expected
= 0x7fffffc3;
388 result
= pRtlUniform(&seed
);
389 ok(result
== expected
,
390 "RtlUniform(&seed (seed == 0)) returns %x, expected %x\n",
393 * The algorithm is now:
395 * seed = (seed * const_1 + 0x7fffffc3) & MAXLONG;
397 * To find out const_1 we can use:
399 * const_1 = RtlUniform(1) - 0x7fffffc3;
401 * If that does not work a search loop can try all possible values of
402 * const_1 and compare to the result to RtlUniform(1).
403 * This way we find out that const_1 is 0xffffffed.
405 * For seed = 1 the const_2 is 0x7fffffc4:
408 expected
= seed
* 0xffffffed + 0x7fffffc3 + 1;
409 result
= pRtlUniform(&seed
);
410 ok(result
== expected
,
411 "RtlUniform(&seed (seed == 1)) returns %x, expected %x\n",
414 * For seed = 2 the const_2 is 0x7fffffc3:
417 expected
= seed
* 0xffffffed + 0x7fffffc3;
418 result
= pRtlUniform(&seed
);
421 * Windows Vista uses different algorithms, so skip the rest of the tests
422 * until that is figured out. Trace output for the failures is about 10.5 MB!
425 if (result
== 0x7fffff9f) {
426 skip("Most likely running on Windows Vista which uses a different algorithm\n");
430 ok(result
== expected
,
431 "RtlUniform(&seed (seed == 2)) returns %x, expected %x\n",
435 * More tests show that if seed is odd the result must be incremented by 1:
438 expected
= seed
* 0xffffffed + 0x7fffffc3 + (seed
& 1);
439 result
= pRtlUniform(&seed
);
440 ok(result
== expected
,
441 "RtlUniform(&seed (seed == 3)) returns %x, expected %x\n",
445 expected
= seed
* 0xffffffed + 0x7fffffc3;
446 result
= pRtlUniform(&seed
);
447 ok(result
== expected
,
448 "RtlUniform(&seed (seed == 0x6bca1aa)) returns %x, expected %x\n",
452 expected
= seed
* 0xffffffed + 0x7fffffc3 + 1;
453 result
= pRtlUniform(&seed
);
454 ok(result
== expected
,
455 "RtlUniform(&seed (seed == 0x6bca1ab)) returns %x, expected %x\n",
458 * When seed is 0x6bca1ac there is an exception:
461 expected
= seed
* 0xffffffed + 0x7fffffc3 + 2;
462 result
= pRtlUniform(&seed
);
463 ok(result
== expected
,
464 "RtlUniform(&seed (seed == 0x6bca1ac)) returns %x, expected %x\n",
467 * Note that up to here const_3 is not used
468 * (the highest bit of the result is not set).
470 * Starting with 0x6bca1ad: If seed is even the result must be incremented by 1:
473 expected
= (seed
* 0xffffffed + 0x7fffffc3) & MAXLONG
;
474 result
= pRtlUniform(&seed
);
475 ok(result
== expected
,
476 "RtlUniform(&seed (seed == 0x6bca1ad)) returns %x, expected %x\n",
480 expected
= (seed
* 0xffffffed + 0x7fffffc3 + 1) & MAXLONG
;
481 result
= pRtlUniform(&seed
);
482 ok(result
== expected
,
483 "RtlUniform(&seed (seed == 0x6bca1ae)) returns %x, expected %x\n",
486 * There are several ranges where for odd or even seed the result must be
487 * incremented by 1. You can see this ranges in the following test.
489 * For a full test use one of the following loop heads:
491 * for (num = 0; num <= 0xffffffff; num++) {
496 * for (num = 0; num <= 0xffffffff; num++) {
500 for (num
= 0; num
<= 100000; num
++) {
502 expected
= seed
* 0xffffffed + 0x7fffffc3;
503 if (seed
< 0x6bca1ac) {
504 expected
= expected
+ (seed
& 1);
505 } else if (seed
== 0x6bca1ac) {
506 expected
= (expected
+ 2) & MAXLONG
;
507 } else if (seed
< 0xd79435c) {
508 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
509 } else if (seed
< 0x1435e50b) {
510 expected
= expected
+ (seed
& 1);
511 } else if (seed
< 0x1af286ba) {
512 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
513 } else if (seed
< 0x21af2869) {
514 expected
= expected
+ (seed
& 1);
515 } else if (seed
< 0x286bca18) {
516 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
517 } else if (seed
< 0x2f286bc7) {
518 expected
= expected
+ (seed
& 1);
519 } else if (seed
< 0x35e50d77) {
520 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
521 } else if (seed
< 0x3ca1af26) {
522 expected
= expected
+ (seed
& 1);
523 } else if (seed
< 0x435e50d5) {
524 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
525 } else if (seed
< 0x4a1af284) {
526 expected
= expected
+ (seed
& 1);
527 } else if (seed
< 0x50d79433) {
528 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
529 } else if (seed
< 0x579435e2) {
530 expected
= expected
+ (seed
& 1);
531 } else if (seed
< 0x5e50d792) {
532 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
533 } else if (seed
< 0x650d7941) {
534 expected
= expected
+ (seed
& 1);
535 } else if (seed
< 0x6bca1af0) {
536 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
537 } else if (seed
< 0x7286bc9f) {
538 expected
= expected
+ (seed
& 1);
539 } else if (seed
< 0x79435e4e) {
540 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
541 } else if (seed
< 0x7ffffffd) {
542 expected
= expected
+ (seed
& 1);
543 } else if (seed
< 0x86bca1ac) {
544 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
545 } else if (seed
== 0x86bca1ac) {
546 expected
= (expected
+ 1) & MAXLONG
;
547 } else if (seed
< 0x8d79435c) {
548 expected
= expected
+ (seed
& 1);
549 } else if (seed
< 0x9435e50b) {
550 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
551 } else if (seed
< 0x9af286ba) {
552 expected
= expected
+ (seed
& 1);
553 } else if (seed
< 0xa1af2869) {
554 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
555 } else if (seed
< 0xa86bca18) {
556 expected
= expected
+ (seed
& 1);
557 } else if (seed
< 0xaf286bc7) {
558 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
559 } else if (seed
== 0xaf286bc7) {
560 expected
= (expected
+ 2) & MAXLONG
;
561 } else if (seed
< 0xb5e50d77) {
562 expected
= expected
+ (seed
& 1);
563 } else if (seed
< 0xbca1af26) {
564 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
565 } else if (seed
< 0xc35e50d5) {
566 expected
= expected
+ (seed
& 1);
567 } else if (seed
< 0xca1af284) {
568 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
569 } else if (seed
< 0xd0d79433) {
570 expected
= expected
+ (seed
& 1);
571 } else if (seed
< 0xd79435e2) {
572 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
573 } else if (seed
< 0xde50d792) {
574 expected
= expected
+ (seed
& 1);
575 } else if (seed
< 0xe50d7941) {
576 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
577 } else if (seed
< 0xebca1af0) {
578 expected
= expected
+ (seed
& 1);
579 } else if (seed
< 0xf286bc9f) {
580 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
581 } else if (seed
< 0xf9435e4e) {
582 expected
= expected
+ (seed
& 1);
583 } else if (seed
< 0xfffffffd) {
584 expected
= (expected
+ (~seed
& 1)) & MAXLONG
;
586 expected
= expected
+ (seed
& 1);
589 result
= pRtlUniform(&seed
);
590 ok(result
== expected
,
591 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) returns %x, expected %x\n",
592 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, expected
);
594 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) sets seed to %x, expected %x\n",
595 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, expected
);
598 * Further investigation shows: In the different regions the highest bit
599 * is set or cleared when even or odd seeds need an increment by 1.
600 * This leads to a simplified algorithm:
602 * seed = seed * 0xffffffed + 0x7fffffc3;
603 * if (seed == 0xffffffff || seed == 0x7ffffffe) {
604 * seed = (seed + 2) & MAXLONG;
605 * } else if (seed == 0x7fffffff) {
607 * } else if ((seed & 0x80000000) == 0) {
608 * seed = seed + (~seed & 1);
610 * seed = (seed + (seed & 1)) & MAXLONG;
613 * This is also the algorithm used for RtlUniform of wine (see dlls/ntdll/rtl.c).
615 * Now comes the funny part:
616 * It took me one weekend, to find the complicated algorithm and one day more,
617 * to find the simplified algorithm. Several weeks later I found out: The value
618 * MAXLONG (=0x7fffffff) is never returned, neither with the native function
619 * nor with the simplified algorithm. In reality the native function and our
620 * function return a random number distributed over [0..MAXLONG-1]. Note
621 * that this is different from what native documentation states [0..MAXLONG].
622 * Expressed with D.H. Lehmer's 1948 algorithm it looks like:
624 * seed = (seed * const_1 + const_2) % MAXLONG;
626 * Further investigations show that the real algorithm is:
628 * seed = (seed * 0x7fffffed + 0x7fffffc3) % MAXLONG;
630 * This is checked with the test below:
633 for (num
= 0; num
<= 100000; num
++) {
634 expected
= (seed
* 0x7fffffed + 0x7fffffc3) % 0x7fffffff;
636 result
= pRtlUniform(&seed
);
637 ok(result
== expected
,
638 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) returns %x, expected %x\n",
639 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, expected
);
641 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) sets seed to %x, expected %x\n",
642 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, expected
);
645 * More tests show that RtlUniform does not return 0x7ffffffd for seed values
646 * in the range [0..MAXLONG-1]. Additionally 2 is returned twice. This shows
647 * that there is more than one cycle of generated randon numbers ...
652 static ULONG
my_RtlRandom(PULONG seed
)
654 static ULONG saved_value
[128] =
655 { /* 0 */ 0x4c8bc0aa, 0x4c022957, 0x2232827a, 0x2f1e7626, 0x7f8bdafb, 0x5c37d02a, 0x0ab48f72, 0x2f0c4ffa,
656 /* 8 */ 0x290e1954, 0x6b635f23, 0x5d3885c0, 0x74b49ff8, 0x5155fa54, 0x6214ad3f, 0x111e9c29, 0x242a3a09,
657 /* 16 */ 0x75932ae1, 0x40ac432e, 0x54f7ba7a, 0x585ccbd5, 0x6df5c727, 0x0374dad1, 0x7112b3f1, 0x735fc311,
658 /* 24 */ 0x404331a9, 0x74d97781, 0x64495118, 0x323e04be, 0x5974b425, 0x4862e393, 0x62389c1d, 0x28a68b82,
659 /* 32 */ 0x0f95da37, 0x7a50bbc6, 0x09b0091c, 0x22cdb7b4, 0x4faaed26, 0x66417ccd, 0x189e4bfa, 0x1ce4e8dd,
660 /* 40 */ 0x5274c742, 0x3bdcf4dc, 0x2d94e907, 0x32eac016, 0x26d33ca3, 0x60415a8a, 0x31f57880, 0x68c8aa52,
661 /* 48 */ 0x23eb16da, 0x6204f4a1, 0x373927c1, 0x0d24eb7c, 0x06dd7379, 0x2b3be507, 0x0f9c55b1, 0x2c7925eb,
662 /* 56 */ 0x36d67c9a, 0x42f831d9, 0x5e3961cb, 0x65d637a8, 0x24bb3820, 0x4d08e33d, 0x2188754f, 0x147e409e,
663 /* 64 */ 0x6a9620a0, 0x62e26657, 0x7bd8ce81, 0x11da0abb, 0x5f9e7b50, 0x23e444b6, 0x25920c78, 0x5fc894f0,
664 /* 72 */ 0x5e338cbb, 0x404237fd, 0x1d60f80f, 0x320a1743, 0x76013d2b, 0x070294ee, 0x695e243b, 0x56b177fd,
665 /* 80 */ 0x752492e1, 0x6decd52f, 0x125f5219, 0x139d2e78, 0x1898d11e, 0x2f7ee785, 0x4db405d8, 0x1a028a35,
666 /* 88 */ 0x63f6f323, 0x1f6d0078, 0x307cfd67, 0x3f32a78a, 0x6980796c, 0x462b3d83, 0x34b639f2, 0x53fce379,
667 /* 96 */ 0x74ba50f4, 0x1abc2c4b, 0x5eeaeb8d, 0x335a7a0d, 0x3973dd20, 0x0462d66b, 0x159813ff, 0x1e4643fd,
668 /* 104 */ 0x06bc5c62, 0x3115e3fc, 0x09101613, 0x47af2515, 0x4f11ec54, 0x78b99911, 0x3db8dd44, 0x1ec10b9b,
669 /* 112 */ 0x5b5506ca, 0x773ce092, 0x567be81a, 0x5475b975, 0x7a2cde1a, 0x494536f5, 0x34737bb4, 0x76d9750b,
670 /* 120 */ 0x2a1f6232, 0x2e49644d, 0x7dddcbe7, 0x500cebdb, 0x619dab9e, 0x48c626fe, 0x1cda3193, 0x52dabe9d };
675 rand
= (*seed
* 0x7fffffed + 0x7fffffc3) % 0x7fffffff;
676 *seed
= (rand
* 0x7fffffed + 0x7fffffc3) % 0x7fffffff;
678 result
= saved_value
[pos
];
679 saved_value
[pos
] = rand
;
684 static void test_RtlRandom(void)
691 ULONG result_expected
;
695 win_skip("RtlRandom is not available\n");
700 * Unlike RtlUniform, RtlRandom is not documented. We guess that for
701 * RtlRandom D.H. Lehmer's 1948 algorithm is used like stated in
702 * the documentation of the RtlUniform function. This algorithm is:
704 * seed = (seed * const_1 + const_2) % const_3;
706 * According to the RtlUniform documentation the random number is
707 * distributed over [0..MAXLONG], but in reality it is distributed
708 * over [0..MAXLONG-1]. Therefore const_3 might be MAXLONG + 1 or
711 * seed = (seed * const_1 + const_2) % (MAXLONG + 1);
715 * seed = (seed * const_1 + const_2) % MAXLONG;
717 * To find out const_2 we just call RtlRandom with seed set to 0:
720 result_expected
= 0x320a1743;
721 seed_expected
=0x44b;
722 result
= pRtlRandom(&seed
);
725 * Windows Vista uses different algorithms, so skip the rest of the tests
726 * until that is figured out. Trace output for the failures is about 10.5 MB!
730 skip("Most likely running on Windows Vista which uses a different algorithm\n");
734 ok(result
== result_expected
,
735 "pRtlRandom(&seed (seed == 0)) returns %x, expected %x\n",
736 result
, result_expected
);
737 ok(seed
== seed_expected
,
738 "pRtlRandom(&seed (seed == 0)) sets seed to %x, expected %x\n",
739 seed
, seed_expected
);
741 * Seed is not equal to result as with RtlUniform. To see more we
742 * call RtlRandom again with seed set to 0:
745 result_expected
= 0x7fffffc3;
746 seed_expected
=0x44b;
747 result
= pRtlRandom(&seed
);
748 ok(result
== result_expected
,
749 "RtlRandom(&seed (seed == 0)) returns %x, expected %x\n",
750 result
, result_expected
);
751 ok(seed
== seed_expected
,
752 "RtlRandom(&seed (seed == 0)) sets seed to %x, expected %x\n",
753 seed
, seed_expected
);
755 * Seed is set to the same value as before but the result is different.
756 * To see more we call RtlRandom again with seed set to 0:
759 result_expected
= 0x7fffffc3;
760 seed_expected
=0x44b;
761 result
= pRtlRandom(&seed
);
762 ok(result
== result_expected
,
763 "RtlRandom(&seed (seed == 0)) returns %x, expected %x\n",
764 result
, result_expected
);
765 ok(seed
== seed_expected
,
766 "RtlRandom(&seed (seed == 0)) sets seed to %x, expected %x\n",
767 seed
, seed_expected
);
769 * Seed is again set to the same value as before. This time we also
770 * have the same result as before. Interestingly the value of the
771 * result is 0x7fffffc3 which is the same value used in RtlUniform
772 * as const_2. If we do
775 * result = RtlUniform(&seed);
777 * we get the same result (0x7fffffc3) as with
782 * result = RtlRandom(&seed);
784 * And there is another interesting thing. If we do
790 * seed is set to the value 0x44b which ist the same value that
795 * assigns to seed. Putting these two findings together leads to
796 * the conclusion that RtlRandom saves the value in some variable,
797 * like in the following algorithm:
799 * result = saved_value;
800 * saved_value = RtlUniform(&seed);
804 * Now we do further tests with seed set to 1:
807 result_expected
= 0x7a50bbc6;
808 seed_expected
=0x5a1;
809 result
= pRtlRandom(&seed
);
810 ok(result
== result_expected
,
811 "RtlRandom(&seed (seed == 1)) returns %x, expected %x\n",
812 result
, result_expected
);
813 ok(seed
== seed_expected
,
814 "RtlRandom(&seed (seed == 1)) sets seed to %x, expected %x\n",
815 seed
, seed_expected
);
817 * If there is just one saved_value the result now would be
818 * 0x7fffffc3. From this test we can see that there is more than
819 * one saved_value, like with this algorithm:
821 * result = saved_value[pos];
822 * saved_value[pos] = RtlUniform(&seed);
826 * But how is the value of pos determined? The calls to RtlUniform
827 * create a sequence of random numbers. Every second random number
828 * is put into the saved_value array and is used in some later call
829 * of RtlRandom as result. The only reasonable source to determine
830 * pos are the random numbers generated by RtlUniform which are not
831 * put into the saved_value array. This are the values of seed
832 * between the two calls of RtlUniform as in this algorithm:
834 * rand = RtlUniform(&seed);
836 * pos = position(seed);
837 * result = saved_value[pos];
838 * saved_value[pos] = rand;
841 * What remains to be determined is: The size of the saved_value array,
842 * the initial values of the saved_value array and the function
843 * position(seed). These tests are not shown here.
844 * The result of these tests is: The size of the saved_value array
845 * is 128, the initial values can be seen in the my_RtlRandom
846 * function and the position(seed) function is (seed & 0x7f).
848 * For a full test of RtlRandom use one of the following loop heads:
850 * for (num = 0; num <= 0xffffffff; num++) {
855 * for (num = 0; num <= 0xffffffff; num++) {
859 for (num
= 0; num
<= 100000; num
++) {
861 seed_expected
= seed
;
862 result_expected
= my_RtlRandom(&seed_expected
);
863 /* The following corrections are necessary because the */
864 /* previous tests changed the saved_value array */
866 result_expected
= 0x7fffffc3;
867 } else if (num
== 81) {
868 result_expected
= 0x7fffffb1;
870 result
= pRtlRandom(&seed
);
871 ok(result
== result_expected
,
872 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) returns %x, expected %x\n",
873 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, result_expected
);
874 ok(seed
== seed_expected
,
875 "test: 0x%x%08x RtlUniform(&seed (seed == %x)) sets seed to %x, expected %x\n",
876 (DWORD
)(num
>> 32), (DWORD
)num
, seed_bak
, result
, seed_expected
);
882 ACCESS_MASK GrantedAccess
;
883 ACCESS_MASK DesiredAccess
;
887 static const all_accesses_t all_accesses
[] = {
888 {0xFEDCBA76, 0xFEDCBA76, 1},
889 {0x00000000, 0xFEDCBA76, 0},
890 {0xFEDCBA76, 0x00000000, 1},
891 {0x00000000, 0x00000000, 1},
892 {0xFEDCBA76, 0xFEDCBA70, 1},
893 {0xFEDCBA70, 0xFEDCBA76, 0},
894 {0xFEDCBA76, 0xFEDC8A76, 1},
895 {0xFEDC8A76, 0xFEDCBA76, 0},
896 {0xFEDCBA76, 0xC8C4B242, 1},
897 {0xC8C4B242, 0xFEDCBA76, 0},
899 #define NB_ALL_ACCESSES (sizeof(all_accesses)/sizeof(*all_accesses))
902 static void test_RtlAreAllAccessesGranted(void)
904 unsigned int test_num
;
907 if (!pRtlAreAllAccessesGranted
)
909 win_skip("RtlAreAllAccessesGranted is not available\n");
913 for (test_num
= 0; test_num
< NB_ALL_ACCESSES
; test_num
++) {
914 result
= pRtlAreAllAccessesGranted(all_accesses
[test_num
].GrantedAccess
,
915 all_accesses
[test_num
].DesiredAccess
);
916 ok(all_accesses
[test_num
].result
== result
,
917 "(test %d): RtlAreAllAccessesGranted(%08x, %08x) returns %d, expected %d\n",
918 test_num
, all_accesses
[test_num
].GrantedAccess
,
919 all_accesses
[test_num
].DesiredAccess
,
920 result
, all_accesses
[test_num
].result
);
926 ACCESS_MASK GrantedAccess
;
927 ACCESS_MASK DesiredAccess
;
931 static const any_accesses_t any_accesses
[] = {
932 {0xFEDCBA76, 0xFEDCBA76, 1},
933 {0x00000000, 0xFEDCBA76, 0},
934 {0xFEDCBA76, 0x00000000, 0},
935 {0x00000000, 0x00000000, 0},
936 {0xFEDCBA76, 0x01234589, 0},
937 {0x00040000, 0xFEDCBA76, 1},
938 {0x00040000, 0xFED8BA76, 0},
939 {0xFEDCBA76, 0x00040000, 1},
940 {0xFED8BA76, 0x00040000, 0},
942 #define NB_ANY_ACCESSES (sizeof(any_accesses)/sizeof(*any_accesses))
945 static void test_RtlAreAnyAccessesGranted(void)
947 unsigned int test_num
;
950 if (!pRtlAreAnyAccessesGranted
)
952 win_skip("RtlAreAnyAccessesGranted is not available\n");
956 for (test_num
= 0; test_num
< NB_ANY_ACCESSES
; test_num
++) {
957 result
= pRtlAreAnyAccessesGranted(any_accesses
[test_num
].GrantedAccess
,
958 any_accesses
[test_num
].DesiredAccess
);
959 ok(any_accesses
[test_num
].result
== result
,
960 "(test %d): RtlAreAnyAccessesGranted(%08x, %08x) returns %d, expected %d\n",
961 test_num
, any_accesses
[test_num
].GrantedAccess
,
962 any_accesses
[test_num
].DesiredAccess
,
963 result
, any_accesses
[test_num
].result
);
967 static void test_RtlComputeCrc32(void)
971 if (!pRtlComputeCrc32
)
973 win_skip("RtlComputeCrc32 is not available\n");
977 crc
= pRtlComputeCrc32(crc
, (const BYTE
*)src
, LEN
);
978 ok(crc
== 0x40861dc2,"Expected 0x40861dc2, got %8x\n", crc
);
982 typedef struct MY_HANDLE
984 RTL_HANDLE RtlHandle
;
988 static inline void RtlpMakeHandleAllocated(RTL_HANDLE
* Handle
)
990 ULONG_PTR
*AllocatedBit
= (ULONG_PTR
*)(&Handle
->Next
);
991 *AllocatedBit
= *AllocatedBit
| 1;
994 static void test_HandleTables(void)
999 MY_HANDLE
* MyHandle
;
1000 RTL_HANDLE_TABLE HandleTable
;
1002 if (!pRtlInitializeHandleTable
)
1004 win_skip("RtlInitializeHandleTable is not available\n");
1008 pRtlInitializeHandleTable(0x3FFF, sizeof(MY_HANDLE
), &HandleTable
);
1009 MyHandle
= (MY_HANDLE
*)pRtlAllocateHandle(&HandleTable
, &Index
);
1010 ok(MyHandle
!= NULL
, "RtlAllocateHandle failed\n");
1011 RtlpMakeHandleAllocated(&MyHandle
->RtlHandle
);
1013 result
= pRtlIsValidIndexHandle(&HandleTable
, Index
, (RTL_HANDLE
**)&MyHandle
);
1014 ok(result
, "Handle %p wasn't valid\n", MyHandle
);
1015 result
= pRtlFreeHandle(&HandleTable
, &MyHandle
->RtlHandle
);
1016 ok(result
, "Couldn't free handle %p\n", MyHandle
);
1017 status
= pRtlDestroyHandleTable(&HandleTable
);
1018 ok(status
== STATUS_SUCCESS
, "RtlDestroyHandleTable failed with error 0x%08x\n", status
);
1021 static void test_RtlAllocateAndInitializeSid(void)
1024 SID_IDENTIFIER_AUTHORITY sia
= {{ 1, 2, 3, 4, 5, 6 }};
1027 if (!pRtlAllocateAndInitializeSid
)
1029 win_skip("RtlAllocateAndInitializeSid is not available\n");
1033 ret
= pRtlAllocateAndInitializeSid(&sia
, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid
);
1034 ok(!ret
, "RtlAllocateAndInitializeSid error %08x\n", ret
);
1035 ret
= pRtlFreeSid(psid
);
1036 ok(!ret
, "RtlFreeSid error %08x\n", ret
);
1038 /* these tests crash on XP */
1041 pRtlAllocateAndInitializeSid(NULL
, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid
);
1042 pRtlAllocateAndInitializeSid(&sia
, 0, 1, 2, 3, 4, 5, 6, 7, 8, NULL
);
1045 ret
= pRtlAllocateAndInitializeSid(&sia
, 9, 1, 2, 3, 4, 5, 6, 7, 8, &psid
);
1046 ok(ret
== STATUS_INVALID_SID
, "wrong error %08x\n", ret
);
1049 static void test_RtlDeleteTimer(void)
1053 if (!pRtlDeleteTimer
)
1055 win_skip("RtlDeleteTimer is not available\n");
1059 ret
= pRtlDeleteTimer(NULL
, NULL
, NULL
);
1060 ok(ret
== STATUS_INVALID_PARAMETER_1
||
1061 ret
== STATUS_INVALID_PARAMETER
, /* W2K */
1062 "expected STATUS_INVALID_PARAMETER_1 or STATUS_INVALID_PARAMETER, got %x\n", ret
);
1065 static void test_RtlThreadErrorMode(void)
1072 if (!pRtlGetThreadErrorMode
|| !pRtlSetThreadErrorMode
)
1074 win_skip("RtlGetThreadErrorMode and/or RtlSetThreadErrorMode not available\n");
1078 if (!pIsWow64Process
|| !pIsWow64Process(GetCurrentProcess(), &is_wow64
))
1081 oldmode
= pRtlGetThreadErrorMode();
1083 status
= pRtlSetThreadErrorMode(0x70, &mode
);
1084 ok(status
== STATUS_SUCCESS
||
1085 status
== STATUS_WAIT_1
, /* Vista */
1086 "RtlSetThreadErrorMode failed with error 0x%08x\n", status
);
1088 "RtlSetThreadErrorMode returned mode 0x%x, expected 0x%x\n",
1090 ok(pRtlGetThreadErrorMode() == 0x70,
1091 "RtlGetThreadErrorMode returned 0x%x, expected 0x%x\n", mode
, 0x70);
1092 if (!is_wow64
&& pNtCurrentTeb
)
1093 ok(pNtCurrentTeb()->HardErrorDisabled
== 0x70,
1094 "The TEB contains 0x%x, expected 0x%x\n",
1095 pNtCurrentTeb()->HardErrorDisabled
, 0x70);
1097 status
= pRtlSetThreadErrorMode(0, &mode
);
1098 ok(status
== STATUS_SUCCESS
||
1099 status
== STATUS_WAIT_1
, /* Vista */
1100 "RtlSetThreadErrorMode failed with error 0x%08x\n", status
);
1102 "RtlSetThreadErrorMode returned mode 0x%x, expected 0x%x\n",
1104 ok(pRtlGetThreadErrorMode() == 0,
1105 "RtlGetThreadErrorMode returned 0x%x, expected 0x%x\n", mode
, 0);
1106 if (!is_wow64
&& pNtCurrentTeb
)
1107 ok(pNtCurrentTeb()->HardErrorDisabled
== 0,
1108 "The TEB contains 0x%x, expected 0x%x\n",
1109 pNtCurrentTeb()->HardErrorDisabled
, 0);
1111 for (mode
= 1; mode
; mode
<<= 1)
1113 status
= pRtlSetThreadErrorMode(mode
, NULL
);
1115 ok(status
== STATUS_SUCCESS
||
1116 status
== STATUS_WAIT_1
, /* Vista */
1117 "RtlSetThreadErrorMode(%x,NULL) failed with error 0x%08x\n",
1120 ok(status
== STATUS_INVALID_PARAMETER_1
,
1121 "RtlSetThreadErrorMode(%x,NULL) returns 0x%08x, "
1122 "expected STATUS_INVALID_PARAMETER_1\n",
1126 pRtlSetThreadErrorMode(oldmode
, NULL
);
1129 static void test_LdrProcessRelocationBlock(void)
1131 IMAGE_BASE_RELOCATION
*ret
;
1136 if(!pLdrProcessRelocationBlock
) {
1137 win_skip("LdrProcessRelocationBlock not available\n");
1142 reloc
= IMAGE_REL_BASED_HIGHLOW
<<12;
1143 ret
= pLdrProcessRelocationBlock(&addr32
, 1, &reloc
, 0x500050);
1144 ok((USHORT
*)ret
== &reloc
+1, "ret = %p, expected %p\n", ret
, &reloc
+1);
1145 ok(addr32
== 0x550055, "addr32 = %x, expected 0x550055\n", addr32
);
1148 reloc
= IMAGE_REL_BASED_HIGH
<<12;
1149 ret
= pLdrProcessRelocationBlock(&addr16
, 1, &reloc
, 0x500060);
1150 ok((USHORT
*)ret
== &reloc
+1, "ret = %p, expected %p\n", ret
, &reloc
+1);
1151 ok(addr16
== 0x555, "addr16 = %x, expected 0x555\n", addr16
);
1154 reloc
= IMAGE_REL_BASED_LOW
<<12;
1155 ret
= pLdrProcessRelocationBlock(&addr16
, 1, &reloc
, 0x500060);
1156 ok((USHORT
*)ret
== &reloc
+1, "ret = %p, expected %p\n", ret
, &reloc
+1);
1157 ok(addr16
== 0x565, "addr16 = %x, expected 0x565\n", addr16
);
1160 static void test_RtlIpv4AddressToString(void)
1167 if (!pRtlIpv4AddressToStringA
)
1169 win_skip("RtlIpv4AddressToStringA not available\n");
1173 ip
.S_un
.S_un_b
.s_b1
= 1;
1174 ip
.S_un
.S_un_b
.s_b2
= 2;
1175 ip
.S_un
.S_un_b
.s_b3
= 3;
1176 ip
.S_un
.S_un_b
.s_b4
= 4;
1178 memset(buffer
, '#', sizeof(buffer
) - 1);
1179 buffer
[sizeof(buffer
) -1] = 0;
1180 res
= pRtlIpv4AddressToStringA(&ip
, buffer
);
1181 len
= strlen(buffer
);
1182 ok(res
== (buffer
+ len
), "got %p with '%s' (expected %p)\n", res
, buffer
, buffer
+ len
);
1184 res
= pRtlIpv4AddressToStringA(&ip
, NULL
);
1185 ok( (res
== (char *)~0) ||
1186 broken(res
== (char *)len
), /* XP and w2003 */
1187 "got %p (expected ~0)\n", res
);
1190 /* this crashes in windows */
1191 memset(buffer
, '#', sizeof(buffer
) - 1);
1192 buffer
[sizeof(buffer
) -1] = 0;
1193 res
= pRtlIpv4AddressToStringA(NULL
, buffer
);
1194 trace("got %p with '%s'\n", res
, buffer
);
1198 /* this crashes in windows */
1199 res
= pRtlIpv4AddressToStringA(NULL
, NULL
);
1200 trace("got %p\n", res
);
1204 static void test_RtlIpv4AddressToStringEx(void)
1206 CHAR ip_1234
[] = "1.2.3.4";
1207 CHAR ip_1234_80
[] = "1.2.3.4:80";
1216 if (!pRtlIpv4AddressToStringExA
)
1218 win_skip("RtlIpv4AddressToStringExA not available\n");
1222 ip
.S_un
.S_un_b
.s_b1
= 1;
1223 ip
.S_un
.S_un_b
.s_b2
= 2;
1224 ip
.S_un
.S_un_b
.s_b3
= 3;
1225 ip
.S_un
.S_un_b
.s_b4
= 4;
1228 expect
= ip_1234_80
;
1230 size
= sizeof(buffer
);
1231 memset(buffer
, '#', sizeof(buffer
) - 1);
1232 buffer
[sizeof(buffer
) -1] = 0;
1233 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1234 used
= strlen(buffer
);
1235 ok( (res
== STATUS_SUCCESS
) &&
1236 (size
== strlen(expect
) + 1) && !strcmp(buffer
, expect
),
1237 "got 0x%x and size %d with '%s'\n", res
, size
, buffer
);
1240 memset(buffer
, '#', sizeof(buffer
) - 1);
1241 buffer
[sizeof(buffer
) -1] = 0;
1242 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1243 ok( (res
== STATUS_SUCCESS
) &&
1244 (size
== strlen(expect
) + 1) && !strcmp(buffer
, expect
),
1245 "got 0x%x and size %d with '%s'\n", res
, size
, buffer
);
1248 memset(buffer
, '#', sizeof(buffer
) - 1);
1249 buffer
[sizeof(buffer
) -1] = 0;
1250 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1251 ok( (res
== STATUS_INVALID_PARAMETER
) && (size
== used
+ 1),
1252 "got 0x%x and %d with '%s' (expected STATUS_INVALID_PARAMETER and %d)\n",
1253 res
, size
, buffer
, used
+ 1);
1256 memset(buffer
, '#', sizeof(buffer
) - 1);
1257 buffer
[sizeof(buffer
) -1] = 0;
1258 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1259 ok( (res
== STATUS_INVALID_PARAMETER
) && (size
== used
+ 1),
1260 "got 0x%x and %d with '%s' (expected STATUS_INVALID_PARAMETER and %d)\n",
1261 res
, size
, buffer
, used
+ 1);
1264 /* to get only the ip, use 0 as port */
1268 size
= sizeof(buffer
);
1269 memset(buffer
, '#', sizeof(buffer
) - 1);
1270 buffer
[sizeof(buffer
) -1] = 0;
1271 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1272 used
= strlen(buffer
);
1273 ok( (res
== STATUS_SUCCESS
) &&
1274 (size
== strlen(expect
) + 1) && !strcmp(buffer
, expect
),
1275 "got 0x%x and size %d with '%s'\n", res
, size
, buffer
);
1278 memset(buffer
, '#', sizeof(buffer
) - 1);
1279 buffer
[sizeof(buffer
) -1] = 0;
1280 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1281 ok( (res
== STATUS_SUCCESS
) &&
1282 (size
== strlen(expect
) + 1) && !strcmp(buffer
, expect
),
1283 "got 0x%x and size %d with '%s'\n", res
, size
, buffer
);
1286 memset(buffer
, '#', sizeof(buffer
) - 1);
1287 buffer
[sizeof(buffer
) -1] = 0;
1288 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1289 ok( (res
== STATUS_INVALID_PARAMETER
) && (size
== used
+ 1),
1290 "got 0x%x and %d with '%s' (expected STATUS_INVALID_PARAMETER and %d)\n",
1291 res
, size
, buffer
, used
+ 1);
1294 memset(buffer
, '#', sizeof(buffer
) - 1);
1295 buffer
[sizeof(buffer
) -1] = 0;
1296 res
= pRtlIpv4AddressToStringExA(&ip
, port
, buffer
, &size
);
1297 ok( (res
== STATUS_INVALID_PARAMETER
) && (size
== used
+ 1),
1298 "got 0x%x and %d with '%s' (expected STATUS_INVALID_PARAMETER and %d)\n",
1299 res
, size
, buffer
, used
+ 1);
1302 /* parameters are checked */
1303 memset(buffer
, '#', sizeof(buffer
) - 1);
1304 buffer
[sizeof(buffer
) -1] = 0;
1305 res
= pRtlIpv4AddressToStringExA(&ip
, 0, buffer
, NULL
);
1306 ok(res
== STATUS_INVALID_PARAMETER
,
1307 "got 0x%x with '%s' (expected STATUS_INVALID_PARAMETER)\n", res
, buffer
);
1309 size
= sizeof(buffer
);
1310 res
= pRtlIpv4AddressToStringExA(&ip
, 0, NULL
, &size
);
1311 ok( res
== STATUS_INVALID_PARAMETER
,
1312 "got 0x%x and size %d (expected STATUS_INVALID_PARAMETER)\n", res
, size
);
1314 size
= sizeof(buffer
);
1315 memset(buffer
, '#', sizeof(buffer
) - 1);
1316 buffer
[sizeof(buffer
) -1] = 0;
1317 res
= pRtlIpv4AddressToStringExA(NULL
, 0, buffer
, &size
);
1318 ok( res
== STATUS_INVALID_PARAMETER
,
1319 "got 0x%x and size %d with '%s' (expected STATUS_INVALID_PARAMETER)\n",
1323 static void test_RtlIpv4StringToAddress(void)
1326 IN_ADDR ip
, expected_ip
;
1333 int terminator_offset
;
1335 BOOL strict_is_different
;
1336 NTSTATUS res_strict
;
1337 int terminator_offset_strict
;
1341 { "", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1342 { " ", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1343 { "1.1.1.1", STATUS_SUCCESS
, 7, { 1, 1, 1, 1 } },
1344 { "0.0.0.0", STATUS_SUCCESS
, 7, { 0, 0, 0, 0 } },
1345 { "255.255.255.255", STATUS_SUCCESS
, 15, { 255, 255, 255, 255 } },
1346 { "255.255.255.255:123",
1347 STATUS_SUCCESS
, 15, { 255, 255, 255, 255 } },
1348 { "255.255.255.256", STATUS_INVALID_PARAMETER
, 15, { -1 } },
1349 { "255.255.255.4294967295",
1350 STATUS_INVALID_PARAMETER
, 22, { -1 } },
1351 { "255.255.255.4294967296",
1352 STATUS_INVALID_PARAMETER
, 21, { -1 } },
1353 { "255.255.255.4294967297",
1354 STATUS_INVALID_PARAMETER
, 21, { -1 } },
1355 { "a", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1356 { "1.1.1.0xaA", STATUS_SUCCESS
, 10, { 1, 1, 1, 170 },
1357 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1358 { "1.1.1.0XaA", STATUS_SUCCESS
, 10, { 1, 1, 1, 170 },
1359 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1360 { "1.1.1.0x", STATUS_INVALID_PARAMETER
, 8, { -1 } },
1361 { "1.1.1.0xff", STATUS_SUCCESS
, 10, { 1, 1, 1, 255 },
1362 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1363 { "1.1.1.0x100", STATUS_INVALID_PARAMETER
, 11, { -1 },
1364 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1365 { "1.1.1.0xffffffff",STATUS_INVALID_PARAMETER
, 16, { -1 },
1366 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1367 { "1.1.1.0x100000000",
1368 STATUS_INVALID_PARAMETER
, 16, { -1, 0, 0, 0 },
1369 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1370 { "1.1.1.010", STATUS_SUCCESS
, 9, { 1, 1, 1, 8 },
1371 TRUE
, STATUS_INVALID_PARAMETER
, 7, { -1 } },
1372 { "1.1.1.00", STATUS_SUCCESS
, 8, { 1, 1, 1, 0 },
1373 TRUE
, STATUS_INVALID_PARAMETER
, 7, { -1 } },
1374 { "1.1.1.007", STATUS_SUCCESS
, 9, { 1, 1, 1, 7 },
1375 TRUE
, STATUS_INVALID_PARAMETER
, 7, { -1 } },
1376 { "1.1.1.08", STATUS_INVALID_PARAMETER
, 7, { -1 } },
1377 { "1.1.1.008", STATUS_SUCCESS
, 8, { 1, 1, 1, 0 },
1378 TRUE
, STATUS_INVALID_PARAMETER
, 7, { -1 } },
1379 { "1.1.1.0a", STATUS_SUCCESS
, 7, { 1, 1, 1, 0 } },
1380 { "1.1.1.0o10", STATUS_SUCCESS
, 7, { 1, 1, 1, 0 } },
1381 { "1.1.1.0b10", STATUS_SUCCESS
, 7, { 1, 1, 1, 0 } },
1382 { "1.1.1.-2", STATUS_INVALID_PARAMETER
, 6, { -1 } },
1383 { "1", STATUS_SUCCESS
, 1, { 0, 0, 0, 1 },
1384 TRUE
, STATUS_INVALID_PARAMETER
, 1, { -1 } },
1385 { "-1", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1386 { "203569230", STATUS_SUCCESS
, 9, { 12, 34, 56, 78 },
1387 TRUE
, STATUS_INVALID_PARAMETER
, 9, { -1 } },
1388 { "1.223756", STATUS_SUCCESS
, 8, { 1, 3, 106, 12 },
1389 TRUE
, STATUS_INVALID_PARAMETER
, 8, { -1 } },
1390 { "3.4.756", STATUS_SUCCESS
, 7, { 3, 4, 2, 244 },
1391 TRUE
, STATUS_INVALID_PARAMETER
, 7, { -1 } },
1392 { "3.4.756.1", STATUS_INVALID_PARAMETER
, 9, { -1 } },
1393 { "3.4.65536", STATUS_INVALID_PARAMETER
, 9, { -1 } },
1394 { "3.4.5.6.7", STATUS_INVALID_PARAMETER
, 7, { -1 } },
1395 { "3.4.5.+6", STATUS_INVALID_PARAMETER
, 6, { -1 } },
1396 { " 3.4.5.6", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1397 { "\t3.4.5.6", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1398 { "3.4.5.6 ", STATUS_SUCCESS
, 7, { 3, 4, 5, 6 } },
1399 { "3. 4.5.6", STATUS_INVALID_PARAMETER
, 2, { -1 } },
1400 { ".", STATUS_INVALID_PARAMETER
, 1, { -1 } },
1401 { "..", STATUS_INVALID_PARAMETER
, 1, { -1 } },
1402 { "1.", STATUS_INVALID_PARAMETER
, 2, { -1 } },
1403 { "1..", STATUS_INVALID_PARAMETER
, 3, { -1 } },
1404 { ".1", STATUS_INVALID_PARAMETER
, 1, { -1 } },
1405 { ".1.", STATUS_INVALID_PARAMETER
, 1, { -1 } },
1406 { ".1.2.3", STATUS_INVALID_PARAMETER
, 1, { -1 } },
1407 { "0.1.2.3", STATUS_SUCCESS
, 7, { 0, 1, 2, 3 } },
1408 { "0.1.2.3.", STATUS_INVALID_PARAMETER
, 7, { -1 } },
1409 { "[0.1.2.3]", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1410 { "::1", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1411 { ":1", STATUS_INVALID_PARAMETER
, 0, { -1 } },
1413 const int testcount
= sizeof(tests
) / sizeof(tests
[0]);
1416 if (!pRtlIpv4StringToAddressA
)
1418 skip("RtlIpv4StringToAddress not available\n");
1424 /* leaving either parameter NULL crashes on Windows */
1425 res
= pRtlIpv4StringToAddressA(NULL
, FALSE
, &terminator
, &ip
);
1426 res
= pRtlIpv4StringToAddressA("1.1.1.1", FALSE
, NULL
, &ip
);
1427 res
= pRtlIpv4StringToAddressA("1.1.1.1", FALSE
, &terminator
, NULL
);
1428 /* same for the wide char version */
1430 res = pRtlIpv4StringToAddressW(NULL, FALSE, &terminatorW, &ip);
1431 res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, NULL, &ip);
1432 res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, &terminatorW, NULL);
1436 for (i
= 0; i
< testcount
; i
++)
1439 terminator
= &dummy
;
1440 ip
.S_un
.S_addr
= 0xabababab;
1441 res
= pRtlIpv4StringToAddressA(tests
[i
].address
, FALSE
, &terminator
, &ip
);
1442 ok(res
== tests
[i
].res
,
1443 "[%s] res = 0x%08x, expected 0x%08x\n",
1444 tests
[i
].address
, res
, tests
[i
].res
);
1445 ok(terminator
== tests
[i
].address
+ tests
[i
].terminator_offset
,
1446 "[%s] terminator = %p, expected %p\n",
1447 tests
[i
].address
, terminator
, tests
[i
].address
+ tests
[i
].terminator_offset
);
1448 if (tests
[i
].ip
[0] == -1)
1449 expected_ip
.S_un
.S_addr
= 0xabababab;
1452 expected_ip
.S_un
.S_un_b
.s_b1
= tests
[i
].ip
[0];
1453 expected_ip
.S_un
.S_un_b
.s_b2
= tests
[i
].ip
[1];
1454 expected_ip
.S_un
.S_un_b
.s_b3
= tests
[i
].ip
[2];
1455 expected_ip
.S_un
.S_un_b
.s_b4
= tests
[i
].ip
[3];
1457 ok(ip
.S_un
.S_addr
== expected_ip
.S_un
.S_addr
,
1458 "[%s] ip = %08x, expected %08x\n",
1459 tests
[i
].address
, ip
.S_un
.S_addr
, expected_ip
.S_un
.S_addr
);
1461 if (!tests
[i
].strict_is_different
)
1463 tests
[i
].res_strict
= tests
[i
].res
;
1464 tests
[i
].terminator_offset_strict
= tests
[i
].terminator_offset
;
1465 tests
[i
].ip_strict
[0] = tests
[i
].ip
[0];
1466 tests
[i
].ip_strict
[1] = tests
[i
].ip
[1];
1467 tests
[i
].ip_strict
[2] = tests
[i
].ip
[2];
1468 tests
[i
].ip_strict
[3] = tests
[i
].ip
[3];
1471 terminator
= &dummy
;
1472 ip
.S_un
.S_addr
= 0xabababab;
1473 res
= pRtlIpv4StringToAddressA(tests
[i
].address
, TRUE
, &terminator
, &ip
);
1474 ok(res
== tests
[i
].res_strict
,
1475 "[%s] res = 0x%08x, expected 0x%08x\n",
1476 tests
[i
].address
, res
, tests
[i
].res_strict
);
1477 ok(terminator
== tests
[i
].address
+ tests
[i
].terminator_offset_strict
,
1478 "[%s] terminator = %p, expected %p\n",
1479 tests
[i
].address
, terminator
, tests
[i
].address
+ tests
[i
].terminator_offset_strict
);
1480 if (tests
[i
].ip_strict
[0] == -1)
1481 expected_ip
.S_un
.S_addr
= 0xabababab;
1484 expected_ip
.S_un
.S_un_b
.s_b1
= tests
[i
].ip_strict
[0];
1485 expected_ip
.S_un
.S_un_b
.s_b2
= tests
[i
].ip_strict
[1];
1486 expected_ip
.S_un
.S_un_b
.s_b3
= tests
[i
].ip_strict
[2];
1487 expected_ip
.S_un
.S_un_b
.s_b4
= tests
[i
].ip_strict
[3];
1489 ok(ip
.S_un
.S_addr
== expected_ip
.S_un
.S_addr
,
1490 "[%s] ip = %08x, expected %08x\n",
1491 tests
[i
].address
, ip
.S_un
.S_addr
, expected_ip
.S_un
.S_addr
);
1495 static void test_LdrAddRefDll(void)
1503 win_skip( "LdrAddRefDll not supported\n" );
1507 mod
= LoadLibraryA("comctl32.dll");
1508 ok(mod
!= NULL
, "got %p\n", mod
);
1509 ret
= FreeLibrary(mod
);
1510 ok(ret
, "got %d\n", ret
);
1512 mod2
= GetModuleHandleA("comctl32.dll");
1513 ok(mod2
== NULL
, "got %p\n", mod2
);
1515 /* load, addref and release 2 times */
1516 mod
= LoadLibraryA("comctl32.dll");
1517 ok(mod
!= NULL
, "got %p\n", mod
);
1518 status
= pLdrAddRefDll(0, mod
);
1519 ok(status
== STATUS_SUCCESS
, "got 0x%08x\n", status
);
1520 ret
= FreeLibrary(mod
);
1521 ok(ret
, "got %d\n", ret
);
1523 mod2
= GetModuleHandleA("comctl32.dll");
1524 ok(mod2
!= NULL
, "got %p\n", mod2
);
1525 ret
= FreeLibrary(mod
);
1526 ok(ret
, "got %d\n", ret
);
1528 mod2
= GetModuleHandleA("comctl32.dll");
1529 ok(mod2
== NULL
, "got %p\n", mod2
);
1532 mod
= LoadLibraryA("comctl32.dll");
1533 ok(mod
!= NULL
, "got %p\n", mod
);
1534 status
= pLdrAddRefDll(LDR_ADDREF_DLL_PIN
, mod
);
1535 ok(status
== STATUS_SUCCESS
, "got 0x%08x\n", status
);
1537 ret
= FreeLibrary(mod
);
1538 ok(ret
, "got %d\n", ret
);
1539 ret
= FreeLibrary(mod
);
1540 ok(ret
, "got %d\n", ret
);
1541 ret
= FreeLibrary(mod
);
1542 ok(ret
, "got %d\n", ret
);
1543 ret
= FreeLibrary(mod
);
1544 ok(ret
, "got %d\n", ret
);
1546 mod2
= GetModuleHandleA("comctl32.dll");
1547 ok(mod2
!= NULL
, "got %p\n", mod2
);
1550 static void test_LdrLockLoaderLock(void)
1556 if (!pLdrLockLoaderLock
)
1558 win_skip("LdrLockLoaderLock() is not available\n");
1565 status
= pLdrLockLoaderLock(0x10, &result
, &magic
);
1566 ok(status
== STATUS_INVALID_PARAMETER_1
, "got 0x%08x\n", status
);
1567 ok(result
== 0, "got %d\n", result
);
1568 ok(magic
== 0, "got %lx\n", magic
);
1571 status
= pLdrLockLoaderLock(0x10, NULL
, &magic
);
1572 ok(status
== STATUS_INVALID_PARAMETER_1
, "got 0x%08x\n", status
);
1573 ok(magic
== 0, "got %lx\n", magic
);
1576 status
= pLdrLockLoaderLock(0x10, &result
, NULL
);
1577 ok(status
== STATUS_INVALID_PARAMETER_1
, "got 0x%08x\n", status
);
1578 ok(result
== 0, "got %d\n", result
);
1580 /* non-blocking mode, result is null */
1582 status
= pLdrLockLoaderLock(0x2, NULL
, &magic
);
1583 ok(status
== STATUS_INVALID_PARAMETER_2
, "got 0x%08x\n", status
);
1584 ok(magic
== 0, "got %lx\n", magic
);
1586 /* magic pointer is null */
1588 status
= pLdrLockLoaderLock(0, &result
, NULL
);
1589 ok(status
== STATUS_INVALID_PARAMETER_3
, "got 0x%08x\n", status
);
1590 ok(result
== 0, "got %d\n", result
);
1592 /* lock in non-blocking mode */
1595 status
= pLdrLockLoaderLock(0x2, &result
, &magic
);
1596 ok(status
== STATUS_SUCCESS
, "got 0x%08x\n", status
);
1597 ok(result
== 1, "got %d\n", result
);
1598 ok(magic
!= 0, "got %lx\n", magic
);
1599 pLdrUnlockLoaderLock(0, magic
);
1606 test_RtlCompareMemory();
1607 test_RtlCompareMemoryUlong();
1608 test_RtlMoveMemory();
1609 test_RtlFillMemory();
1610 test_RtlFillMemoryUlong();
1611 test_RtlZeroMemory();
1612 test_RtlUlonglongByteSwap();
1615 test_RtlAreAllAccessesGranted();
1616 test_RtlAreAnyAccessesGranted();
1617 test_RtlComputeCrc32();
1618 test_HandleTables();
1619 test_RtlAllocateAndInitializeSid();
1620 test_RtlDeleteTimer();
1621 test_RtlThreadErrorMode();
1622 test_LdrProcessRelocationBlock();
1623 test_RtlIpv4AddressToString();
1624 test_RtlIpv4AddressToStringEx();
1625 test_RtlIpv4StringToAddress();
1626 test_LdrAddRefDll();
1627 test_LdrLockLoaderLock();