Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeajames authored Mar 19, 2020
1 parent 2a70947 commit 5834659
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions patchfinder64.m
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ static int DecodeMov(uint32_t opcode, uint64_t total, int first, uint64_t *newva
static void *Kernel_mh = 0;
static addr_t Kernel_delta = 0;

static uint32_t magic = 0;

int
InitPatchfinder(addr_t base, const char *filename)
{
Expand All @@ -520,8 +522,7 @@ static int DecodeMov(uint32_t opcode, uint64_t total, int first, uint64_t *newva
if (fd < 0) {
return -1;
}

uint32_t magic = 0;

read(fd, &magic, 4);
if (magic == 0xbebafeca) {
lseek(fd, 28, SEEK_SET); // kerneldec gives a FAT binary for some reason
Expand Down Expand Up @@ -665,6 +666,8 @@ static int DecodeMov(uint32_t opcode, uint64_t total, int first, uint64_t *newva
q = q + cmd->cmdsize;
}

if (magic == 0xbebafeca) Kernel += 28;

close(fd);

(void)base;
Expand All @@ -674,6 +677,7 @@ static int DecodeMov(uint32_t opcode, uint64_t total, int first, uint64_t *newva
void
TermPatchfinder(void)
{
if (magic == 0xbebafeca) Kernel -= 28;
free(Kernel);
}

Expand Down

0 comments on commit 5834659

Please sign in to comment.