Leaked source code of windows server 2003
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.

191 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. WksGtInf.c
  5. Abstract:
  6. This file contains the RpcXlate code to handle the NetWkstaGetInfo API.
  7. Author:
  8. John Rogers (JohnRo) 15-Aug-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 15-Aug-1991 JohnRo
  14. Implement downlevel NetWksta APIs.
  15. 11-Nov-1991 JohnRo
  16. Moved most of the code from here to WksGtOld.c for sharing with
  17. RxNetWkstaUserEnum().
  18. 21-Nov-1991 JohnRo
  19. Removed NT dependencies to reduce recompiles.
  20. 07-Feb-1992 JohnRo
  21. Use NetApiBufferAllocate() instead of private version.
  22. --*/
  23. // These must be included first:
  24. #include <windef.h> // IN, DWORD, etc.
  25. #include <lmcons.h> // LM20_ equates, NET_API_STATUS, etc.
  26. #include <rap.h> // Needed by <strucinf.h>.
  27. // These may be included in any order:
  28. #include <dlwksta.h> // NetpIsNewWkstaInfoLevel().
  29. #include <lmapibuf.h> // NetApiBufferAllocate(), NetApiBufferFree().
  30. #include <lmerr.h> // ERROR_ and NERR_ equates.
  31. #include <netdebug.h> // DBGSTATIC, NetpKdPrint(()), FORMAT_ equates.
  32. #include <rxpdebug.h> // IF_DEBUG().
  33. #include <rxwksta.h> // My prototypes, RxpGetWkstaInfoLevelEquivalent
  34. #include <strucinf.h> // NetpWkstaStructureInfo().
  35. NET_API_STATUS
  36. RxNetWkstaGetInfo (
  37. IN LPTSTR UncServerName,
  38. IN DWORD Level,
  39. OUT LPBYTE *BufPtr
  40. )
  41. /*++
  42. Routine Description:
  43. RxNetWkstaGetInfo performs the same function as NetWkstaGetInfo, except
  44. that the server name is known to refer to a downlevel server.
  45. Arguments:
  46. (Same as NetWkstaGetInfo, except UncServerName must not be null, and
  47. must not refer to the local computer.)
  48. Return Value:
  49. (Same as NetWkstaGetInfo.)
  50. --*/
  51. {
  52. LPBYTE NewApiBuffer32; // Buffer to be returned to caller.
  53. DWORD NewApiBufferSize32;
  54. DWORD NewFixedSize;
  55. DWORD NewStringSize;
  56. LPBYTE OldApiBuffer32 = NULL; // Buffer from remote system.
  57. DWORD OldLevel;
  58. NET_API_STATUS Status;
  59. IF_DEBUG(WKSTA) {
  60. NetpKdPrint(("RxNetWkstaGetInfo: starting, server=" FORMAT_LPTSTR
  61. ", lvl=" FORMAT_DWORD ".\n", UncServerName, Level));
  62. }
  63. //
  64. // Error check DLL stub and the app.
  65. //
  66. NetpAssert(UncServerName != NULL);
  67. if ( !NetpIsNewWkstaInfoLevel( Level )) {
  68. return (ERROR_INVALID_LEVEL);
  69. }
  70. if (BufPtr == NULL) {
  71. return (ERROR_INVALID_PARAMETER);
  72. }
  73. *BufPtr = NULL; // assume error; it makes error handlers easy to code.
  74. // This also forces possible GP fault before we allocate memory.
  75. //
  76. // Caller must have given us a new info level. Find matching old level.
  77. //
  78. Status = RxpGetWkstaInfoLevelEquivalent(
  79. Level, // from level
  80. & OldLevel, // to level
  81. NULL // don't care we have incomplete info
  82. );
  83. if (Status != NERR_Success) {
  84. return (Status);
  85. }
  86. //
  87. // Learn about new info level.
  88. //
  89. Status = NetpWkstaStructureInfo (
  90. Level, // level to learn about
  91. PARMNUM_ALL, // No parmnum with this.
  92. TRUE, // Need native sizes.
  93. NULL, // don't need data desc16 for new level
  94. NULL, // don't need data desc32 for new level
  95. NULL, // don't need data descSMB for new level
  96. & NewApiBufferSize32, // max buffer size (native)
  97. & NewFixedSize, // fixed size.
  98. & NewStringSize // string size.
  99. );
  100. if (Status != NERR_Success) {
  101. return (Status);
  102. }
  103. //
  104. // Actually remote the API, which will get back the (old) info level
  105. // data in native format.
  106. //
  107. Status = RxpWkstaGetOldInfo (
  108. UncServerName,
  109. OldLevel,
  110. (LPBYTE *) & OldApiBuffer32); // alloc buffer and set ptr
  111. NetpAssert( Status != ERROR_MORE_DATA );
  112. NetpAssert( Status != NERR_BufTooSmall );
  113. if (Status == NERR_Success) {
  114. // Allocate memory for 32-bit version of new info, which we'll return to
  115. // caller. (Caller must free it with NetApiBufferFree.)
  116. Status = NetApiBufferAllocate(
  117. NewApiBufferSize32,
  118. (LPVOID *) & NewApiBuffer32);
  119. if (Status != NERR_Success) {
  120. if ( OldApiBuffer32 != NULL ) {
  121. (void) NetApiBufferFree( OldApiBuffer32 );
  122. }
  123. return (Status);
  124. }
  125. IF_DEBUG(WKSTA) {
  126. NetpKdPrint(( "RxNetWkstaGetInfo: allocated new buffer at "
  127. FORMAT_LPVOID "\n", (LPVOID) NewApiBuffer32 ));
  128. }
  129. //
  130. // Copy/convert data from OldApiBuffer32 to NewApiBuffer32.
  131. //
  132. Status = NetpConvertWkstaInfo (
  133. OldLevel, // from level
  134. OldApiBuffer32, // FromInfo,
  135. TRUE, // from native format
  136. Level, // ToLevel,
  137. NewApiBuffer32, // ToInfo,
  138. NewFixedSize, // ToFixedLength,
  139. NewStringSize, // ToStringLength,
  140. TRUE, // to native format
  141. NULL // don't need string area top
  142. );
  143. NetpAssert(Status == NERR_Success);
  144. *BufPtr = NewApiBuffer32;
  145. }
  146. if ( OldApiBuffer32 != NULL ) {
  147. (void) NetApiBufferFree( OldApiBuffer32 );
  148. }
  149. return (Status);
  150. } // RxNetWkstaGetInfo