| 1 | /* $Id: rtl.cpp,v 1.11 2000-08-20 15:16:59 phaller 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 | #include <odinwrap.h>
|
|---|
| 22 | #include <os2win.h>
|
|---|
| 23 |
|
|---|
| 24 | #include "debugtools.h"
|
|---|
| 25 | #include "ntdll.h"
|
|---|
| 26 |
|
|---|
| 27 | #include "winuser.h"
|
|---|
| 28 | #include "windef.h"
|
|---|
| 29 | #include "winerror.h"
|
|---|
| 30 | #include "stackframe.h"
|
|---|
| 31 | #include "ntddk.h"
|
|---|
| 32 | #include "imagehlp.h"
|
|---|
| 33 | #include "winreg.h"
|
|---|
| 34 | #include "heapstring.h"
|
|---|
| 35 |
|
|---|
| 36 | #include <misc.h>
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | ODINDEBUGCHANNEL(NTDLL-RTL)
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | * WINE Adoption - we won't support the Win64 model.
|
|---|
| 44 | */
|
|---|
| 45 | #define SIZE_T UINT
|
|---|
| 46 |
|
|---|
| 47 | /*
|
|---|
| 48 | * resource functions
|
|---|
| 49 | */
|
|---|
| 50 |
|
|---|
| 51 | /***********************************************************************
|
|---|
| 52 | * RtlInitializeResource (NTDLL.409)
|
|---|
| 53 | *
|
|---|
| 54 | * xxxResource() functions implement multiple-reader-single-writer lock.
|
|---|
| 55 | * The code is based on information published in WDJ January 1999 issue.
|
|---|
| 56 | */
|
|---|
| 57 | void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl)
|
|---|
| 58 | {
|
|---|
| 59 | dprintf(("NTDLL: RtlInitializeResource(%08xh)\n",
|
|---|
| 60 | rwl));
|
|---|
| 61 |
|
|---|
| 62 | if( rwl )
|
|---|
| 63 | {
|
|---|
| 64 | rwl->iNumberActive = 0;
|
|---|
| 65 | rwl->uExclusiveWaiters = 0;
|
|---|
| 66 | rwl->uSharedWaiters = 0;
|
|---|
| 67 | rwl->hOwningThreadId = 0;
|
|---|
| 68 | rwl->dwTimeoutBoost = 0; /* no info on this one, default value is 0 */
|
|---|
| 69 | InitializeCriticalSection( &rwl->rtlCS );
|
|---|
| 70 | rwl->hExclusiveReleaseSemaphore = CreateSemaphoreA( NULL, 0, 65535, NULL );
|
|---|
| 71 | rwl->hSharedReleaseSemaphore = CreateSemaphoreA( NULL, 0, 65535, NULL );
|
|---|
| 72 | }
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 | /***********************************************************************
|
|---|
| 77 | * RtlDeleteResource (NTDLL.330)
|
|---|
| 78 | */
|
|---|
| 79 | void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl)
|
|---|
| 80 | {
|
|---|
| 81 | dprintf(("NTDLL: RtlDeleteResource(%08xh)\n",
|
|---|
| 82 | rwl));
|
|---|
| 83 |
|
|---|
| 84 | if( rwl )
|
|---|
| 85 | {
|
|---|
| 86 | EnterCriticalSection( &rwl->rtlCS );
|
|---|
| 87 | if( rwl->iNumberActive || rwl->uExclusiveWaiters || rwl->uSharedWaiters )
|
|---|
| 88 | dprintf(("NTDLL: RtlDeleteResource active MRSW lock (%p), expect failure\n",
|
|---|
| 89 | rwl));
|
|---|
| 90 |
|
|---|
| 91 | rwl->hOwningThreadId = 0;
|
|---|
| 92 | rwl->uExclusiveWaiters = rwl->uSharedWaiters = 0;
|
|---|
| 93 | rwl->iNumberActive = 0;
|
|---|
| 94 | CloseHandle( rwl->hExclusiveReleaseSemaphore );
|
|---|
| 95 | CloseHandle( rwl->hSharedReleaseSemaphore );
|
|---|
| 96 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 97 | DeleteCriticalSection( &rwl->rtlCS );
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | /***********************************************************************
|
|---|
| 103 | * RtlAcquireResourceExclusive (NTDLL.256)
|
|---|
| 104 | */
|
|---|
| 105 | BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl,
|
|---|
| 106 | BYTE fWait)
|
|---|
| 107 | {
|
|---|
| 108 | BYTE retVal = 0;
|
|---|
| 109 |
|
|---|
| 110 | if( !rwl )
|
|---|
| 111 | return 0;
|
|---|
| 112 |
|
|---|
| 113 | dprintf(("NTDLL: RtlAcquireResourceExclusive(%08xh,%08xh)\n",
|
|---|
| 114 | rwl,
|
|---|
| 115 | fWait));
|
|---|
| 116 |
|
|---|
| 117 | start:
|
|---|
| 118 | EnterCriticalSection( &rwl->rtlCS );
|
|---|
| 119 | if( rwl->iNumberActive == 0 ) /* lock is free */
|
|---|
| 120 | {
|
|---|
| 121 | rwl->iNumberActive = -1;
|
|---|
| 122 | retVal = 1;
|
|---|
| 123 | }
|
|---|
| 124 | else if( rwl->iNumberActive < 0 ) /* exclusive lock in progress */
|
|---|
| 125 | {
|
|---|
| 126 | if( rwl->hOwningThreadId == GetCurrentThreadId() )
|
|---|
| 127 | {
|
|---|
| 128 | retVal = 1;
|
|---|
| 129 | rwl->iNumberActive--;
|
|---|
| 130 | goto done;
|
|---|
| 131 | }
|
|---|
| 132 | wait:
|
|---|
| 133 | if( fWait )
|
|---|
| 134 | {
|
|---|
| 135 | rwl->uExclusiveWaiters++;
|
|---|
| 136 |
|
|---|
| 137 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 138 | if( WaitForSingleObject( rwl->hExclusiveReleaseSemaphore, INFINITE ) == WAIT_FAILED )
|
|---|
| 139 | goto done;
|
|---|
| 140 | goto start; /* restart the acquisition to avoid deadlocks */
|
|---|
| 141 | }
|
|---|
| 142 | }
|
|---|
| 143 | else /* one or more shared locks are in progress */
|
|---|
| 144 | if( fWait )
|
|---|
| 145 | goto wait;
|
|---|
| 146 |
|
|---|
| 147 | if( retVal == 1 )
|
|---|
| 148 | rwl->hOwningThreadId = GetCurrentThreadId();
|
|---|
| 149 | done:
|
|---|
| 150 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 151 | return retVal;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | /***********************************************************************
|
|---|
| 155 | * RtlAcquireResourceShared (NTDLL.257)
|
|---|
| 156 | */
|
|---|
| 157 | BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl,
|
|---|
| 158 | BYTE fWait)
|
|---|
| 159 | {
|
|---|
| 160 | DWORD dwWait = WAIT_FAILED;
|
|---|
| 161 | BYTE retVal = 0;
|
|---|
| 162 |
|
|---|
| 163 | if( !rwl )
|
|---|
| 164 | return 0;
|
|---|
| 165 |
|
|---|
| 166 | dprintf(("NTDLL: RtlAcquireResourceShared(%08xh,%08xh)\n",
|
|---|
| 167 | rwl,
|
|---|
| 168 | fWait));
|
|---|
| 169 |
|
|---|
| 170 | start:
|
|---|
| 171 | EnterCriticalSection( &rwl->rtlCS );
|
|---|
| 172 | if( rwl->iNumberActive < 0 )
|
|---|
| 173 | {
|
|---|
| 174 | if( rwl->hOwningThreadId == GetCurrentThreadId() )
|
|---|
| 175 | {
|
|---|
| 176 | rwl->iNumberActive--;
|
|---|
| 177 | retVal = 1;
|
|---|
| 178 | goto done;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | if( fWait )
|
|---|
| 182 | {
|
|---|
| 183 | rwl->uSharedWaiters++;
|
|---|
| 184 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 185 | if( (dwWait = WaitForSingleObject( rwl->hSharedReleaseSemaphore, INFINITE )) == WAIT_FAILED )
|
|---|
| 186 | goto done;
|
|---|
| 187 | goto start;
|
|---|
| 188 | }
|
|---|
| 189 | }
|
|---|
| 190 | else
|
|---|
| 191 | {
|
|---|
| 192 | if( dwWait != WAIT_OBJECT_0 ) /* otherwise RtlReleaseResource() has already done it */
|
|---|
| 193 | rwl->iNumberActive++;
|
|---|
| 194 | retVal = 1;
|
|---|
| 195 | }
|
|---|
| 196 | done:
|
|---|
| 197 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 198 | return retVal;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 | /***********************************************************************
|
|---|
| 203 | * RtlReleaseResource (NTDLL.471)
|
|---|
| 204 | */
|
|---|
| 205 | void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl)
|
|---|
| 206 | {
|
|---|
| 207 | dprintf(("NTDLL: RtlReleaseResource(%08xh)\n",
|
|---|
| 208 | rwl));
|
|---|
| 209 |
|
|---|
| 210 | EnterCriticalSection( &rwl->rtlCS );
|
|---|
| 211 |
|
|---|
| 212 | if( rwl->iNumberActive > 0 ) /* have one or more readers */
|
|---|
| 213 | {
|
|---|
| 214 | if( --rwl->iNumberActive == 0 )
|
|---|
| 215 | {
|
|---|
| 216 | if( rwl->uExclusiveWaiters )
|
|---|
| 217 | {
|
|---|
| 218 | wake_exclusive:
|
|---|
| 219 | rwl->uExclusiveWaiters--;
|
|---|
| 220 | ReleaseSemaphore( rwl->hExclusiveReleaseSemaphore, 1, NULL );
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 | }
|
|---|
| 224 | else
|
|---|
| 225 | if( rwl->iNumberActive < 0 ) /* have a writer, possibly recursive */
|
|---|
| 226 | {
|
|---|
| 227 | if( ++rwl->iNumberActive == 0 )
|
|---|
| 228 | {
|
|---|
| 229 | rwl->hOwningThreadId = 0;
|
|---|
| 230 | if( rwl->uExclusiveWaiters )
|
|---|
| 231 | goto wake_exclusive;
|
|---|
| 232 | else
|
|---|
| 233 | if( rwl->uSharedWaiters )
|
|---|
| 234 | {
|
|---|
| 235 | UINT n = rwl->uSharedWaiters;
|
|---|
| 236 | rwl->iNumberActive = rwl->uSharedWaiters; /* prevent new writers from joining until
|
|---|
| 237 | * all queued readers have done their thing */
|
|---|
| 238 | rwl->uSharedWaiters = 0;
|
|---|
| 239 | ReleaseSemaphore( rwl->hSharedReleaseSemaphore, n, NULL );
|
|---|
| 240 | }
|
|---|
| 241 | }
|
|---|
| 242 | }
|
|---|
| 243 | LeaveCriticalSection( &rwl->rtlCS );
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | /***********************************************************************
|
|---|
| 248 | * RtlDumpResource (NTDLL.340)
|
|---|
| 249 | */
|
|---|
| 250 | void WINAPI RtlDumpResource(LPRTL_RWLOCK rwl)
|
|---|
| 251 | {
|
|---|
| 252 | dprintf(("NTDLL: RtlDumpResource(%08x)\n",
|
|---|
| 253 | rwl));
|
|---|
| 254 |
|
|---|
| 255 | if( rwl )
|
|---|
| 256 | {
|
|---|
| 257 | dprintf(("NTDLL: RtlDumpResource(%p):\n\tactive count = %i\n\twaiting readers = %i\n\twaiting writers = %i\n",
|
|---|
| 258 | rwl,
|
|---|
| 259 | rwl->iNumberActive,
|
|---|
| 260 | rwl->uSharedWaiters,
|
|---|
| 261 | rwl->uExclusiveWaiters));
|
|---|
| 262 |
|
|---|
| 263 | if( rwl->iNumberActive )
|
|---|
| 264 | dprintf(("NTDLL: \towner thread = %08x\n",
|
|---|
| 265 | rwl->hOwningThreadId ));
|
|---|
| 266 | }
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 | /*
|
|---|
| 271 | * heap functions
|
|---|
| 272 | */
|
|---|
| 273 |
|
|---|
| 274 | /******************************************************************************
|
|---|
| 275 | * RtlCreateHeap [NTDLL]
|
|---|
| 276 | */
|
|---|
| 277 | HANDLE WINAPI RtlCreateHeap(ULONG Flags,
|
|---|
| 278 | PVOID BaseAddress,
|
|---|
| 279 | ULONG SizeToReserve,
|
|---|
| 280 | ULONG SizeToCommit,
|
|---|
| 281 | PVOID Unknown,
|
|---|
| 282 | PRTL_HEAP_DEFINITION Definition)
|
|---|
| 283 | {
|
|---|
| 284 | dprintf(("NTDLL: RtlCreateHeap(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh).\n",
|
|---|
| 285 | Flags,
|
|---|
| 286 | BaseAddress,
|
|---|
| 287 | SizeToReserve,
|
|---|
| 288 | SizeToCommit,
|
|---|
| 289 | Unknown,
|
|---|
| 290 | Definition));
|
|---|
| 291 |
|
|---|
| 292 | return HeapCreate(Flags,
|
|---|
| 293 | SizeToCommit,
|
|---|
| 294 | SizeToReserve);
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 | /******************************************************************************
|
|---|
| 299 | * RtlAllocateHeap [NTDLL]
|
|---|
| 300 | */
|
|---|
| 301 | PVOID WINAPI RtlAllocateHeap(HANDLE Heap,
|
|---|
| 302 | ULONG Flags,
|
|---|
| 303 | ULONG Size)
|
|---|
| 304 | {
|
|---|
| 305 | dprintf(("NTDLL: RtlAllocateHeap(%08xh,%08xh,%08xh).\n",
|
|---|
| 306 | Heap,
|
|---|
| 307 | Flags,
|
|---|
| 308 | Size));
|
|---|
| 309 |
|
|---|
| 310 | return HeapAlloc(Heap,
|
|---|
| 311 | Flags,
|
|---|
| 312 | Size);
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 | /******************************************************************************
|
|---|
| 317 | * RtlFreeHeap [NTDLL]
|
|---|
| 318 | */
|
|---|
| 319 | BOOLEAN WINAPI RtlFreeHeap(HANDLE Heap,
|
|---|
| 320 | ULONG Flags,
|
|---|
| 321 | PVOID Address)
|
|---|
| 322 | {
|
|---|
| 323 | dprintf(("NTDLL: RtlFreeHeap(%08xh,%08xh,%08xh)\n",
|
|---|
| 324 | Heap,
|
|---|
| 325 | Flags,
|
|---|
| 326 | Address));
|
|---|
| 327 |
|
|---|
| 328 | return HeapFree(Heap, Flags, Address);
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 | /******************************************************************************
|
|---|
| 333 | * RtlDestroyHeap [NTDLL]
|
|---|
| 334 | *
|
|---|
| 335 | * FIXME: prototype guessed
|
|---|
| 336 | */
|
|---|
| 337 | BOOLEAN WINAPI RtlDestroyHeap(HANDLE Heap)
|
|---|
| 338 | {
|
|---|
| 339 | dprintf(("NTDLL: RtlDestroyHeap(%08xh)\n",
|
|---|
| 340 | Heap));
|
|---|
| 341 |
|
|---|
| 342 | return HeapDestroy(Heap);
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 | /******************************************************************************
|
|---|
| 348 | * RtlSizeHeap [NTDLL]
|
|---|
| 349 | */
|
|---|
| 350 |
|
|---|
| 351 | ODINFUNCTION3(DWORD,RtlSizeHeap,HANDLE,hHeap,
|
|---|
| 352 | DWORD, dwFlags,
|
|---|
| 353 | PVOID, pAddress)
|
|---|
| 354 | {
|
|---|
| 355 | return HeapSize(hHeap,
|
|---|
| 356 | dwFlags,
|
|---|
| 357 | pAddress);
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | /*
|
|---|
| 363 | * misc functions
|
|---|
| 364 | */
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 | /******************************************************************************
|
|---|
| 368 | * RtlAcquirePebLock [NTDLL]
|
|---|
| 369 | */
|
|---|
| 370 | VOID WINAPI RtlAcquirePebLock(void)
|
|---|
| 371 | {
|
|---|
| 372 | dprintf(("NTDLL: RtlAcquirePebLock() not implemented.\n"));
|
|---|
| 373 |
|
|---|
| 374 | /* enter critical section ? */
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 | /******************************************************************************
|
|---|
| 379 | * RtlReleasePebLock [NTDLL]
|
|---|
| 380 | */
|
|---|
| 381 | VOID WINAPI RtlReleasePebLock(void)
|
|---|
| 382 | {
|
|---|
| 383 | dprintf(("NTDLL: RtlReleasePebLock() not implemented.\n"));
|
|---|
| 384 |
|
|---|
| 385 | /* leave critical section ? */
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 | /******************************************************************************
|
|---|
| 390 | * RtlIntegerToChar [NTDLL]
|
|---|
| 391 | */
|
|---|
| 392 | DWORD WINAPI RtlIntegerToChar(DWORD x1,
|
|---|
| 393 | DWORD x2,
|
|---|
| 394 | DWORD x3,
|
|---|
| 395 | DWORD x4)
|
|---|
| 396 | {
|
|---|
| 397 | dprintf(("NTDLL: RtlIntegerToChar(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 398 | x1,
|
|---|
| 399 | x2,
|
|---|
| 400 | x3,
|
|---|
| 401 | x4));
|
|---|
| 402 |
|
|---|
| 403 | return 0;
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 | /******************************************************************************
|
|---|
| 408 | * RtlSetEnvironmentVariable [NTDLL]
|
|---|
| 409 | */
|
|---|
| 410 | DWORD WINAPI RtlSetEnvironmentVariable(DWORD x1,
|
|---|
| 411 | PUNICODE_STRING key,
|
|---|
| 412 | PUNICODE_STRING val)
|
|---|
| 413 | {
|
|---|
| 414 | dprintf(("NTDLL: RtlSetEnvironmentVariable(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 415 | x1,
|
|---|
| 416 | key,
|
|---|
| 417 | val));
|
|---|
| 418 |
|
|---|
| 419 | return 0;
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 | /******************************************************************************
|
|---|
| 424 | * RtlNewSecurityObject [NTDLL]
|
|---|
| 425 | */
|
|---|
| 426 | DWORD WINAPI RtlNewSecurityObject(DWORD x1,
|
|---|
| 427 | DWORD x2,
|
|---|
| 428 | DWORD x3,
|
|---|
| 429 | DWORD x4,
|
|---|
| 430 | DWORD x5,
|
|---|
| 431 | DWORD x6)
|
|---|
| 432 | {
|
|---|
| 433 | dprintf(("NTDLL: RtlNewSecurityObject(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 434 | x1,
|
|---|
| 435 | x2,
|
|---|
| 436 | x3,
|
|---|
| 437 | x4,
|
|---|
| 438 | x5,
|
|---|
| 439 | x6));
|
|---|
| 440 |
|
|---|
| 441 | return 0;
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 | /******************************************************************************
|
|---|
| 446 | * RtlDeleteSecurityObject [NTDLL]
|
|---|
| 447 | */
|
|---|
| 448 | DWORD WINAPI RtlDeleteSecurityObject(DWORD x1)
|
|---|
| 449 | {
|
|---|
| 450 | dprintf(("NTDLL: RtlDeleteSecurityObject(%08xh) not implemented.\n",
|
|---|
| 451 | x1));
|
|---|
| 452 |
|
|---|
| 453 | return 0;
|
|---|
| 454 | }
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 | /**************************************************************************
|
|---|
| 458 | * RtlNormalizeProcessParams [NTDLL.441]
|
|---|
| 459 | */
|
|---|
| 460 | LPVOID WINAPI RtlNormalizeProcessParams(LPVOID x)
|
|---|
| 461 | {
|
|---|
| 462 | dprintf(("NTDLL: RtlNormalizeProcessParams(%08xh) not implemented.\n",
|
|---|
| 463 | x));
|
|---|
| 464 |
|
|---|
| 465 | return x;
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 | /**************************************************************************
|
|---|
| 470 | * RtlNtStatusToDosError [NTDLL.442]
|
|---|
| 471 | */
|
|---|
| 472 | DWORD WINAPI RtlNtStatusToDosError(DWORD error)
|
|---|
| 473 | {
|
|---|
| 474 | dprintf(("NTDLL: RtlNtStatusToDosError(%08xh) partially implemented.\n",
|
|---|
| 475 | error));
|
|---|
| 476 |
|
|---|
| 477 | switch (error)
|
|---|
| 478 | {
|
|---|
| 479 | case STATUS_SUCCESS: return ERROR_SUCCESS;
|
|---|
| 480 | case STATUS_INVALID_PARAMETER: return ERROR_BAD_ARGUMENTS;
|
|---|
| 481 | case STATUS_BUFFER_TOO_SMALL: return ERROR_INSUFFICIENT_BUFFER;
|
|---|
| 482 | /* case STATUS_INVALID_SECURITY_DESCR: return ERROR_INVALID_SECURITY_DESCR;*/
|
|---|
| 483 | case STATUS_NO_MEMORY: return ERROR_NOT_ENOUGH_MEMORY;
|
|---|
| 484 | /* case STATUS_UNKNOWN_REVISION:
|
|---|
| 485 | case STATUS_BUFFER_OVERFLOW:*/
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | dprintf(("NTDLL: RtlNtStatusToDosError(%08xh is unknown !)\n",
|
|---|
| 489 | error));
|
|---|
| 490 |
|
|---|
| 491 | return ERROR_SUCCESS;
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 |
|
|---|
| 495 | /**************************************************************************
|
|---|
| 496 | * RtlGetNtProductType [NTDLL.390]
|
|---|
| 497 | */
|
|---|
| 498 | BOOLEAN WINAPI RtlGetNtProductType(LPDWORD type)
|
|---|
| 499 | {
|
|---|
| 500 | dprintf(("NTDLL: RtlGetNtProductType(%08xh) not correctly implemented.\n",
|
|---|
| 501 | type));
|
|---|
| 502 |
|
|---|
| 503 | *type=3; /* dunno. 1 for client, 3 for server? */
|
|---|
| 504 | return 1;
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 | /******************************************************************************
|
|---|
| 509 | * RtlEnlargedIntegerMultiply [NTDLL.341]
|
|---|
| 510 | * Note: This even works, since gcc returns 64bit values in eax/edx just like
|
|---|
| 511 | * the caller expects. However... The relay code won't grok this I think.
|
|---|
| 512 | *
|
|---|
| 513 | * @@@PH: Parameters are unknown
|
|---|
| 514 | */
|
|---|
| 515 | /* longlong in VAC++ ? */
|
|---|
| 516 |
|
|---|
| 517 | extern INT WINAPI RtlEnlargedIntegerMultiply(INT factor1,
|
|---|
| 518 | INT factor2);
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 | /******************************************************************************
|
|---|
| 522 | * RtlExtendedLargeIntegerDivide [NTDLL.359]
|
|---|
| 523 | */
|
|---|
| 524 | extern INT WINAPI RtlExtendedLargeIntegerDivide(LARGE_INTEGER dividend,
|
|---|
| 525 | DWORD divisor,
|
|---|
| 526 | LPDWORD rest);
|
|---|
| 527 |
|
|---|
| 528 | /******************************************************************************
|
|---|
| 529 | * RtlExtendedLargeIntegerMultiply [NTDLL.358]
|
|---|
| 530 | * Note: This even works, since gcc returns 64bit values in eax/edx just like
|
|---|
| 531 | * the caller expects. However... The relay code won't grok this I think.
|
|---|
| 532 | */
|
|---|
| 533 | /* longlong in VAC++ ? */
|
|---|
| 534 |
|
|---|
| 535 | extern LARGE_INTEGER WINAPI RtlExtendedIntegerMultiply(LARGE_INTEGER factor1,
|
|---|
| 536 | INT factor2);
|
|---|
| 537 |
|
|---|
| 538 | /******************************************************************************
|
|---|
| 539 | * RtlFormatCurrentUserKeyPath [NTDLL.371]
|
|---|
| 540 | */
|
|---|
| 541 | DWORD WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING pustrKeyPath)
|
|---|
| 542 | {
|
|---|
| 543 | dprintf(("NTDLL: RtlFormatCurrentUserKeyPath(%08xh) not correctly implemented.\n",
|
|---|
| 544 | pustrKeyPath));
|
|---|
| 545 |
|
|---|
| 546 | LPSTR Path = "\\REGISTRY\\USER\\.DEFAULT";
|
|---|
| 547 | ANSI_STRING AnsiPath;
|
|---|
| 548 |
|
|---|
| 549 | RtlInitAnsiString(&AnsiPath, Path);
|
|---|
| 550 | return RtlAnsiStringToUnicodeString(pustrKeyPath, &AnsiPath, TRUE);
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 |
|
|---|
| 554 | /******************************************************************************
|
|---|
| 555 | * RtlOpenCurrentUser [NTDLL]
|
|---|
| 556 | */
|
|---|
| 557 | ODINFUNCTION2(DWORD, RtlOpenCurrentUser,
|
|---|
| 558 | ACCESS_MASK,DesiredAccess,
|
|---|
| 559 | PHANDLE, pKeyHandle)
|
|---|
| 560 | {
|
|---|
| 561 | /* Note: this is not the correct solution,
|
|---|
| 562 | * But this works pretty good on wine and NT4.0 binaries
|
|---|
| 563 | */
|
|---|
| 564 |
|
|---|
| 565 | if (DesiredAccess == 0x2000000 )
|
|---|
| 566 | {
|
|---|
| 567 | *pKeyHandle = HKEY_CURRENT_USER;
|
|---|
| 568 | return TRUE;
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | return FALSE;
|
|---|
| 572 | /* PH 2000/08/18 currently disabled
|
|---|
| 573 | OBJECT_ATTRIBUTES ObjectAttributes;
|
|---|
| 574 | UNICODE_STRING ObjectName;
|
|---|
| 575 | NTSTATUS ret;
|
|---|
| 576 |
|
|---|
| 577 | RtlFormatCurrentUserKeyPath(&ObjectName);
|
|---|
| 578 | InitializeObjectAttributes(&ObjectAttributes,&ObjectName,OBJ_CASE_INSENSITIVE,0, NULL);
|
|---|
| 579 | ret = NtOpenKey(pKeyHandle, DesiredAccess, &ObjectAttributes);
|
|---|
| 580 | RtlFreeUnicodeString(&ObjectName);
|
|---|
| 581 | return ret;
|
|---|
| 582 | */
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 | /**************************************************************************
|
|---|
| 587 | * RtlDosPathNameToNtPathName_U [NTDLL.338]
|
|---|
| 588 | *
|
|---|
| 589 | * FIXME: convert to UNC or whatever is expected here
|
|---|
| 590 | */
|
|---|
| 591 | BOOLEAN WINAPI RtlDosPathNameToNtPathName_U(LPWSTR from,
|
|---|
| 592 | PUNICODE_STRING us,
|
|---|
| 593 | DWORD x2,
|
|---|
| 594 | DWORD x3)
|
|---|
| 595 | {
|
|---|
| 596 | LPSTR fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from);
|
|---|
| 597 |
|
|---|
| 598 | dprintf(("NTDLL: RtlDosPathNameToNtPathName_U(%08xh,%08h,%08xh,%08xh) not implemented.\n",
|
|---|
| 599 | from,
|
|---|
| 600 | us,
|
|---|
| 601 | x2,
|
|---|
| 602 | x3));
|
|---|
| 603 |
|
|---|
| 604 | if (us)
|
|---|
| 605 | RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from));
|
|---|
| 606 |
|
|---|
| 607 | return TRUE;
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 | /***********************************************************************
|
|---|
| 612 | * RtlImageNtHeader (NTDLL)
|
|---|
| 613 | */
|
|---|
| 614 | PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule)
|
|---|
| 615 | {
|
|---|
| 616 | IMAGE_NT_HEADERS *ret = NULL;
|
|---|
| 617 | IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)hModule;
|
|---|
| 618 |
|
|---|
| 619 | if (dos->e_magic == IMAGE_DOS_SIGNATURE)
|
|---|
| 620 | {
|
|---|
| 621 | ret = (IMAGE_NT_HEADERS *)((char *)dos + dos->e_lfanew);
|
|---|
| 622 | if (ret->Signature != IMAGE_NT_SIGNATURE) ret = NULL;
|
|---|
| 623 | }
|
|---|
| 624 | return ret;
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | /******************************************************************************
|
|---|
| 628 | * RtlCreateEnvironment [NTDLL]
|
|---|
| 629 | */
|
|---|
| 630 | DWORD WINAPI RtlCreateEnvironment(DWORD x1,
|
|---|
| 631 | DWORD x2)
|
|---|
| 632 | {
|
|---|
| 633 | dprintf(("NTDLL: RtlCreateEnvironment(%08xh, %08xh) not implemented.\n",
|
|---|
| 634 | x1,
|
|---|
| 635 | x2));
|
|---|
| 636 |
|
|---|
| 637 | return 0;
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 |
|
|---|
| 641 | /******************************************************************************
|
|---|
| 642 | * RtlDestroyEnvironment [NTDLL]
|
|---|
| 643 | */
|
|---|
| 644 | DWORD WINAPI RtlDestroyEnvironment(DWORD x)
|
|---|
| 645 | {
|
|---|
| 646 | dprintf(("NTDLL: RtlDestroyEnvironment(%08xh) not implemented.\n",
|
|---|
| 647 | x));
|
|---|
| 648 |
|
|---|
| 649 | return 0;
|
|---|
| 650 | }
|
|---|
| 651 |
|
|---|
| 652 |
|
|---|
| 653 | /******************************************************************************
|
|---|
| 654 | * RtlQueryEnvironmentVariable_U [NTDLL]
|
|---|
| 655 | */
|
|---|
| 656 | DWORD WINAPI RtlQueryEnvironmentVariable_U(DWORD x1,
|
|---|
| 657 | PUNICODE_STRING key,
|
|---|
| 658 | PUNICODE_STRING val)
|
|---|
| 659 | {
|
|---|
| 660 | dprintf(("NTDLL: RtlQueryEnvironmentVariable_U(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 661 | x1,
|
|---|
| 662 | key,
|
|---|
| 663 | val));
|
|---|
| 664 |
|
|---|
| 665 | return 0;
|
|---|
| 666 | }
|
|---|
| 667 |
|
|---|
| 668 | /******************************************************************************
|
|---|
| 669 | * RtlInitializeGenericTable [NTDLL]
|
|---|
| 670 | */
|
|---|
| 671 | DWORD WINAPI RtlInitializeGenericTable(void)
|
|---|
| 672 | {
|
|---|
| 673 | FIXME("\n");
|
|---|
| 674 | return 0;
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | /******************************************************************************
|
|---|
| 678 | * RtlInitializeBitMap [NTDLL]
|
|---|
| 679 | *
|
|---|
| 680 | */
|
|---|
| 681 | NTSTATUS WINAPI RtlInitializeBitMap(DWORD x1,DWORD x2,DWORD x3)
|
|---|
| 682 | {
|
|---|
| 683 | FIXME("(0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3);
|
|---|
| 684 | return 0;
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | /******************************************************************************
|
|---|
| 688 | * RtlSetBits [NTDLL]
|
|---|
| 689 | *
|
|---|
| 690 | */
|
|---|
| 691 | NTSTATUS WINAPI RtlSetBits(DWORD x1,DWORD x2,DWORD x3)
|
|---|
| 692 | {
|
|---|
| 693 | FIXME("(0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3);
|
|---|
| 694 | return 0;
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 | /******************************************************************************
|
|---|
| 698 | * RtlFindClearBits [NTDLL]
|
|---|
| 699 | *
|
|---|
| 700 | */
|
|---|
| 701 | NTSTATUS WINAPI RtlFindClearBits(DWORD x1,DWORD x2,DWORD x3)
|
|---|
| 702 | {
|
|---|
| 703 | FIXME("(0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3);
|
|---|
| 704 | return 0;
|
|---|
| 705 | }
|
|---|
| 706 |
|
|---|
| 707 | /******************************************************************************
|
|---|
| 708 | * RtlClearBits [NTDLL]
|
|---|
| 709 | *
|
|---|
| 710 | */
|
|---|
| 711 | NTSTATUS WINAPI RtlClearBits(DWORD x1,DWORD x2,DWORD x3)
|
|---|
| 712 | {
|
|---|
| 713 | FIXME("(0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3);
|
|---|
| 714 | return 0;
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | /******************************************************************************
|
|---|
| 718 | * RtlCopyMemory [NTDLL]
|
|---|
| 719 | *
|
|---|
| 720 | */
|
|---|
| 721 | #undef RtlCopyMemory
|
|---|
| 722 | VOID WINAPI RtlCopyMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
|
|---|
| 723 | {
|
|---|
| 724 | memcpy(Destination, Source, Length);
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 | /******************************************************************************
|
|---|
| 728 | * RtlMoveMemory [NTDLL]
|
|---|
| 729 | */
|
|---|
| 730 | #undef RtlMoveMemory
|
|---|
| 731 | VOID WINAPI RtlMoveMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
|
|---|
| 732 | {
|
|---|
| 733 | memmove(Destination, Source, Length);
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | /******************************************************************************
|
|---|
| 737 | * RtlFillMemory [NTDLL]
|
|---|
| 738 | */
|
|---|
| 739 | #undef RtlFillMemory
|
|---|
| 740 | VOID WINAPI RtlFillMemory( VOID *Destination, SIZE_T Length, UINT Fill )
|
|---|
| 741 | {
|
|---|
| 742 | memset(Destination, Fill, Length);
|
|---|
| 743 | }
|
|---|
| 744 |
|
|---|
| 745 | /******************************************************************************
|
|---|
| 746 | * RtlZeroMemory [NTDLL]
|
|---|
| 747 | */
|
|---|
| 748 | #undef RtlZeroMemory
|
|---|
| 749 | VOID WINAPI RtlZeroMemory( VOID *Destination, SIZE_T Length )
|
|---|
| 750 | {
|
|---|
| 751 | memset(Destination, 0, Length);
|
|---|
| 752 | }
|
|---|
| 753 |
|
|---|
| 754 | /******************************************************************************
|
|---|
| 755 | * RtlCompareMemory [NTDLL]
|
|---|
| 756 | */
|
|---|
| 757 | SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T Length)
|
|---|
| 758 | {
|
|---|
| 759 | int i;
|
|---|
| 760 | for(i=0; (i<Length) && (((LPBYTE)Source1)[i]==((LPBYTE)Source2)[i]); i++);
|
|---|
| 761 | return i;
|
|---|
| 762 | }
|
|---|
| 763 |
|
|---|
| 764 | /******************************************************************************
|
|---|
| 765 | * RtlAssert [NTDLL]
|
|---|
| 766 | *
|
|---|
| 767 | * Not implemented in non-debug versions.
|
|---|
| 768 | */
|
|---|
| 769 | void WINAPI RtlAssert(LPVOID x1,LPVOID x2,DWORD x3, DWORD x4)
|
|---|
| 770 | {
|
|---|
| 771 | FIXME("(%p,%p,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4);
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 | /*****************************************************************************
|
|---|
| 775 | * Name : RtlCopyLuid
|
|---|
| 776 | * Purpose : copy local unique identifier?
|
|---|
| 777 | * Parameters: PLUID pluid1
|
|---|
| 778 | * PLUID pluid2
|
|---|
| 779 | * Variables :
|
|---|
| 780 | * Result :
|
|---|
| 781 | * Remark : NTDLL.321
|
|---|
| 782 | * Status : COMPLETELY ? IMPLEMENTED TESTED ?
|
|---|
| 783 | *
|
|---|
| 784 | * Author : Patrick Haller [Tue, 1999/11/09 09:00]
|
|---|
| 785 | *****************************************************************************/
|
|---|
| 786 |
|
|---|
| 787 | PLUID WINAPI RtlCopyLuid(PLUID pluid1,
|
|---|
| 788 | PLUID pluid2)
|
|---|
| 789 | {
|
|---|
| 790 | pluid2->LowPart = pluid1->LowPart;
|
|---|
| 791 | pluid2->HighPart = pluid1->HighPart;
|
|---|
| 792 | return (pluid1);
|
|---|
| 793 | }
|
|---|