| 1 | /* $Id: nt.cpp,v 1.10 2000-10-02 13:10:10 phaller Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 |  | 
|---|
| 4 | /* | 
|---|
| 5 | * NT basis DLL | 
|---|
| 6 | * | 
|---|
| 7 | * This file contains the Nt* API functions of NTDLL.DLL. | 
|---|
| 8 | * In the original ntdll.dll they all seem to just call int 0x2e (down to the HAL) | 
|---|
| 9 | * | 
|---|
| 10 | * Copyright 1996-1998 Marcus Meissner | 
|---|
| 11 | * Copyright 1999      Patrick Haller | 
|---|
| 12 | */ | 
|---|
| 13 |  | 
|---|
| 14 | #include <odin.h> | 
|---|
| 15 | #include <odinwrap.h> | 
|---|
| 16 | #include <os2sel.h> | 
|---|
| 17 |  | 
|---|
| 18 |  | 
|---|
| 19 | #include <stdlib.h> | 
|---|
| 20 | #include <string.h> | 
|---|
| 21 | #include <time.h> | 
|---|
| 22 | #include <os2win.h> | 
|---|
| 23 | #include <handlemanager.h> | 
|---|
| 24 |  | 
|---|
| 25 | #include "ntdll.h" | 
|---|
| 26 | #include <ntdllsec.h> | 
|---|
| 27 |  | 
|---|
| 28 |  | 
|---|
| 29 | ODINDEBUGCHANNEL(NTDLL-NT) | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 | /* move to winbase.h */ | 
|---|
| 33 |  | 
|---|
| 34 | // @@@PH can't compile this WINE code | 
|---|
| 35 | //typedef VOID (CALLBACK *PTIMERAPCROUTINE)(LPVOID lpArgToCompletionRoutine,DWORD dwTimerLowValue,DWORD dwTimerHighValue); | 
|---|
| 36 | typedef PVOID PTIMERAPCROUTINE; | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | /* | 
|---|
| 40 | * Timer object | 
|---|
| 41 | */ | 
|---|
| 42 |  | 
|---|
| 43 | /************************************************************************** | 
|---|
| 44 | *    NtCreateTimer                               [NTDLL.87] | 
|---|
| 45 | */ | 
|---|
| 46 | NTSTATUS WINAPI NtCreateTimer(PHANDLE            TimerHandle, | 
|---|
| 47 | ACCESS_MASK        DesiredAccess, | 
|---|
| 48 | POBJECT_ATTRIBUTES ObjectAttributes, | 
|---|
| 49 | TIMER_TYPE         TimerType) | 
|---|
| 50 | { | 
|---|
| 51 | dprintf(("NTDLL: NtCreateTimer(%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 52 | TimerHandle, | 
|---|
| 53 | DesiredAccess, | 
|---|
| 54 | ObjectAttributes, | 
|---|
| 55 | TimerType)); | 
|---|
| 56 |  | 
|---|
| 57 | return 0; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | /************************************************************************** | 
|---|
| 62 | *    NtSetTimer                               [NTDLL.221] | 
|---|
| 63 | */ | 
|---|
| 64 | NTSTATUS WINAPI NtSetTimer(HANDLE           TimerHandle, | 
|---|
| 65 | PLARGE_INTEGER   DueTime, | 
|---|
| 66 | PTIMERAPCROUTINE TimerApcRoutine, | 
|---|
| 67 | PVOID            TimerContext, | 
|---|
| 68 | BOOLEAN          WakeTimer, | 
|---|
| 69 | ULONG            Period, | 
|---|
| 70 | PBOOLEAN         PreviousState) | 
|---|
| 71 | { | 
|---|
| 72 | dprintf(("NTDLL: NtSetTimer(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 73 | TimerHandle, | 
|---|
| 74 | DueTime, | 
|---|
| 75 | TimerApcRoutine, | 
|---|
| 76 | TimerContext, | 
|---|
| 77 | WakeTimer, | 
|---|
| 78 | Period, | 
|---|
| 79 | PreviousState)); | 
|---|
| 80 |  | 
|---|
| 81 | return 0; | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 |  | 
|---|
| 85 | /****************************************************************************** | 
|---|
| 86 | * NtQueryTimerResolution [NTDLL.129] | 
|---|
| 87 | */ | 
|---|
| 88 | NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1, | 
|---|
| 89 | DWORD x2, | 
|---|
| 90 | DWORD x3) | 
|---|
| 91 | { | 
|---|
| 92 | dprintf(("NTDLL: NtQueryTimerResolution(%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 93 | x1, | 
|---|
| 94 | x2, | 
|---|
| 95 | x3)); | 
|---|
| 96 |  | 
|---|
| 97 | return 1; | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 |  | 
|---|
| 101 | /* | 
|---|
| 102 | * Process object | 
|---|
| 103 | */ | 
|---|
| 104 |  | 
|---|
| 105 | /****************************************************************************** | 
|---|
| 106 | *  NtTerminateProcess                         [NTDLL.] | 
|---|
| 107 | * | 
|---|
| 108 | *  Native applications must kill themselves when done | 
|---|
| 109 | * FIXME: return value 0-success | 
|---|
| 110 | */ | 
|---|
| 111 | NTSTATUS WINAPI NtTerminateProcess(HANDLE ProcessHandle, | 
|---|
| 112 | LONG   ExitStatus) | 
|---|
| 113 | { | 
|---|
| 114 | dprintf(("NTDLL: NtTerminateProcess(%08xh,%08xh)", | 
|---|
| 115 | ProcessHandle, | 
|---|
| 116 | ExitStatus)); | 
|---|
| 117 |  | 
|---|
| 118 | /* win32 (0x7fffffff) to nt (-1) */ | 
|---|
| 119 | if ( NtCurrentProcess() == ProcessHandle ) | 
|---|
| 120 | ProcessHandle = GetCurrentProcess(); | 
|---|
| 121 |  | 
|---|
| 122 | /* @@@PH return code looks suspicious ! */ | 
|---|
| 123 | return (! TerminateProcess( ProcessHandle, ExitStatus )); | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 |  | 
|---|
| 127 | /****************************************************************************** | 
|---|
| 128 | *  NtQueryInformationProcess                [NTDLL.] | 
|---|
| 129 | * | 
|---|
| 130 | */ | 
|---|
| 131 | NTSTATUS WINAPI NtQueryInformationProcess(HANDLE           ProcessHandle, | 
|---|
| 132 | PROCESSINFOCLASS ProcessInformationClass, | 
|---|
| 133 | PVOID            ProcessInformation, | 
|---|
| 134 | ULONG            ProcessInformationLength, | 
|---|
| 135 | PULONG           ReturnLength) | 
|---|
| 136 | { | 
|---|
| 137 | dprintf(("NTDLL: NtQueryInformationProcess(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 138 | ProcessHandle, | 
|---|
| 139 | ProcessInformationClass, | 
|---|
| 140 | ProcessInformation, | 
|---|
| 141 | ProcessInformationLength, | 
|---|
| 142 | ReturnLength)); | 
|---|
| 143 |  | 
|---|
| 144 | // fake application, no debugger is running :) | 
|---|
| 145 | if(ProcessInformationClass == ProcessDebugPort) | 
|---|
| 146 | { | 
|---|
| 147 | memset(ProcessInformation, 0, ProcessInformationLength); | 
|---|
| 148 | return TRUE; | 
|---|
| 149 | } | 
|---|
| 150 |  | 
|---|
| 151 | return 0; | 
|---|
| 152 | } | 
|---|
| 153 |  | 
|---|
| 154 | /****************************************************************************** | 
|---|
| 155 | * NtSetInformationProcess [NTDLL.207] | 
|---|
| 156 | */ | 
|---|
| 157 | NTSTATUS WINAPI NtSetInformationProcess(HANDLE           ProcessHandle, | 
|---|
| 158 | PROCESSINFOCLASS ProcessInformationClass, | 
|---|
| 159 | PVOID            ProcessInformation, | 
|---|
| 160 | ULONG            ProcessInformationLength) | 
|---|
| 161 | { | 
|---|
| 162 | dprintf(("NTDLL: NtSetInformationProcess(%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 163 | ProcessHandle, | 
|---|
| 164 | ProcessInformationClass, | 
|---|
| 165 | ProcessInformation, | 
|---|
| 166 | ProcessInformationLength)); | 
|---|
| 167 |  | 
|---|
| 168 | return 0; | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 |  | 
|---|
| 172 | /* | 
|---|
| 173 | * Thread | 
|---|
| 174 | */ | 
|---|
| 175 |  | 
|---|
| 176 | /****************************************************************************** | 
|---|
| 177 | *  NtResumeThread                       [NTDLL] | 
|---|
| 178 | */ | 
|---|
| 179 | NTSTATUS WINAPI NtResumeThread(HANDLE ThreadHandle, | 
|---|
| 180 | PULONG SuspendCount) | 
|---|
| 181 | { | 
|---|
| 182 | dprintf(("NTDLL: NtResumeThread(%08xh,%08x) not implemented.\n", | 
|---|
| 183 | ThreadHandle, | 
|---|
| 184 | SuspendCount)); | 
|---|
| 185 |  | 
|---|
| 186 | return 0; | 
|---|
| 187 | } | 
|---|
| 188 |  | 
|---|
| 189 |  | 
|---|
| 190 | /****************************************************************************** | 
|---|
| 191 | *  NtTerminateThread                    [NTDLL] | 
|---|
| 192 | */ | 
|---|
| 193 | NTSTATUS WINAPI NtTerminateThread(HANDLE ThreadHandle, | 
|---|
| 194 | NTSTATUS ExitStatus) | 
|---|
| 195 | { | 
|---|
| 196 | dprintf(("NTDLL: NtTerminateThread(%08xh,%08xh) not correctly implemented.\n", | 
|---|
| 197 | ThreadHandle, | 
|---|
| 198 | ExitStatus)); | 
|---|
| 199 |  | 
|---|
| 200 | if ( TerminateThread(ThreadHandle,ExitStatus) ) | 
|---|
| 201 | return 0; | 
|---|
| 202 |  | 
|---|
| 203 | return 0xc0000000; /* FIXME: lasterror->ntstatus */ | 
|---|
| 204 | } | 
|---|
| 205 |  | 
|---|
| 206 |  | 
|---|
| 207 | /****************************************************************************** | 
|---|
| 208 | *  NtQueryInformationThread                 [NTDLL.] | 
|---|
| 209 | * | 
|---|
| 210 | */ | 
|---|
| 211 | NTSTATUS WINAPI NtQueryInformationThread(HANDLE          ThreadHandle, | 
|---|
| 212 | THREADINFOCLASS ThreadInformationClass, | 
|---|
| 213 | PVOID           ThreadInformation, | 
|---|
| 214 | ULONG           ThreadInformationLength, | 
|---|
| 215 | PULONG          ReturnLength) | 
|---|
| 216 | { | 
|---|
| 217 | dprintf(("NTDLL: NtQueryInformationThread(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 218 | ThreadHandle, | 
|---|
| 219 | ThreadInformationClass, | 
|---|
| 220 | ThreadInformation, | 
|---|
| 221 | ThreadInformationLength, | 
|---|
| 222 | ReturnLength)); | 
|---|
| 223 |  | 
|---|
| 224 | return 0; | 
|---|
| 225 | } | 
|---|
| 226 |  | 
|---|
| 227 |  | 
|---|
| 228 | /****************************************************************************** | 
|---|
| 229 | *  NtSetInformationThread                  [NTDLL] | 
|---|
| 230 | */ | 
|---|
| 231 | NTSTATUS WINAPI NtSetInformationThread(HANDLE          ThreadHandle, | 
|---|
| 232 | THREADINFOCLASS ThreadInformationClass, | 
|---|
| 233 | PVOID           ThreadInformation, | 
|---|
| 234 | ULONG           ThreadInformationLength) | 
|---|
| 235 | { | 
|---|
| 236 | dprintf(("NTDLL: NtSetInformationThread(%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 237 | ThreadHandle, | 
|---|
| 238 | ThreadInformationClass, | 
|---|
| 239 | ThreadInformation, | 
|---|
| 240 | ThreadInformationLength)); | 
|---|
| 241 |  | 
|---|
| 242 | return 0; | 
|---|
| 243 | } | 
|---|
| 244 |  | 
|---|
| 245 |  | 
|---|
| 246 | /* | 
|---|
| 247 | * Token | 
|---|
| 248 | */ | 
|---|
| 249 |  | 
|---|
| 250 | /****************************************************************************** | 
|---|
| 251 | *  NtDuplicateToken                        [NTDLL] | 
|---|
| 252 | */ | 
|---|
| 253 | NTSTATUS WINAPI NtDuplicateToken(HANDLE                       ExistingToken, | 
|---|
| 254 | ACCESS_MASK                  DesiredAccess, | 
|---|
| 255 | POBJECT_ATTRIBUTES           ObjectAttributes, | 
|---|
| 256 | SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, | 
|---|
| 257 | TOKEN_TYPE                   TokenType, | 
|---|
| 258 | PHANDLE                      NewToken) | 
|---|
| 259 | { | 
|---|
| 260 | dprintf(("NTDLL: NtDuplicateToken(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 261 | ExistingToken, | 
|---|
| 262 | DesiredAccess, | 
|---|
| 263 | ObjectAttributes, | 
|---|
| 264 | ImpersonationLevel, | 
|---|
| 265 | TokenType, | 
|---|
| 266 | NewToken)); | 
|---|
| 267 |  | 
|---|
| 268 | return 0; | 
|---|
| 269 | } | 
|---|
| 270 |  | 
|---|
| 271 | /****************************************************************************** | 
|---|
| 272 | *  NtOpenProcessToken                      [NTDLL] | 
|---|
| 273 | */ | 
|---|
| 274 | NTSTATUS WINAPI NtOpenProcessToken(HANDLE  ProcessHandle, | 
|---|
| 275 | DWORD   DesiredAccess, | 
|---|
| 276 | PHANDLE TokenHandle) | 
|---|
| 277 | { | 
|---|
| 278 | dprintf(("NTDLL: NtOpenProcessToken(%08xh,%08xh,%08xh) not correctly implemented.\n", | 
|---|
| 279 | ProcessHandle, | 
|---|
| 280 | DesiredAccess, | 
|---|
| 281 | TokenHandle)); | 
|---|
| 282 |  | 
|---|
| 283 | if(ProcessHandle == GetCurrentProcess()) { | 
|---|
| 284 | HMOpenProcessToken(ProcessHandle, DesiredAccess, (ULONG)&ProcSecInfo, TokenHandle); | 
|---|
| 285 | return STATUS_SUCCESS; | 
|---|
| 286 | } | 
|---|
| 287 | *TokenHandle = 0; | 
|---|
| 288 | return ERROR_INVALID_HANDLE; | 
|---|
| 289 | } | 
|---|
| 290 |  | 
|---|
| 291 |  | 
|---|
| 292 | /****************************************************************************** | 
|---|
| 293 | *  NtOpenThreadToken                       [NTDLL] | 
|---|
| 294 | */ | 
|---|
| 295 | NTSTATUS WINAPI NtOpenThreadToken(HANDLE  ThreadHandle, | 
|---|
| 296 | DWORD   DesiredAccess, | 
|---|
| 297 | BOOLEAN OpenAsSelf, | 
|---|
| 298 | PHANDLE TokenHandle) | 
|---|
| 299 | { | 
|---|
| 300 | dprintf(("NTDLL: NtOpenThreadToken(%08xh,%08xh,%08xh,%08xh) partly implemented.\n", | 
|---|
| 301 | ThreadHandle, | 
|---|
| 302 | DesiredAccess, | 
|---|
| 303 | OpenAsSelf, | 
|---|
| 304 | TokenHandle)); | 
|---|
| 305 |  | 
|---|
| 306 | return HMOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle); | 
|---|
| 307 | } | 
|---|
| 308 |  | 
|---|
| 309 |  | 
|---|
| 310 | /****************************************************************************** | 
|---|
| 311 | *  NtAdjustPrivilegesToken                 [NTDLL] | 
|---|
| 312 | * | 
|---|
| 313 | * FIXME: parameters unsafe | 
|---|
| 314 | */ | 
|---|
| 315 | NTSTATUS WINAPI NtAdjustPrivilegesToken(HANDLE            TokenHandle, | 
|---|
| 316 | BOOLEAN           DisableAllPrivileges, | 
|---|
| 317 | PTOKEN_PRIVILEGES NewState, | 
|---|
| 318 | DWORD             BufferLength, | 
|---|
| 319 | PTOKEN_PRIVILEGES PreviousState, | 
|---|
| 320 | PDWORD            ReturnLength) | 
|---|
| 321 | { | 
|---|
| 322 | dprintf(("NTDLL: NtAdjustPrivilegesToken(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 323 | TokenHandle, | 
|---|
| 324 | DisableAllPrivileges, | 
|---|
| 325 | NewState, | 
|---|
| 326 | BufferLength, | 
|---|
| 327 | PreviousState, | 
|---|
| 328 | ReturnLength)); | 
|---|
| 329 |  | 
|---|
| 330 | return 0; | 
|---|
| 331 | } | 
|---|
| 332 |  | 
|---|
| 333 |  | 
|---|
| 334 | /****************************************************************************** | 
|---|
| 335 | *  NtQueryInformationToken                  [NTDLL.156] | 
|---|
| 336 | * | 
|---|
| 337 | */ | 
|---|
| 338 | ODINFUNCTION5(NTSTATUS, NtQueryInformationToken, | 
|---|
| 339 | HANDLE,   Token, | 
|---|
| 340 | DWORD,    TokenInformationClass, | 
|---|
| 341 | LPVOID,   TokenInformation, | 
|---|
| 342 | DWORD,    TokenInformationLength, | 
|---|
| 343 | LPDWORD,  ReturnLength) | 
|---|
| 344 | { | 
|---|
| 345 | PROCESSTHREAD_SECURITYINFO *pSecInfo; | 
|---|
| 346 |  | 
|---|
| 347 | dprintf(("NTDLL: NtQueryInformationToken not correctly implemented.\n")); | 
|---|
| 348 |  | 
|---|
| 349 | pSecInfo = (PROCESSTHREAD_SECURITYINFO*)HMHandleGetUserData(Token); | 
|---|
| 350 | if((ULONG)pSecInfo == -1) { | 
|---|
| 351 | return ERROR_INVALID_HANDLE; | 
|---|
| 352 | } | 
|---|
| 353 | switch (TokenInformationClass) | 
|---|
| 354 | { | 
|---|
| 355 | case TokenGroups:                    /* 2 */ | 
|---|
| 356 | *ReturnLength = sizeof (TOKEN_GROUPS); | 
|---|
| 357 | if(TokenInformationLength < sizeof (TOKEN_GROUPS)) { | 
|---|
| 358 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 359 | } | 
|---|
| 360 | memcpy(TokenInformation, (LPVOID)pSecInfo->pTokenGroups, sizeof(TOKEN_GROUPS)); | 
|---|
| 361 | break; | 
|---|
| 362 | case TokenUser:                     /* 1 */ | 
|---|
| 363 | { | 
|---|
| 364 | int len = sizeof (TOKEN_USER) + sizeof(SID); | 
|---|
| 365 | *ReturnLength = len; | 
|---|
| 366 | if(len <= TokenInformationLength) { | 
|---|
| 367 | if(TokenInformation) | 
|---|
| 368 | { | 
|---|
| 369 | TOKEN_USER *tuser = (TOKEN_USER *)TokenInformation; | 
|---|
| 370 | PSID sid = (PSID) &((LPBYTE)TokenInformation)[sizeof(TOKEN_USER)]; | 
|---|
| 371 | SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY}; | 
|---|
| 372 | RtlInitializeSid(sid, &localSidAuthority, 1); | 
|---|
| 373 | *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID; | 
|---|
| 374 | tuser->User.Sid = sid; | 
|---|
| 375 | } | 
|---|
| 376 | } | 
|---|
| 377 | else { | 
|---|
| 378 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 379 | } | 
|---|
| 380 | break; | 
|---|
| 381 | } | 
|---|
| 382 | case TokenPrivileges: | 
|---|
| 383 | *ReturnLength = sizeof (TOKEN_PRIVILEGES); | 
|---|
| 384 | if(TokenInformationLength < sizeof (TOKEN_PRIVILEGES)) { | 
|---|
| 385 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 386 | } | 
|---|
| 387 | memset(TokenInformation, 0, sizeof(TOKEN_PRIVILEGES)); | 
|---|
| 388 | break; | 
|---|
| 389 | case TokenOwner: | 
|---|
| 390 | *ReturnLength = sizeof (TOKEN_OWNER); | 
|---|
| 391 | if(TokenInformationLength < sizeof (TOKEN_OWNER)) { | 
|---|
| 392 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 393 | } | 
|---|
| 394 | memset(TokenInformation, 0, sizeof(TOKEN_OWNER)); | 
|---|
| 395 | break; | 
|---|
| 396 | case TokenPrimaryGroup: | 
|---|
| 397 | *ReturnLength = sizeof (TOKEN_PRIMARY_GROUP); | 
|---|
| 398 | if(TokenInformationLength < sizeof (TOKEN_PRIMARY_GROUP)) { | 
|---|
| 399 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 400 | } | 
|---|
| 401 | memset(TokenInformation, 0, sizeof(TOKEN_PRIMARY_GROUP)); | 
|---|
| 402 | break; | 
|---|
| 403 | case TokenDefaultDacl: | 
|---|
| 404 | *ReturnLength = sizeof (TOKEN_DEFAULT_DACL); | 
|---|
| 405 | if(TokenInformationLength < sizeof (TOKEN_DEFAULT_DACL)) { | 
|---|
| 406 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 407 | } | 
|---|
| 408 | memset(TokenInformation, 0, sizeof(TOKEN_DEFAULT_DACL)); | 
|---|
| 409 | break; | 
|---|
| 410 | case TokenSource: | 
|---|
| 411 | *ReturnLength = sizeof (TOKEN_SOURCE); | 
|---|
| 412 | if(TokenInformationLength < sizeof (TOKEN_SOURCE)) { | 
|---|
| 413 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 414 | } | 
|---|
| 415 | memset(TokenInformation, 0, sizeof(TOKEN_SOURCE)); | 
|---|
| 416 | break; | 
|---|
| 417 | case TokenType: | 
|---|
| 418 | *ReturnLength = sizeof (TOKEN_TYPE); | 
|---|
| 419 | if(TokenInformationLength < sizeof (TOKEN_TYPE)) { | 
|---|
| 420 | return STATUS_BUFFER_TOO_SMALL; | 
|---|
| 421 | } | 
|---|
| 422 | memset(TokenInformation, 0, sizeof(TOKEN_TYPE)); | 
|---|
| 423 | break; | 
|---|
| 424 | #if 0 | 
|---|
| 425 | case TokenImpersonationLevel: | 
|---|
| 426 | case TokenStatistics: | 
|---|
| 427 | #endif /* 0 */ | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | return STATUS_SUCCESS; | 
|---|
| 431 | } | 
|---|
| 432 |  | 
|---|
| 433 |  | 
|---|
| 434 | /* | 
|---|
| 435 | * Section | 
|---|
| 436 | */ | 
|---|
| 437 |  | 
|---|
| 438 | /****************************************************************************** | 
|---|
| 439 | *  NtCreateSection                      [NTDLL] | 
|---|
| 440 | */ | 
|---|
| 441 | NTSTATUS WINAPI NtCreateSection(PHANDLE SectionHandle, | 
|---|
| 442 | ACCESS_MASK DesiredAccess, | 
|---|
| 443 | POBJECT_ATTRIBUTES ObjectAttributes, | 
|---|
| 444 | PLARGE_INTEGER MaximumSize, | 
|---|
| 445 | ULONG SectionPageProtection, | 
|---|
| 446 | ULONG AllocationAttributes, | 
|---|
| 447 | HANDLE FileHandle) | 
|---|
| 448 | { | 
|---|
| 449 | dprintf(("NTDLL: NtCreateSection(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 450 | SectionHandle, | 
|---|
| 451 | DesiredAccess, | 
|---|
| 452 | ObjectAttributes, | 
|---|
| 453 | MaximumSize, | 
|---|
| 454 | SectionPageProtection, | 
|---|
| 455 | AllocationAttributes, | 
|---|
| 456 | FileHandle)); | 
|---|
| 457 |  | 
|---|
| 458 | return 0; | 
|---|
| 459 | } | 
|---|
| 460 |  | 
|---|
| 461 |  | 
|---|
| 462 | /****************************************************************************** | 
|---|
| 463 | *  NtOpenSection [NTDLL] | 
|---|
| 464 | */ | 
|---|
| 465 | NTSTATUS WINAPI NtOpenSection(PHANDLE SectionHandle, | 
|---|
| 466 | ACCESS_MASK DesiredAccess, | 
|---|
| 467 | POBJECT_ATTRIBUTES ObjectAttributes) | 
|---|
| 468 | { | 
|---|
| 469 | dprintf(("NTDLL: NtOpenSection(%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 470 | SectionHandle, | 
|---|
| 471 | DesiredAccess, | 
|---|
| 472 | ObjectAttributes)); | 
|---|
| 473 |  | 
|---|
| 474 | return 0; | 
|---|
| 475 | } | 
|---|
| 476 |  | 
|---|
| 477 |  | 
|---|
| 478 | /****************************************************************************** | 
|---|
| 479 | *  NtQuerySection                       [NTDLL] | 
|---|
| 480 | */ | 
|---|
| 481 | NTSTATUS WINAPI NtQuerySection(HANDLE SectionHandle, | 
|---|
| 482 | PVOID SectionInformationClass, | 
|---|
| 483 | PVOID SectionInformation, | 
|---|
| 484 | ULONG Length, | 
|---|
| 485 | PULONG ResultLength) | 
|---|
| 486 | { | 
|---|
| 487 | dprintf(("NTDLL: NtQuerySection(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 488 | SectionHandle, | 
|---|
| 489 | SectionInformationClass, | 
|---|
| 490 | SectionInformation, | 
|---|
| 491 | Length, | 
|---|
| 492 | ResultLength)); | 
|---|
| 493 |  | 
|---|
| 494 | return 0; | 
|---|
| 495 | } | 
|---|
| 496 |  | 
|---|
| 497 |  | 
|---|
| 498 | /****************************************************************************** | 
|---|
| 499 | * NtMapViewOfSection                    [NTDLL] | 
|---|
| 500 | * FUNCTION: Maps a view of a section into the virtual address space of a process | 
|---|
| 501 | * | 
|---|
| 502 | * ARGUMENTS: | 
|---|
| 503 | *  SectionHandle Handle of the section | 
|---|
| 504 | *  ProcessHandle Handle of the process | 
|---|
| 505 | *  BaseAddress                          Desired base address (or NULL) on entry | 
|---|
| 506 | *       Actual base address of the view on exit | 
|---|
| 507 | *  ZeroBits      Number of high order address bits that must be zero | 
|---|
| 508 | *  CommitSize    Size bytes of the initially committed section of the view | 
|---|
| 509 | *  SectionOffset Offset bytes from the beginning of the section to the beginning of the view | 
|---|
| 510 | *  ViewSize      Desired length of map (or zero to map all) on entry | 
|---|
| 511 | Actual length mapped on exit | 
|---|
| 512 | *  InheritDisposition                   Specified how the view is to be shared with | 
|---|
| 513 | *       child processes | 
|---|
| 514 | *  AllocateType  Type of allocation for the pages | 
|---|
| 515 | *  Protect    Protection for the committed region of the view | 
|---|
| 516 | */ | 
|---|
| 517 | NTSTATUS WINAPI NtMapViewOfSection(HANDLE          SectionHandle, | 
|---|
| 518 | HANDLE          ProcessHandle, | 
|---|
| 519 | PVOID*          BaseAddress, | 
|---|
| 520 | ULONG           ZeroBits, | 
|---|
| 521 | ULONG           CommitSize, | 
|---|
| 522 | PLARGE_INTEGER  SectionOffset, | 
|---|
| 523 | PULONG          ViewSize, | 
|---|
| 524 | SECTION_INHERIT InheritDisposition, | 
|---|
| 525 | ULONG           AllocationType, | 
|---|
| 526 | ULONG           Protect) | 
|---|
| 527 | { | 
|---|
| 528 | dprintf(("NTDLL: NtMapViewOfSection(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 529 | SectionHandle, | 
|---|
| 530 | ProcessHandle, | 
|---|
| 531 | BaseAddress, | 
|---|
| 532 | ZeroBits, | 
|---|
| 533 | CommitSize, | 
|---|
| 534 | SectionOffset, | 
|---|
| 535 | ViewSize, | 
|---|
| 536 | InheritDisposition, | 
|---|
| 537 | AllocationType, | 
|---|
| 538 | Protect)); | 
|---|
| 539 |  | 
|---|
| 540 | return 0; | 
|---|
| 541 | } | 
|---|
| 542 |  | 
|---|
| 543 |  | 
|---|
| 544 | /* | 
|---|
| 545 | * ports | 
|---|
| 546 | */ | 
|---|
| 547 |  | 
|---|
| 548 | /****************************************************************************** | 
|---|
| 549 | *  NtCreatePort                         [NTDLL] | 
|---|
| 550 | */ | 
|---|
| 551 | NTSTATUS WINAPI NtCreatePort(DWORD x1, | 
|---|
| 552 | DWORD x2, | 
|---|
| 553 | DWORD x3, | 
|---|
| 554 | DWORD x4, | 
|---|
| 555 | DWORD x5) | 
|---|
| 556 | { | 
|---|
| 557 | dprintf(("NTDLL: NtCreatePort(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 558 | x1, | 
|---|
| 559 | x2, | 
|---|
| 560 | x3, | 
|---|
| 561 | x4, | 
|---|
| 562 | x5)); | 
|---|
| 563 |  | 
|---|
| 564 | return 0; | 
|---|
| 565 | } | 
|---|
| 566 |  | 
|---|
| 567 |  | 
|---|
| 568 | /****************************************************************************** | 
|---|
| 569 | *  NtConnectPort                        [NTDLL] | 
|---|
| 570 | */ | 
|---|
| 571 | NTSTATUS WINAPI NtConnectPort(DWORD           x1, | 
|---|
| 572 | PUNICODE_STRING uni, | 
|---|
| 573 | DWORD           x3, | 
|---|
| 574 | DWORD           x4, | 
|---|
| 575 | DWORD           x5, | 
|---|
| 576 | DWORD           x6, | 
|---|
| 577 | DWORD           x7, | 
|---|
| 578 | DWORD           x8) | 
|---|
| 579 | { | 
|---|
| 580 | dprintf(("NTDLL: NtConnectPort(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 581 | x1, | 
|---|
| 582 | uni, | 
|---|
| 583 | x3, | 
|---|
| 584 | x4, | 
|---|
| 585 | x5, | 
|---|
| 586 | x6, | 
|---|
| 587 | x7, | 
|---|
| 588 | x8)); | 
|---|
| 589 |  | 
|---|
| 590 | return 0; | 
|---|
| 591 | } | 
|---|
| 592 |  | 
|---|
| 593 |  | 
|---|
| 594 | /****************************************************************************** | 
|---|
| 595 | *  NtListenPort                         [NTDLL] | 
|---|
| 596 | */ | 
|---|
| 597 | NTSTATUS WINAPI NtListenPort(DWORD x1, | 
|---|
| 598 | DWORD x2) | 
|---|
| 599 | { | 
|---|
| 600 | dprintf(("NTDLL: NtListenPort(%08xh,%08xh) not implemented.\n", | 
|---|
| 601 | x1, | 
|---|
| 602 | x2)); | 
|---|
| 603 |  | 
|---|
| 604 | return 0; | 
|---|
| 605 | } | 
|---|
| 606 |  | 
|---|
| 607 |  | 
|---|
| 608 | /****************************************************************************** | 
|---|
| 609 | *  NtAcceptConnectPort                  [NTDLL] | 
|---|
| 610 | */ | 
|---|
| 611 | NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1, | 
|---|
| 612 | DWORD x2, | 
|---|
| 613 | DWORD x3, | 
|---|
| 614 | DWORD x4, | 
|---|
| 615 | DWORD x5, | 
|---|
| 616 | DWORD x6) | 
|---|
| 617 | { | 
|---|
| 618 | dprintf(("NTDLL: NtAcceptConnectPort(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 619 | x1, | 
|---|
| 620 | x2, | 
|---|
| 621 | x3, | 
|---|
| 622 | x4, | 
|---|
| 623 | x5, | 
|---|
| 624 | x6)); | 
|---|
| 625 |  | 
|---|
| 626 | return 0; | 
|---|
| 627 | } | 
|---|
| 628 |  | 
|---|
| 629 |  | 
|---|
| 630 | /****************************************************************************** | 
|---|
| 631 | *  NtCompleteConnectPort                [NTDLL] | 
|---|
| 632 | */ | 
|---|
| 633 | NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1) | 
|---|
| 634 | { | 
|---|
| 635 | dprintf(("NTDLL: NtCompleteConnectPort(%08xh) not implemented.\n", | 
|---|
| 636 | x1)); | 
|---|
| 637 |  | 
|---|
| 638 | return 0; | 
|---|
| 639 | } | 
|---|
| 640 |  | 
|---|
| 641 |  | 
|---|
| 642 | /****************************************************************************** | 
|---|
| 643 | *  NtRegisterThreadTerminatePort        [NTDLL] | 
|---|
| 644 | */ | 
|---|
| 645 | NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1) | 
|---|
| 646 | { | 
|---|
| 647 | dprintf(("NTDLL: NtRegisterThreadTerminatePort(%08xh) not implemented.\n", | 
|---|
| 648 | x1)); | 
|---|
| 649 |  | 
|---|
| 650 | return 0; | 
|---|
| 651 | } | 
|---|
| 652 |  | 
|---|
| 653 |  | 
|---|
| 654 | /****************************************************************************** | 
|---|
| 655 | *  NtRequestWaitReplyPort                  [NTDLL] | 
|---|
| 656 | */ | 
|---|
| 657 | NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1, | 
|---|
| 658 | DWORD x2, | 
|---|
| 659 | DWORD x3) | 
|---|
| 660 | { | 
|---|
| 661 | dprintf(("NTDLL: NtRequestWaitReplyPort(%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 662 | x1, | 
|---|
| 663 | x2, | 
|---|
| 664 | x3)); | 
|---|
| 665 |  | 
|---|
| 666 | return 0; | 
|---|
| 667 | } | 
|---|
| 668 |  | 
|---|
| 669 |  | 
|---|
| 670 | /****************************************************************************** | 
|---|
| 671 | *  NtReplyWaitReceivePort               [NTDLL] | 
|---|
| 672 | */ | 
|---|
| 673 | NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1, | 
|---|
| 674 | DWORD x2, | 
|---|
| 675 | DWORD x3, | 
|---|
| 676 | DWORD x4) | 
|---|
| 677 | { | 
|---|
| 678 | dprintf(("NTDLL: NtReplyWaitReceivePort(%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 679 | x1, | 
|---|
| 680 | x2, | 
|---|
| 681 | x3, | 
|---|
| 682 | x4)); | 
|---|
| 683 |  | 
|---|
| 684 | return 0; | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 |  | 
|---|
| 688 | /* | 
|---|
| 689 | * Misc | 
|---|
| 690 | */ | 
|---|
| 691 |  | 
|---|
| 692 | /****************************************************************************** | 
|---|
| 693 | *  NtSetIntervalProfile                 [NTDLL] | 
|---|
| 694 | */ | 
|---|
| 695 | NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1, | 
|---|
| 696 | DWORD x2) | 
|---|
| 697 | { | 
|---|
| 698 | dprintf(("NTDLL: NtSetIntervalProfile(%08xh,%08xh) not implemented.\n", | 
|---|
| 699 | x1, | 
|---|
| 700 | x2)); | 
|---|
| 701 |  | 
|---|
| 702 | return 0; | 
|---|
| 703 | } | 
|---|
| 704 |  | 
|---|
| 705 |  | 
|---|
| 706 | /****************************************************************************** | 
|---|
| 707 | *  NtQueryPerformanceCounter            [NTDLL] | 
|---|
| 708 | */ | 
|---|
| 709 | NTSTATUS WINAPI NtQueryPerformanceCounter(PLARGE_INTEGER Counter, | 
|---|
| 710 | PLARGE_INTEGER Frequency) | 
|---|
| 711 | { | 
|---|
| 712 | dprintf(("NTDLL: NtQueryPerformanceCounter(%08xh,%08xh) not implemented.\n", | 
|---|
| 713 | Counter, | 
|---|
| 714 | Frequency)); | 
|---|
| 715 |  | 
|---|
| 716 | return 0; | 
|---|
| 717 | } | 
|---|
| 718 |  | 
|---|
| 719 |  | 
|---|
| 720 | /****************************************************************************** | 
|---|
| 721 | *  NtCreateMailSlotFile                 [NTDLL] | 
|---|
| 722 | */ | 
|---|
| 723 | NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1, | 
|---|
| 724 | DWORD x2, | 
|---|
| 725 | DWORD x3, | 
|---|
| 726 | DWORD x4, | 
|---|
| 727 | DWORD x5, | 
|---|
| 728 | DWORD x6, | 
|---|
| 729 | DWORD x7, | 
|---|
| 730 | DWORD x8) | 
|---|
| 731 | { | 
|---|
| 732 | dprintf(("NTDLL: NtCreateMailslotFile(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 733 | x1, | 
|---|
| 734 | x2, | 
|---|
| 735 | x3, | 
|---|
| 736 | x4, | 
|---|
| 737 | x5, | 
|---|
| 738 | x6, | 
|---|
| 739 | x7, | 
|---|
| 740 | x8)); | 
|---|
| 741 |  | 
|---|
| 742 | return 0; | 
|---|
| 743 | } | 
|---|
| 744 |  | 
|---|
| 745 |  | 
|---|
| 746 | /****************************************************************************** | 
|---|
| 747 | * NtQuerySystemInformation [NTDLL.168] | 
|---|
| 748 | * | 
|---|
| 749 | * ARGUMENTS: | 
|---|
| 750 | *  SystemInformationClass               Index to a certain information structure | 
|---|
| 751 | * SystemTimeAdjustmentInformation       SYSTEM_TIME_ADJUSTMENT | 
|---|
| 752 | * SystemCacheInformation                   SYSTEM_CACHE_INFORMATION | 
|---|
| 753 | * SystemConfigurationInformation        CONFIGURATION_INFORMATION | 
|---|
| 754 | * observed (class/len): | 
|---|
| 755 | *    0x0/0x2c | 
|---|
| 756 | *    0x12/0x18 | 
|---|
| 757 | *    0x2/0x138 | 
|---|
| 758 | *    0x8/0x600 | 
|---|
| 759 | *  SystemInformation                    caller supplies storage for the information structure | 
|---|
| 760 | *  Length     size of the structure | 
|---|
| 761 | *  ResultLength  Data written | 
|---|
| 762 | */ | 
|---|
| 763 | NTSTATUS WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, | 
|---|
| 764 | PVOID                    SystemInformation, | 
|---|
| 765 | ULONG                    Length, | 
|---|
| 766 | PULONG                   ResultLength) | 
|---|
| 767 | { | 
|---|
| 768 | dprintf(("NTDLL: NtQuerySystemInformation(%08xh,%08xh,%08xh,%08xh) not implemented.\n", | 
|---|
| 769 | SystemInformationClass, | 
|---|
| 770 | SystemInformation, | 
|---|
| 771 | Length, | 
|---|
| 772 | ResultLength)); | 
|---|
| 773 |  | 
|---|
| 774 | ZeroMemory (SystemInformation, Length); | 
|---|
| 775 | return 0; | 
|---|
| 776 | } | 
|---|
| 777 |  | 
|---|
| 778 |  | 
|---|
| 779 | /****************************************************************************** | 
|---|
| 780 | *  NtCreatePagingFile                      [NTDLL] | 
|---|
| 781 | */ | 
|---|
| 782 | NTSTATUS WINAPI NtCreatePagingFile(PUNICODE_STRING PageFileName, | 
|---|
| 783 | ULONG MinimumSize, | 
|---|
| 784 | ULONG MaximumSize, | 
|---|
| 785 | PULONG ActualSize) | 
|---|
| 786 | { | 
|---|
| 787 | dprintf(("NTDLL: NtCreatePagingFile(%08xh, %08xh, %08xh, %08xh) not implemented.\n", | 
|---|
| 788 | PageFileName, | 
|---|
| 789 | MinimumSize, | 
|---|
| 790 | MaximumSize, | 
|---|
| 791 | ActualSize)); | 
|---|
| 792 |  | 
|---|
| 793 | return 0; | 
|---|
| 794 | } | 
|---|
| 795 |  | 
|---|
| 796 |  | 
|---|
| 797 | /****************************************************************************** | 
|---|
| 798 | *  NtDisplayString                               [NTDLL.95] | 
|---|
| 799 | * | 
|---|
| 800 | * writes a string to the nt-textmode screen eg. during startup | 
|---|
| 801 | */ | 
|---|
| 802 | NTSTATUS WINAPI NtDisplayString (PUNICODE_STRING string) | 
|---|
| 803 | { | 
|---|
| 804 | dprintf(("NTDLL: NtDisplayString(%08xh\n", | 
|---|
| 805 | string)); | 
|---|
| 806 |  | 
|---|
| 807 | WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), | 
|---|
| 808 | string->Buffer, | 
|---|
| 809 | string->Length, | 
|---|
| 810 | 0, | 
|---|
| 811 | 0); | 
|---|
| 812 |  | 
|---|
| 813 | return 0; | 
|---|
| 814 | } | 
|---|
| 815 |  | 
|---|
| 816 | /****************************************************************************** | 
|---|
| 817 | *  NtPowerInformation                          [NTDLL] | 
|---|
| 818 | * | 
|---|
| 819 | */ | 
|---|
| 820 | NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5) | 
|---|
| 821 | { | 
|---|
| 822 | dprintf(("NTDLL: NtPowerInformation(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx) not implemented\n", | 
|---|
| 823 | x1,x2,x3,x4,x5)); | 
|---|
| 824 | return 0; | 
|---|
| 825 | } | 
|---|
| 826 |  | 
|---|
| 827 | /****************************************************************************** | 
|---|
| 828 | *  NtAllocateLocallyUniqueId | 
|---|
| 829 | * | 
|---|
| 830 | * FIXME: the server should do that | 
|---|
| 831 | */ | 
|---|
| 832 | NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID pLuid) | 
|---|
| 833 | { | 
|---|
| 834 | static LUID luid; | 
|---|
| 835 |  | 
|---|
| 836 | dprintf(("NTDLL: NtAllocateLocallyUniqueId %p (0x%08lx%08lx)\n", | 
|---|
| 837 | pLuid, | 
|---|
| 838 | luid.HighPart, | 
|---|
| 839 | luid.LowPart)); | 
|---|
| 840 |  | 
|---|
| 841 | luid.LowPart++;        // PH: why don't we use 64-bit arithmetic here? | 
|---|
| 842 | if (luid.LowPart == 0) // handle overflow | 
|---|
| 843 | luid.HighPart++; | 
|---|
| 844 |  | 
|---|
| 845 | pLuid->LowPart  = luid.LowPart; | 
|---|
| 846 | pLuid->HighPart = luid.HighPart; | 
|---|
| 847 | return STATUS_SUCCESS; | 
|---|
| 848 | } | 
|---|
| 849 |  | 
|---|