00233 {
00234
NTSTATUS Status;
00235 STRING
DirectoryName;
00236 STRING LinkName;
00237 STRING LinkTarget;
00238 STRING SectionName;
00239 OBJECT_ATTRIBUTES
ObjectAttributes;
00240 HANDLE
DirectoryHandle, LinkHandle, SectionHandle;
00241 ULONG ReturnedLength;
00242
CHAR ObjectInfoBuffer[ 512 ];
00243 OBJECT_BASIC_INFORMATION ObjectBasicInfo;
00244 POBJECT_NAME_INFORMATION ObjectNameInfo;
00245 POBJECT_TYPE_INFORMATION ObjectTypeInfo;
00246 LARGE_INTEGER SectionSize;
00247
00248
Status = STATUS_SUCCESS;
00249
00250
DbgPrint(
"Entering Object Manager User Mode Test Program\n" );
00251
00252
RtlInitString( &SectionName,
"\\A:\\OSO001.MSG" );
00253 InitializeObjectAttributes( &ObjectAttributes,
00254 &SectionName,
00255 OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
00256 NULL,
00257 NULL
00258 );
00259
00260 SectionSize.LowPart = 0x1000;
00261 SectiinSize.HighPart = 0;
00262
Status =
NtCreateSection( &SectionHandle,
00263 GENERIC_READ,
00264 &ObjectAttributes,
00265 &SectionSize,
00266 PAGE_READONLY,
00267 SEC_RESERVE,
00268 NULL
00269 );
00270
if (!
NT_SUCCESS( Status )) {
00271
DbgPrint(
"Unable to create %Z section object (%X) [OK]\n", &SectionName, Status );
00272 }
00273
00274
RtlInitString( &DirectoryName,
"\\Drives" );
00275 InitializeObjectAttributes( &ObjectAttributes,
00276 &DirectoryName,
00277 OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
00278 NULL,
00279 (PSECURITY_DESCRIPTOR)1
00280
00281 );
00282
ObjectAttributes.Length = 0;
00283
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00284 -1,
00285 &ObjectAttributes
00286 );
00287
if (!
NT_SUCCESS( Status )) {
00288
DbgPrint(
"Unable to create %Z directory object (%X) [OK]\n",
00289 &DirectoryName, Status );
00290 }
00291
00292
RtlInitString( &DirectoryName,
"\\Drives" );
00293 InitializeObjectAttributes( &ObjectAttributes,
00294 &DirectoryName,
00295 OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
00296 NULL,
00297 (PSECURITY_DESCRIPTOR)1
00298
00299 );
00300
ObjectAttributes.Length = 0;
00301
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00302 DIRECTORY_ALL_ACCESS,
00303 &ObjectAttributes
00304 );
00305
if (!
NT_SUCCESS( Status )) {
00306
DbgPrint(
"Unable to create %Z directory object (%X) [OK]\n",
00307 &DirectoryName, Status );
00308 }
00309
00310 InitializeObjectAttributes( &ObjectAttributes,
00311 &DirectoryName,
00312 -1,
00313 NULL,
00314 (PSECURITY_DESCRIPTOR)1
00315
00316 );
00317
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00318 DIRECTORY_ALL_ACCESS,
00319 &ObjectAttributes
00320 );
00321
if (!
NT_SUCCESS( Status )) {
00322
DbgPrint(
"Unable to create %Z directory object (%X) [OK]\n",
00323 &DirectoryName, Status );
00324 }
00325
00326 InitializeObjectAttributes( &ObjectAttributes,
00327 &DirectoryName,
00328 OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
00329 NULL,
00330 (PSECURITY_DESCRIPTOR)1
00331
00332 );
00333
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00334 DIRECTORY_ALL_ACCESS,
00335 &ObjectAttributes
00336 );
00337
if (!
NT_SUCCESS( Status )) {
00338
DbgPrint(
"Unable to create %Z directory object (%X) [OK]\n",
00339 &DirectoryName, Status );
00340 }
00341
00342 InitializeObjectAttributes( &ObjectAttributes,
00343 &DirectoryName,
00344 OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
00345 NULL,
00346 NULL
00347
00348 );
00349
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00350 DIRECTORY_ALL_ACCESS,
00351 &ObjectAttributes
00352 );
00353
if (!
NT_SUCCESS( Status )) {
00354
DbgPrint(
"Unable to create %Z directory object (%X)\n",
00355 &DirectoryName, Status );
00356
NtTerminateProcess( NtCurrentProcess(), Status );
00357 }
00358
00359
Status =
NtClose( DirectoryHandle );
00360
if (!
NT_SUCCESS( Status )) {
00361
DbgPrint(
"Unable to close %Z directory object handle - %lx (%X)\n",
00362 &DirectoryName,
00363 DirectoryHandle,
00364 Status
00365 );
00366
NtTerminateProcess( NtCurrentProcess(), Status );
00367 }
00368
00369 InitializeObjectAttributes( &ObjectAttributes,
00370 &DirectoryName,
00371 OBJ_CASE_INSENSITIVE,
00372 NULL,
00373 NULL
00374 );
00375
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00376 DIRECTORY_ALL_ACCESS,
00377 &ObjectAttributes
00378 );
00379
if (!
NT_SUCCESS( Status )) {
00380
DbgPrint(
"Unable to open %Z directory object (%X)\n",
00381 &DirectoryName, Status );
00382
NtTerminateProcess( NtCurrentProcess(), Status );
00383 }
00384
00385
Status =
NtQueryObject( DirectoryHandle,
00386 ObjectBasicInformation,
00387 &ObjectBasicInfo,
00388
sizeof( ObjectBasicInfo ),
00389 &ReturnedLength
00390 );
00391
if (!
NT_SUCCESS( Status )) {
00392
DbgPrint(
"NtQueryObject( %lx, ObjectBasicInfo ) failed - Status == %X\n",
00393 DirectoryHandle,
00394 Status
00395 );
00396
NtTerminateProcess( NtCurrentProcess(), Status );
00397 }
00398
DbgPrint(
"NtQueryObject( %lx, ObjectBasicInfo ) returned %lx bytes\n",
00399 DirectoryHandle,
00400 ReturnedLength
00401 );
00402
DbgPrint(
" Attributes = %lx\n", ObjectBasicInfo.Attributes );
00403
DbgPrint(
" GrantedAccess = %lx\n", ObjectBasicInfo.GrantedAccess );
00404
DbgPrint(
" HandleCount = %lx\n", ObjectBasicInfo.HandleCount );
00405
DbgPrint(
" PointerCount = %lx\n", ObjectBasicInfo.PointerCount );
00406
DbgPrint(
" PagedPoolCharge = %lx\n", ObjectBasicInfo.PagedPoolCharge );
00407
DbgPrint(
" NonPagedPoolCharge = %lx\n", ObjectBasicInfo.NonPagedPoolCharge );
00408
DbgPrint(
" NameInfoSize = %lx\n", ObjectBasicInfo.NameInfoSize );
00409
DbgPrint(
" TypeInfoSize = %lx\n", ObjectBasicInfo.TypeInfoSize );
00410
DbgPrint(
" SecurityDescriptorSize = %lx\n", ObjectBasicInfo.SecurityDescriptorSize );
00411
00412 ObjectNameInfo = (POBJECT_NAME_INFORMATION)ObjectInfoBuffer;
00413
Status =
NtQueryObject( DirectoryHandle,
00414 ObjectNameInformation,
00415 ObjectNameInfo,
00416
sizeof( ObjectInfoBuffer ),
00417 &ReturnedLength
00418 );
00419
if (!
NT_SUCCESS( Status )) {
00420
DbgPrint(
"NtQueryObject( %lx, ObjectNameInfo ) failed - Status == %X\n",
00421 DirectoryHandle,
00422 Status
00423 );
00424
NtTerminateProcess( NtCurrentProcess(), Status );
00425 }
00426
DbgPrint(
"NtQueryObject( %lx, ObjectNameInfo ) returned %lx bytes\n",
00427 DirectoryHandle,
00428 ReturnedLength
00429 );
00430
DbgPrint(
" Name = (%ld,%ld) '%Z'\n",
00431 ObjectNameInfo->Name.MaximumLength,
00432 ObjectNameInfo->Name.Length,
00433 &ObjectNameInfo->Name
00434 );
00435
00436
00437 ObjectTypeInfo = (POBJECT_TYPE_INFORMATION)ObjectInfoBuffer;
00438
Status =
NtQueryObject( DirectoryHandle,
00439 ObjectTypeInformation,
00440 ObjectTypeInfo,
00441
sizeof( ObjectInfoBuffer ),
00442 &ReturnedLength
00443 );
00444
if (!
NT_SUCCESS( Status )) {
00445
DbgPrint(
"NtQueryObject( %lx, ObjectTypeInfo ) failed - Status == %X\n",
00446 DirectoryHandle,
00447 Status
00448 );
00449
NtTerminateProcess( NtCurrentProcess(), Status );
00450 }
00451
DbgPrint(
"NtQueryObject( %lx, ObjectTypeInfo ) returned %lx bytes\n",
00452 DirectoryHandle,
00453 ReturnedLength
00454 );
00455
DbgPrint(
" TypeName = (%ld,%ld) '%Z'\n",
00456 ObjectTypeInfo->TypeName.MaximumLength,
00457 ObjectTypeInfo->TypeName.Length,
00458 &ObjectTypeInfo->TypeName
00459 );
00460
00461
RtlInitString( &LinkName,
"TestSymbolicLink" );
00462 InitializeObjectAttributes( &ObjectAttributes,
00463 &LinkName,
00464 OBJ_CASE_INSENSITIVE,
00465 NULL,
00466 NULL
00467 );
00468
ObjectAttributes.RootDirectory =
DirectoryHandle;
00469
RtlInitString( &LinkTarget,
"\\Device\\FileSystem" );
00470
Status =
NtCreateSymbolicLinkObject( &LinkHandle,
00471 SYMBOLIC_LINK_ALL_ACCESS,
00472 &ObjectAttributes,
00473 &LinkTarget
00474 );
00475
00476
if (!
NT_SUCCESS( Status )) {
00477
DbgPrint(
"Unable to create %Z => %Z symbolic link object (%X)\n",
00478 &LinkName, &LinkTarget, Status );
00479
NtTerminateProcess( NtCurrentProcess(), Status );
00480 }
00481
00482
Status =
NtClose( DirectoryHandle );
00483
if (!
NT_SUCCESS( Status )) {
00484
DbgPrint(
"Unable to close %Z directory object handle - %lx (%X)\n",
00485 &DirectoryName,
00486 DirectoryHandle,
00487 Status
00488 );
00489
NtTerminateProcess( NtCurrentProcess(), Status );
00490 }
00491
00492
RtlInitString( &DirTypeName,
"Directory" );
00493
RtlInitString( &LinkTypeName,
"SymbolicLink" );
00494
DumpObjectDirs(
"\\", 0 );
00495
00496
RtlInitString( &LinkName,
"TestSymbolicLink" );
00497 InitializeObjectAttributes( &ObjectAttributes,
00498 &LinkName,
00499 OBJ_CASE_INSENSITIVE,
00500 NULL,
00501 NULL
00502 );
00503
ObjectAttributes.RootDirectory = LinkHandle;
00504
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00505 DIRECTORY_ALL_ACCESS,
00506 &ObjectAttributes
00507 );
00508
if (!
NT_SUCCESS( Status )) {
00509
DbgPrint(
"Unable to open %Z directory object (%X) [OK]\n", &DirectoryName, Status );
00510 }
00511
00512
Status =
NtClose( LinkHandle );
00513
if (!
NT_SUCCESS( Status )) {
00514
DbgPrint(
"Unable to close %Z symbolic link handle - %lx (%X)\n",
00515 &LinkName,
00516 LinkHandle,
00517 Status
00518 );
00519
NtTerminateProcess( NtCurrentProcess(), Status );
00520 }
00521
00522 InitializeObjectAttributes( &ObjectAttributes,
00523 &DirectoryName,
00524 OBJ_CASE_INSENSITIVE,
00525 NULL,
00526 NULL
00527 );
00528
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00529 DIRECTORY_ALL_ACCESS,
00530 &ObjectAttributes
00531 );
00532
if (!
NT_SUCCESS( Status )) {
00533
DbgPrint(
"Unable to open %Z directory object (%X)\n", &DirectoryName, Status );
00534
NtTerminateProcess( NtCurrentProcess(), Status );
00535 }
00536
00537
Status =
NtMakeTemporaryObject( DirectoryHandle );
00538
if (!
NT_SUCCESS( Status )) {
00539
DbgPrint(
"NtMakeTemporaryObject( %lx ) failed - Status == %X\n",
00540 DirectoryHandle,
00541 Status
00542 );
00543
NtTerminateProcess( NtCurrentProcess(), Status );
00544 }
00545
00546
Status =
NtClose( DirectoryHandle );
00547
if (!
NT_SUCCESS( Status )) {
00548
DbgPrint(
"Unable to close %Z directory object handle - %lx (%X)\n",
00549 &DirectoryName,
00550 DirectoryHandle,
00551 Status
00552 );
00553
NtTerminateProcess( NtCurrentProcess(), Status );
00554 }
00555
00556 InitializeObjectAttributes( &ObjectAttributes,
00557 &DirectoryName,
00558 OBJ_CASE_INSENSITIVE,
00559 NULL,
00560 NULL
00561 );
00562
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00563 DIRECTORY_ALL_ACCESS,
00564 &ObjectAttributes
00565 );
00566
if (!
NT_SUCCESS( Status )) {
00567
DbgPrint(
"Unable to open %Z directory object (%X) [OK]\n", &DirectoryName, Status );
00568 }
00569
00570
RtlInitString( &DirectoryName,
"\\ExclusiveDir" );
00571 InitializeObjectAttributes( &ObjectAttributes,
00572 &DirectoryName,
00573 OBJ_CASE_INSENSITIVE | OBJ_EXCLUSIVE,
00574 NULL,
00575 NULL
00576
00577 );
00578
Status =
NtCreateDirectoryObject( &DirectoryHandle,
00579 DIRECTORY_ALL_ACCESS,
00580 &ObjectAttributes
00581 );
00582
if (!
NT_SUCCESS( Status )) {
00583
DbgPrint(
"Unable to create %Z directory object (%X)\n",
00584 &DirectoryName, Status );
00585
NtTerminateProcess( NtCurrentProcess(), Status );
00586 }
00587
00588 InitializeObjectAttributes( &ObjectAttributes,
00589 &DirectoryName,
00590 OBJ_CASE_INSENSITIVE | OBJ_EXCLUSIVE,
00591 NULL,
00592 NULL
00593 );
00594
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00595 DIRECTORY_ALL_ACCESS,
00596 &ObjectAttributes
00597 );
00598
if (!
NT_SUCCESS( Status )) {
00599
DbgPrint(
"Unable to open %Z directory object (%X)\n",
00600 &DirectoryName, Status );
00601
NtTerminateProcess( NtCurrentProcess(), Status );
00602 }
00603
00604 InitializeObjectAttributes( &ObjectAttributes,
00605 &DirectoryName,
00606 OBJ_CASE_INSENSITIVE,
00607 NULL,
00608 NULL
00609 );
00610
Status =
NtOpenDirectoryObject( &DirectoryHandle,
00611 DIRECTORY_ALL_ACCESS,
00612 &ObjectAttributes
00613 );
00614
if (!
NT_SUCCESS( Status )) {
00615
DbgPrint(
"Unable to open %Z directory object (%X) [OK]\n",
00616 &DirectoryName, Status );
00617 }
00618
00619
DbgPrint(
"Exiting Object Manager User Mode Test Program with Status = %X\n", Status );
00620 }