Enumerations.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * PERWAPI - An API for Reading and Writing PE Files
  3. *
  4. * Copyright (c) Diane Corney, Queensland University of Technology, 2004.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the PERWAPI Copyright as included with this
  8. * distribution in the file PERWAPIcopyright.rtf.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY as is explained in the copyright notice.
  12. *
  13. * The author may be contacted at d.corney@qut.edu.au
  14. *
  15. * Version Date: 26/01/07
  16. */
  17. using System;
  18. namespace QUT.PERWAPI
  19. {
  20. /**************************************************************************/
  21. // Various Enumerations for PEFiles
  22. /// <summary>
  23. /// flags for the assembly (.corflags)
  24. /// </summary>
  25. public enum CorFlags
  26. {
  27. /// <summary>
  28. /// IL only
  29. /// </summary>
  30. CF_IL_ONLY = 1,
  31. /// <summary>
  32. /// 32 bits
  33. /// </summary>
  34. CF_32_BITREQUIRED = 2,
  35. /// <summary>
  36. /// strong name signed
  37. /// </summary>
  38. CF_STRONGNAMESIGNED = 8,
  39. /// <summary>
  40. /// track debug data
  41. /// </summary>
  42. CF_TRACKDEBUGDATA = 0x10000
  43. }
  44. /// <summary>
  45. /// subsystem for the assembly (.subsystem)
  46. /// </summary>
  47. public enum SubSystem
  48. {
  49. /// <summary>
  50. /// native subsystem
  51. /// </summary>
  52. Native = 1,
  53. /// <summary>
  54. /// gui app
  55. /// </summary>
  56. Windows_GUI = 2,
  57. /// <summary>
  58. /// console app
  59. /// </summary>
  60. Windows_CUI = 3,
  61. /// <summary>
  62. /// os2 console
  63. /// </summary>
  64. OS2_CUI = 5,
  65. /// <summary>
  66. /// posix console
  67. /// </summary>
  68. POSIX_CUI = 7,
  69. /// <summary>
  70. /// native windows
  71. /// </summary>
  72. Native_Windows = 8,
  73. /// <summary>
  74. /// CE gui
  75. /// </summary>
  76. Windows_CE_GUI = 9
  77. }
  78. /// <summary>
  79. /// Hash algorithms for the assembly
  80. /// </summary>
  81. public enum HashAlgorithmType
  82. {
  83. /// <summary>
  84. /// No hash algorithm
  85. /// </summary>
  86. None,
  87. /// <summary>
  88. /// SHA1
  89. /// </summary>
  90. SHA1 = 0x8004
  91. }
  92. /// <summary>
  93. /// Attributes for this assembly
  94. /// </summary>
  95. public enum AssemAttr
  96. {
  97. /// <summary>
  98. /// Public key assembly attribute
  99. /// </summary>
  100. PublicKey = 0x01,
  101. /// <summary>
  102. /// retargetable assembly
  103. /// </summary>
  104. Retargetable = 0x100,
  105. /// <summary>
  106. /// JIT tracking
  107. /// </summary>
  108. EnableJITCompileTracking = 0x8000,
  109. /// <summary>
  110. /// Disable JIT compile optimizer
  111. /// </summary>
  112. DisableJITCompileOptimizer = 0x4000
  113. }
  114. /// <summary>
  115. /// Method call conventions
  116. /// </summary>
  117. [FlagsAttribute]
  118. public enum CallConv
  119. {
  120. /// <summary>
  121. /// default cc
  122. /// </summary>
  123. Default,
  124. /// <summary>
  125. /// cdecl
  126. /// </summary>
  127. Cdecl,
  128. /// <summary>
  129. /// stdcall
  130. /// </summary>
  131. Stdcall,
  132. /// <summary>
  133. /// this call
  134. /// </summary>
  135. Thiscall,
  136. /// <summary>
  137. /// fast call
  138. /// </summary>
  139. Fastcall,
  140. /// <summary>
  141. /// var arg
  142. /// </summary>
  143. Vararg,
  144. /// <summary>
  145. /// generic
  146. /// </summary>
  147. Generic = 0x10,
  148. /// <summary>
  149. /// instance
  150. /// </summary>
  151. Instance = 0x20,
  152. /// <summary>
  153. /// explicit instance
  154. /// </summary>
  155. InstanceExplicit = 0x60
  156. }
  157. /// <summary>
  158. /// Method Types for Events and Properties
  159. /// </summary>
  160. public enum MethodType
  161. {
  162. /// <summary>
  163. /// setter
  164. /// </summary>
  165. Setter = 0x01,
  166. /// <summary>
  167. /// getter
  168. /// </summary>
  169. Getter,
  170. /// <summary>
  171. /// other
  172. /// </summary>
  173. Other = 0x04,
  174. /// <summary>
  175. /// add on
  176. /// </summary>
  177. AddOn = 0x08,
  178. /// <summary>
  179. /// remove on
  180. /// </summary>
  181. RemoveOn = 0x10,
  182. /// <summary>
  183. /// Fire
  184. /// </summary>
  185. Fire = 0x20
  186. }
  187. /// <summary>
  188. /// Type custom modifier
  189. /// </summary>
  190. public enum CustomModifier
  191. {
  192. /// <summary>
  193. /// mod req
  194. /// </summary>
  195. modreq = 0x1F,
  196. /// <summary>
  197. /// mod opt
  198. /// </summary>
  199. modopt
  200. };
  201. /// <summary>
  202. /// Attibutes for a class
  203. /// </summary>
  204. [FlagsAttribute]
  205. public enum TypeAttr
  206. {
  207. Private, Public, NestedPublic, NestedPrivate,
  208. NestedFamily, NestedAssembly, NestedFamAndAssem, NestedFamOrAssem,
  209. SequentialLayout, ExplicitLayout = 0x10, Interface = 0x20,
  210. Abstract = 0x80, PublicAbstract = 0x81, Sealed = 0x100,
  211. PublicSealed = 0x101, SpecialName = 0x400, RTSpecialName = 0x800,
  212. Import = 0x1000, Serializable = 0x2000, UnicodeClass = 0x10000,
  213. AutoClass = 0x20000, BeforeFieldInit = 0x100000
  214. }
  215. /// <summary>
  216. /// Attributes for a field
  217. /// </summary>
  218. [FlagsAttribute]
  219. public enum FieldAttr
  220. {
  221. Default, Private, FamAndAssem, Assembly,
  222. Family, FamOrAssem, Public, Static = 0x10, PublicStatic = 0x16,
  223. Initonly = 0x20, Literal = 0x40, Notserialized = 0x80,
  224. SpecialName = 0x200, RTSpecialName = 0x400
  225. }
  226. /// <summary>
  227. /// Attributes for a method
  228. /// </summary>
  229. [FlagsAttribute]
  230. public enum MethAttr
  231. {
  232. Default, Private, FamAndAssem, Assembly,
  233. Family, FamOrAssem, Public, Static = 0x0010, PublicStatic = 0x16,
  234. Final = 0x0020, PublicStaticFinal = 0x36, Virtual = 0x0040,
  235. PrivateVirtual, PublicVirtual = 0x0046, HideBySig = 0x0080,
  236. NewSlot = 0x0100, Abstract = 0x0400, SpecialName = 0x0800,
  237. RTSpecialName = 0x1000, SpecialRTSpecialName = 0x1800,
  238. RequireSecObject = 0x8000
  239. }
  240. /// <summary>
  241. /// Attributes for .pinvokeimpl method declarations
  242. /// </summary>
  243. [FlagsAttribute]
  244. public enum PInvokeAttr
  245. {
  246. ansi = 2, unicode = 4, autochar = 6,
  247. lasterr = 0x040, winapi = 0x100, cdecl = 0x200, stdcall = 0x300,
  248. thiscall = 0x400, fastcall = 0x500
  249. }
  250. /// <summary>
  251. /// Implementation attributes for a method
  252. /// </summary>
  253. [FlagsAttribute]
  254. public enum ImplAttr
  255. {
  256. IL, Native, OPTIL, Runtime, Unmanaged,
  257. ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000,
  258. Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008
  259. }
  260. /// <summary>
  261. /// Modes for a parameter
  262. /// </summary>
  263. [FlagsAttribute]
  264. public enum ParamAttr { Default, In, Out, Opt = 4 }
  265. /// <summary>
  266. /// Flags for a generic parameter
  267. /// </summary>
  268. [Flags]
  269. public enum GenericParamAttr
  270. {
  271. NonVariant,
  272. Covariant,
  273. Contravariant,
  274. ReferenceType = 0x4,
  275. RequireDefaultCtor = 0x10
  276. }
  277. /// <summary>
  278. /// Which version of PE file to build
  279. /// </summary>
  280. public enum NetVersion
  281. {
  282. Everett, /* version 1.1.4322 */
  283. Whidbey40, /* version 2.0.40607 beta 1*/
  284. Whidbey41, /* version 2.0.41202 */
  285. Whidbey50, /* version 2.0.50215 beta2*/
  286. Version2, /* version 2.0.50727.0 */
  287. V2_Compact /* version 2.0.0.0 compact framework */
  288. }
  289. /// <summary>
  290. /// CIL instructions
  291. /// </summary>
  292. public enum Op
  293. {
  294. nop, breakOp, ldarg_0, ldarg_1, ldarg_2, ldarg_3, ldloc_0, ldloc_1, ldloc_2,
  295. ldloc_3, stloc_0, stloc_1, stloc_2, stloc_3,
  296. ldnull = 0x14, ldc_i4_m1, ldc_i4_0, ldc_i4_1, ldc_i4_2, ldc_i4_3,
  297. ldc_i4_4, ldc_i4_5, ldc_i4_6, ldc_i4_7, ldc_i4_8, dup = 0x25, pop,
  298. ret = 0x2A, ldind_i1 = 0x46, ldind_u1, ldind_i2, ldind_u2, ldind_i4,
  299. ldind_u4, ldind_i8, ldind_i, ldind_r4, ldind_r8, ldind_ref, stind_ref,
  300. stind_i1, stind_i2, stind_i4, stind_i8, stind_r4, stind_r8, add, sub, mul,
  301. div, div_un, rem, rem_un, and, or, xor, shl, shr, shr_un, neg, not,
  302. conv_i1, conv_i2, conv_i4, conv_i8, conv_r4, conv_r8, conv_u4, conv_u8,
  303. conv_r_un = 0x76, throwOp = 0x7A, conv_ovf_i1_un = 0x82, conv_ovf_i2_un,
  304. conv_ovf_i4_un, conv_ovf_i8_un, conf_ovf_u1_un, conv_ovf_u2_un,
  305. conv_ovf_u4_un, conv_ovf_u8_un, conv_ovf_i_un, conv_ovf_u_un,
  306. ldlen = 0x8E, ldelem_i1 = 0x90, ldelem_u1, ldelem_i2, ldelem_u2,
  307. ldelem_i4, ldelem_u4, ldelem_i8, ldelem_i, ldelem_r4, ldelem_r8,
  308. ldelem_ref, stelem_i, stelem_i1, stelem_i2, stelem_i4, stelem_i8,
  309. stelem_r4, stelem_r8, stelem_ref, conv_ovf_i1 = 0xb3, conv_ovf_u1,
  310. conv_ovf_i2, conv_ovf_u2, conv_ovf_i4, conv_ovf_u4, conv_ovf_i8,
  311. conv_ovf_u8, ckfinite = 0xC3, conv_u2 = 0xD1, conv_u1, conv_i,
  312. conv_ovf_i, conv_ovf_u, add_ovf, add_ovf_un, mul_ovf, mul_ovf_un,
  313. sub_ovf, sub_ovf_un, endfinally, stind_i = 0xDF, conv_u,
  314. arglist = 0xFE00, ceq, cgt, cgt_un, clt, clt_un, localloc = 0xFE0F,
  315. endfilter = 0xFE11, volatile_ = 0xFE13, tail_, cpblk = 0xFE17, initblk,
  316. rethrow = 0xFE1A, refanytype = 0xFE1D, readOnly
  317. }
  318. /// <summary>
  319. /// CIL instructions requiring an integer parameter
  320. /// </summary>
  321. public enum IntOp
  322. {
  323. ldarg_s = 0x0E, ldarga_s, starg_s, ldloc_s, ldloca_s,
  324. stloc_s, ldc_i4_s = 0x1F, ldc_i4, ldarg = 0xFE09,
  325. ldarga, starg, ldloc, ldloca, stloc, unaligned = 0xFE12
  326. }
  327. /// <summary>
  328. /// CIL instructions requiring a field parameter
  329. /// </summary>
  330. public enum FieldOp
  331. {
  332. ldfld = 0x7B, ldflda, stfld, ldsfld, ldsflda,
  333. stsfld, ldtoken = 0xD0
  334. }
  335. /// <summary>
  336. /// CIL instructions requiring a method parameter
  337. /// </summary>
  338. public enum MethodOp
  339. {
  340. jmp = 0x27, call, callvirt = 0x6F, newobj = 0x73,
  341. ldtoken = 0xD0, ldftn = 0xFE06, ldvirtfn
  342. }
  343. /// <summary>
  344. /// CIL instructions requiring a type parameter
  345. /// </summary>
  346. public enum TypeOp
  347. {
  348. cpobj = 0x70, ldobj, castclass = 0x74, isinst,
  349. unbox = 0x79, stobj = 0x81, box = 0x8C, newarr,
  350. ldelema = 0x8F, ldelem_any = 0xA3, stelem_any, unbox_any,
  351. refanyval = 0xC2, mkrefany = 0xC6,
  352. ldtoken = 0xD0, initobj = 0xFE15, constrained, sizeOf = 0xFE1C
  353. }
  354. /// <summary>
  355. /// CIL branch instructions
  356. /// </summary>
  357. public enum BranchOp
  358. {
  359. br_s = 0x2B, brfalse_s, brtrue_s, beq_s, bge_s, bgt_s, ble_s,
  360. blt_s, bne_un_s, bge_un_s, bgt_un_s, ble_un_s, blt_un_s,
  361. br, brfalse, brtrue, beq, bge, bgt, ble, blt, bne_un, bge_un, bgt_un, ble_un, blt_un,
  362. leave = 0xDD, leave_s
  363. }
  364. public enum SpecialOp
  365. {
  366. ldc_i8 = 0x21, ldc_r4, ldc_r8, calli = 0x29,
  367. Switch = 0x45, ldstr = 0x72
  368. }
  369. /// <summary>
  370. /// Index for all the tables in the meta data
  371. /// </summary>
  372. public enum MDTable
  373. {
  374. Module, TypeRef, TypeDef, Field = 0x04, Method = 0x06,
  375. Param = 0x08, InterfaceImpl, MemberRef, Constant, CustomAttribute,
  376. FieldMarshal, DeclSecurity, ClassLayout, FieldLayout, StandAloneSig,
  377. EventMap, Event = 0x14, PropertyMap, Property = 0x17, MethodSemantics,
  378. MethodImpl, ModuleRef, TypeSpec, ImplMap, FieldRVA, Assembly = 0x20,
  379. AssemblyProcessor, AssemblyOS, AssemblyRef, AssemblyRefProcessor,
  380. AssemblyRefOS, File, ExportedType, ManifestResource, NestedClass,
  381. GenericParam, MethodSpec, GenericParamConstraint, MaxMDTable
  382. }
  383. public enum NativeTypeIx
  384. {
  385. Void = 0x01, Boolean, I1, U1, I2, U2, I4, U4,
  386. I8, U8, R4, R8, SysChar, Variant, Currency, Ptr, Decimal, Date, BStr,
  387. LPStr, LPWStr, LPTStr, FixedSysString, ObjectRef, IUnknown, IDispatch,
  388. Struct, Intf, SafeArray, FixedArray, Int, UInt, NestedStruct, ByValStr,
  389. AnsiBStr, TBStr, VariantBool, Func, AsAny = 0x28, Array = 0x2A, LPStruct,
  390. CustomMarshaller, Error
  391. }
  392. public enum SafeArrayType
  393. {
  394. int16 = 2, int32, float32, float64,
  395. currency, date, bstr, dispatch, error, boolean, variant, unknown,
  396. Decimal, int8 = 16, uint8, uint16, uint32, Int = 22, UInt,
  397. record = 0x24,
  398. MAX = 0x50
  399. }
  400. internal enum CIx
  401. {
  402. TypeDefOrRef, HasConstant, HasCustomAttr, HasFieldMarshal,
  403. HasDeclSecurity, MemberRefParent, HasSemantics, MethodDefOrRef,
  404. MemberForwarded, Implementation, CustomAttributeType, ResolutionScope,
  405. TypeOrMethodDef, MaxCIx
  406. }
  407. internal enum MapType { eventMap, propertyMap, nestedClass }
  408. public enum ElementType : byte
  409. {
  410. End, Void, Boolean, Char, I1, U1, I2, U2, I4, U4,
  411. I8, U8, R4, R8, String, Ptr, ByRef, ValueType, Class, Var, Array, GenericInst,
  412. TypedByRef, I = 0x18, U, FnPtr = 0x1B, Object, SZArray, MVar, CmodReqd,
  413. CmodOpt, Internal, Modifier = 0x40, Sentinel, Pinned = 0x45, ClassType = 0x50
  414. }
  415. public enum SecurityAction
  416. {
  417. Request = 0x01, Demand, Assert, Deny, PermitOnly,
  418. LinkDemand, InheritanceDemand, RequestMinimum, RequestOptional, RequestRefuse,
  419. PreJITGrant, PreJITDeny, NonCASDemand, NonCASLinkDemand, NonCASInheritanceDemand
  420. }
  421. internal enum IType
  422. {
  423. op, methOp, fieldOp, typeOp, specialOp, int8Op, uint8Op, uint16Op,
  424. int32Op, branchOp
  425. }
  426. }