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.

173 lines
5.1 KiB

  1. // Replace:
  2. // {capgroup} is the name of group in caps as it appears in typedefs.
  3. // {date} with today's date in dd-Mmm-yyyy form.
  4. // {email} with your email ID.
  5. // {filename} with name of this file (including .c at end)
  6. // {fullname} with your full name
  7. // {header} is the header file name part (e.g. "wksta" in lmwksta.h)
  8. // {icgroup} is name of group with initial caps, e.g. "Server".
  9. // Take care of all {expand} replacements.
  10. // Delete these instructions.
  11. /*++
  12. Copyright (c) 1991-1992 Microsoft Corporation
  13. Module Name:
  14. {filename}
  15. Abstract:
  16. This file contains the RpcXlate code to handle the Net{icgroup}GetInfo API.
  17. Author:
  18. {fullname} ({email}) {date}
  19. Environment:
  20. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  21. Requires ANSI C extensions: slash-slash comments, long external names.
  22. Revision History:
  23. {date} {email}
  24. Created.
  25. --*/
  26. // These must be included first:
  27. #include <windef.h> // IN, DWORD, etc.
  28. #include <lmcons.h> // LM20_ equates, NET_API_STATUS, etc.
  29. // These may be included in any order:
  30. #include <apinums.h> // API_ equates.
  31. #include <lmapibuf.h> // NetapipBufferAllocate().
  32. #include <lmerr.h> // ERROR_ and NERR_ equates.
  33. #include <netdebug.h> // NetpDbgPrint(), FORMAT_ equates, etc.
  34. #include <rap.h> // LPDESC.
  35. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  36. #include <rx.h> // RxRemoteApi().
  37. #include <rxpdebug.h> // IF_DEBUG().
  38. #include <rx{header}.h> // My prototype.
  39. #include <strucinf.h> // Netp{icgroup}StructureInfo().
  40. NET_API_STATUS
  41. RxNet{icgroup}GetInfo (
  42. IN LPTSTR UncServerName,
  43. {expand}
  44. IN DWORD Level,
  45. OUT LPBYTE *BufPtr
  46. )
  47. /*++
  48. Routine Description:
  49. RxNet{icgroup}GetInfo performs the same function as Net{icgroup}GetInfo,
  50. except that the server name is known to refer to a downlevel server.
  51. Arguments:
  52. (Same as Net{icgroup}GetInfo, except UncServerName must not be null, and
  53. must not refer to the local computer.)
  54. Return Value:
  55. (Same as Net{icgroup}GetInfo.)
  56. --*/
  57. {
  58. LPBYTE ApiBuffer32; // Buffer to be returned to caller.
  59. DWORD ApiBufferSize32;
  60. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  61. NET_API_STATUS Status;
  62. DWORD TotalAvail;
  63. IF_DEBUG({capgroup}) {
  64. NetpDbgPrint("RxNet{icgroup}GetInfo: starting, server=" FORMAT_LPTSTR
  65. ", lvl=" FORMAT_DWORD ".\n", UncServerName, Level);
  66. }
  67. //
  68. // Error check DLL stub and the app.
  69. //
  70. NetpAssert(UncServerName != NULL);
  71. if (BufPtr == NULL) {
  72. return (ERROR_INVALID_PARAMETER);
  73. }
  74. *BufPtr = NULL; // assume error; it makes error handlers easy to code.
  75. // This also forces possible GP fault before we allocate memory.
  76. //
  77. // Learn about info level.
  78. //
  79. Status = Netp{icgroup}StructureInfo (
  80. Level, // level to learn about
  81. PARMNUM_ALL, // No parmnum with this.
  82. TRUE, // Need native sizes.
  83. & DataDesc16,
  84. & DataDesc32,
  85. & DataDescSmb,
  86. & ApiBufferSize32, // max buffer size (native)
  87. NULL, // don't need fixed size.
  88. NULL // don't need string size.
  89. );
  90. if (Status != NERR_Success) {
  91. return (Status);
  92. }
  93. //
  94. // Allocate memory for 32-bit version of info, which we'll use to get
  95. // data from the remote computer.
  96. //
  97. Status = NetapipBufferAllocate(
  98. ApiBufferSize32,
  99. (LPVOID *) & ApiBuffer32);
  100. if (Status != NERR_Success) {
  101. return (Status);
  102. }
  103. IF_DEBUG({capgroup}) {
  104. NetpDbgPrint( "RxNet{icgroup}GetInfo: allocated buffer at "
  105. FORMAT_LPVOID "\n", (LPVOID) ApiBuffer32 );
  106. }
  107. //
  108. // Actually remote the API, which will get back the
  109. // data in native format.
  110. //
  111. Status = RxRemoteApi(
  112. API_W{icgroup}GetInfo, // API number
  113. UncServerName, // Required, with \\name.
  114. REMSmb_Net{icgroup}GetInfo_P, // parm desc
  115. DataDesc16,
  116. DataDesc32,
  117. DataDescSmb,
  118. NULL, // no aux data desc 16
  119. NULL, // no aux data desc 32
  120. NULL, // no aux data desc SMB
  121. 0, // Flags: normal
  122. // rest of API's arguments, in 32-bit LM 2.x format:
  123. {expand},
  124. Level,
  125. ApiBuffer32,
  126. ApiBufferSize32,
  127. & TotalAvail); // total size (BUGBUG meaningless?)
  128. NetpAssert( Status != ERROR_MORE_DATA );
  129. NetpAssert( Status != NERR_BufTooSmall );
  130. if (Status == NERR_Success) {
  131. *BufPtr = ApiBuffer32;
  132. } else {
  133. (void) NetApiBufferFree( ApiBuffer32 );
  134. }
  135. return (Status);
  136. } // RxNet{icgroup}GetInfo