OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcMachoLibInternal.h File Reference

Go to the source code of this file.

Macros

#define SYM_MAX_NAME_LEN   256U
 

Functions

BOOLEAN InternalRetrieveSymtabs (IN OUT OC_MACHO_CONTEXT *Context)
 
MACH_RELOCATION_INFOInternalGetExternRelocationByOffset (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address)
 
MACH_RELOCATION_INFOInternalGetLocalRelocationByOffset (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address)
 
BOOLEAN InternalSymbolIsSane32 (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST *Symbol)
 
BOOLEAN InternalSymbolIsSane64 (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_64 *Symbol)
 
BOOLEAN InternalMachoSymbolGetDirectFileOffset32 (IN OUT OC_MACHO_CONTEXT *Context, IN UINT32 Address, OUT UINT32 *FileOffset, OUT UINT32 *MaxSize OPTIONAL)
 
BOOLEAN InternalMachoSymbolGetDirectFileOffset64 (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address, OUT UINT32 *FileOffset, OUT UINT32 *MaxSize OPTIONAL)
 
UINT32 InternalMachoGetVmSize32 (IN OUT OC_MACHO_CONTEXT *Context)
 
UINT32 InternalMachoGetVmSize64 (IN OUT OC_MACHO_CONTEXT *Context)
 
UINT32 InternalMachoGetLastAddress32 (IN OUT OC_MACHO_CONTEXT *Context)
 
UINT64 InternalMachoGetLastAddress64 (IN OUT OC_MACHO_CONTEXT *Context)
 
MACH_LOAD_COMMANDInternalMachoGetNextCommand32 (IN OUT OC_MACHO_CONTEXT *Context, IN MACH_LOAD_COMMAND_TYPE LoadCommandType, IN CONST MACH_LOAD_COMMAND *LoadCommand OPTIONAL)
 
MACH_LOAD_COMMANDInternalMachoGetNextCommand64 (IN OUT OC_MACHO_CONTEXT *Context, IN MACH_LOAD_COMMAND_TYPE LoadCommandType, IN CONST MACH_LOAD_COMMAND *LoadCommand OPTIONAL)
 
VOID * InternalMachoGetFilePointerByAddress32 (IN OUT OC_MACHO_CONTEXT *Context, IN UINT32 Address, OUT UINT32 *MaxSize OPTIONAL)
 
VOID * InternalMachoGetFilePointerByAddress64 (IN OUT OC_MACHO_CONTEXT *Context, IN UINT64 Address, OUT UINT32 *MaxSize OPTIONAL)
 
UINT32 InternalMachoExpandImage32 (IN OC_MACHO_CONTEXT *Context, IN BOOLEAN CalculateSizeOnly, OUT UINT8 *Destination, IN UINT32 DestinationSize, IN BOOLEAN Strip, OUT UINT64 *FileOffset OPTIONAL)
 
UINT32 InternalMachoExpandImage64 (IN OC_MACHO_CONTEXT *Context, IN BOOLEAN CalculateSizeOnly, OUT UINT8 *Destination, IN UINT32 DestinationSize, IN BOOLEAN Strip, OUT UINT64 *FileOffset OPTIONAL)
 
BOOLEAN InternalMachoMergeSegments32 (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *Prefix)
 
BOOLEAN InternalMachoMergeSegments64 (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *Prefix)
 

Macro Definition Documentation

◆ SYM_MAX_NAME_LEN

#define SYM_MAX_NAME_LEN   256U

Private data of OcMachoLib.

Copyright (C) 2018, Download-Fritz. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition at line 22 of file OcMachoLibInternal.h.

Function Documentation

◆ InternalGetExternRelocationByOffset()

MACH_RELOCATION_INFO * InternalGetExternRelocationByOffset ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address )

Retrieves an extern Relocation by the address it targets.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressThe address to search for.
Return values
NULLNULL is returned on failure.

Definition at line 211 of file Relocations.c.

◆ InternalGetLocalRelocationByOffset()

MACH_RELOCATION_INFO * InternalGetLocalRelocationByOffset ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address )

Retrieves a Relocation by the address it targets.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressThe address to search for.
Return values
NULLNULL is returned on failure.

Retrieves an extern Relocation by the address it targets.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressThe address to search for.
Return values
NULLNULL is returned on failure.

Definition at line 244 of file Relocations.c.

◆ InternalMachoExpandImage32()

UINT32 InternalMachoExpandImage32 ( IN OC_MACHO_CONTEXT * Context,
IN BOOLEAN CalculateSizeOnly,
OUT UINT8 * Destination,
IN UINT32 DestinationSize,
IN BOOLEAN Strip,
OUT UINT64 *FileOffset OPTIONAL )

Expand 32-bit Mach-O image to Destination (make segment file sizes equal to vm sizes).

Parameters
[in]ContextContext of the Mach-O.
[in]CalculateSizeOnlyTRUE to only calcuate a size and not actually expand the image.
[out]DestinationOutput buffer.
[in]DestinationSizeOutput buffer maximum size.
[in]StripOutput with stripped prelink commands.
[in]FileOffsetPointer to the file offset of the first segment.
Returns
New image size or 0 on failure.

◆ InternalMachoExpandImage64()

UINT32 InternalMachoExpandImage64 ( IN OC_MACHO_CONTEXT * Context,
IN BOOLEAN CalculateSizeOnly,
OUT UINT8 * Destination,
IN UINT32 DestinationSize,
IN BOOLEAN Strip,
OUT UINT64 *FileOffset OPTIONAL )

Expand 64-bit Mach-O image to Destination (make segment file sizes equal to vm sizes).

Parameters
[in]ContextContext of the Mach-O.
[in]CalculateSizeOnlyTRUE to only calcuate a size and not actually expand the image.
[out]DestinationOutput buffer.
[in]DestinationSizeOutput buffer maximum size.
[in]StripOutput with stripped prelink commands.
[in]FileOffsetPointer to the file offset of the first segment.
Returns
New image size or 0 on failure.

◆ InternalMachoGetFilePointerByAddress32()

VOID * InternalMachoGetFilePointerByAddress32 ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT32 Address,
OUT UINT32 *MaxSize OPTIONAL )

Returns a pointer to the 32-bit Mach-O file at the specified virtual address.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressVirtual address to look up.
[out]MaxSizeMaximum data safely available from FileOffset. If NULL is returned, the output is undefined.

◆ InternalMachoGetFilePointerByAddress64()

VOID * InternalMachoGetFilePointerByAddress64 ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address,
OUT UINT32 *MaxSize OPTIONAL )

Returns a pointer to the 64-bit Mach-O file at the specified virtual address.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressVirtual address to look up.
[out]MaxSizeMaximum data safely available from FileOffset. If NULL is returned, the output is undefined.

◆ InternalMachoGetLastAddress32()

UINT32 InternalMachoGetLastAddress32 ( IN OUT OC_MACHO_CONTEXT * Context)

Returns the last virtual address of a 32-bit Mach-O.

Parameters
[in]ContextContext of the Mach-O.
Return values
0The binary is malformed.

◆ InternalMachoGetLastAddress64()

UINT64 InternalMachoGetLastAddress64 ( IN OUT OC_MACHO_CONTEXT * Context)

Returns the last virtual address of a 64-bit Mach-O.

Parameters
[in]ContextContext of the Mach-O.
Return values
0The binary is malformed.

◆ InternalMachoGetNextCommand32()

MACH_LOAD_COMMAND * InternalMachoGetNextCommand32 ( IN OUT OC_MACHO_CONTEXT * Context,
IN MACH_LOAD_COMMAND_TYPE LoadCommandType,
IN CONST MACH_LOAD_COMMAND *LoadCommand OPTIONAL )

Retrieves the next 32-bit Load Command of type LoadCommandType.

Parameters
[in,out]ContextContext of the Mach-O.
[in]LoadCommandTypeType of the Load Command to retrieve.
[in]LoadCommandPrevious Load Command. If NULL, the first match is returned.
Return values
NULLNULL is returned on failure.

◆ InternalMachoGetNextCommand64()

MACH_LOAD_COMMAND * InternalMachoGetNextCommand64 ( IN OUT OC_MACHO_CONTEXT * Context,
IN MACH_LOAD_COMMAND_TYPE LoadCommandType,
IN CONST MACH_LOAD_COMMAND *LoadCommand OPTIONAL )

Retrieves the next 64-bit Load Command of type LoadCommandType.

Parameters
[in,out]ContextContext of the Mach-O.
[in]LoadCommandTypeType of the Load Command to retrieve.
[in]LoadCommandPrevious Load Command. If NULL, the first match is returned.
Return values
NULLNULL is returned on failure.

◆ InternalMachoGetVmSize32()

UINT32 InternalMachoGetVmSize32 ( IN OUT OC_MACHO_CONTEXT * Context)

Returns the 32-bit Mach-O's virtual address space size.

Parameters
[out]ContextContext of the Mach-O.

◆ InternalMachoGetVmSize64()

UINT32 InternalMachoGetVmSize64 ( IN OUT OC_MACHO_CONTEXT * Context)

Returns the 64-bit Mach-O's virtual address space size.

Parameters
[out]ContextContext of the Mach-O.

◆ InternalMachoMergeSegments32()

BOOLEAN InternalMachoMergeSegments32 ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * Prefix )

Merge 32-bit Mach-O segments into one with lowest protection.

Parameters
[in,out]ContextContext of the Mach-O.
[in]PrefixSegment prefix to merge.
Return values
TRUEon success

◆ InternalMachoMergeSegments64()

BOOLEAN InternalMachoMergeSegments64 ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * Prefix )

Merge 64-bit Mach-O segments into one with lowest protection.

Parameters
[in,out]ContextContext of the Mach-O.
[in]PrefixSegment prefix to merge.
Return values
TRUEon success

◆ InternalMachoSymbolGetDirectFileOffset32()

BOOLEAN InternalMachoSymbolGetDirectFileOffset32 ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT32 Address,
OUT UINT32 * FileOffset,
OUT UINT32 *MaxSize OPTIONAL )

Retrieves the Mach-O file offset of the address pointed to by a 32-bit Symbol.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressVirtual address to retrieve the offset of.
[out]FileOffsetPointer the file offset is returned into. If FALSE is returned, the output is undefined.
[out]MaxSizeMaximum data safely available from FileOffset.
Return values
00 is returned on failure.

◆ InternalMachoSymbolGetDirectFileOffset64()

BOOLEAN InternalMachoSymbolGetDirectFileOffset64 ( IN OUT OC_MACHO_CONTEXT * Context,
IN UINT64 Address,
OUT UINT32 * FileOffset,
OUT UINT32 *MaxSize OPTIONAL )

Retrieves the Mach-O file offset of the address pointed to by a 64-bit Symbol.

Parameters
[in,out]ContextContext of the Mach-O.
[in]AddressVirtual address to retrieve the offset of.
[out]FileOffsetPointer the file offset is returned into. If FALSE is returned, the output is undefined.
[out]MaxSizeMaximum data safely available from FileOffset.
Return values
00 is returned on failure.

◆ InternalRetrieveSymtabs()

BOOLEAN InternalRetrieveSymtabs ( IN OUT OC_MACHO_CONTEXT * Context)

Retrieves the SYMTAB command.

Parameters
[in]ContextContext of the Mach-O.
Return values
NULLNULL is returned on failure.

Definition at line 508 of file Header.c.

◆ InternalSymbolIsSane32()

BOOLEAN InternalSymbolIsSane32 ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST * Symbol )

Check 32-bit symbol validity.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol from some table.
Return values
TRUEon success.

◆ InternalSymbolIsSane64()

BOOLEAN InternalSymbolIsSane64 ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_64 * Symbol )

Check 64-bit symbol validity.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolSymbol from some table.
Return values
TRUEon success.