Windows DLL exported symbols listing utility
修订版 | 546df9f466918b0e8a05d945ecbfc51af0cfb9c4 (tree) |
---|---|
时间 | 2013-05-28 21:15:07 |
作者 | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Correct some obfuscated typedef portability issues.
@@ -1,3 +1,26 @@ | ||
1 | +2013-05-28 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Correct some obfuscated typedef portability issues. | |
4 | + | |
5 | + * pexports.c: Include inttypes.h; it permits use of... | |
6 | + (PRIdPTR): ...this ISO-C99 standard macro, in preference to... | |
7 | + (INT_PTR_FORMAT): ...this non-standard contrivance; similarly... | |
8 | + (intptr_t): ...substitute this ISO-C99 standard typedef... | |
9 | + (INT_PTR): ...for this non-standard type. | |
10 | + | |
11 | + * pexports.h: Include stdint.h; typedef... | |
12 | + (BYTE): ...this, as explicitly equivalent to uint8_t. | |
13 | + (WORD): ...this, as explicitly equivalent to uint16_t. | |
14 | + (DWORD): ...this, as explicitly equivalent to uint32_t. | |
15 | + (INT_PTR, INT_PTR_FORMAT): No longer required; delete them. | |
16 | + (ULONGLONG): Explicitly typedef as equivalent to uint64_t; although | |
17 | + 'unsigned long long' seems a better fit, our present usage requires | |
18 | + the explicit 64-bit association, and use of this standard type allows | |
19 | + us to eliminate all references to Microsoft's non-standard __int64. | |
20 | + (LONG): Explicitly typedef as equivalent to int32_t; technically, this | |
21 | + is incorrect, but misuse elsewhere requires the explicit 32-bit type, | |
22 | + which is not guaranteed by ISO-C99's standard 'long' type. | |
23 | + | |
1 | 24 | 2011-09-14 Daniel Collins <solemnwarning@solemnwarning.net> |
2 | 25 | |
3 | 26 | Avoid segmentation faults in forwarder function checks. |
@@ -1,7 +1,8 @@ | ||
1 | 1 | #include <string.h> |
2 | 2 | #include <stdlib.h> |
3 | -#include <errno.h> | |
3 | +#include <inttypes.h> | |
4 | 4 | #include <sys/stat.h> |
5 | +#include <errno.h> | |
5 | 6 | |
6 | 7 | #include "str_tree.h" |
7 | 8 | #include "pexports.h" |
@@ -302,7 +303,7 @@ dump_symbol(char *name, int ord, DWORD rva) | ||
302 | 303 | str_tree *symbol = str_tree_find(symbols, name); |
303 | 304 | /* if a symbol was found, emit size of stack */ |
304 | 305 | if (symbol) |
305 | - sprintf(s, "%s@%"INT_PTR_FORMAT, name, (INT_PTR) symbol->extra); | |
306 | + sprintf(s, "%s@%"PRIdPTR, name, (intptr_t)(symbol->extra)); | |
306 | 307 | else |
307 | 308 | sprintf(s, "%s", name); |
308 | 309 |
@@ -14,32 +14,26 @@ | ||
14 | 14 | #define _pexports_h |
15 | 15 | |
16 | 16 | #include <stdio.h> |
17 | +#include <stdint.h> | |
17 | 18 | |
18 | 19 | #include "str_tree.h" |
19 | 20 | |
20 | 21 | #define VER_MAJOR 0 |
21 | 22 | #define VER_MINOR 44 |
22 | 23 | |
23 | -/* These are needed */ | |
24 | -typedef unsigned short WORD; | |
25 | -typedef unsigned int DWORD; | |
26 | -typedef unsigned char BYTE; | |
24 | +/* These are needed: | |
25 | + * FIXME: However, I'd really much prefer to see ISO-C99 standard | |
26 | + * types used throughout, in preference to these Micrsoft-inspired | |
27 | + * obfuscated typedefs. | |
28 | + */ | |
29 | +typedef uint8_t BYTE; | |
30 | +typedef uint16_t WORD; | |
31 | +typedef uint32_t DWORD; | |
27 | 32 | typedef void* PVOID; |
28 | -typedef long LONG; | |
29 | -#if defined(__MINGW32__) || defined(_MSC_VER) | |
30 | -typedef unsigned __int64 ULONGLONG; | |
31 | -#else | |
32 | -typedef unsigned long long ULONGLONG; | |
33 | -#endif | |
33 | +typedef int32_t LONG; | |
34 | +typedef uint64_t ULONGLONG; | |
34 | 35 | typedef int BOOL; |
35 | 36 | typedef void* HMODULE; |
36 | -#ifdef _WIN64 | |
37 | -typedef __int64 INT_PTR; | |
38 | -#define INT_PTR_FORMAT "I64d" | |
39 | -#else | |
40 | -typedef int INT_PTR; | |
41 | -#define INT_PTR_FORMAT "d" | |
42 | -#endif | |
43 | 37 | |
44 | 38 | #define FALSE 0 |
45 | 39 | #define TRUE 1 |
@@ -209,7 +203,7 @@ rva_to_ptr(DWORD rva); | ||
209 | 203 | void |
210 | 204 | dump_exports(DWORD exports_rva, DWORD exports_size); |
211 | 205 | |
212 | -#define ADD_FUNCTION(nm,n) str_tree_add(&symbols, nm, (void*)(INT_PTR)n) | |
206 | +#define ADD_FUNCTION(nm,n) str_tree_add(&symbols, nm, (void*)(intptr_t)(n)) | |
213 | 207 | extern str_tree *symbols; |
214 | 208 | |
215 | 209 | #endif /* _pexports_h */ |