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.

256 lines
7.7 KiB

  1. //***************************************************************************
  2. // Copyright (c) Microsoft Corporation
  3. //
  4. // Module Name:
  5. // TAKEOWN.H
  6. //
  7. // Abstract:
  8. // Contains function prototypes and macros.
  9. //
  10. // Author:
  11. // Wipro Technologies
  12. //
  13. // Revision History:
  14. // Wipro Technologies 22-jun-01 : Created It.
  15. //***************************************************************************
  16. #ifndef __TAKEOWN_H
  17. #define __TAKEOWN_H
  18. LPWSTR lpwszTempDummyPtr ;
  19. // constants / defines / enumerations
  20. #define MAX_OPTIONS 8
  21. #define FILESYSNAMEBUFSIZE 1024
  22. //Command line parser index
  23. #define CMD_PARSE_SERVER 0
  24. #define CMD_PARSE_USER 1
  25. #define CMD_PARSE_PWD 2
  26. #define CMD_PARSE_USG 3
  27. #define CMD_PARSE_FN 4
  28. #define CMD_PARSE_RECURSE 5
  29. #define CMD_PARSE_ADMIN 6
  30. #define CMD_PARSE_CONFIRM 7
  31. //warning message
  32. #define IGNORE_LOCALCREDENTIALS GetResString( IDS_IGNORE_LOCALCREDENTIALS )
  33. // Error constants
  34. #define ERROR_PATH_NAME GetResString( IDS_ERROR_PATH_NAME )
  35. // Error constants
  36. #define ERROR_USER_WITH_NOSERVER GetResString( IDS_USER_NMACHINE )
  37. #define ERROR_PASSWORD_WITH_NUSER GetResString( IDS_PASSWORD_NUSER )
  38. #define ERROR_NULL_SERVER GetResString( IDS_NULL_SERVER )
  39. #define ERROR_NULL_USER GetResString( IDS_NULL_USER )
  40. #define ERROR_INVALID_WILDCARD GetResString( IDS_INVALID_WILDCARD )
  41. #define ERROR_SYNTAX_ERROR GetResString( IDS_SYNTAX_ERROR )
  42. #define ERROR_STRING GetResString( IDS_ERROR_STRING )
  43. #define GIVE_FULL_PERMISSIONS GetResString(IDS_GIVE_FULL_PERMISSIONS)
  44. #define GIVE_FULL_PERMISSIONS2 GetResString(IDS_GIVE_FULL_PERMISSIONS2)
  45. //success string
  46. #define TAKEOWN_SUCCESSFUL GetResString( IDS_FILE_PROTECTION_SUCCESSFUL )
  47. #define TAKEOWN_SUCCESSFUL_USER GetResString( IDS_FILE_PROTECTION_SUCCESSFUL_USER )
  48. #define LOWER_YES GetResString( IDS_LOWER_YES )
  49. #define LOWER_NO GetResString( IDS_LOWER_NO )
  50. #define LOWER_CANCEL GetResString( IDS_LOWER_CANCEL )
  51. #define SPACE_CHAR L" "
  52. //command line options
  53. #define CMDOPTION_USAGE L"?"
  54. #define CMDOPTION_SERVER L"S"
  55. #define CMDOPTION_USER L"U"
  56. #define CMDOPTION_PASSWORD L"P"
  57. #define CMDOPTION_FILENAME L"F"
  58. #define CMDOPTION_RECURSE L"R"
  59. #define CMDOPTION_ADMIN L"A"
  60. #define TRIM_SPACES TEXT(" \0")
  61. #define WILDCARD L"*"
  62. #define DOUBLE_QUOTE L"\\\\"
  63. #define SINGLE_QUOTE L'\\'
  64. #define BACK_SLASH L"/"
  65. #define TRIPLE_SLASH L"\\\\\\"
  66. #define DOLLOR L'$'
  67. #define COLON L':'
  68. #define ALL_FILES L"\\*.*"
  69. #define DOT L"."
  70. #define DOTS L".."
  71. #define CHAR_SET L"\"/?<>|"
  72. #define CHAR_SET2 L"\\\"/:?<>|*.+,$#@![](){}~&?^|="
  73. #define CHAR_SET3 L":"
  74. #define ADMINISTRATOR L"Administrator"
  75. #define ADMINISTRATORS L"Administrators"
  76. #define SUCCESS 0
  77. #define FAILURE 1
  78. #define RETVALZERO 0
  79. #define MAX_PATHNAME 512
  80. #define MAX_SYSTEMNAME 64
  81. #define C_COLON L"C:\\"
  82. #define D_COLON L"D:\\"
  83. #define E_COLON L"E:\\"
  84. #define F_COLON L"F:\\"
  85. #define G_COLON L"G:\\"
  86. #define H_COLON L"H:\\"
  87. #define EXTRA_MEM 10
  88. #define NULL_U_STRING L"\0"
  89. #define NULL_U_CHAR L'\0'
  90. #define EXIT_FAIL 255
  91. #define EXIT_SUCC 0
  92. #define EXIT_CANCELED 1000
  93. #define BOUNDARYVALUE 128
  94. #define MAX_CONFIRM_VALUE 10
  95. #define DASH L"-"
  96. #define BASE_TEN 10
  97. #define FREE_MEMORY( VARIABLE ) \
  98. FreeMemory(&VARIABLE); \
  99. 1
  100. #define CLOSE_FILE_HANDLE( FILE_HANDLE ) \
  101. if( FILE_HANDLE != 0 ) \
  102. { \
  103. FindClose( FILE_HANDLE ) ; \
  104. FILE_HANDLE = 0 ; \
  105. } \
  106. 1
  107. // function prototypes
  108. BOOL
  109. ParseCmdLine(
  110. IN DWORD argc,
  111. IN LPCWSTR argv[],
  112. OUT LPWSTR* szMachineName,
  113. OUT LPWSTR* szUserName,
  114. OUT LPWSTR* szPassword,
  115. OUT LPWSTR* szFileName,
  116. OUT BOOL *pbUsage,
  117. OUT BOOL *pbNeedPassword,
  118. OUT BOOL *pbRecursive,
  119. OUT BOOL *pbAdminsOwner,
  120. OUT LPWSTR szConfirm
  121. );
  122. VOID
  123. DisplayUsage(
  124. );
  125. BOOL
  126. TakeOwnerShip(
  127. IN LPCWSTR lpszFileName
  128. );
  129. BOOL
  130. GetTokenHandle(
  131. OUT PHANDLE hTokenHandle
  132. );
  133. BOOL
  134. AssertTakeOwnership(
  135. IN HANDLE hTokenHandle
  136. );
  137. BOOL
  138. TakeOwnerShipAll(IN LPWSTR lpszFileName,
  139. IN BOOL bCurrDirTakeOwnAllFiles,
  140. IN PDWORD dwFileCount,
  141. IN BOOL bDriveCurrDirTakeOwnAllFiles,
  142. IN BOOL bAdminsOwner,
  143. IN LPWSTR szOwnerString,
  144. BOOL bMatchPattern,
  145. LPWSTR wszPatternString);
  146. BOOL
  147. TakeOwnerShipRecursive(IN LPWSTR lpszFileName,
  148. IN BOOL bCurrDirTakeOwnAllFiles,
  149. IN BOOL bAdminsOwner,
  150. IN LPWSTR szOwnerString,
  151. IN BOOL bTakeOwnAllFiles,
  152. IN BOOL bDriveCurrDirTakeOwnAllFiles,
  153. IN BOOL bMatchPattern,
  154. IN LPWSTR wszPatternString,
  155. IN LPWSTR szConfirm);
  156. DWORD IsLogonDomainAdmin(IN LPWSTR szOwnerString, OUT PBOOL pbLogonDomainAdmin);
  157. typedef struct __STORE_PATH_NAME
  158. {
  159. LPTSTR pszDirName ;
  160. struct __STORE_PATH_NAME *NextNode ;
  161. } Store_Path_Name , *PStore_Path_Name ;
  162. DWORD
  163. StoreSubDirectory(IN LPTSTR lpszPathName,
  164. IN PBOOL pbACLChgPermGranted,
  165. IN LPWSTR szOwnerString,
  166. IN BOOL bMatchPattern,
  167. IN LPWSTR wszPatternString,
  168. IN LPWSTR szConfirm,
  169. IN BOOL bAdminsOwner);
  170. BOOL GetOwnershipForFiles(IN LPWSTR lpszPathName,
  171. IN BOOL bAdminsOwner,
  172. IN LPWSTR szOwnerString,
  173. IN BOOL bMatchPattern,
  174. IN LPWSTR wszPatternString,
  175. IN OUT PBOOL pbFilesNone);
  176. BOOL Pop( void );
  177. BOOL Push( IN LPTSTR szPathName );
  178. DWORD GetMatchedFiles(
  179. IN BOOL bAdminsOwner,
  180. IN LPWSTR szOwnerString,
  181. IN BOOL bMatchPattern,
  182. IN LPWSTR wszPatternString,
  183. IN OUT PBOOL pbFilesNone,
  184. IN LPWSTR szConfirms);
  185. BOOL
  186. TakeOwnerShipIndividual( IN LPCTSTR lpszFileName );
  187. DWORD
  188. IsNTFSFileSystem(IN LPWSTR lpszPath,
  189. BOOL bLocalSystem,
  190. //BOOL bFileInUNCFormat,
  191. BOOL bCurrDirTakeOwnAllFiles,
  192. LPWSTR szUserName,
  193. OUT PBOOL pbNTFSFileSystem);
  194. DWORD
  195. IsNTFSFileSystem2(IN LPWSTR lpszTempDrive,
  196. OUT PBOOL pbNTFSFileSystem);
  197. BOOL
  198. AddAccessRights(IN WCHAR *lpszFileName,
  199. IN DWORD dwAccessMask,
  200. IN LPWSTR dwUserName,
  201. IN BOOL bAdminsOwner);
  202. DWORD RemoveStarFromPattern( IN OUT LPWSTR szPattern );
  203. #endif // __TAKEOWN_H