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
Merge branch 'master' of git://localhost/acess2
[tpg/acess2.git]
/
Usermode
/
Libraries
/
ld-acess.so_src
/
loadlib.c
diff --git
a/Usermode/Libraries/ld-acess.so_src/loadlib.c
b/Usermode/Libraries/ld-acess.so_src/loadlib.c
index
b6637c2
..
dcacd8a
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/loadlib.c
+++ b/
Usermode/Libraries/ld-acess.so_src/loadlib.c
@@
-4,6
+4,7
@@
*/
#include "common.h"
#include <stdint.h>
*/
#include "common.h"
#include <stdint.h>
+#include <acess/sys.h>
#define DEBUG 0
#define DEBUG 0
@@
-15,7
+16,6
@@
// === PROTOTYPES ===
void *IsFileLoaded(const char *file);
// === PROTOTYPES ===
void *IsFileLoaded(const char *file);
- int GetSymbolFromBase(void *base, const char *name, void **ret);
// === IMPORTS ===
extern const struct {
// === IMPORTS ===
extern const struct {
@@
-23,6
+23,7
@@
extern const struct {
char *Name;
} caLocalExports[];
extern const int ciNumLocalExports;
char *Name;
} caLocalExports[];
extern const int ciNumLocalExports;
+extern char **gEnvP;
// === GLOABLS ===
tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES];
// === GLOABLS ===
tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES];
@@
-77,7
+78,7
@@
void *LoadLibrary(const char *SoName, const char *SearchDir, char **envp)
DEBUGS(" LoadLibrary: SysLoadBin()");
// Load Library
DEBUGS(" LoadLibrary: SysLoadBin()");
// Load Library
- base = SysLoadBin(filename, (void**)&fEntry);
+ base =
_
SysLoadBin(filename, (void**)&fEntry);
if(!base) {
DEBUGS("LoadLibrary: RETURN 0");
return 0;
if(!base) {
DEBUGS("LoadLibrary: RETURN 0");
return 0;
@@
-87,10
+88,13
@@
void *LoadLibrary(const char *SoName, const char *SearchDir, char **envp)
// Load Symbols
fEntry = DoRelocate( base, envp, filename );
// Load Symbols
fEntry = DoRelocate( base, envp, filename );
+ if( !fEntry ) {
+ return 0;
+ }
// Call Entrypoint
DEBUGS(" LoadLibrary: '%s' Entry %p", SoName, fEntry);
// Call Entrypoint
DEBUGS(" LoadLibrary: '%s' Entry %p", SoName, fEntry);
- fEntry(base, 0, NULL,
envp
);
+ fEntry(base, 0, NULL,
gEnvP
);
DEBUGS("LoadLibrary: RETURN 1");
return base;
DEBUGS("LoadLibrary: RETURN 1");
return base;
@@
-169,7
+173,7
@@
void Unload(void *Base)
if(id == MAX_LOADED_LIBRARIES) return;
// Unload Binary
if(id == MAX_LOADED_LIBRARIES) return;
// Unload Binary
- SysUnloadBin( Base );
+
_
SysUnloadBin( Base );
// Save String Pointer
str = gLoadedLibraries[id].Name;
// Save String Pointer
str = gLoadedLibraries[id].Name;
@@
-197,26
+201,31
@@
void Unload(void *Base)
\fn Uint GetSymbol(const char *name)
\brief Gets a symbol value from a loaded library
*/
\fn Uint GetSymbol(const char *name)
\brief Gets a symbol value from a loaded library
*/
-
void *GetSymbol(const char *nam
e)
+
int GetSymbol(const char *name, void **Value, size_t *Siz
e)
{
int i;
{
int i;
- void *ret;
//SysDebug("ciNumLocalExports = %i", ciNumLocalExports);
for(i=0;i<ciNumLocalExports;i++)
{
//SysDebug("ciNumLocalExports = %i", ciNumLocalExports);
for(i=0;i<ciNumLocalExports;i++)
{
- if( strcmp(caLocalExports[i].Name, name) == 0 )
- return caLocalExports[i].Value;
+ if( strcmp(caLocalExports[i].Name, name) == 0 ) {
+ *Value = caLocalExports[i].Value;
+ if(Size)
+ *Size = 0;
+ return 1;
+ }
}
// Entry 0 is ld-acess, ignore it
for(i = 1; i < MAX_LOADED_LIBRARIES; i ++)
{
}
// Entry 0 is ld-acess, ignore it
for(i = 1; i < MAX_LOADED_LIBRARIES; i ++)
{
- if(gLoadedLibraries[i].Base == 0) break;
+ if(gLoadedLibraries[i].Base == 0)
+ break;
//SysDebug(" GetSymbol: Trying 0x%x, '%s'",
// gLoadedLibraries[i].Base, gLoadedLibraries[i].Name);
//SysDebug(" GetSymbol: Trying 0x%x, '%s'",
// gLoadedLibraries[i].Base, gLoadedLibraries[i].Name);
- if(GetSymbolFromBase(gLoadedLibraries[i].Base, name, &ret)) return ret;
+ if(GetSymbolFromBase(gLoadedLibraries[i].Base, name, Value, Size))
+ return 1;
}
SysDebug("GetSymbol: === Symbol '%s' not found ===", name);
return 0;
}
SysDebug("GetSymbol: === Symbol '%s' not found ===", name);
return 0;
@@
-226,13
+235,13
@@
void *GetSymbol(const char *name)
\fn int GetSymbolFromBase(Uint base, char *name, Uint *ret)
\breif Gets a symbol from a specified library
*/
\fn int GetSymbolFromBase(Uint base, char *name, Uint *ret)
\breif Gets a symbol from a specified library
*/
-int GetSymbolFromBase(void *base, const char *name, void **ret)
+int GetSymbolFromBase(void *base, const char *name, void **ret
, size_t *Size
)
{
uint8_t *hdr = base;
if(hdr[0] == 0x7F && hdr[1] == 'E' && hdr[2] == 'L' && hdr[3] == 'F')
{
uint8_t *hdr = base;
if(hdr[0] == 0x7F && hdr[1] == 'E' && hdr[2] == 'L' && hdr[3] == 'F')
- return ElfGetSymbol(base, name, ret);
+ return ElfGetSymbol(base, name, ret
, Size
);
if(hdr[0] == 'M' && hdr[1] == 'Z')
if(hdr[0] == 'M' && hdr[1] == 'Z')
- return PE_GetSymbol(base, name, ret);
+ return PE_GetSymbol(base, name, ret
, Size
);
SysDebug("Unknown type at %p (%02x %02x %02x %02x)", base,
hdr[0], hdr[1], hdr[2], hdr[3]);
return 0;
SysDebug("Unknown type at %p (%02x %02x %02x %02x)", base,
hdr[0], hdr[1], hdr[2], hdr[3]);
return 0;
UCC
git Repository :: git.ucc.asn.au