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.

197 lines
6.1 KiB

  1. // ****************************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. // OpenFiles.h
  8. //
  9. // Abstract:
  10. //
  11. // macros and function prototypes of OpenFiles.cpp
  12. //
  13. // Author:
  14. //
  15. // Akhil Gokhale ([email protected]) 1-Nov-2000
  16. //
  17. // Revision History:
  18. //
  19. // Akhil Gokhale ([email protected]) 1-Nov-2000 : Created It.
  20. //
  21. // ****************************************************************************
  22. #ifndef _OPENFILES_H
  23. #define _OPENFILES_H
  24. #include "pch.h"
  25. #include "resource.h"
  26. #include "chstring.h"
  27. #define FORMAT_OPTIONS GetResString(IDS_FORMAT_OPTIONS)
  28. #define OPENMODE_OPTIONS GetResString(IDS_OPENMODE_OPTION)
  29. #define NULL_CHAR L'\0'
  30. // command line options and their indexes in the array
  31. #define MAX_OPTIONS 5
  32. #define MAX_QUERY_OPTIONS 7
  33. #define MAX_DISCONNECT_OPTIONS 8
  34. #define MAX_LOCAL_OPTIONS 1
  35. #define INVALID_USER_CHARS L"\\/\"[]:|<>+=;,?@" // * is allowed.
  36. #define INVALID_FILE_NAME_CHARS L"/?\"<>|"
  37. // options allowed ( no need to localize )
  38. // command line options
  39. const WCHAR szDisconnectOption[] = L"disconnect";
  40. const WCHAR szQueryOption[] = L"query";
  41. const WCHAR szUsageOption[] = L"?";
  42. const WCHAR szServerNameOption[] = L"s";
  43. const WCHAR szUserNameOption[] = L"u";
  44. const WCHAR szPasswordOption[] = L"p";
  45. const WCHAR szIDOption[] = L"id";
  46. const WCHAR szAccessedByOption[] = L"a";
  47. const WCHAR szOpenModeOption[] = L"o";;
  48. const WCHAR szOpenFileOption[] = L"op";
  49. const WCHAR szFormatOption[] = L"fo";
  50. const WCHAR szNoHeadeOption[] = L"nh";
  51. const WCHAR szVerboseOption[] = L"v";
  52. const WCHAR szLocalOption[] = L"local";
  53. #define DOUBLE_SLASH _T("\\\\")
  54. #define SINGLE_SLASH _T("\\")
  55. #define SINGLE_DOT _T(".")
  56. #define DOT_DOT L".."
  57. #define BLANK_LINE L"\n"
  58. // option indexes MAIN
  59. #define OI_DISCONNECT 0
  60. #define OI_QUERY 1
  61. #define OI_USAGE 2
  62. #define OI_LOCAL 3
  63. #define OI_DEFAULT 4
  64. // Option Indexes QUERY
  65. #define OI_Q_QUERY 0
  66. #define OI_Q_SERVER_NAME 1
  67. #define OI_Q_USER_NAME 2
  68. #define OI_Q_PASSWORD 3
  69. #define OI_Q_FORMAT 4
  70. #define OI_Q_NO_HEADER 5
  71. #define OI_Q_VERBOSE 6
  72. // Option Indexes DISCONNECT
  73. #define OI_D_DISCONNECT 0
  74. #define OI_D_SERVER_NAME 1
  75. #define OI_D_USER_NAME 2
  76. #define OI_D_PASSWORD 3
  77. #define OI_D_ID 4
  78. #define OI_D_ACCESSED_BY 5
  79. #define OI_D_OPEN_MODE 6
  80. #define OI_D_OPEN_FILE 7
  81. // Option Indexes for LOCAL
  82. #define OI_O_LOCAL 0
  83. // Option Index for showresult for locally open files
  84. // LOF means Localy Open Files
  85. #define LOF_ID 0
  86. #define LOF_TYPE 1
  87. #define LOF_ACCESSED_BY 2
  88. #define LOF_PID 3
  89. #define LOF_PROCESS_NAME 4
  90. #define LOF_OPEN_FILENAME 5
  91. // No of columns in locally open file
  92. #define NO_OF_COL_LOCAL_OPENFILE 6
  93. // Column width for local open file showresult
  94. #define COL_L_ID 5
  95. #define COL_L_TYPE 10
  96. #define COL_L_ACCESSED_BY 15
  97. #define COL_L_PROCESS_NAME 20
  98. #define COL_L_PID 8
  99. #define COL_L_OPEN_FILENAME 50
  100. BOOL
  101. DoLocalOpenFiles(
  102. IN DWORD dwFormat,
  103. IN BOOL bShowNoHeader,
  104. IN BOOL bVerbose,
  105. IN LPCTSTR pszLocalValue
  106. );
  107. BOOL
  108. GetProcessOwner(
  109. OUT LPTSTR pszUserName,
  110. IN DWORD hFile
  111. );
  112. #define MAC_DLL_FILE_NAME L"\\SFMAPI.DLL"
  113. #define NTAUTHORITY_USER L"NT AUTHORITY"
  114. #define MIN_MEMORY_REQUIRED 256
  115. // Macro definitions
  116. #define SAFEDELETE(pObj) \
  117. if (pObj) \
  118. { \
  119. delete[] pObj; \
  120. pObj = NULL; \
  121. }
  122. #define SAFEIRELEASE(pIObj) \
  123. if (pIObj) \
  124. {\
  125. pIObj->Release(); \
  126. pIObj = NULL;\
  127. }
  128. // SAFEBSTRFREE
  129. #define SAFEBSTRFREE(bstrVal) \
  130. if (bstrVal) \
  131. { \
  132. SysFreeString(bstrVal); \
  133. bstrVal = NULL; \
  134. }
  135. #define SAFERELDYNARRAY(pArray)\
  136. if(pArray!=NULL)\
  137. {\
  138. DestroyDynamicArray(&pArray);\
  139. pArray = NULL;\
  140. }
  141. #define FREE_LIBRARY(hModule)\
  142. if(hModule!=NULL)\
  143. {\
  144. ::FreeLibrary (hModule);\
  145. hModule = NULL;\
  146. }
  147. // Following are Windows Undocumented defines and structures
  148. //////////////////////////////////////////////////////////////////
  149. // START UNDOCUMETED FEATURES
  150. //////////////////////////////////////////////////////////////////
  151. #define AFP_OPEN_MODE_NONE 0x00000000
  152. #define AFP_OPEN_MODE_READ 0x00000001
  153. #define AFP_OPEN_MODE_WRITE 0x00000002
  154. // Fork type of an open file
  155. #define AFP_FORK_DATA 0x00000000
  156. #define AFP_FORK_RESOURCE 0x00000001
  157. typedef struct _AFP_FILE_INFO
  158. {
  159. DWORD afpfile_id; // Id of the open file fork
  160. DWORD afpfile_open_mode; // Mode in which file is opened
  161. DWORD afpfile_num_locks; // Number of locks on the file
  162. DWORD afpfile_fork_type; // Fork type
  163. LPWSTR afpfile_username; // File opened by this user. max UNLEN
  164. LPWSTR afpfile_path; // Absolute canonical path to the file
  165. } AFP_FILE_INFO, *PAFP_FILE_INFO;
  166. // Used as RPC binding handle to server
  167. typedef ULONG_PTR AFP_SERVER_HANDLE;
  168. typedef ULONG_PTR *PAFP_SERVER_HANDLE;
  169. /////////////////////////////////////////////////////////////////////////////
  170. // END UNDOCUMETED FEATURES
  171. /////////////////////////////////////////////////////////////////////////////
  172. #endif