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.

152 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. ErrRead.c
  5. Abstract:
  6. This file contains the RpcXlate code to handle the NetErrorLogRead API.
  7. Author:
  8. John Rogers (JohnRo) 12-Nov-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. Notes:
  13. The logic in this routine is based on the logic in AudRead.c.
  14. Make sure that you check both files if you find a bug in either.
  15. Revision History:
  16. 12-Nov-1991 JohnRo
  17. Created.
  18. 20-Nov-1991 JohnRo
  19. Handle empty log file.
  20. Added some assertion checks.
  21. 10-Sep-1992 JohnRo
  22. RAID 5174: event viewer _access violates after NetErrorRead.
  23. 04-Nov-1992 JohnRo
  24. RAID 9355: Event viewer: won't focus on LM UNIX machine.
  25. --*/
  26. // These must be included first:
  27. #include <windef.h> // IN, DWORD, etc.
  28. #include <lmcons.h> // NET_API_STATUS, etc.
  29. #include <lmerrlog.h> // Needed by rxerrlog.h
  30. // These may be included in any order:
  31. #include <apinums.h> // API_ equates.
  32. #include <lmapibuf.h> // NetApiBufferFree().
  33. #include <netdebug.h> // NetpKdPrint(()), FORMAT_ equates.
  34. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  35. #include <rx.h> // RxRemoteApi().
  36. #include <rxerrlog.h> // My prototype, RxpConvertErrorLogArray().
  37. #include <winerror.h> // NO_ERROR.
  38. NET_API_STATUS
  39. RxNetErrorLogRead (
  40. IN LPTSTR UncServerName,
  41. IN LPTSTR Reserved1 OPTIONAL,
  42. IN LPHLOG ErrorLogHandle,
  43. IN DWORD Offset,
  44. IN LPDWORD Reserved2 OPTIONAL,
  45. IN DWORD Reserved3,
  46. IN DWORD OffsetFlag,
  47. OUT LPBYTE * BufPtr,
  48. IN DWORD PrefMaxSize,
  49. OUT LPDWORD BytesRead,
  50. OUT LPDWORD TotalBytes
  51. )
  52. {
  53. const DWORD BufSize = 65535;
  54. NET_API_STATUS Status;
  55. LPBYTE UnconvertedBuffer;
  56. DWORD UnconvertedSize;
  57. UNREFERENCED_PARAMETER(PrefMaxSize);
  58. NetpAssert(UncServerName != NULL);
  59. NetpAssert(*UncServerName != '\0');
  60. *BufPtr = NULL; // set in case of error, and GP fault if necessary.
  61. Status = RxRemoteApi(
  62. API_WErrorLogRead, // API number
  63. UncServerName,
  64. REMSmb_NetErrorLogRead_P, // parm desc
  65. REM16_ErrorLogReturnBuf, // data desc 16
  66. REM16_ErrorLogReturnBuf, // data desc 32 (same as 16)
  67. REMSmb_ErrorLogReturnBuf, // data desc SMB
  68. NULL, // no aux desc 16
  69. NULL, // no aux desc 32
  70. NULL, // no aux desc SMB
  71. ALLOCATE_RESPONSE, // flags: not a null session API
  72. // rest of API's arguments, in 32-bit LM2.x format:
  73. Reserved1,
  74. ErrorLogHandle, // log handle (input)
  75. ErrorLogHandle, // log handle (output)
  76. Offset,
  77. Reserved2,
  78. Reserved3,
  79. OffsetFlag,
  80. & UnconvertedBuffer, // buffer (alloc for us)
  81. BufSize,
  82. & UnconvertedSize,
  83. TotalBytes); // total available (approximate)
  84. if (Status != NO_ERROR) {
  85. return (Status);
  86. }
  87. if (UnconvertedSize > 0) {
  88. NetpAssert( UnconvertedBuffer != NULL );
  89. Status = RxpConvertErrorLogArray(
  90. UnconvertedBuffer, // input array
  91. UnconvertedSize, // input byte count
  92. BufPtr, // will be alloc'ed
  93. BytesRead); // output byte count
  94. (void) NetApiBufferFree( UnconvertedBuffer );
  95. if (Status != NO_ERROR) {
  96. *BufPtr = NULL;
  97. *BytesRead = 0;
  98. *TotalBytes = 0;
  99. return (Status);
  100. }
  101. } else {
  102. *BytesRead = 0;
  103. *TotalBytes = 0;
  104. NetpAssert( *BufPtr == NULL );
  105. if (UnconvertedBuffer != NULL) {
  106. (void) NetApiBufferFree( UnconvertedBuffer );
  107. }
  108. }
  109. if ( *BytesRead == 0) {
  110. NetpAssert( *BufPtr == NULL );
  111. } else {
  112. NetpAssert( *BufPtr != NULL );
  113. }
  114. return (Status);
  115. } // RxNetErrorLogRead