about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-03 16:47:44 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-03 16:47:44 +0100
commit5fe45a93414b32883ed9d34e25272e764219b2d1 (patch)
tree346804b38249c11a6d3f0915d61185516cae3d29 /src
parentf4829a8ce42b1abbcc8621802d6c6fad3a56cd5d (diff)
downloadbox64-5fe45a93414b32883ed9d34e25272e764219b2d1.tar.gz
box64-5fe45a93414b32883ed9d34e25272e764219b2d1.zip
Add symbols from main elf to maplib
Diffstat (limited to 'src')
-rwxr-xr-xsrc/include/box64context.h2
-rwxr-xr-xsrc/main.c36
2 files changed, 27 insertions, 11 deletions
diff --git a/src/include/box64context.h b/src/include/box64context.h
index c9c25bf3..ed8cd118 100755
--- a/src/include/box64context.h
+++ b/src/include/box64context.h
@@ -62,7 +62,7 @@ typedef struct box64context_s {
 
     path_collection_t   box64_emulated_libs;    // Collection of libs that should not be wrapped
 
-    int                 x86trace;
+    int                 x64trace;
     int                 trace_tid;
 
     uint32_t            sel_serial;     // will be increment each time selectors changes
diff --git a/src/main.c b/src/main.c
index 7ed01e90..dd45c716 100755
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,8 @@
 #include "auxval.h"
 #include "x64emu.h"
 #include "threads.h"
+#include "x64trace.h"
+#include "librarian.h"
 
 box64context_t *my_context = NULL;
 int box64_log = LOG_NONE;
@@ -411,20 +413,19 @@ void LoadEnvVars(box64context_t *context)
     char* p = getenv("BOX64_TRACE");
     if(p) {
         if (strcmp(p, "0"))
-            context->x86trace = 1;
+            context->x64trace = 1;
     }
     p = getenv("BOX64_TRACE_INIT");
     if(p) {
         if (strcmp(p, "0"))
-            context->x86trace = 1;
+            context->x64trace = 1;
     }
-    if(my_context->x86trace) {
-        /*printf_log(LOG_INFO, "Initializing Zydis lib\n");
-        if(InitX86Trace(my_context)) {
+    if(my_context->x64trace) {
+        printf_log(LOG_INFO, "Initializing Zydis lib\n");
+        if(InitX64Trace(my_context)) {
             printf_log(LOG_INFO, "Zydis init failed, no x86 trace activated\n");
-            context->x86trace = 0;
-        }*/
-            context->x86trace = 0;  // not implemented yet
+            context->x64trace = 0;
+        }
     }
 #endif
 }
@@ -488,10 +489,10 @@ void setupTrace(box64context_t* context)
                 }
             }
         } else {
-            if (0/*GetGlobalSymbolStartEnd(my_context->maplib, p, &trace_start, &trace_end)*/) {
+            if (GetGlobalSymbolStartEnd(my_context->maplib, p, &trace_start, &trace_end)) {
                 SetTraceEmu(trace_start, trace_end);
                 printf_log(LOG_INFO, "TRACE on %s only (%p-%p)\n", p, (void*)trace_start, (void*)trace_end);
-            } else if(0/*GetLocalSymbolStartEnd(my_context->maplib, p, &trace_start, &trace_end, NULL)*/) {
+            } else if(GetLocalSymbolStartEnd(my_context->maplib, p, &trace_start, &trace_end, NULL)) {
                 SetTraceEmu(trace_start, trace_end);
                 printf_log(LOG_INFO, "TRACE on %s only (%p-%p)\n", p, (void*)trace_start, (void*)trace_end);
             } else {
@@ -833,6 +834,21 @@ int main(int argc, const char **argv, const char **env) {
     thread_set_emu(emu);
 
     setupTraceInit(my_context);
+    // export symbols
+    AddSymbols(my_context->maplib, GetMapSymbol(my_context->maplib), GetWeakSymbol(my_context->maplib), GetLocalSymbol(my_context->maplib), elf_header);
+    if(wine_preloaded) {
+        uintptr_t wineinfo = FindSymbol(GetMapSymbol(my_context->maplib), "wine_main_preload_info");
+        if(!wineinfo) wineinfo = FindSymbol(GetWeakSymbol(my_context->maplib), "wine_main_preload_info");
+        if(!wineinfo) wineinfo = FindSymbol(GetLocalSymbol(my_context->maplib), "wine_main_preload_info");
+        if(!wineinfo) {printf_log(LOG_NONE, "Warning, Symbol wine_main_preload_info not found\n");}
+        else {
+            *(void**)wineinfo = get_wine_prereserve();
+            printf_log(LOG_DEBUG, "WINE wine_main_preload_info found and updated\n");
+        }
+        #ifdef DYNAREC
+        dynarec_wine_prereserve();
+        #endif
+    }
 
     return 0;
 }