• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Windows DLL exported symbols listing utility


Commit MetaInfo

修訂546df9f466918b0e8a05d945ecbfc51af0cfb9c4 (tree)
時間2013-05-28 21:15:07
作者Keith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Correct some obfuscated typedef portability issues.

Change Summary

差異

--- a/ChangeLog
+++ b/ChangeLog
@@ -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+
124 2011-09-14 Daniel Collins <solemnwarning@solemnwarning.net>
225
326 Avoid segmentation faults in forwarder function checks.
--- a/pexports.c
+++ b/pexports.c
@@ -1,7 +1,8 @@
11 #include <string.h>
22 #include <stdlib.h>
3-#include <errno.h>
3+#include <inttypes.h>
44 #include <sys/stat.h>
5+#include <errno.h>
56
67 #include "str_tree.h"
78 #include "pexports.h"
@@ -302,7 +303,7 @@ dump_symbol(char *name, int ord, DWORD rva)
302303 str_tree *symbol = str_tree_find(symbols, name);
303304 /* if a symbol was found, emit size of stack */
304305 if (symbol)
305- sprintf(s, "%s@%"INT_PTR_FORMAT, name, (INT_PTR) symbol->extra);
306+ sprintf(s, "%s@%"PRIdPTR, name, (intptr_t)(symbol->extra));
306307 else
307308 sprintf(s, "%s", name);
308309
--- a/pexports.h
+++ b/pexports.h
@@ -14,32 +14,26 @@
1414 #define _pexports_h
1515
1616 #include <stdio.h>
17+#include <stdint.h>
1718
1819 #include "str_tree.h"
1920
2021 #define VER_MAJOR 0
2122 #define VER_MINOR 44
2223
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;
2732 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;
3435 typedef int BOOL;
3536 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
4337
4438 #define FALSE 0
4539 #define TRUE 1
@@ -209,7 +203,7 @@ rva_to_ptr(DWORD rva);
209203 void
210204 dump_exports(DWORD exports_rva, DWORD exports_size);
211205
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))
213207 extern str_tree *symbols;
214208
215209 #endif /* _pexports_h */