Skip to content

Commit

Permalink
Add indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
GoGoOtaku committed Oct 18, 2023
1 parent 83861a4 commit eb394b6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions lib/libpe/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,24 @@ pe_err_e pe_unload(pe_ctx_t *ctx) {
pe_err_e pe_parse(pe_ctx_t *ctx) {
ctx->pe.dos_hdr = ctx->map_addr;
if (ctx->pe.dos_hdr->e_magic == MAGIC_MZ) {

const uint32_t *signature_ptr = LIBPE_PTR_ADD(ctx->pe.dos_hdr,
ctx->pe.dos_hdr->e_lfanew);
if (!pe_can_read(ctx, signature_ptr, LIBPE_SIZEOF_MEMBER(pe_file_t, signature)))
return LIBPE_E_INVALID_LFANEW;

// NT signature (PE\0\0)
ctx->pe.signature = *signature_ptr;

switch (ctx->pe.signature) {
default:
//fprintf(stderr, "Invalid signature: %x\n", ctx->pe.signature);
return LIBPE_E_INVALID_SIGNATURE;
case SIGNATURE_PE:
break;
}

ctx->pe.coff_hdr = LIBPE_PTR_ADD(signature_ptr,
LIBPE_SIZEOF_MEMBER(pe_file_t, signature));
const uint32_t *signature_ptr = LIBPE_PTR_ADD(ctx->pe.dos_hdr,
ctx->pe.dos_hdr->e_lfanew);
if (!pe_can_read(ctx, signature_ptr, LIBPE_SIZEOF_MEMBER(pe_file_t, signature)))
return LIBPE_E_INVALID_LFANEW;

// NT signature (PE\0\0)
ctx->pe.signature = *signature_ptr;

switch (ctx->pe.signature) {
default:
//fprintf(stderr, "Invalid signature: %x\n", ctx->pe.signature);
return LIBPE_E_INVALID_SIGNATURE;
case SIGNATURE_PE:
break;
}

ctx->pe.coff_hdr = LIBPE_PTR_ADD(signature_ptr,
LIBPE_SIZEOF_MEMBER(pe_file_t, signature));

} else if (pe_machine_type_name(ctx->pe.dos_hdr->e_magic) != NULL) {
ctx->pe.coff_hdr = (void *)ctx->pe.dos_hdr;
Expand Down

0 comments on commit eb394b6

Please sign in to comment.