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.

174 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. FilGtInf.c
  5. Abstract:
  6. This file contains the RpcXlate code to handle the NetFileGetInfo API.
  7. Author:
  8. John Rogers (JohnRo) 23-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. 23-Aug-1991 JohnRo
  14. Implement downlevel NetFile APIs.
  15. 22-Oct-1991 JohnRo
  16. Free buffer on error.
  17. 21-Nov-1991 JohnRo
  18. Removed NT dependencies to reduce recompiles.
  19. 07-Feb-1992 JohnRo
  20. Use NetApiBufferAllocate() instead of private version.
  21. --*/
  22. // These must be included first:
  23. #include <windef.h> // IN, DWORD, etc.
  24. #include <lmcons.h> // LM20_ equates, NET_API_STATUS, etc.
  25. // These may be included in any order:
  26. #include <apinums.h> // API_ equates.
  27. #include <lmapibuf.h> // NetApiBufferAllocate().
  28. #include <lmerr.h> // ERROR_ and NERR_ equates.
  29. #include <netdebug.h> // DBGSTATIC, NetpKdPrint(()), FORMAT_ equates.
  30. #include <netlib.h> // NetpSetParmError().
  31. #include <rap.h> // LPDESC.
  32. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  33. #include <rx.h> // RxRemoteApi().
  34. #include <rxp.h> // RxpFatalErrorCode().
  35. #include <rxpdebug.h> // IF_DEBUG().
  36. #include <rxfile.h> // My prototype.
  37. #include <strucinf.h> // NetpFileStructureInfo().
  38. NET_API_STATUS
  39. RxNetFileGetInfo (
  40. IN LPTSTR UncServerName,
  41. IN DWORD FileId,
  42. IN DWORD Level,
  43. OUT LPBYTE *BufPtr
  44. )
  45. /*++
  46. Routine Description:
  47. RxNetFileGetInfo performs the same function as NetFileGetInfo, except
  48. that the server name is known to refer to a downlevel server.
  49. Arguments:
  50. (Same as NetFileGetInfo, except UncServerName must not be null, and
  51. must not refer to the local computer.)
  52. Return Value:
  53. (Same as NetFileGetInfo.)
  54. --*/
  55. {
  56. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  57. LPBYTE ApiBuffer32; // Buffer to be returned to caller.
  58. DWORD ApiBufferSize32;
  59. NET_API_STATUS Status;
  60. DWORD TotalAvail;
  61. IF_DEBUG(FILE) {
  62. NetpKdPrint(("RxNetFileGetInfo: starting, server=" FORMAT_LPTSTR
  63. ", lvl=" FORMAT_DWORD ".\n", UncServerName, Level));
  64. }
  65. //
  66. // Error check DLL stub and the app.
  67. //
  68. NetpAssert(UncServerName != NULL);
  69. if ( (Level != 2) && (Level != 3) ) {
  70. return (ERROR_INVALID_LEVEL);
  71. }
  72. if (BufPtr == NULL) {
  73. return (ERROR_INVALID_PARAMETER);
  74. }
  75. *BufPtr = NULL; // assume error; it makes error handlers easy to code.
  76. // This also forces possible GP fault before we allocate memory.
  77. //
  78. // Learn about info level.
  79. //
  80. Status = NetpFileStructureInfo (
  81. Level, // level to learn about
  82. PARMNUM_ALL, // No parmnum with this.
  83. TRUE, // Need native sizes.
  84. & DataDesc16,
  85. & DataDesc32,
  86. & DataDescSmb,
  87. & ApiBufferSize32, // max buffer size (native)
  88. NULL, // don't need fixed size.
  89. NULL // don't need string size.
  90. );
  91. if (Status != NERR_Success) {
  92. return (Status);
  93. }
  94. //
  95. // Allocate memory for 32-bit version of info, which we'll use to get
  96. // data from the remote computer.
  97. //
  98. Status = NetApiBufferAllocate(
  99. ApiBufferSize32,
  100. (LPVOID *) & ApiBuffer32);
  101. if (Status != NERR_Success) {
  102. return (Status);
  103. }
  104. IF_DEBUG(FILE) {
  105. NetpKdPrint(( "RxNetFileGetInfo: allocated buffer at "
  106. FORMAT_LPVOID "\n", (LPVOID) ApiBuffer32 ));
  107. }
  108. //
  109. // Actually remote the API, which will get back the
  110. // data in native format.
  111. //
  112. Status = RxRemoteApi(
  113. API_WFileGetInfo, // API number
  114. UncServerName, // Required, with \\name.
  115. REMSmb_NetFileGetInfo_P, // parm desc
  116. DataDesc16,
  117. DataDesc32,
  118. DataDescSmb,
  119. NULL, // no aux data desc 16
  120. NULL, // no aux data desc 32
  121. NULL, // no aux data desc SMB
  122. FALSE, // not a null session API
  123. // rest of API's arguments, in 32-bit LM 2.x format:
  124. FileId,
  125. Level,
  126. ApiBuffer32,
  127. ApiBufferSize32,
  128. & TotalAvail); // total size
  129. NetpAssert( Status != ERROR_MORE_DATA );
  130. NetpAssert( Status != NERR_BufTooSmall );
  131. if (Status == NERR_Success) {
  132. *BufPtr = ApiBuffer32;
  133. } else {
  134. (void) NetApiBufferFree( ApiBuffer32 );
  135. }
  136. return (Status);
  137. } // RxNetFileGetInfo