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.

149 lines
3.5 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. UserFrag.c
  5. Abstract:
  6. User mode fragment exchange test.
  7. Author:
  8. Cory West [corywest] 05-Jan-1996
  9. ***/
  10. #include "ndsapi32.h"
  11. #include <nds.h>
  12. int
  13. _cdecl main(
  14. int argc,
  15. char **argv
  16. ) {
  17. NTSTATUS Status;
  18. HANDLE hNdsTree;
  19. OEM_STRING OemArg;
  20. UNICODE_STRING NdsTree;
  21. WCHAR TreeBuffer[48]; // Max nds tree name length.
  22. UNICODE_STRING Object;
  23. WCHAR ObjectBuffer[256]; // Max nds name length.
  24. DWORD dwResolverFlags;
  25. DWORD dwOid;
  26. DWORD dwReplyLength;
  27. BYTE NdsReply[NDS_BUFFER_SIZE];
  28. //
  29. // Who do we want to monkey with?
  30. //
  31. if ( argc != 3 ) {
  32. printf( "Usage: userfrag [server name] [nds object]\n" );
  33. return -1;
  34. }
  35. //
  36. // Get the server.
  37. //
  38. OemArg.Length = strlen( argv[1] );
  39. OemArg.MaximumLength = OemArg.Length;
  40. OemArg.Buffer = argv[1];
  41. NdsTree.Length = 0;
  42. NdsTree.MaximumLength = sizeof( TreeBuffer );
  43. NdsTree.Buffer = TreeBuffer;
  44. RtlOemStringToUnicodeString( &NdsTree, &OemArg, FALSE );
  45. //
  46. // Open up a handle to the tree.
  47. //
  48. Status = NwNdsOpenTreeHandle( &NdsTree,
  49. &hNdsTree );
  50. if ( !NT_SUCCESS( Status ) ) {
  51. printf( "The supplied tree name is invalid or the tree is unavailable.\n" );
  52. return -1;
  53. }
  54. //
  55. // Get the object information.
  56. //
  57. OemArg.Length = strlen( argv[2] );
  58. OemArg.MaximumLength = OemArg.Length;
  59. OemArg.Buffer = argv[2];
  60. Object.Length = 0;
  61. Object.MaximumLength = sizeof( ObjectBuffer );
  62. Object.Buffer = ObjectBuffer;
  63. RtlOemStringToUnicodeString( &Object, &OemArg, FALSE );
  64. dwResolverFlags = RSLV_DEREF_ALIASES | RSLV_WALK_TREE | RSLV_WRITABLE;
  65. Status = FragExWithWait( hNdsTree,
  66. NDSV_RESOLVE_NAME,
  67. NdsReply,
  68. NDS_BUFFER_SIZE,
  69. &dwReplyLength,
  70. "DDDSDDDD",
  71. 0, // version
  72. dwResolverFlags, // flags
  73. 0, // scope
  74. &Object, // distinguished name
  75. 1,0, // transport type
  76. 1,0 ); // treeWalker type
  77. if ( !NT_SUCCESS( Status ) ) {
  78. printf( "The resolve name failed.\n" );
  79. goto ExitWithClose;
  80. }
  81. Status = ParseResponse( NdsReply,
  82. dwReplyLength,
  83. "G_D",
  84. 2 * sizeof( DWORD ), // Skip the first two DWORDs
  85. &dwOid );
  86. if ( !NT_SUCCESS( Status ) ) {
  87. printf( "The resolve name response was undecipherable.\n" );
  88. goto ExitWithClose;
  89. }
  90. Status = FragExWithWait( hNdsTree,
  91. NDSV_READ_ENTRY_INFO,
  92. NdsReply,
  93. NDS_BUFFER_SIZE,
  94. &dwReplyLength,
  95. "DD",
  96. 0,
  97. dwOid );
  98. if ( !NT_SUCCESS( Status ) ) {
  99. printf( "The get object info failed.\n" );
  100. goto ExitWithClose;
  101. }
  102. ExitWithClose:
  103. CloseHandle( hNdsTree );
  104. if ( NT_SUCCESS( Status ) ) {
  105. return 0;
  106. }
  107. printf( "Unable to complete the requested operation: 0x%08lx\n", Status );
  108. return -1;
  109. }