• R/O
  • HTTP
  • SSH
  • HTTPS

pexports: Commit

Windows DLL exported symbols listing utility


Commit MetaInfo

Revisión466c07d586e9748095549cc11274444613e285fc (tree)
Tiempo2015-09-08 06:00:26
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Avoid uint32_t difference overflow in 64-bit pointer adjustment.

Cambiar Resumen

Diferencia

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
11 2015-09-07 Keith Marshall <keithmarshall@users.sourceforge.net>
22
3+ Avoid uint32_t difference overflow in 64-bit pointer adjustment.
4+
5+ * pexports.c (rva_to_ptr): Do not compute uint32_t offset differences;
6+ apply each offset adjustment individually to the base pointer.
7+
8+ * pexports.h: Add '#pragma ms_struct on', to keep structures aligned
9+ per MSVC convention.
10+
11+2015-09-07 Keith Marshall <keithmarshall@users.sourceforge.net>
12+
313 Eliminate Microsoft inspired obfuscated typedef insanity.
414
515 * pexports.c pexports.h (BYTE, WORD, DWORD): Delete typedefs;
--- a/pexports.c
+++ b/pexports.c
@@ -228,10 +228,10 @@ dump_exports(uint32_t exports_rva, uint32_t exports_size)
228228 exports = RVA_TO_PTR(exports_rva, IMAGE_EXPORT_DIRECTORY *);
229229
230230 /* set up various pointers */
231- export_name = RVA_TO_PTR(exports->Name,char*);
232- ordinal_table = RVA_TO_PTR(exports->AddressOfNameOrdinals, uint16_t *);
231+ export_name = RVA_TO_PTR(exports->Name, char *);
233232 name_table = RVA_TO_PTR(exports->AddressOfNames, uint32_t *);
234- function_table = RVA_TO_PTR(exports->AddressOfFunctions,void*);
233+ ordinal_table = RVA_TO_PTR(exports->AddressOfNameOrdinals, uint16_t *);
234+ function_table = RVA_TO_PTR(exports->AddressOfFunctions, void *);
235235
236236 if (verbose)
237237 {
@@ -344,10 +344,9 @@ void *
344344 rva_to_ptr(uint32_t rva)
345345 {
346346 IMAGE_SECTION_HEADER *section = find_section(rva);
347- if (section->PointerToRawData == 0)
348- return NULL;
349- else
350- return ((char *) dos_hdr + rva - (section->VirtualAddress - section->PointerToRawData));
347+ return (section->PointerToRawData != 0)
348+ ? (char *)(dos_hdr) + rva - section->VirtualAddress + section->PointerToRawData
349+ : NULL;
351350 }
352351
353352 /* Load a portable executable into memory */
--- a/pexports.h
+++ b/pexports.h
@@ -12,6 +12,8 @@
1212 #ifndef _pexports_h
1313 #define _pexports_h
1414
15+#pragma ms_struct on
16+
1517 #include <stdio.h>
1618 #include <stdint.h>
1719
Show on old repository browser