Web lists-archives.com

Re: [MPlayer-dev-eng] how to add lookup / add functions in loader/win32.c ?




On Sun, May 17, 2015 at 08:39:54AM +0200, Reimar Döffinger wrote:
> On Sat, May 16, 2015 at 06:27:16PM -0400, compn wrote:
> > Called unk_ATL90.DLL:15
> 
> I don't know how this works, but that entry is a 0 pointer
> in the original DLL.
> One problem is that we are missing support for pure ordinal
> exports without a name, patch below might fix it.
> Then something like
> {NULL, 15, 0}
> might do it (more consistent would be to use (void*)-1 for the last
> one, but that way of specifying undefined functions doesn't actually
> work for ordinal lookup - looks like a bug).

Or attached patch and use UNDEFORD(15)
commit 89ffedda6a5fa478fe2a3e9f8b772966dbbe2dd2
Author: Reimar Döffinger <Reimar.Doeffinger@xxxxxx>
Date:   Sun May 17 08:40:50 2015 +0200

    Support undefined (NULL) pure-ordinal-only exports.
    
    Add UNDEFORD macro for them.

diff --git a/loader/win32.c b/loader/win32.c
index 34a4b0c..bbd3fae 100644
--- a/loader/win32.c
+++ b/loader/win32.c
@@ -5177,6 +5177,9 @@ struct libs
 #define UNDEFF(X, Y) \
     {#X, Y, (void*)-1},
 
+#define UNDEFORD(Y) \
+    {NULL, Y, (void*)-1},
+
 static const struct exports exp_kernel32[]=
 {
     FF(GetVolumeInformationA,-1)
@@ -5751,6 +5754,8 @@ void* LookupExternal(const char* library, int ordinal)
 	    if(ordinal!=libraries[i].exps[j].id)
 		continue;
 	    //printf("Hit: 0x%p\n", libraries[i].exps[j].func);
+	    if((unsigned int)(libraries[i].exps[j].func) == -1)
+		return NULL; //undefined func
 	    return libraries[i].exps[j].func;
 	}
     }
@@ -5813,7 +5818,7 @@ void* LookupExternalByName(const char* library, const char* name)
 	    continue;
 	for(j=0; j<libraries[i].length; j++)
 	{
-	    if(strcmp(name, libraries[i].exps[j].name))
+	    if(libraries[i].exps[j].name && strcmp(name, libraries[i].exps[j].name))
 		continue;
  	    if((unsigned int)(libraries[i].exps[j].func) == -1)
 		return NULL; //undefined func
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng