AcessNative - Fixing errors caused by API changes
[tpg/acess2.git] / AcessNative / ld-acess_src / binary.c
index 6439fb9..08ae6e9 100644 (file)
@@ -6,7 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#define LIBRARY_PATH   "$$$$../Usermode/Output/i386/Libs"
+#define LIBRARY_PATH   "$$$$../Usermode/Output/x86/Libs"
 
 // === TYPES ===
 typedef struct sBinary {
@@ -19,8 +19,8 @@ typedef struct sBinary {
 
 // === IMPORTS ===
 extern void    *Elf_Load(int fd);
-extern uintptr_t       Elf_Relocate(void *Base);
-extern int     Elf_GetSymbol(void *Base, char *Name, uintptr_t *ret);
+extern uintptr_t       ElfRelocate(void *Base);
+extern int     ElfGetSymbol(void *Base, char *Name, uintptr_t *ret, size_t *size);
 extern int     ciNumBuiltinSymbols;
 extern tSym    caBuiltinSymbols[];
 
@@ -33,8 +33,8 @@ tBinFmt       gElf_FormatDef = {
 //     .Magic = "\x7F""ELF",
        .Name = "ELF32",
        .Load = Elf_Load,
-       .Relocate = Elf_Relocate,
-       .GetSymbol = Elf_GetSymbol
+       .Relocate = ElfRelocate,
+       .GetSymbol = ElfGetSymbol
        };
 tBinary        *gLoadedBinaries;
 
@@ -96,7 +96,7 @@ void *Binary_LoadLibrary(const char *Name)
 {
        char    *path;
        void    *ret;
-        int    (*entry)(int,char*[],char**) = NULL;
+        int    (*entry)(void *,int,char*[],char**) = NULL;
 
        // Find File
        path = Binary_LocateLibrary(Name);
@@ -108,6 +108,7 @@ void *Binary_LoadLibrary(const char *Name)
        }
 
        ret = Binary_Load(path, (uintptr_t*)&entry);
+       printf("LOADED '%s' to %p (Entry=%p)\n", path, ret, entry);
        free(path);
        
        #if DEBUG
@@ -118,7 +119,7 @@ void *Binary_LoadLibrary(const char *Name)
                #if DEBUG
                printf("Calling '%s' entry point %p\n", Name, entry);
                #endif
-               entry(0, argv, NULL);
+               entry(ret, 0, argv, NULL);
        }
 
        return ret;
@@ -155,7 +156,7 @@ void *Binary_Load(const char *Filename, uintptr_t *EntryPoint)
                return NULL;
        }
 
-       acess_read(fd, 4, &dword);
+       acess_read(fd, &dword, 4);
        acess_seek(fd, 0, ACESS_SEEK_SET);
        
        if( memcmp(&dword, "\x7F""ELF", 4) == 0 ) {
@@ -220,7 +221,7 @@ void Binary_SetReadyToUse(void *Base)
        }
 }
 
-int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value)
+int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size)
 {
         int    i;
        tBinary *bin;
@@ -235,6 +236,7 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value)
        {
                if( strcmp(caBuiltinSymbols[i].Name, SymbolName) == 0 ) {
                        *Value = (uintptr_t)caBuiltinSymbols[i].Value;
+                       if(Size)        *Size = 0;
                        return 1;
                }
        }
@@ -244,7 +246,7 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value)
        {
                if( !bin->Ready )       continue;
                //printf(" Binary_GetSymbol: bin = %p{%p, %s}\n", bin, bin->Base, bin->Path);
-               if( bin->Format->GetSymbol(bin->Base, (char*)SymbolName, Value) )
+               if( bin->Format->GetSymbol(bin->Base, (char*)SymbolName, Value, Size) )
                        return 1;
        }
 

UCC git Repository :: git.ucc.asn.au