pefile.c revision 0fa2cac4f0cdefaf1addd7f1fe0fd8113db9360b
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/*
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program 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
* Lesser General Public License for more details.
*
* Copyright (C) 2015 Kay Sievers <kay@vrfy.org>
*/
#include <efi.h>
#include <efilib.h>
#include "util.h"
#include "pefile.h"
struct DosFileHeader {
} __attribute__((packed));
#define PE_HEADER_MACHINE_I386 0x014c
#define PE_HEADER_MACHINE_X64 0x8664
struct PeFileHeader {
} __attribute__((packed));
struct PeSectionHeader {
} __attribute__((packed));
EFI_STATUS pefile_locate_sections(EFI_FILE *dir, CHAR16 *path, CHAR8 **sections, UINTN *addrs, UINTN *offsets, UINTN *sizes) {
struct DosFileHeader dos;
struct PeFileHeader pe;
UINTN i;
return err;
/* MS-DOS stub */
goto out;
goto out;
}
goto out;
}
goto out;
/* PE header */
goto out;
goto out;
}
goto out;
}
goto out;
goto out;
}
/* PE32+ Subsystem type */
goto out;
}
goto out;
}
/* the sections start directly after the headers */
err = uefi_call_wrapper(handle->SetPosition, 2, handle, dos.ExeHeader + sizeof(magic) + sizeof(pe) + pe.SizeOfOptionalHeader);
goto out;
for (i = 0; i < pe.NumberOfSections; i++) {
struct PeSectionHeader sect;
UINTN j;
goto out;
goto out;
}
for (j = 0; sections[j]; j++) {
continue;
if (addrs)
if (offsets)
if (sizes)
}
}
out:
return err;
}