vaseboot/include/VasEBoot/machoload.h

89 lines
3.3 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_MACHOLOAD_HEADER
#define VasEBoot_MACHOLOAD_HEADER 1
#include <VasEBoot/err.h>
#include <VasEBoot/elf.h>
#include <VasEBoot/file.h>
#include <VasEBoot/symbol.h>
#include <VasEBoot/types.h>
struct VasEBoot_macho_file
{
VasEBoot_file_t file;
VasEBoot_ssize_t offset32;
VasEBoot_ssize_t end32;
int ncmds32;
VasEBoot_size_t cmdsize32;
VasEBoot_uint8_t *cmds32;
VasEBoot_uint8_t *uncompressed32;
int compressed32;
VasEBoot_size_t compressed_size32;
VasEBoot_size_t uncompressed_size32;
VasEBoot_ssize_t offset64;
VasEBoot_ssize_t end64;
int ncmds64;
VasEBoot_size_t cmdsize64;
VasEBoot_uint8_t *cmds64;
VasEBoot_uint8_t *uncompressed64;
int compressed64;
VasEBoot_size_t compressed_size64;
VasEBoot_size_t uncompressed_size64;
};
typedef struct VasEBoot_macho_file *VasEBoot_macho_t;
VasEBoot_macho_t VasEBoot_macho_open (const char *, int is_64bit);
VasEBoot_macho_t VasEBoot_macho_file (VasEBoot_file_t file, const char *filename,
int is_64bit);
VasEBoot_err_t VasEBoot_macho_close (VasEBoot_macho_t);
VasEBoot_err_t VasEBoot_macho_size32 (VasEBoot_macho_t macho, VasEBoot_uint32_t *segments_start,
VasEBoot_uint32_t *segments_end, int flags,
const char *filename);
VasEBoot_uint32_t VasEBoot_macho_get_entry_point32 (VasEBoot_macho_t macho,
const char *filename);
VasEBoot_err_t VasEBoot_macho_size64 (VasEBoot_macho_t macho, VasEBoot_uint64_t *segments_start,
VasEBoot_uint64_t *segments_end, int flags,
const char *filename);
VasEBoot_uint64_t VasEBoot_macho_get_entry_point64 (VasEBoot_macho_t macho,
const char *filename);
/* Ignore BSS segments when loading. */
#define VasEBoot_MACHO_NOBSS 0x1
VasEBoot_err_t VasEBoot_macho_load32 (VasEBoot_macho_t macho, const char *filename,
char *offset, int flags, int *darwin_version);
VasEBoot_err_t VasEBoot_macho_load64 (VasEBoot_macho_t macho, const char *filename,
char *offset, int flags, int *darwin_version);
/* Like filesize and file_read but take only 32-bit part
for current architecture. */
VasEBoot_size_t VasEBoot_macho_filesize32 (VasEBoot_macho_t macho);
VasEBoot_err_t VasEBoot_macho_readfile32 (VasEBoot_macho_t macho, const char *filename,
void *dest);
VasEBoot_size_t VasEBoot_macho_filesize64 (VasEBoot_macho_t macho);
VasEBoot_err_t VasEBoot_macho_readfile64 (VasEBoot_macho_t macho, const char *filename,
void *dest);
void VasEBoot_macho_parse32 (VasEBoot_macho_t macho, const char *filename);
void VasEBoot_macho_parse64 (VasEBoot_macho_t macho, const char *filename);
#endif /* ! VasEBoot_MACHOLOAD_HEADER */