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.

143 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. AudRead.c
  5. Abstract:
  6. This file contains the RpcXlate code to handle the NetAuditRead API.
  7. Author:
  8. John Rogers (JohnRo) 05-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 ErrRead.c.
  14. Make sure that you check both files if you find a bug in either.
  15. Revision History:
  16. 05-Nov-1991 JohnRo
  17. Created.
  18. 20-Nov-1991 JohnRo
  19. Handle empty log file.
  20. 04-Nov-1992 JohnRo
  21. RAID 9355: Event viewer: won't focus on LM UNIX machine.
  22. --*/
  23. // These must be included first:
  24. #include <windef.h> // IN, DWORD, etc.
  25. #include <lmcons.h> // DEVLEN, NET_API_STATUS, etc.
  26. #include <lmaudit.h> // Needed by rxaudit.h
  27. // These may be included in any order:
  28. #include <apinums.h> // API_ equates.
  29. #include <lmapibuf.h> // NetApiBufferFree().
  30. #include <lmerr.h> // ERROR_ and NERR_ equates.
  31. #include <netdebug.h> // NetpAssert().
  32. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  33. #include <rx.h> // RxRemoteApi().
  34. #include <rxaudit.h> // My prototype(s).
  35. NET_API_STATUS
  36. RxNetAuditRead (
  37. IN LPTSTR UncServerName,
  38. IN LPTSTR service OPTIONAL,
  39. IN LPHLOG auditloghandle,
  40. IN DWORD offset,
  41. IN LPDWORD reserved1 OPTIONAL,
  42. IN DWORD reserved2,
  43. IN DWORD offsetflag,
  44. OUT LPBYTE *BufPtr,
  45. IN DWORD prefmaxlen,
  46. OUT LPDWORD BytesRead,
  47. OUT LPDWORD totalavailable // approximate!!!
  48. )
  49. {
  50. const DWORD BufSize = 65535;
  51. NET_API_STATUS Status;
  52. LPBYTE UnconvertedBuffer;
  53. DWORD UnconvertedSize;
  54. UNREFERENCED_PARAMETER(prefmaxlen);
  55. NetpAssert(UncServerName != NULL);
  56. NetpAssert(*UncServerName != '\0');
  57. *BufPtr = NULL; // set in case of error, and GP fault if necessary.
  58. Status = RxRemoteApi(
  59. API_WAuditRead, // API number
  60. UncServerName,
  61. REMSmb_NetAuditRead_P, // parm desc
  62. REM16_AuditLogReturnBuf, // data desc 16
  63. REM16_AuditLogReturnBuf, // data desc 32 (same as 16)
  64. REMSmb_AuditLogReturnBuf, // data desc SMB
  65. NULL, // no aux desc 16
  66. NULL, // no aux desc 32
  67. NULL, // no aux desc SMB
  68. ALLOCATE_RESPONSE, // flags: alloc buffer for us
  69. // rest of API's arguments, in 32-bit LM2.x format:
  70. service, // service name (was reserved)
  71. auditloghandle, // log handle (input)
  72. auditloghandle, // log handle (output)
  73. offset,
  74. reserved1,
  75. reserved2,
  76. offsetflag,
  77. & UnconvertedBuffer, // buffer (alloc for us)
  78. BufSize,
  79. & UnconvertedSize,
  80. totalavailable); // total available (approximate)
  81. if (Status != NERR_Success) {
  82. return (Status);
  83. }
  84. if (UnconvertedSize > 0) {
  85. NetpAssert( UnconvertedBuffer != NULL );
  86. Status = RxpConvertAuditArray(
  87. UnconvertedBuffer, // input array
  88. UnconvertedSize, // input byte count
  89. BufPtr, // will be alloc'ed
  90. BytesRead); // output byte count
  91. (void) NetApiBufferFree( UnconvertedBuffer );
  92. if (Status == ERROR_NOT_ENOUGH_MEMORY) {
  93. *BufPtr = NULL;
  94. return (Status);
  95. }
  96. NetpAssert( Status == NERR_Success );
  97. } else {
  98. *BytesRead = 0;
  99. *totalavailable = 0;
  100. NetpAssert( *BufPtr == NULL );
  101. if (UnconvertedBuffer != NULL) {
  102. (void) NetApiBufferFree( UnconvertedBuffer );
  103. }
  104. }
  105. return (Status);
  106. } // RxNetAuditRead