Advertisement
fernandop

libpe_example

Dec 2nd, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. $ cat example.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #include "pe.h"
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.         pe_ctx_t ctx;
  10.  
  11.         pe_err_e err = pe_load_file(&ctx, argv[argc-1]);
  12.         if (err != LIBPE_E_OK) {
  13.                 pe_error_print(stderr, err);
  14.                 return EXIT_FAILURE;
  15.         }
  16.  
  17.         err = pe_parse(&ctx);
  18.         if (err != LIBPE_E_OK) {
  19.                 pe_error_print(stderr, err);
  20.                 return EXIT_FAILURE;
  21.         }
  22.  
  23.         if (!pe_is_pe(&ctx))
  24.                 return EXIT_FAILURE;
  25.  
  26.         IMAGE_COFF_HEADER *coff = pe_coff(&ctx);
  27.             printf("Machine: %x\n", coff->Machine);
  28.  
  29.         return 0;
  30. }
  31.  
  32.  
  33.  
  34.  
  35. $ gcc -o example example.c -L. -lpe
  36.  
  37. $ ./example ~/winapp/wrar530.exe
  38. Machine: 14c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement