ReactOS  0.4.13-dev-249-gcba1a2f
exeformat.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED   (1 << 0)
 
#define EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP   (1 << 1)
 
#define EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED   (1 << 2)
 
#define EXEFMT_LOAD_ASSUME_SEGMENTS_OK
 
#define EXEFMT_LOAD_HEADER_SIZE   (0x2000)
 
#define EXEFMT_LOAD_BASE_NONE   ((ULONG_PTR)-1)
 
#define EXEFMT_LOAD_BASE_ANY   ((ULONG_PTR)-2)
 
#define FACILITY_ROS_EXEFMT   (0x10)
 
#define STATUS_ROS_EXEFMT_UNKNOWN_FORMAT   ((NTSTATUS)0xA0100001)
 
#define FACILITY_ROS_EXEFMT_FORMAT   (0x11)
 
#define STATUS_ROS_EXEFMT_LOADED_FORMAT   ((NTSTATUS)0x60110000)
 
#define EXEFMT_LOADED_EXTENDED   (0x0000FFFF)
 
#define EXEFMT_LOADED_PE32   (0x00000000)
 
#define EXEFMT_LOADED_PE64   (0x00000001)
 
#define EXEFMT_LOADED_WINE32   (0x00000002)
 
#define EXEFMT_LOADED_WINE64   (0x00000003)
 
#define EXEFMT_LOADED_ELF32   (0x00000004)
 
#define EXEFMT_LOADED_ELF64   (0x00000005)
 
#define PEFMT_FIELDS_EQUAL(TYPE1_, TYPE2_, FIELD_)
 

Typedefs

typedef NTSTATUS(NTAPIPEXEFMT_CB_READ_FILE) (IN PVOID File, IN PLARGE_INTEGER Offset, IN ULONG Length, OUT PVOID *Data, OUT PVOID *AllocBase, OUT PULONG ReadSize)
 
typedef PMM_SECTION_SEGMENT(NTAPIPEXEFMT_CB_ALLOCATE_SEGMENTS) (IN ULONG NrSegments)
 
typedef NTSTATUS(NTAPIPEXEFMT_LOADER) (IN CONST VOID *FileHeader, IN SIZE_T FileHeaderSize, IN PVOID File, OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject, OUT PULONG Flags, IN PEXEFMT_CB_READ_FILE ReadFileCb, IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb)
 

Functions

static __inline BOOLEAN Intsafe_CanAddULongPtr (IN ULONG_PTR Addend1, IN ULONG_PTR Addend2)
 
static __inline BOOLEAN Intsafe_CanAddLong64 (IN LONG64 Addend1, IN LONG64 Addend2)
 
static __inline BOOLEAN Intsafe_CanAddULong32 (IN ULONG Addend1, IN ULONG Addend2)
 
static __inline BOOLEAN Intsafe_AddULong32 (OUT PULONG Result, IN ULONG Addend1, IN ULONG Addend2)
 
static __inline BOOLEAN Intsafe_CanMulULong32 (IN ULONG Factor1, IN ULONG Factor2)
 
static __inline BOOLEAN Intsafe_CanOffsetPointer (IN CONST VOID *Pointer, IN SIZE_T Offset)
 
static __inline BOOLEAN IsPowerOf2 (IN ULONG Number)
 
static __inline ULONG ModPow2 (IN ULONG Address, IN ULONG Alignment)
 
static __inline BOOLEAN IsAligned (IN ULONG Address, IN ULONG Alignment)
 
static __inline BOOLEAN AlignUp (OUT PULONG AlignedAddress, IN ULONG Address, IN ULONG Alignment)
 

Macro Definition Documentation

◆ EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP

#define EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP   (1 << 1)

Definition at line 9 of file exeformat.h.

◆ EXEFMT_LOAD_ASSUME_SEGMENTS_OK

#define EXEFMT_LOAD_ASSUME_SEGMENTS_OK
Value:
( \
EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED | \
EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP | \
EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED \
)

Definition at line 12 of file exeformat.h.

◆ EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED

#define EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED   (1 << 2)

Definition at line 10 of file exeformat.h.

◆ EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED

#define EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED   (1 << 0)

Definition at line 8 of file exeformat.h.

◆ EXEFMT_LOAD_BASE_ANY

#define EXEFMT_LOAD_BASE_ANY   ((ULONG_PTR)-2)

Definition at line 33 of file exeformat.h.

◆ EXEFMT_LOAD_BASE_NONE

#define EXEFMT_LOAD_BASE_NONE   ((ULONG_PTR)-1)

Definition at line 30 of file exeformat.h.

◆ EXEFMT_LOAD_HEADER_SIZE

#define EXEFMT_LOAD_HEADER_SIZE   (0x2000)

Definition at line 23 of file exeformat.h.

◆ EXEFMT_LOADED_ELF32

#define EXEFMT_LOADED_ELF32   (0x00000004)

Definition at line 95 of file exeformat.h.

◆ EXEFMT_LOADED_ELF64

#define EXEFMT_LOADED_ELF64   (0x00000005)

Definition at line 96 of file exeformat.h.

◆ EXEFMT_LOADED_EXTENDED

#define EXEFMT_LOADED_EXTENDED   (0x0000FFFF)

Definition at line 84 of file exeformat.h.

◆ EXEFMT_LOADED_PE32

#define EXEFMT_LOADED_PE32   (0x00000000)

Definition at line 87 of file exeformat.h.

◆ EXEFMT_LOADED_PE64

#define EXEFMT_LOADED_PE64   (0x00000001)

Definition at line 88 of file exeformat.h.

◆ EXEFMT_LOADED_WINE32

#define EXEFMT_LOADED_WINE32   (0x00000002)

Definition at line 91 of file exeformat.h.

◆ EXEFMT_LOADED_WINE64

#define EXEFMT_LOADED_WINE64   (0x00000003)

Definition at line 92 of file exeformat.h.

◆ FACILITY_ROS_EXEFMT

#define FACILITY_ROS_EXEFMT   (0x10)

Definition at line 65 of file exeformat.h.

◆ FACILITY_ROS_EXEFMT_FORMAT

#define FACILITY_ROS_EXEFMT_FORMAT   (0x11)

Definition at line 80 of file exeformat.h.

◆ PEFMT_FIELDS_EQUAL

#define PEFMT_FIELDS_EQUAL (   TYPE1_,
  TYPE2_,
  FIELD_ 
)
Value:
( \
(FIELD_OFFSET(TYPE1_, FIELD_) == FIELD_OFFSET(TYPE2_, FIELD_)) && \
(RTL_FIELD_SIZE(TYPE1_, FIELD_) == RTL_FIELD_SIZE(TYPE2_, FIELD_)) \
)
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254

Definition at line 165 of file exeformat.h.

◆ STATUS_ROS_EXEFMT_LOADED_FORMAT

#define STATUS_ROS_EXEFMT_LOADED_FORMAT   ((NTSTATUS)0x60110000)

Definition at line 81 of file exeformat.h.

◆ STATUS_ROS_EXEFMT_UNKNOWN_FORMAT

#define STATUS_ROS_EXEFMT_UNKNOWN_FORMAT   ((NTSTATUS)0xA0100001)

Definition at line 72 of file exeformat.h.

Typedef Documentation

◆ PEXEFMT_CB_ALLOCATE_SEGMENTS

typedef PMM_SECTION_SEGMENT(NTAPI * PEXEFMT_CB_ALLOCATE_SEGMENTS) (IN ULONG NrSegments)

Definition at line 46 of file exeformat.h.

◆ PEXEFMT_CB_READ_FILE

typedef NTSTATUS(NTAPI * PEXEFMT_CB_READ_FILE) (IN PVOID File, IN PLARGE_INTEGER Offset, IN ULONG Length, OUT PVOID *Data, OUT PVOID *AllocBase, OUT PULONG ReadSize)

Definition at line 36 of file exeformat.h.

◆ PEXEFMT_LOADER

typedef NTSTATUS(NTAPI * PEXEFMT_LOADER) (IN CONST VOID *FileHeader, IN SIZE_T FileHeaderSize, IN PVOID File, OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject, OUT PULONG Flags, IN PEXEFMT_CB_READ_FILE ReadFileCb, IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb)

Definition at line 51 of file exeformat.h.

Function Documentation

◆ AlignUp()

static __inline BOOLEAN AlignUp ( OUT PULONG  AlignedAddress,
IN ULONG  Address,
IN ULONG  Alignment 
)
static

Definition at line 152 of file exeformat.h.

153 {
154  ULONG nExcess = ModPow2(Address, Alignment);
155 
156  if(nExcess == 0)
157  {
158  *AlignedAddress = Address;
159  return nExcess == 0;
160  }
161  else
162  return Intsafe_AddULong32(AlignedAddress, Address, Alignment - nExcess);
163 }
static __inline ULONG ModPow2(IN ULONG Address, IN ULONG Alignment)
Definition: exeformat.h:141
static WCHAR Address[46]
Definition: ping.c:68
static __inline BOOLEAN Intsafe_AddULong32(OUT PULONG Result, IN ULONG Addend1, IN ULONG Addend2)
Definition: exeformat.h:114
unsigned int ULONG
Definition: retypes.h:1

◆ Intsafe_AddULong32()

static __inline BOOLEAN Intsafe_AddULong32 ( OUT PULONG  Result,
IN ULONG  Addend1,
IN ULONG  Addend2 
)
static

Definition at line 114 of file exeformat.h.

115 {
116  if(!Intsafe_CanAddULong32(Addend1, Addend2))
117  return FALSE;
118 
119  *Result = Addend1 + Addend2;
120  return TRUE;
121 }
_In_ LARGE_INTEGER Addend2
Definition: rtlfuncs.h:3089
#define TRUE
Definition: types.h:120
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static __inline BOOLEAN Intsafe_CanAddULong32(IN ULONG Addend1, IN ULONG Addend2)
Definition: exeformat.h:109

Referenced by AlignUp(), and PeFmtCreateSection().

◆ Intsafe_CanAddLong64()

static __inline BOOLEAN Intsafe_CanAddLong64 ( IN LONG64  Addend1,
IN LONG64  Addend2 
)
static

Definition at line 104 of file exeformat.h.

105 {
106  return Addend1 <= (MAXLONGLONG - Addend2);
107 }
_In_ LARGE_INTEGER Addend2
Definition: rtlfuncs.h:3089
#define MAXLONGLONG

Referenced by PeFmtCreateSection().

◆ Intsafe_CanAddULong32()

static __inline BOOLEAN Intsafe_CanAddULong32 ( IN ULONG  Addend1,
IN ULONG  Addend2 
)
static

Definition at line 109 of file exeformat.h.

110 {
111  return Addend1 <= (MAXULONG - Addend2);
112 }
_In_ LARGE_INTEGER Addend2
Definition: rtlfuncs.h:3089
#define MAXULONG
Definition: typedefs.h:250

Referenced by Intsafe_AddULong32().

◆ Intsafe_CanAddULongPtr()

static __inline BOOLEAN Intsafe_CanAddULongPtr ( IN ULONG_PTR  Addend1,
IN ULONG_PTR  Addend2 
)
static

Definition at line 99 of file exeformat.h.

100 {
101  return Addend1 <= (MAXULONG_PTR - Addend2);
102 }
_In_ LARGE_INTEGER Addend2
Definition: rtlfuncs.h:3089
#define MAXULONG_PTR
Definition: basetsd.h:103

Referenced by Intsafe_CanOffsetPointer().

◆ Intsafe_CanMulULong32()

static __inline BOOLEAN Intsafe_CanMulULong32 ( IN ULONG  Factor1,
IN ULONG  Factor2 
)
static

Definition at line 123 of file exeformat.h.

124 {
125  return Factor1 <= (MAXULONG / Factor2);
126 }
#define MAXULONG
Definition: typedefs.h:250

Referenced by PeFmtCreateSection().

◆ Intsafe_CanOffsetPointer()

static __inline BOOLEAN Intsafe_CanOffsetPointer ( IN CONST VOID Pointer,
IN SIZE_T  Offset 
)
static

Definition at line 128 of file exeformat.h.

129 {
130  /* FIXME: (PVOID)MAXULONG_PTR isn't necessarily a valid address */
131  return Intsafe_CanAddULongPtr((ULONG_PTR)Pointer, Offset);
132 }
static __inline BOOLEAN Intsafe_CanAddULongPtr(IN ULONG_PTR Addend1, IN ULONG_PTR Addend2)
Definition: exeformat.h:99
uint32_t ULONG_PTR
Definition: typedefs.h:63
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101

Referenced by PeFmtCreateSection().

◆ IsAligned()

static __inline BOOLEAN IsAligned ( IN ULONG  Address,
IN ULONG  Alignment 
)
static

Definition at line 147 of file exeformat.h.

148 {
149  return ModPow2(Address, Alignment) == 0;
150 }
static __inline ULONG ModPow2(IN ULONG Address, IN ULONG Alignment)
Definition: exeformat.h:141
static WCHAR Address[46]
Definition: ping.c:68

Referenced by PeFmtCreateSection().

◆ IsPowerOf2()

static __inline BOOLEAN IsPowerOf2 ( IN ULONG  Number)
static

Definition at line 134 of file exeformat.h.

135 {
136  if(Number == 0)
137  return FALSE;
138  return (Number & (Number - 1)) == 0;
139 }
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204

Referenced by ModPow2(), and PeFmtCreateSection().

◆ ModPow2()

static __inline ULONG ModPow2 ( IN ULONG  Address,
IN ULONG  Alignment 
)
static

Definition at line 141 of file exeformat.h.

142 {
144  return Address & (Alignment - 1);
145 }
static WCHAR Address[46]
Definition: ping.c:68
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static __inline BOOLEAN IsPowerOf2(IN ULONG Number)
Definition: exeformat.h:134

Referenced by AlignUp(), and IsAligned().