Alexandre Julliard : winedump: List exported functions sorted by ordinal.

Alexandre Julliard julliard at winehq.org
Tue Jan 6 08:23:20 CST 2009


Module: wine
Branch: master
Commit: d6617258b71e6041bcbe72f4221f89e8f5a97369
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d6617258b71e6041bcbe72f4221f89e8f5a97369

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jan  6 15:11:06 2009 +0100

winedump: List exported functions sorted by ordinal.

---

 tools/winedump/pe.c |   46 ++++++++++++++++++----------------------------
 1 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c
index 31a744e..2f6c46b 100644
--- a/tools/winedump/pe.c
+++ b/tools/winedump/pe.c
@@ -469,7 +469,7 @@ static	void	dump_dir_exported_functions(void)
     const DWORD*		pFunc;
     const DWORD*		pName;
     const WORD* 		pOrdl;
-    DWORD*		        map;
+    DWORD*		        funcs;
 
     if (!exportDir) return;
 
@@ -496,37 +496,27 @@ static	void	dump_dir_exported_functions(void)
     pOrdl = RVA(exportDir->AddressOfNameOrdinals, exportDir->NumberOfNames * sizeof(WORD));
     if (!pOrdl) {printf("Can't grab functions' ordinal table\n"); return;}
 
-    /* bit map of used funcs */
-    map = calloc(((exportDir->NumberOfFunctions + 31) & ~31) / 32, sizeof(DWORD));
-    if (!map) fatal("no memory");
+    funcs = calloc( exportDir->NumberOfFunctions, sizeof(*funcs) );
+    if (!funcs) fatal("no memory");
 
-    for (i = 0; i < exportDir->NumberOfNames; i++, pName++, pOrdl++)
-    {
-	map[*pOrdl / 32] |= 1 << (*pOrdl % 32);
+    for (i = 0; i < exportDir->NumberOfNames; i++) funcs[pOrdl[i]] = pName[i];
 
-        printf("  %08X  %4u %s", pFunc[*pOrdl], exportDir->Base + *pOrdl,
-               get_symbol_str((const char*)RVA(*pName, sizeof(DWORD))));
-        /* check for forwarded function */
-        if ((const char *)RVA(pFunc[*pOrdl],sizeof(void*)) >= (const char *)exportDir &&
-            (const char *)RVA(pFunc[*pOrdl],sizeof(void*)) < (const char *)exportDir + size)
-            printf( " (-> %s)", (const char *)RVA(pFunc[*pOrdl],1));
-        printf("\n");
-    }
-    pFunc = RVA(exportDir->AddressOfFunctions, exportDir->NumberOfFunctions * sizeof(DWORD));
-    if (!pFunc)
-    {
-        printf("Can't grab functions' address table\n");
-        free(map);
-        return;
-    }
     for (i = 0; i < exportDir->NumberOfFunctions; i++)
     {
-	if (pFunc[i] && !(map[i / 32] & (1 << (i % 32))))
-	{
-            printf("  %08X  %4u <by ordinal>\n", pFunc[i], exportDir->Base + i);
-	}
+        if (!pFunc[i]) continue;
+        printf("  %08X %5u ", pFunc[i], exportDir->Base + i);
+        if (funcs[i])
+        {
+            printf("%s", get_symbol_str((const char*)RVA(funcs[i], sizeof(DWORD))));
+            /* check for forwarded function */
+            if ((const char *)RVA(pFunc[i],1) >= (const char *)exportDir &&
+                (const char *)RVA(pFunc[i],1) < (const char *)exportDir + size)
+                printf(" (-> %s)", (const char *)RVA(pFunc[i],1));
+            printf("\n");
+        }
+        else printf("<by ordinal>\n");
     }
-    free(map);
+    free(funcs);
     printf("\n");
 }
 




More information about the wine-cvs mailing list