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.

399 lines
12 KiB

  1. //
  2. // No Check-in Source Code.
  3. //
  4. // Do not make this code available to non-Microsoft personnel
  5. // without Intel's express permission
  6. //
  7. /**
  8. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  9. ***
  10. *** The information and source code contained herein is the exclusive
  11. *** property of Intel Corporation and may not be disclosed, examined
  12. *** or reproduced in whole or in part without explicit written authorization
  13. *** from the company.
  14. **/
  15. /*++
  16. Copyright (c) 1990 Microsoft Corporation
  17. Module Name:
  18. genntfs.c
  19. Abstract:
  20. This module implements a program which generates IA64 machine dependent
  21. structure offset definitions for kernel structures that are accessed in
  22. assembly code.
  23. Author:
  24. David N. Cutler (davec) 27-Mar-1990
  25. Revision History:
  26. Allen M. Kay (akay) 25-Jan-1996 Modified this file for IA64.
  27. --*/
  28. //#include "ki.h"
  29. //#pragma hdrstop
  30. //#define HEADER_FILE
  31. #include "ntos.h"
  32. #include "stdio.h"
  33. #include "stdlib.h"
  34. #include "zwapi.h"
  35. #include "nt.h"
  36. #include "excpt.h"
  37. #include "ntdef.h"
  38. #include "ntkeapi.h"
  39. #include "ntia64.h"
  40. #include "ntimage.h"
  41. #include "ntseapi.h"
  42. #include "ntobapi.h"
  43. #include "ntlpcapi.h"
  44. #include "ntioapi.h"
  45. #include "ntmmapi.h"
  46. #include "ntldr.h"
  47. #include "ntpsapi.h"
  48. #include "ntexapi.h"
  49. #include "ntnls.h"
  50. #include "nturtl.h"
  51. #include "ntcsrmsg.h"
  52. #include "ntcsrsrv.h"
  53. #include "ntxcapi.h"
  54. #include "ia64.h"
  55. #include "arc.h"
  56. #include "ntstatus.h"
  57. #include "kxia64.h"
  58. #include "stdarg.h"
  59. #include "setjmp.h"
  60. #include "ntioapi.h"
  61. #include "fsrtl.h"
  62. //#include "index.h"
  63. #include "nodetype.h"
  64. #include "ntfs.h"
  65. #include "ntfsstru.h"
  66. #include "ntfsdata.h"
  67. #include "ntfslog.h"
  68. #include "ntfsproc.h"
  69. //
  70. // Define architecture specific generation macros.
  71. //
  72. #define genAlt(Name, Type, Member) \
  73. dumpf("#define " #Name " 0x%lx\n", OFFSET(Type, Member))
  74. #define genCom(Comment) \
  75. dumpf("\n"); \
  76. dumpf("//\n"); \
  77. dumpf("// " Comment "\n"); \
  78. dumpf("//\n"); \
  79. dumpf("\n")
  80. #define genDef(Prefix, Type, Member) \
  81. dumpf("#define " #Prefix #Member " 0x%lx\n", OFFSET(Type, Member))
  82. #define genDef2(Prefix, Type, Name, Member) \
  83. dumpf("#define " #Prefix #Name " 0x%lx\n", OFFSET(Type, Member))
  84. #define genVal(Name, Value) \
  85. dumpf("#define " #Name " 0x%lx\n", Value)
  86. #define genSpc() dumpf("\n");
  87. //
  88. // Define member offset computation macro.
  89. //
  90. #define OFFSET(type, field) ((LONG)(&((type *)0)->field))
  91. FILE *NtfsDefs;
  92. //
  93. // EnableInc(a) - Enables output to goto specified include file
  94. //
  95. #define EnableInc(a) OutputEnabled |= a;
  96. //
  97. // DisableInc(a) - Disables output to goto specified include file
  98. //
  99. #define DisableInc(a) OutputEnabled &= ~a;
  100. ULONG OutputEnabled;
  101. #define NTFSDEFS 0x01
  102. #define KERNEL NTFSDEFS
  103. VOID dumpf (const char *format, ...);
  104. //
  105. // This routine returns the bit number right to left of a field.
  106. //
  107. LONG
  108. t (
  109. IN ULONG z
  110. )
  111. {
  112. LONG i;
  113. for (i = 0; i < 32; i += 1) {
  114. if ((z >> i) & 1) {
  115. break;
  116. }
  117. }
  118. return i;
  119. }
  120. //
  121. // This program generates the IA64 machine dependent assembler offset
  122. // definitions.
  123. //
  124. VOID
  125. main (argc, argv)
  126. int argc;
  127. char *argv[];
  128. {
  129. char *outName;
  130. //
  131. // Create file for output.
  132. //
  133. if (argc == 2) {
  134. outName = argv[ 1 ];
  135. } else {
  136. outName = "ntfsdefs.h";
  137. }
  138. outName = argc >= 2 ? argv[1] : "ntfsdefs.h";
  139. NtfsDefs = fopen( outName, "w" );
  140. if (NtfsDefs == NULL) {
  141. fprintf( stderr, "GENNTFS: Cannot open %s for writing.\n", outName);
  142. perror("NTFSDEFS");
  143. exit(1);
  144. }
  145. fprintf( stderr, "GENNTFS: Writing %s header file.\n", outName );
  146. //
  147. // Constant definitions
  148. //
  149. dumpf("\n");
  150. dumpf("//\n");
  151. dumpf("// Constant definitions\n");
  152. dumpf("//\n");
  153. dumpf("\n");
  154. genVal(LowPart, 0);
  155. genVal(HighPart, 4);
  156. genVal(MASTER_FILE_TABLE_NUMBER, MASTER_FILE_TABLE_NUMBER);
  157. genVal(MASTER_FILE_TABLE2_NUMBER, MASTER_FILE_TABLE2_NUMBER);
  158. genVal(LOG_FILE_NUMBER, LOG_FILE_NUMBER);
  159. genVal(VOLUME_DASD_NUMBER, VOLUME_DASD_NUMBER);
  160. genVal(ATTRIBUTE_DEF_TABLE_NUMBER, ATTRIBUTE_DEF_TABLE_NUMBER);
  161. genVal(ROOT_FILE_NAME_INDEX_NUMBER, ROOT_FILE_NAME_INDEX_NUMBER);
  162. genVal(BIT_MAP_FILE_NUMBER, BIT_MAP_FILE_NUMBER);
  163. genVal(BOOT_FILE_NUMBER, BOOT_FILE_NUMBER);
  164. genVal(BAD_CLUSTER_FILE_NUMBER, BAD_CLUSTER_FILE_NUMBER);
  165. genVal(QUOTA_TABLE_NUMBER, QUOTA_TABLE_NUMBER);
  166. genVal(UPCASE_TABLE_NUMBER, UPCASE_TABLE_NUMBER);
  167. genVal($STANDARD_INFORMATION, $STANDARD_INFORMATION);
  168. genVal($ATTRIBUTE_LIST, $ATTRIBUTE_LIST);
  169. genVal($FILE_NAME, $FILE_NAME);
  170. genVal($OBJECT_ID, $OBJECT_ID);
  171. genVal($SECURITY_DESCRIPTOR, $SECURITY_DESCRIPTOR);
  172. genVal($VOLUME_NAME, $VOLUME_NAME);
  173. genVal($VOLUME_INFORMATION, $VOLUME_INFORMATION);
  174. genVal($DATA, $DATA);
  175. genVal($INDEX_ROOT, $INDEX_ROOT);
  176. genVal($INDEX_ALLOCATION, $INDEX_ALLOCATION);
  177. genVal($BITMAP, $BITMAP);
  178. genVal($SYMBOLIC_LINK, $SYMBOLIC_LINK);
  179. genVal($EA_INFORMATION, $EA_INFORMATION);
  180. genVal($EA, $EA);
  181. genVal($FIRST_USER_DEFINED_ATTRIBUTE, $FIRST_USER_DEFINED_ATTRIBUTE);
  182. genVal($END, $END);
  183. genVal(SEQUENCE_NUMBER_STRIDE, SEQUENCE_NUMBER_STRIDE);
  184. //
  185. // MFT_SEGMENT_REFERENCE
  186. //
  187. genDef(REF_, MFT_SEGMENT_REFERENCE, SegmentNumberLowPart);
  188. genDef(REF_, MFT_SEGMENT_REFERENCE, SegmentNumberHighPart);
  189. genDef(REF_, MFT_SEGMENT_REFERENCE, SequenceNumber);
  190. //
  191. // MULTI_SECTOR_HEADER
  192. //
  193. genDef(MSH_, MULTI_SECTOR_HEADER, Signature);
  194. genDef(MSH_, MULTI_SECTOR_HEADER, UpdateSequenceArrayOffset);
  195. genDef(MSH_, MULTI_SECTOR_HEADER, UpdateSequenceArraySize);
  196. //
  197. // FILE_RECORD_SEGMENT_HEADER
  198. //
  199. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, MultiSectorHeader);
  200. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, Lsn);
  201. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, SequenceNumber);
  202. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, ReferenceCount);
  203. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, FirstAttributeOffset);
  204. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, Flags);
  205. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, FirstFreeByte);
  206. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, BytesAvailable);
  207. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, BaseFileRecordSegment);
  208. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, NextAttributeInstance);
  209. genDef(FRS_, FILE_RECORD_SEGMENT_HEADER, UpdateArrayForCreateOnly);
  210. genVal(FILE_RECORD_SEGMENT_IN_USE, FILE_RECORD_SEGMENT_IN_USE);
  211. genVal(FILE_FILE_NAME_INDEX_PRESENT, FILE_FILE_NAME_INDEX_PRESENT);
  212. //
  213. // ATTRIBUTE_RECORD_HEADER
  214. //
  215. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, TypeCode);
  216. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, RecordLength);
  217. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, FormCode);
  218. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, NameLength);
  219. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, NameOffset);
  220. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, Flags);
  221. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, Instance);
  222. genDef(ATTR_, ATTRIBUTE_RECORD_HEADER, Form);
  223. //
  224. // Resident
  225. //
  226. genDef2(RES_,ATTRIBUTE_RECORD_HEADER,ValueLength,Form.Resident.ValueLength);
  227. genDef2(RES_,ATTRIBUTE_RECORD_HEADER,ValueOffset,Form.Resident.ValueOffset);
  228. genDef2(RES_,ATTRIBUTE_RECORD_HEADER,ResidentFlags,Form.Resident.ResidentFlags);
  229. genDef2(RES_,ATTRIBUTE_RECORD_HEADER,Reserved,Form.Resident.Reserved);
  230. //
  231. // Nonresident
  232. //
  233. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,LowestVcn,Form.Nonresident.LowestVcn);
  234. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,HighestVcn,Form.Nonresident.HighestVcn);
  235. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,MappingPairOffset,Form.Nonresident.MappingPairsOffset);
  236. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,CompressionUnit,Form.Nonresident.CompressionUnit);
  237. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,Reserved,Form.Nonresident.Reserved);
  238. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,AllocatedLength,Form.Nonresident.AllocatedLength);
  239. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,FileSize,Form.Nonresident.FileSize);
  240. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,ValidDataLength,Form.Nonresident.ValidDataLength);
  241. genDef2(NONRES_,ATTRIBUTE_RECORD_HEADER,TotalAllocated,Form.Nonresident.TotalAllocated);
  242. genVal(RESIDENT_FORM, RESIDENT_FORM);
  243. genVal(NONRESIDENT_FORM, NONRESIDENT_FORM);
  244. genVal(ATTRIBUTE_FLAG_COMPRESSION_MASK, ATTRIBUTE_FLAG_COMPRESSION_MASK);
  245. //
  246. // ATTRIBUTE_LIST_ENTRY
  247. //
  248. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, AttributeTypeCode);
  249. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, RecordLength);
  250. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, AttributeNameLength);
  251. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, AttributeNameOffset);
  252. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, LowestVcn);
  253. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, SegmentReference);
  254. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, Instance);
  255. genDef(ATTRLIST_, ATTRIBUTE_LIST_ENTRY, AttributeName);
  256. genVal(FAT_DIRENT_ATTR_READ_ONLY, FAT_DIRENT_ATTR_READ_ONLY);
  257. genVal(FAT_DIRENT_ATTR_HIDDEN, FAT_DIRENT_ATTR_HIDDEN);
  258. genVal(FAT_DIRENT_ATTR_SYSTEM, FAT_DIRENT_ATTR_SYSTEM);
  259. genVal(FAT_DIRENT_ATTR_VOLUME_ID, FAT_DIRENT_ATTR_VOLUME_ID);
  260. genVal(FAT_DIRENT_ATTR_ARCHIVE, FAT_DIRENT_ATTR_ARCHIVE);
  261. genVal(FAT_DIRENT_ATTR_DEVICE, FAT_DIRENT_ATTR_DEVICE);
  262. //
  263. // DUPLICATED_INFORMATION
  264. //
  265. genDef(DUPINFO_, DUPLICATED_INFORMATION, CreationTime);
  266. genDef(DUPINFO_, DUPLICATED_INFORMATION, LastModificationTime);
  267. genDef(DUPINFO_, DUPLICATED_INFORMATION, LastChangeTime);
  268. genDef(DUPINFO_, DUPLICATED_INFORMATION, LastAccessTime);
  269. genDef(DUPINFO_, DUPLICATED_INFORMATION, AllocatedLength);
  270. genDef(DUPINFO_, DUPLICATED_INFORMATION, FileSize);
  271. genDef(DUPINFO_, DUPLICATED_INFORMATION, FileAttributes);
  272. genDef(DUPINFO_, DUPLICATED_INFORMATION, PackedEaSize);
  273. genDef(DUPINFO_, DUPLICATED_INFORMATION, Reserved);
  274. //
  275. // FILE_NAME
  276. //
  277. genDef(FN_, FILE_NAME, ParentDirectory);
  278. genDef(FN_, FILE_NAME, Info);
  279. genDef(FN_, FILE_NAME, FileNameLength);
  280. genDef(FN_, FILE_NAME, Flags);
  281. genDef(FN_, FILE_NAME, FileName);
  282. genVal(FILE_NAME_NTFS, FILE_NAME_NTFS);
  283. genVal(FILE_NAME_DOS, FILE_NAME_DOS);
  284. genVal(FILE_NAME_LINK, 4);
  285. //
  286. // INDEX_HEADER
  287. //
  288. genDef(IH_, INDEX_HEADER, FirstIndexEntry);
  289. genDef(IH_, INDEX_HEADER, FirstFreeByte);
  290. genDef(IH_, INDEX_HEADER, BytesAvailable);
  291. genDef(IH_, INDEX_HEADER, Flags);
  292. genDef(IH_, INDEX_HEADER, Reserved);
  293. genVal(INDEX_NODE, INDEX_NODE);
  294. //
  295. // INDEX_ROOT
  296. //
  297. genDef(IR_, INDEX_ROOT, IndexedAttributeType);
  298. genDef(IR_, INDEX_ROOT, CollationRule);
  299. genDef(IR_, INDEX_ROOT, BytesPerIndexBuffer);
  300. genDef(IR_, INDEX_ROOT, BlocksPerIndexBuffer);
  301. genDef(IR_, INDEX_ROOT, Reserved);
  302. genDef(IR_, INDEX_ROOT, IndexHeader);
  303. //
  304. // INDEX_ALLOCATION_BUFFER
  305. //
  306. genDef(IB_, INDEX_ALLOCATION_BUFFER, MultiSectorHeader);
  307. genDef(IB_, INDEX_ALLOCATION_BUFFER, Lsn);
  308. genDef(IB_, INDEX_ALLOCATION_BUFFER, ThisBlock);
  309. genDef(IB_, INDEX_ALLOCATION_BUFFER, IndexHeader);
  310. genDef(IB_, INDEX_ALLOCATION_BUFFER, UpdateSequenceArray);
  311. //
  312. // INDEX_ENTRY
  313. //
  314. genDef(IE_, INDEX_ENTRY, FileReference);
  315. genDef(IE_, INDEX_ENTRY, Length);
  316. genDef(IE_, INDEX_ENTRY, AttributeLength);
  317. genDef(IE_, INDEX_ENTRY, Flags);
  318. genDef(IE_, INDEX_ENTRY, Reserved);
  319. genVal(INDEX_ENTRY_NODE, INDEX_ENTRY_NODE);
  320. genVal(INDEX_ENTRY_END, INDEX_ENTRY_END);
  321. fclose(NtfsDefs);
  322. }
  323. VOID
  324. dumpf (const char *format, ...)
  325. {
  326. va_list(arglist);
  327. va_start(arglist, format);
  328. // if (OutputEnabled & NTFSDEFS) {
  329. vfprintf (NtfsDefs, format, arglist);
  330. // }
  331. va_end(arglist);
  332. }