Windows DLL exported symbols listing utility
Revisión | 466c07d586e9748095549cc11274444613e285fc (tree) |
---|---|
Tiempo | 2015-09-08 06:00:26 |
Autor | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Avoid uint32_t difference overflow in 64-bit pointer adjustment.
@@ -1,5 +1,15 @@ | ||
1 | 1 | 2015-09-07 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 2 | |
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 | + | |
3 | 13 | Eliminate Microsoft inspired obfuscated typedef insanity. |
4 | 14 | |
5 | 15 | * pexports.c pexports.h (BYTE, WORD, DWORD): Delete typedefs; |
@@ -228,10 +228,10 @@ dump_exports(uint32_t exports_rva, uint32_t exports_size) | ||
228 | 228 | exports = RVA_TO_PTR(exports_rva, IMAGE_EXPORT_DIRECTORY *); |
229 | 229 | |
230 | 230 | /* 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 *); | |
233 | 232 | 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 *); | |
235 | 235 | |
236 | 236 | if (verbose) |
237 | 237 | { |
@@ -344,10 +344,9 @@ void * | ||
344 | 344 | rva_to_ptr(uint32_t rva) |
345 | 345 | { |
346 | 346 | 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; | |
351 | 350 | } |
352 | 351 | |
353 | 352 | /* Load a portable executable into memory */ |
@@ -12,6 +12,8 @@ | ||
12 | 12 | #ifndef _pexports_h |
13 | 13 | #define _pexports_h |
14 | 14 | |
15 | +#pragma ms_struct on | |
16 | + | |
15 | 17 | #include <stdio.h> |
16 | 18 | #include <stdint.h> |
17 | 19 |