git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode/ld-acess - Implemented R_836_COPY and R_X86_64_COPY
[tpg/acess2.git]
/
Usermode
/
Libraries
/
ld-acess.so_src
/
main.c
diff --git
a/Usermode/Libraries/ld-acess.so_src/main.c
b/Usermode/Libraries/ld-acess.so_src/main.c
index
dfb1b61
..
ff715bb
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/main.c
+++ b/
Usermode/Libraries/ld-acess.so_src/main.c
@@
-3,16
+3,15
@@
By thePowersGang
\r
*/
\r
#include <stdint.h>
\r
By thePowersGang
\r
*/
\r
#include <stdint.h>
\r
+#include <stddef.h>
\r
#include "common.h"
\r
\r
// === PROTOTYPES ===
\r
#include "common.h"
\r
\r
// === PROTOTYPES ===
\r
-void *DoRelocate(void *base, char **envp, char *Filename);
\r
+void *DoRelocate(void *base, char **envp, c
onst c
har *Filename);
\r
int CallUser(void *Entry, void *SP);
\r
int CallUser(void *Entry, void *SP);
\r
-void *ElfRelocate(void *Base, char *envp[], char *Filename);
\r
-void *PE_Relocate(void *Base, char *envp[], char *Filename);
\r
\r
// === Imports ===
\r
\r
// === Imports ===
\r
-extern
void gLinkedBase
;
\r
+extern
char gLinkedBase[]
;
\r
extern tLoadedLib gLoadedLibraries[];
\r
\r
// === CODE ===
\r
extern tLoadedLib gLoadedLibraries[];
\r
\r
// === CODE ===
\r
@@
-21,7
+20,7
@@
extern tLoadedLib gLoadedLibraries[];
\brief Library entry point
\r
\note This is the entrypoint for the library
\r
*/
\r
\brief Library entry point
\r
\note This is the entrypoint for the library
\r
*/
\r
-
int SoMain(void *base, void *arg1
)
\r
+
void *SoMain(void *base
)
\r
{
\r
void *ret;
\r
\r
{
\r
void *ret;
\r
\r
@@
-50,28
+49,29
@@
int SoMain(void *base, void *arg1)
_exit(-1);
\r
for(;;);
\r
}
\r
_exit(-1);
\r
for(;;);
\r
}
\r
-
\r
- // And call user
\r
- //SysDebug("Calling User at 0x%x\n", ret);
\r
- CallUser( ret, &arg1 );
\r
-
\r
- return 0;
\r
+
\r
+ SysDebug("ld-acess - SoMain: ret = %p", ret);
\r
+ return ret;
\r
}
\r
\r
/**
\r
\fn int DoRelocate(void *base, char **envp)
\r
\brief Relocates an in-memory image
\r
*/
\r
}
\r
\r
/**
\r
\fn int DoRelocate(void *base, char **envp)
\r
\brief Relocates an in-memory image
\r
*/
\r
-void *DoRelocate(void *base, char **envp, char *Filename)
\r
+void *DoRelocate(void *base, char **envp, c
onst c
har *Filename)
\r
{
\r
{
\r
+ uint8_t *hdr = base;
\r
// Load Executable
\r
// Load Executable
\r
- if(
*(Uint32*)base == (0x7F|('E'<<8)|('L'<<16)|('F'<<24))
)
\r
+ if(
memcmp(base, "\x7F""ELF", 4) == 0
)
\r
return ElfRelocate(base, envp, Filename);
\r
return ElfRelocate(base, envp, Filename);
\r
- if(*(Uint16*)base == ('M'|('Z'<<8)))
\r
+ if(hdr[0] == 0x7F && hdr[1] == 'E' && hdr[2] == 'L' && hdr[3] == 'F')
\r
+ return ElfRelocate(base, envp, Filename);
\r
+
\r
+ if(hdr[0] == 'M' && hdr[1] == 'Z')
\r
return PE_Relocate(base, envp, Filename);
\r
\r
SysDebug("ld-acess - DoRelocate: Unkown file format '0x%x 0x%x 0x%x 0x%x'\n",
\r
return PE_Relocate(base, envp, Filename);
\r
\r
SysDebug("ld-acess - DoRelocate: Unkown file format '0x%x 0x%x 0x%x 0x%x'\n",
\r
-
*(Uint8*)(base), *(Uint8*)(base+1), *(Uint8*)(base+2), *(Uint8*)(base+3)
);
\r
+
hdr[0], hdr[1], hdr[2], hdr[3]
);
\r
SysDebug("ld-acess - DoRelocate: File '%s'\n", Filename);
\r
_exit(-1);
\r
for(;;);
\r
SysDebug("ld-acess - DoRelocate: File '%s'\n", Filename);
\r
_exit(-1);
\r
for(;;);
\r
UCC
git Repository :: git.ucc.asn.au