Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.4 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. VolInfo.c
  5. Abstract:
  6. A command line NDS utility for resolving volume objects.
  7. Author:
  8. Cory West [corywest] 25-Oct-95
  9. ***/
  10. #include "ndsapi32.h"
  11. int
  12. _cdecl main(
  13. int argc,
  14. char **argv
  15. ) {
  16. NTSTATUS Status;
  17. HANDLE hNdsTree;
  18. OEM_STRING OemArg;
  19. UNICODE_STRING NdsTree;
  20. WCHAR TreeBuffer[48]; // Max nds tree name length.
  21. UNICODE_STRING Volume;
  22. WCHAR VolumeBuffer[256]; // Max nds name length.
  23. UNICODE_STRING HostServer, HostVolume;
  24. WCHAR HostServerBuffer[48];
  25. WCHAR HostVolumeBuffer[256];
  26. //
  27. // Who do we want to monkey with?
  28. //
  29. if ( argc != 3 ) {
  30. printf( "Usage: volinfo [tree name] [volume object]\n" );
  31. return -1;
  32. }
  33. //
  34. // Get the tree.
  35. //
  36. OemArg.Length = strlen( argv[1] );
  37. OemArg.MaximumLength = OemArg.Length;
  38. OemArg.Buffer = argv[1];
  39. NdsTree.Length = 0;
  40. NdsTree.MaximumLength = sizeof( TreeBuffer );
  41. NdsTree.Buffer = TreeBuffer;
  42. RtlOemStringToUnicodeString( &NdsTree, &OemArg, FALSE );
  43. //
  44. // Open up a handle to the tree.
  45. //
  46. Status = NwNdsOpenTreeHandle( &NdsTree,
  47. &hNdsTree );
  48. if ( !NT_SUCCESS( Status ) ) {
  49. printf( "The supplied tree name is invalid or the tree is unavailable.\n" );
  50. return -1;
  51. }
  52. //
  53. // Get the volume information.
  54. //
  55. OemArg.Length = strlen( argv[2] );
  56. OemArg.MaximumLength = OemArg.Length;
  57. OemArg.Buffer = argv[2];
  58. Volume.Length = 0;
  59. Volume.MaximumLength = sizeof( VolumeBuffer );
  60. Volume.Buffer = VolumeBuffer;
  61. RtlOemStringToUnicodeString( &Volume, &OemArg, FALSE );
  62. //
  63. // Set up the reply strings.
  64. //
  65. HostServer.Length = 0;
  66. HostServer.MaximumLength = sizeof( HostServerBuffer );
  67. HostServer.Buffer = HostServerBuffer;
  68. HostVolume.Length = 0;
  69. HostVolume.MaximumLength = sizeof( HostVolumeBuffer );
  70. HostVolume.Buffer = HostVolumeBuffer;
  71. Status = NwNdsGetVolumeInformation( hNdsTree,
  72. &Volume,
  73. &HostServer,
  74. &HostVolume );
  75. CloseHandle( hNdsTree );
  76. if ( NT_SUCCESS( Status )) {
  77. printf( "Host Server: %wZ\n", &HostServer );
  78. printf( "Host Volume: %wZ\n", &HostVolume );
  79. return 0;
  80. }
  81. printf( "Unable to complete the requested operation: 0x%08lx\n", Status );
  82. return -1;
  83. }