[MPlayer-cvslog] r21477 - trunk/loader/win32.c

reimar subversion at mplayerhq.hu
Sun Dec 3 20:49:39 CET 2006


Author: reimar
Date: Sun Dec  3 20:49:39 2006
New Revision: 21477

Modified:
   trunk/loader/win32.c

Log:
Fix 21381, make sure gcc does not make any ip-relative calls or similar.


Modified: trunk/loader/win32.c
==============================================================================
--- trunk/loader/win32.c	(original)
+++ trunk/loader/win32.c	Sun Dec  3 20:49:39 2006
@@ -5291,7 +5291,9 @@
 static void ext_stubs(void)
 {
     volatile int idx = 0xdeadabcd;
-    printf("Called unk_%s\n", export_names[idx]);
+    // make sure gcc does not do eip-relative call or something like that
+    volatile void (*my_printf)(char *, char *) = (void *)0xdeadfbcd;
+    my_printf("Called unk_%s\n", export_names[idx]);
 }
 
 #define MAX_STUB_SIZE 0x60
@@ -5302,6 +5304,7 @@
 static void* add_stub(void)
 {
     int i;
+    int found = 0;
     // generated code in runtime!
     char* answ = extcode + pos * MAX_STUB_SIZE;
     if (pos >= MAX_NUM_STUBS) {
@@ -5310,14 +5313,20 @@
     }
     memcpy(answ, ext_stubs, MAX_STUB_SIZE);
     for (i = 0; i < MAX_STUB_SIZE - 3; i++) {
-      if (*(int*)(answ + i) == 0xdeadabcd)
-        break;
+      int *magic = (int *)(answ + i);
+      if (*magic == 0xdeadabcd) {
+        *magic = pos;
+        found |= 1;
+      }
+      if (*magic == 0xdeadfbcd) {
+        *magic = (intptr_t)printf;
+        found |= 2;
+      }
     }
-    if (*(int*)(answ + i) != 0xdeadabcd) {
+    if (found != 3) {
       printf("magic code not found in ext_subs, expect crash\n");
       return NULL;
     }
-    *(int*)(answ + i) = pos;
     pos++;
     return (void*)answ;
 }



More information about the MPlayer-cvslog mailing list