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.

183 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. Nds32NT.c
  5. Abstract:
  6. This module implements functions to Read, Add, Modify, and Remove
  7. NDS Objects and Attributes using the Microsoft Netware redirector.
  8. All functions in this file are NT specific.
  9. Author:
  10. Glenn Curtis [GlennC] 04-Jan-1996
  11. Glenn Curtis [GlennC] 24-Apr-1996 - Added schema APIs
  12. Glenn Curtis [GlennC] 20-Jun-1996 - Added search API
  13. Felix Wong [t-felixw] 24-Sep-1996 - Added Win95 Support
  14. --*/
  15. #include <procs.h>
  16. typedef struct
  17. {
  18. DWORD Signature;
  19. HANDLE NdsTree;
  20. DWORD ObjectId;
  21. DWORD_PTR ResumeId;
  22. DWORD_PTR NdsRawDataBuffer;
  23. DWORD NdsRawDataSize;
  24. DWORD NdsRawDataId;
  25. DWORD NdsRawDataCount;
  26. WCHAR Name[1];
  27. } NDS_OBJECT, * LPNDS_OBJECT;
  28. DWORD
  29. GetFirstNdsSubTreeEntry(
  30. OUT LPNDS_OBJECT lpNdsObject,
  31. IN DWORD BufferSize )
  32. {
  33. NTSTATUS ntstatus;
  34. lpNdsObject->NdsRawDataSize = BufferSize;
  35. //
  36. // Determine size of NDS raw data buffer to use. Set to at least 8KB.
  37. //
  38. if ( lpNdsObject->NdsRawDataSize < 8192 )
  39. lpNdsObject->NdsRawDataSize = 8192;
  40. //
  41. // Create NDS raw data buffer.
  42. //
  43. lpNdsObject->NdsRawDataBuffer = (DWORD_PTR) LocalAlloc( LMEM_ZEROINIT,
  44. lpNdsObject->NdsRawDataSize );
  45. if ( lpNdsObject->NdsRawDataBuffer == 0 )
  46. {
  47. KdPrint(("NWWORKSTATION: NwGetFirstNdsSubTreeEntry LocalAlloc Failed %lu\n", GetLastError()));
  48. return ERROR_NOT_ENOUGH_MEMORY;
  49. }
  50. //
  51. // Set up to get initial NDS subordinate list.
  52. //
  53. lpNdsObject->NdsRawDataId = INITIAL_ITERATION;
  54. ntstatus = NwNdsList( lpNdsObject->NdsTree,
  55. lpNdsObject->ObjectId,
  56. &lpNdsObject->NdsRawDataId,
  57. (LPBYTE) lpNdsObject->NdsRawDataBuffer,
  58. lpNdsObject->NdsRawDataSize );
  59. //
  60. // If error, clean up the Object and return.
  61. //
  62. if ( ntstatus != STATUS_SUCCESS ||
  63. ((PNDS_RESPONSE_SUBORDINATE_LIST)
  64. lpNdsObject->NdsRawDataBuffer)->SubordinateEntries == 0 )
  65. {
  66. if ( lpNdsObject->NdsRawDataBuffer )
  67. (void) LocalFree( (HLOCAL) lpNdsObject->NdsRawDataBuffer );
  68. lpNdsObject->NdsRawDataBuffer = 0;
  69. lpNdsObject->NdsRawDataSize = 0;
  70. lpNdsObject->NdsRawDataId = INITIAL_ITERATION;
  71. lpNdsObject->NdsRawDataCount = 0;
  72. lpNdsObject->ResumeId = 0;
  73. return WN_NO_MORE_ENTRIES;
  74. }
  75. lpNdsObject->NdsRawDataCount = ((PNDS_RESPONSE_SUBORDINATE_LIST)
  76. lpNdsObject->NdsRawDataBuffer)->SubordinateEntries - 1;
  77. lpNdsObject->ResumeId = lpNdsObject->NdsRawDataBuffer +
  78. sizeof(NDS_RESPONSE_SUBORDINATE_LIST);
  79. return RtlNtStatusToDosError(ntstatus);
  80. }
  81. DWORD
  82. GetNextNdsSubTreeEntry(
  83. OUT LPNDS_OBJECT lpNdsObject )
  84. {
  85. NTSTATUS ntstatus = STATUS_SUCCESS;
  86. PBYTE pbRaw;
  87. DWORD dwStrLen;
  88. if ( lpNdsObject->NdsRawDataCount == 0 &&
  89. lpNdsObject->NdsRawDataId == INITIAL_ITERATION )
  90. return WN_NO_MORE_ENTRIES;
  91. if ( lpNdsObject->NdsRawDataCount == 0 &&
  92. lpNdsObject->NdsRawDataId != INITIAL_ITERATION )
  93. {
  94. ntstatus = NwNdsList( lpNdsObject->NdsTree,
  95. lpNdsObject->ObjectId,
  96. &lpNdsObject->NdsRawDataId,
  97. (LPBYTE) lpNdsObject->NdsRawDataBuffer,
  98. lpNdsObject->NdsRawDataSize );
  99. //
  100. // If error, clean up the Object and return.
  101. //
  102. if (ntstatus != STATUS_SUCCESS)
  103. {
  104. if ( lpNdsObject->NdsRawDataBuffer )
  105. (void) LocalFree( (HLOCAL) lpNdsObject->NdsRawDataBuffer );
  106. lpNdsObject->NdsRawDataBuffer = 0;
  107. lpNdsObject->NdsRawDataSize = 0;
  108. lpNdsObject->NdsRawDataId = INITIAL_ITERATION;
  109. lpNdsObject->NdsRawDataCount = 0;
  110. return WN_NO_MORE_ENTRIES;
  111. }
  112. lpNdsObject->NdsRawDataCount = ((PNDS_RESPONSE_SUBORDINATE_LIST)
  113. lpNdsObject->NdsRawDataBuffer)->SubordinateEntries - 1;
  114. lpNdsObject->ResumeId = lpNdsObject->NdsRawDataBuffer +
  115. sizeof(NDS_RESPONSE_SUBORDINATE_LIST);
  116. return RtlNtStatusToDosError(ntstatus);
  117. }
  118. lpNdsObject->NdsRawDataCount--;
  119. //
  120. // Move pointer past the fixed header portion of a
  121. // NDS_RESPONSE_SUBORDINATE_ENTRY
  122. //
  123. pbRaw = (BYTE *) lpNdsObject->ResumeId;
  124. pbRaw += sizeof(NDS_RESPONSE_SUBORDINATE_ENTRY);
  125. //
  126. // Move pointer past the length value of the Class Name string
  127. // of a NDS_RESPONSE_SUBORDINATE_ENTRY
  128. //
  129. dwStrLen = * (DWORD *) pbRaw;
  130. pbRaw += sizeof(DWORD);
  131. //
  132. // Move pointer past the Class Name string of a
  133. // NDS_RESPONSE_SUBORDINATE_ENTRY
  134. //
  135. pbRaw += ROUNDUP4( dwStrLen );
  136. //
  137. // Move pointer past the length value of the Object Name string
  138. // of a NDS_RESPONSE_SUBORDINATE_ENTRY
  139. //
  140. dwStrLen = * (DWORD *) pbRaw;
  141. pbRaw += sizeof(DWORD);
  142. lpNdsObject->ResumeId = (DWORD_PTR) ( pbRaw + ROUNDUP4( dwStrLen ) );
  143. return RtlNtStatusToDosError(ntstatus);
  144. }