source: trunk/src/NTDLL/rtl.c@ 21357

Last change on this file since 21357 was 21357, checked in by rlwalsh, 16 years ago

eliminate GCC warning & info msgs - see Ticket #1

File size: 19.9 KB
Line 
1/* $Id: rtl.c,v 1.6 2003-04-08 12:47:07 sandervl Exp $ */
2
3/*
4 * Project Odin Software License can be found in LICENSE.TXT
5 * Win32 NT Runtime / NTDLL for OS/2
6 *
7 * Copyright 1998 original WINE Author
8 * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
9 *
10 * NT basis DLL
11 *
12 * This file contains the Rtl* API functions. These should be implementable.
13 *
14 * Copyright 1996-1998 Marcus Meissner
15 * 1999 Alex Korobka
16 */
17
18#include <stdlib.h>
19#include <stdio.h>
20#include <string.h>
21
22#include <odinwrap.h>
23
24#include "debugtools.h"
25
26#include "winuser.h"
27#include "windef.h"
28#include "winerror.h"
29#include "stackframe.h"
30#include "ntddk.h"
31#include "winreg.h"
32#include "heapstring.h"
33
34#include <misc.h>
35
36
37ODINDEBUGCHANNEL(NTDLL-RTL)
38
39static CRITICAL_SECTION peb_lock = CRITICAL_SECTION_INIT("peb_lock");
40
41/* CRC polynomial 0xedb88320 */
42static const DWORD CRC_table[256] =
43{
44 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
45 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
46 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
47 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
48 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
49 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
50 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
51 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
52 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
53 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
54 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
55 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
56 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
57 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
58 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
59 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
60 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
61 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
62 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
63 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
64 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
65 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
66 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
67 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
68 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
69 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
70 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
71 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
72 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
73 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
74 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
75 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
76 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
77 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
78 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
79 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
80 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
81 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
82 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
83 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
84 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
85 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
86 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
87};
88
89
90/*
91 * WINE Adoption - we won't support the Win64 model.
92 */
93#define SIZE_T UINT
94
95/*
96 * resource functions
97 */
98
99/***********************************************************************
100 * RtlInitializeResource (NTDLL.409)
101 *
102 * xxxResource() functions implement multiple-reader-single-writer lock.
103 * The code is based on information published in WDJ January 1999 issue.
104 */
105void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl)
106{
107 dprintf(("NTDLL: RtlInitializeResource(%08xh)\n", rwl));
108
109 if( rwl )
110 {
111 rwl->iNumberActive = 0;
112 rwl->uExclusiveWaiters = 0;
113 rwl->uSharedWaiters = 0;
114 rwl->hOwningThreadId = 0;
115 rwl->dwTimeoutBoost = 0; /* no info on this one, default value is 0 */
116 InitializeCriticalSection( &rwl->rtlCS );
117 rwl->hExclusiveReleaseSemaphore = CreateSemaphoreA( NULL, 0, 65535, NULL );
118 rwl->hSharedReleaseSemaphore = CreateSemaphoreA( NULL, 0, 65535, NULL );
119 }
120}
121
122
123/***********************************************************************
124 * RtlDeleteResource (NTDLL.330)
125 */
126void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl)
127{
128 dprintf(("NTDLL: RtlDeleteResource(%08xh)\n",
129 rwl));
130
131 if( rwl )
132 {
133 EnterCriticalSection( &rwl->rtlCS );
134 if( rwl->iNumberActive || rwl->uExclusiveWaiters || rwl->uSharedWaiters )
135 dprintf(("NTDLL: RtlDeleteResource active MRSW lock (%p), expect failure\n",
136 rwl));
137
138 rwl->hOwningThreadId = 0;
139 rwl->uExclusiveWaiters = rwl->uSharedWaiters = 0;
140 rwl->iNumberActive = 0;
141 CloseHandle( rwl->hExclusiveReleaseSemaphore );
142 CloseHandle( rwl->hSharedReleaseSemaphore );
143 LeaveCriticalSection( &rwl->rtlCS );
144 DeleteCriticalSection( &rwl->rtlCS );
145 }
146}
147
148
149/***********************************************************************
150 * RtlAcquireResourceExclusive (NTDLL.256)
151 */
152BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl,
153 BYTE fWait)
154{
155 BYTE retVal = 0;
156
157 if( !rwl )
158 return 0;
159
160 dprintf(("NTDLL: RtlAcquireResourceExclusive(%08xh,%08xh)\n",
161 rwl,
162 fWait));
163
164start:
165 EnterCriticalSection( &rwl->rtlCS );
166 if( rwl->iNumberActive == 0 ) /* lock is free */
167 {
168 rwl->iNumberActive = -1;
169 retVal = 1;
170 }
171 else if( rwl->iNumberActive < 0 ) /* exclusive lock in progress */
172 {
173 if( rwl->hOwningThreadId == GetCurrentThreadId() )
174 {
175 retVal = 1;
176 rwl->iNumberActive--;
177 goto done;
178 }
179wait:
180 if( fWait )
181 {
182 rwl->uExclusiveWaiters++;
183
184 LeaveCriticalSection( &rwl->rtlCS );
185 if( WaitForSingleObject( rwl->hExclusiveReleaseSemaphore, INFINITE ) == WAIT_FAILED )
186 goto done;
187 goto start; /* restart the acquisition to avoid deadlocks */
188 }
189 }
190 else /* one or more shared locks are in progress */
191 if( fWait )
192 goto wait;
193
194 if( retVal == 1 )
195 rwl->hOwningThreadId = GetCurrentThreadId();
196done:
197 LeaveCriticalSection( &rwl->rtlCS );
198 return retVal;
199}
200
201/***********************************************************************
202 * RtlAcquireResourceShared (NTDLL.257)
203 */
204BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl,
205 BYTE fWait)
206{
207 DWORD dwWait = WAIT_FAILED;
208 BYTE retVal = 0;
209
210 if( !rwl )
211 return 0;
212
213 dprintf(("NTDLL: RtlAcquireResourceShared(%08xh,%08xh)\n",
214 rwl,
215 fWait));
216
217start:
218 EnterCriticalSection( &rwl->rtlCS );
219 if( rwl->iNumberActive < 0 )
220 {
221 if( rwl->hOwningThreadId == GetCurrentThreadId() )
222 {
223 rwl->iNumberActive--;
224 retVal = 1;
225 goto done;
226 }
227
228 if( fWait )
229 {
230 rwl->uSharedWaiters++;
231 LeaveCriticalSection( &rwl->rtlCS );
232 if( (dwWait = WaitForSingleObject( rwl->hSharedReleaseSemaphore, INFINITE )) == WAIT_FAILED )
233 goto done;
234 goto start;
235 }
236 }
237 else
238 {
239 if( dwWait != WAIT_OBJECT_0 ) /* otherwise RtlReleaseResource() has already done it */
240 rwl->iNumberActive++;
241 retVal = 1;
242 }
243done:
244 LeaveCriticalSection( &rwl->rtlCS );
245 return retVal;
246}
247
248
249/***********************************************************************
250 * RtlReleaseResource (NTDLL.471)
251 */
252void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl)
253{
254 dprintf(("NTDLL: RtlReleaseResource(%08xh)\n",
255 rwl));
256
257 EnterCriticalSection( &rwl->rtlCS );
258
259 if( rwl->iNumberActive > 0 ) /* have one or more readers */
260 {
261 if( --rwl->iNumberActive == 0 )
262 {
263 if( rwl->uExclusiveWaiters )
264 {
265wake_exclusive:
266 rwl->uExclusiveWaiters--;
267 ReleaseSemaphore( rwl->hExclusiveReleaseSemaphore, 1, NULL );
268 }
269 }
270 }
271 else
272 if( rwl->iNumberActive < 0 ) /* have a writer, possibly recursive */
273 {
274 if( ++rwl->iNumberActive == 0 )
275 {
276 rwl->hOwningThreadId = 0;
277 if( rwl->uExclusiveWaiters )
278 goto wake_exclusive;
279 else
280 if( rwl->uSharedWaiters )
281 {
282 UINT n = rwl->uSharedWaiters;
283 rwl->iNumberActive = rwl->uSharedWaiters; /* prevent new writers from joining until
284 * all queued readers have done their thing */
285 rwl->uSharedWaiters = 0;
286 ReleaseSemaphore( rwl->hSharedReleaseSemaphore, n, NULL );
287 }
288 }
289 }
290 LeaveCriticalSection( &rwl->rtlCS );
291}
292
293
294/***********************************************************************
295 * RtlDumpResource (NTDLL.340)
296 */
297void WINAPI RtlDumpResource(LPRTL_RWLOCK rwl)
298{
299 dprintf(("NTDLL: RtlDumpResource(%08x)\n",
300 rwl));
301
302 if( rwl )
303 {
304 dprintf(("NTDLL: RtlDumpResource(%p):\n\tactive count = %i\n\twaiting readers = %i\n\twaiting writers = %i\n",
305 rwl,
306 rwl->iNumberActive,
307 rwl->uSharedWaiters,
308 rwl->uExclusiveWaiters));
309
310 if( rwl->iNumberActive )
311 dprintf(("NTDLL: \towner thread = %08x\n",
312 rwl->hOwningThreadId ));
313 }
314}
315
316
317/*
318 * heap functions
319 */
320
321
322
323/*
324 * misc functions
325 */
326
327
328/******************************************************************************
329 * RtlAcquirePebLock [NTDLL]
330 */
331VOID WINAPI RtlAcquirePebLock(void)
332{
333 EnterCriticalSection( &peb_lock );
334}
335
336
337/******************************************************************************
338 * RtlReleasePebLock [NTDLL]
339 */
340VOID WINAPI RtlReleasePebLock(void)
341{
342 LeaveCriticalSection( &peb_lock );
343}
344
345/******************************************************************************
346 * RtlSetEnvironmentVariable [NTDLL.@]
347 */
348DWORD WINAPI RtlSetEnvironmentVariable(DWORD x1,PUNICODE_STRING key,PUNICODE_STRING val) {
349 FIXME("(0x%08lx,%s,%s),stub!\n",x1,debugstr_w(key->Buffer),debugstr_w(val->Buffer));
350 return 0;
351}
352
353/******************************************************************************
354 * RtlNewSecurityObject [NTDLL.@]
355 */
356DWORD WINAPI RtlNewSecurityObject(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6) {
357 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
358 return 0;
359}
360
361/******************************************************************************
362 * RtlDeleteSecurityObject [NTDLL.@]
363 */
364DWORD WINAPI RtlDeleteSecurityObject(DWORD x1) {
365 FIXME("(0x%08lx),stub!\n",x1);
366 return 0;
367}
368
369/**************************************************************************
370 * RtlNormalizeProcessParams [NTDLL.@]
371 */
372LPVOID WINAPI RtlNormalizeProcessParams(LPVOID x)
373{
374 FIXME("(%p), stub\n",x);
375 return x;
376}
377
378/**************************************************************************
379 * RtlGetNtProductType [NTDLL.@]
380 */
381BOOLEAN WINAPI RtlGetNtProductType(LPDWORD type)
382{
383 FIXME("(%p): stub\n", type);
384 *type=3; /* dunno. 1 for client, 3 for server? */
385 return 1;
386}
387
388
389/******************************************************************************
390 * RtlFormatCurrentUserKeyPath [NTDLL.371]
391 */
392NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(IN OUT PUNICODE_STRING pustrKeyPath)
393{
394 dprintf(("NTDLL: RtlFormatCurrentUserKeyPath(%08xh) not correctly implemented.\n",
395 pustrKeyPath));
396
397 LPSTR Path = "\\REGISTRY\\USER\\.DEFAULT";
398 ANSI_STRING AnsiPath;
399
400 RtlInitAnsiString(&AnsiPath, Path);
401 return RtlAnsiStringToUnicodeString(pustrKeyPath, &AnsiPath, TRUE);
402}
403
404
405/******************************************************************************
406 * RtlOpenCurrentUser [NTDLL]
407 */
408DWORD WINAPI RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess, OUT PHANDLE pKeyHandle)
409{
410 /* Note: this is not the correct solution,
411 * But this works pretty good on wine and NT4.0 binaries
412 */
413
414 if (DesiredAccess == 0x2000000 )
415 {
416 *pKeyHandle = HKEY_CURRENT_USER;
417 return TRUE;
418 }
419
420 return FALSE;
421/* PH 2000/08/18 currently disabled
422 OBJECT_ATTRIBUTES ObjectAttributes;
423 UNICODE_STRING ObjectName;
424 NTSTATUS ret;
425
426 RtlFormatCurrentUserKeyPath(&ObjectName);
427 InitializeObjectAttributes(&ObjectAttributes,&ObjectName,OBJ_CASE_INSENSITIVE,0, NULL);
428 ret = NtOpenKey(pKeyHandle, DesiredAccess, &ObjectAttributes);
429 RtlFreeUnicodeString(&ObjectName);
430 return ret;
431 */
432}
433
434
435/**************************************************************************
436 * RtlDosPathNameToNtPathName_U [NTDLL.338]
437 *
438 * FIXME: convert to UNC or whatever is expected here
439 */
440BOOLEAN WINAPI RtlDosPathNameToNtPathName_U(LPWSTR from,
441 PUNICODE_STRING us,
442 DWORD x2,
443 DWORD x3)
444{
445// LPSTR fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from);
446
447 dprintf(("NTDLL: RtlDosPathNameToNtPathName_U(%08xh,%08h,%08xh,%08xh) not implemented.\n",
448 from,
449 us,
450 x2,
451 x3));
452
453 if (us)
454 RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from));
455
456 return TRUE;
457}
458
459
460/***********************************************************************
461 * RtlImageNtHeader (NTDLL)
462 */
463PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule)
464{
465 IMAGE_NT_HEADERS *ret = NULL;
466 IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)hModule;
467
468 if (dos->e_magic == IMAGE_DOS_SIGNATURE)
469 {
470 ret = (IMAGE_NT_HEADERS *)((char *)dos + dos->e_lfanew);
471 if (ret->Signature != IMAGE_NT_SIGNATURE) ret = NULL;
472 }
473 return ret;
474}
475
476/******************************************************************************
477 * RtlCreateEnvironment [NTDLL]
478 */
479DWORD WINAPI RtlCreateEnvironment(DWORD x1,
480 DWORD x2)
481{
482 dprintf(("NTDLL: RtlCreateEnvironment(%08xh, %08xh) not implemented.\n",
483 x1,
484 x2));
485
486 return 0;
487}
488
489
490/******************************************************************************
491 * RtlDestroyEnvironment [NTDLL]
492 */
493DWORD WINAPI RtlDestroyEnvironment(DWORD x)
494{
495 dprintf(("NTDLL: RtlDestroyEnvironment(%08xh) not implemented.\n",
496 x));
497
498 return 0;
499}
500
501
502/******************************************************************************
503 * RtlQueryEnvironmentVariable_U [NTDLL]
504 */
505DWORD WINAPI RtlQueryEnvironmentVariable_U(DWORD x1,
506 PUNICODE_STRING key,
507 PUNICODE_STRING val)
508{
509 dprintf(("NTDLL: RtlQueryEnvironmentVariable_U(%08xh,%08xh,%08xh) not implemented.\n",
510 x1,
511 key,
512 val));
513
514 return 0;
515}
516
517/******************************************************************************
518 * RtlInitializeGenericTable [NTDLL]
519 */
520DWORD WINAPI RtlInitializeGenericTable(void)
521{
522 FIXME("\n");
523 return 0;
524}
525
526
527
528
529/******************************************************************************
530 * RtlCopyMemory [NTDLL]
531 *
532 */
533#undef RtlCopyMemory
534VOID WINAPI RtlCopyMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
535{
536 memcpy(Destination, Source, Length);
537}
538
539/******************************************************************************
540 * RtlMoveMemory [NTDLL]
541 */
542#undef RtlMoveMemory
543VOID WINAPI RtlMoveMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
544{
545 memmove(Destination, Source, Length);
546}
547
548/******************************************************************************
549 * RtlFillMemory [NTDLL]
550 */
551#undef RtlFillMemory
552VOID WINAPI RtlFillMemory( VOID *Destination, SIZE_T Length, UINT Fill )
553{
554 memset(Destination, Fill, Length);
555}
556
557/******************************************************************************
558 * RtlZeroMemory [NTDLL]
559 */
560#undef RtlZeroMemory
561VOID WINAPI RtlZeroMemory( VOID *Destination, SIZE_T Length )
562{
563 memset(Destination, 0, Length);
564}
565
566/******************************************************************************
567 * RtlCompareMemory [NTDLL]
568 */
569SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T Length)
570{
571 int i;
572 for(i=0; (i<Length) && (((LPBYTE)Source1)[i]==((LPBYTE)Source2)[i]); i++);
573 return i;
574}
575
576/******************************************************************************
577 * RtlAssert [NTDLL]
578 *
579 * Not implemented in non-debug versions.
580 */
581void WINAPI RtlAssert(LPVOID x1,LPVOID x2,DWORD x3, DWORD x4)
582{
583 FIXME("(%p,%p,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4);
584}
585
586/*****************************************************************************
587 * Name : RtlCopyLuid
588 * Purpose : copy local unique identifier?
589 * Parameters: PLUID pluid1
590 * PLUID pluid2
591 * Variables :
592 * Result :
593 * Remark : NTDLL.321
594 * Status : COMPLETELY ? IMPLEMENTED TESTED ?
595 *
596 * Author : Patrick Haller [Tue, 1999/11/09 09:00]
597 *****************************************************************************/
598
599PLUID WINAPI RtlCopyLuid(PLUID pluid1,
600 PLUID pluid2)
601{
602 pluid2->LowPart = pluid1->LowPart;
603 pluid2->HighPart = pluid1->HighPart;
604 return (pluid1);
605}
606
607/******************************************************************************
608 * RtlGetNtVersionNumbers [NTDLL.@]
609 *
610 * Introduced in Windows XP (NT5.1)
611 */
612void WINAPI RtlGetNtVersionNumbers(LPDWORD major, LPDWORD minor, LPDWORD build)
613{
614 OSVERSIONINFOEXW versionInfo;
615 versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
616 GetVersionExW((OSVERSIONINFOW*)((void*)&versionInfo));
617
618 if (major)
619 {
620 *major = versionInfo.dwMajorVersion;
621 }
622
623 if (minor)
624 {
625 *minor = versionInfo.dwMinorVersion;
626 }
627
628 if (build)
629 {
630 /* FIXME: Does anybody know the real formula? */
631 *build = (0xF0000000 | versionInfo.dwBuildNumber);
632 }
633}
634
635/*************************************************************************
636 * RtlFillMemoryUlong [NTDLL.@]
637 *
638 * Fill memory with a 32 bit (dword) value.
639 *
640 * PARAMS
641 * lpDest [I] Bitmap pointer
642 * ulCount [I] Number of dwords to write
643 * ulValue [I] Value to fill with
644 *
645 * RETURNS
646 * Nothing.
647 */
648VOID WINAPI RtlFillMemoryUlong(ULONG* lpDest, ULONG ulCount, ULONG ulValue)
649{
650 TRACE("(%p,%ld,%ld)\n", lpDest, ulCount, ulValue);
651
652 while(ulCount--)
653 *lpDest++ = ulValue;
654}
655
656/*************************************************************************
657 * RtlGetLongestNtPathLength [NTDLL.@]
658 *
659 * Get the longest allowed path length
660 *
661 * PARAMS
662 * None.
663 *
664 * RETURNS
665 * The longest allowed path length (277 characters under Win2k).
666 */
667DWORD WINAPI RtlGetLongestNtPathLength(void)
668{
669 TRACE("()\n");
670 return 277;
671}
672
673/*********************************************************************
674 * RtlComputeCrc32 [NTDLL.@]
675 *
676 * Calculate the CRC32 checksum of a block of bytes
677 *
678 * PARAMS
679 * dwInitial [I] Initial CRC value
680 * pData [I] Data block
681 * iLen [I] Length of the byte block
682 *
683 * RETURNS
684 * The cumulative CRC32 of dwInitial and iLen bytes of the pData block.
685 */
686DWORD WINAPI RtlComputeCrc32(DWORD dwInitial, PBYTE pData, INT iLen)
687{
688 DWORD crc = ~dwInitial;
689
690 TRACE("(%ld,%p,%d)\n", dwInitial, pData, iLen);
691
692 while (iLen > 0)
693 {
694 crc = CRC_table[(crc ^ *pData) & 0xff] ^ (crc >> 8);
695 pData++;
696 iLen--;
697 }
698 return ~crc;
699}
Note: See TracBrowser for help on using the repository browser.