[CMAKE]
[reactos.git] / include / reactos / exeformat.h
1 #ifndef REACTOS_EXEFORMAT_H_INCLUDED_
2 #define REACTOS_EXEFORMAT_H_INCLUDED_ 1
3
4 /*
5 * LOADER API
6 */
7 /* OUT flags returned by a loader */
8 #define EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED (1 << 0)
9 #define EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP (1 << 1)
10 #define EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED (1 << 2)
11
12 #define EXEFMT_LOAD_ASSUME_SEGMENTS_OK \
13 ( \
14 EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED | \
15 EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP | \
16 EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED \
17 )
18
19 /*
20 Minumum size of the buffer passed to each loader for identification of the
21 executable
22 */
23 #define EXEFMT_LOAD_HEADER_SIZE (0x2000)
24
25 /* Special values for the base address of images */
26 /*
27 Base address can't be represented in an ULONG_PTR: any effective load address
28 will require relocation
29 */
30 #define EXEFMT_LOAD_BASE_NONE ((ULONG_PTR)-1)
31
32 /* Base address never matters, relocation never required */
33 #define EXEFMT_LOAD_BASE_ANY ((ULONG_PTR)-2)
34
35 typedef NTSTATUS (NTAPI * PEXEFMT_CB_READ_FILE)
36 (
37 IN PVOID File,
38 IN PLARGE_INTEGER Offset,
39 IN ULONG Length,
40 OUT PVOID * Data,
41 OUT PVOID * AllocBase,
42 OUT PULONG ReadSize
43 );
44
45 typedef PMM_SECTION_SEGMENT (NTAPI * PEXEFMT_CB_ALLOCATE_SEGMENTS)
46 (
47 IN ULONG NrSegments
48 );
49
50 typedef NTSTATUS (NTAPI * PEXEFMT_LOADER)
51 (
52 IN CONST VOID * FileHeader,
53 IN SIZE_T FileHeaderSize,
54 IN PVOID File,
55 OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject,
56 OUT PULONG Flags,
57 IN PEXEFMT_CB_READ_FILE ReadFileCb,
58 IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb
59 );
60
61 /*
62 * STATUS CONSTANTS
63 */
64
65 #define FACILITY_ROS_EXEFMT (0x10)
66
67 /*
68 * Returned by ExeFormat loaders to tell the caller the format isn't supported,
69 * as opposed to STATUS_INVALID_IMAGE_FORMAT meaning the format is supported,
70 * but the particular file is malformed
71 */
72 #define STATUS_ROS_EXEFMT_UNKNOWN_FORMAT ((NTSTATUS)0xA0100001)
73
74 /*
75 * Returned by MmCreateSection to signal successful loading of an executable
76 * image, saving the caller the effort of determining the executable's format
77 * again. The full status to return is obtained by performing a bitwise OR of
78 * STATUS_ROS_EXEFMT_LOADED_FORMAT and the appropriate EXEFMT_LOADED_XXX
79 */
80 #define FACILITY_ROS_EXEFMT_FORMAT (0x11)
81 #define STATUS_ROS_EXEFMT_LOADED_FORMAT ((NTSTATUS)0x60110000)
82
83 /* non-standard format, ZwQuerySection required to retrieve the format tag */
84 #define EXEFMT_LOADED_EXTENDED (0x0000FFFF)
85
86 /* Windows PE32/PE32+ */
87 #define EXEFMT_LOADED_PE32 (0x00000000)
88 #define EXEFMT_LOADED_PE64 (0x00000001)
89
90 /* Wine ELF */
91 #define EXEFMT_LOADED_WINE32 (0x00000002)
92 #define EXEFMT_LOADED_WINE64 (0x00000003)
93
94 /* regular ELF */
95 #define EXEFMT_LOADED_ELF32 (0x00000004)
96 #define EXEFMT_LOADED_ELF64 (0x00000005)
97
98 #endif
99
100 /* EOF */