27 Commits

Author SHA1 Message Date
Jozef Kolek
9f74016e0d Perform endian swap as needed 2017-04-12 00:24:03 +02:00
Jozef Kolek
aca0344abb Fixed some memory leaks 2017-04-06 20:47:23 +02:00
Jozef Kolek
cb2fd5736f Added clang-format spec - issue #35 2017-03-31 17:01:20 +02:00
Jozef Kolek
1183047cbb Changes made according to clang-tidy review.
* NULL is replaced by nullptr
* Added parameter std::nothrow to operator new so in case of
  failure it returns nullptr instead of throwing exception
  std::bad_alloc. This is important due to check that follows
  the statement. Example:
  parsed_pe *p = new(std::nothrow) parsed_pe();
  if (p == nullptr) {
    ...
  }
* Using range-based for loops.
* Removed redundant boolean literals.
  Example: if (readWord(...) == false) => if (!readWord(...))
* Resolved implicit casts.
  Example: if (!ch) => if (ch == 0u)
* Created functions getImports, getExports, getRelocations from
  parts of ParsePEFromFile to make it smaller and more readable.
* Using reinterpret_cast instead of C-style cast to convert
  between unrelated types.
* Added braces around statements to improve readability.
2017-03-31 00:21:20 +02:00
Jozef Kolek
dcc79b5237 Fix UNIX/Windows build issue 2017-03-22 22:54:56 +01:00
Jozef Kolek
326ca41bc6 Symbol table parsing 2017-03-16 22:18:08 +01:00
hobo-ru
0ddd2f6684 Fix AppleCLang build issue(s) 2017-03-11 23:10:33 +03:00
hobo-ru
1a5455e06b Get rid of boost integer types 2017-03-09 19:10:17 +03:00
artemdinaburg
a8ccfb9df3 Put all of peparse in the peparse namespace. (#26)
* Put all of peparse in the peparse namespace.
* Fixes dupicate symbol problems when using the library inside other applications, namely Python
* Closes #25
2017-03-03 14:41:14 -05:00
Arbiv
6b8aae18e0 Added share for read, write and delete
Opening the file with share enables other processes to use this file while the pe-parse object is still open
2015-05-07 13:27:20 +03:00
Wesley Shields
77b72f3cc9 Implement PE32+ and error reporting.
Teach the parser to properly handle PE32+ binaries.

The major differences are:
  - Fields in the OptionalHeader which are not relative are now 64 bits.
  - Base addresses should all be 64 bits.
  - The BaseOfData field is not available on PE32+

There is now a 16 bit field tacked on to the end of nt_header_32 called
OptionalMagic. This is a duplicate of the Magic field in optional_header_32
and optional_header_64, but is stored in nt_header_32 to make it easier
to determine which optional header is being used.

I also added support for better error reporting. Now when something fails
to parse you can use a couple of functions to find out what happened and
where it happened:
  - GetPEErr(): Return the error as an integer.
  - GetPEErrString(): Return the error as a string.
  - GetPEErrLoc(): Return the function and line number of the error.

Made some changes to pepy to account for these changes. The interface
into pepy is identical. Only externally visible changes are that
pepy.parse() will now return the error string and location when parsing
fails and the baseofdata attribute will throw an exception if the binary
is PE32+.

to_string.h is now included from parse.h, so remove it from dump.cpp.

While here do a bunch of cleanups to make printing consistent. Use '0x'
where appropriate and ensure exceptions are punctuated correctly.
2014-03-07 13:18:24 -05:00
munin
5531d3a249 . 2013-11-11 15:09:57 -05:00
munin
42cf2a4bb0 . 2013-08-05 11:53:47 -04:00
munin
a67651d1f8 . 2013-07-31 14:10:16 -04:00
munin
89d2752a87 . 2013-07-31 14:05:17 -04:00
munin
10bdaac799 now uses mmap instead of malloc 2013-07-31 14:04:56 -04:00
munin
0743e42ef3 compile on linux 2013-07-31 10:39:15 -04:00
Andrew
fe7c433a65 note to self 2013-07-26 13:23:13 -04:00
Andrew
feb1d3391a parsing sections 2013-07-26 13:13:24 -04:00
Andrew
1a3b1f2ccb license time 2013-07-25 18:59:25 -04:00
Andrew
91118152c2 . 2013-07-25 17:10:26 -04:00
Andrew
faf770c598 . 2013-07-25 16:52:03 -04:00
Andrew
166dd4e8df . 2013-07-24 19:15:53 -04:00
Andrew
4a2eb58e82 . 2013-07-24 18:52:38 -04:00
Andrew
25f62aed6c . 2013-07-24 18:43:02 -04:00
Andrew
20aee7ccb9 . 2013-07-24 18:32:56 -04:00
Andrew
50ff629e28 . 2013-07-24 17:57:58 -04:00