ent = VFS_int_GetUserHandles(PID, 1);
- maxhandles = *Threads_GetMaxFD();
+ maxhandles = *Threads_GetMaxFD(NULL);
memcpy(ent->Handles, cur->Handles, maxhandles*sizeof(tVFS_Handle));
// Reference all
LOG("Copying %i FDs from %i", nFD, PID);
- maxhandles = *Threads_GetMaxFD();
+ maxhandles = *Threads_GetMaxFD(NULL);
if( nFD > maxhandles )
nFD = maxhandles;
for( int i = 0; i < nFD; i ++ )
else
{
int pid = Threads_GetPID();
- int maxhandles = *Threads_GetMaxFD();
+ int maxhandles = *Threads_GetMaxFD(NULL);
tUserHandles *ent = VFS_int_GetUserHandles(pid, 0);
if(!ent) {
else {
tUserHandles *ent;
int pid = Threads_GetPID();
- int maxhandles = *Threads_GetMaxFD();
+ int maxhandles = *Threads_GetMaxFD(NULL);
ent = VFS_int_GetUserHandles(pid, 0);
if(!ent) {
if(bIsUser)
{
tUserHandles *ent;
- int maxhandles = *Threads_GetMaxFD();
+ int maxhandles = *Threads_GetMaxFD(NULL);
// Find the PID's handle list
ent = VFS_int_GetUserHandles(Threads_GetPID(), 1);
// Get a handle
tUserHandles *ent = VFS_int_GetUserHandles(PID, 0);
if( !ent ) return;
// Get a handle
- int maxhandles = *Threads_GetMaxFD();
+ int maxhandles = *Threads_GetMaxFD(NULL);
for( int i = 0; i < maxhandles; i ++ )
{
if(ent->Handles[i].Node) continue;
ENTER("iFD", FD);\r
\r
// Check for a program header\r
- if(hdr->phoff == 0) {\r
+ if(hdr->e_phoff == 0) {\r
#if DEBUG_WARN\r
Warning("ELF File does not contain a program header\n");\r
#endif\r
}\r
\r
// Read Program Header Table\r
- phtab = malloc( sizeof(Elf32_Phdr) * hdr->phentcount );\r
+ phtab = malloc( sizeof(Elf32_Phdr) * hdr->e_phnum );\r
if( !phtab ) {\r
LEAVE('n');\r
return NULL;\r
}\r
- LOG("hdr.phoff = 0x%08x\n", hdr->phoff);\r
- acess__SysSeek(FD, hdr->phoff, ACESS_SEEK_SET);\r
- acess__SysRead(FD, phtab, sizeof(Elf32_Phdr) * hdr->phentcount);\r
+ LOG("hdr.e_phoff = 0x%08x\n", hdr->e_phoff);\r
+ acess__SysSeek(FD, hdr->e_phoff, ACESS_SEEK_SET);\r
+ acess__SysRead(FD, phtab, sizeof(Elf32_Phdr) * hdr->e_phnum);\r
\r
// Count Pages\r
iPageCount = 0;\r
- LOG("hdr.phentcount = %i\n", hdr->phentcount);\r
- for( i = 0; i < hdr->phentcount; i++ )\r
+ LOG("hdr.e_phnum = %i\n", hdr->e_phnum);\r
+ for( i = 0; i < hdr->e_phnum; i++ )\r
{\r
// Ignore Non-LOAD types\r
- if(phtab[i].Type != PT_LOAD)\r
+ if(phtab[i].p_type != PT_LOAD)\r
continue;\r
- iPageCount += ((phtab[i].VAddr&0xFFF) + phtab[i].MemSize + 0xFFF) >> 12;\r
- LOG("phtab[%i] = {VAddr:0x%x, MemSize:0x%x}\n", i, phtab[i].VAddr, phtab[i].MemSize);\r
+ iPageCount += ((phtab[i].p_vaddr&0xFFF) + phtab[i].p_memsz + 0xFFF) >> 12;\r
+ LOG("phtab[%i] = {p_vaddr:0x%x, p_memsz:0x%x}\n", i, phtab[i].p_vaddr, phtab[i].MemSize);\r
}\r
\r
LOG("iPageCount = %i\n", iPageCount);\r
// Prescan for base and size\r
max = 0;\r
base = 0xFFFFFFFF;\r
- for( i = 0; i < hdr->phentcount; i ++)\r
+ for( i = 0; i < hdr->e_phnum; i ++)\r
{\r
- if( phtab[i].Type != PT_LOAD )\r
+ if( phtab[i].p_type != PT_LOAD )\r
continue;\r
- if( phtab[i].VAddr < base )\r
- base = phtab[i].VAddr;\r
- if( phtab[i].VAddr + phtab[i].MemSize > max )\r
- max = phtab[i].VAddr + phtab[i].MemSize;\r
+ if( phtab[i].p_vaddr < base )\r
+ base = phtab[i].p_vaddr;\r
+ if( phtab[i].p_vaddr + phtab[i].p_memsz > max )\r
+ max = phtab[i].p_vaddr + phtab[i].p_memsz;\r
}\r
\r
LOG("base = %08x, max = %08x\n", base, max);\r
}\r
\r
// Load Pages\r
- for( i = 0; i < hdr->phentcount; i++ )\r
+ for( i = 0; i < hdr->e_phnum; i++ )\r
{\r
// Get Interpreter Name\r
- if( phtab[i].Type == PT_INTERP )\r
+ if( phtab[i].p_type == PT_INTERP )\r
{\r
char *tmp;\r
//if(ret->Interpreter) continue;\r
- tmp = malloc(phtab[i].FileSize);\r
- acess__SysSeek(FD, phtab[i].Offset, ACESS_SEEK_SET);\r
- acess__SysRead(FD, tmp, phtab[i].FileSize);\r
+ tmp = malloc(phtab[i].p_filesz);\r
+ acess__SysSeek(FD, phtab[i].p_offset, ACESS_SEEK_SET);\r
+ acess__SysRead(FD, tmp, phtab[i].p_filesz);\r
//ret->Interpreter = Binary_RegInterp(tmp);\r
LOG("Interpreter '%s'\n", tmp);\r
free(tmp);\r
continue;\r
}\r
// Ignore non-LOAD types\r
- if(phtab[i].Type != PT_LOAD) continue;\r
+ if(phtab[i].p_type != PT_LOAD) continue;\r
\r
- LOG("phtab[%i] = PT_LOAD {Adj VAddr:0x%x, Offset:0x%x, FileSize:0x%x, MemSize:0x%x}\n",\r
- i, phtab[i].VAddr+baseDiff, phtab[i].Offset, phtab[i].FileSize, phtab[i].MemSize);\r
+ LOG("phtab[%i] = PT_LOAD {Adj p_vaddr:0x%x, p_offset:0x%x, p_filesz:0x%x, p_memsz:0x%x}\n",\r
+ i, phtab[i].p_vaddr+baseDiff, phtab[i].p_offset, phtab[i].p_filesz, phtab[i].p_memsz);\r
\r
- addr = phtab[i].VAddr + baseDiff;\r
+ addr = phtab[i].p_vaddr + baseDiff;\r
\r
- if( AllocateMemory( addr, phtab[i].MemSize ) ) {\r
+ if( AllocateMemory( addr, phtab[i].p_memsz ) ) {\r
fprintf(stderr, "Elf_Load: Unable to map memory at %x (0x%x bytes)\n",\r
- addr, phtab[i].MemSize);\r
+ addr, phtab[i].p_memsz);\r
free( phtab );\r
return NULL;\r
}\r
\r
- acess__SysSeek(FD, phtab[i].Offset, ACESS_SEEK_SET);\r
- acess__SysRead(FD, PTRMK(void, addr), phtab[i].FileSize);\r
- memset( PTRMK(char, addr) + phtab[i].FileSize, 0, phtab[i].MemSize - phtab[i].FileSize );\r
+ acess__SysSeek(FD, phtab[i].p_offset, ACESS_SEEK_SET);\r
+ acess__SysRead(FD, PTRMK(void, addr), phtab[i].p_filesz);\r
+ memset( PTRMK(char, addr) + phtab[i].p_filesz, 0, phtab[i].p_memsz - phtab[i].p_filesz );\r
}\r
\r
// Clean Up\r
LEAVE('n');\r
return NULL;\r
}\r
- LOG("hdr.phoff = 0x%08llx\n", (long long)hdr->e_phoff);\r
+ LOG("hdr.e_phoff = 0x%08llx\n", (long long)hdr->e_phoff);\r
acess__SysSeek(FD, hdr->e_phoff, ACESS_SEEK_SET);\r
acess__SysRead(FD, phtab, sizeof(Elf64_Phdr) * hdr->e_phnum);\r
\r
// Count Pages\r
iPageCount = 0;\r
- LOG("hdr.phentcount = %i\n", hdr->e_phnum);\r
+ LOG("hdr.e_phnum = %i\n", hdr->e_phnum);\r
for( i = 0; i < hdr->e_phnum; i++ )\r
{\r
// Ignore Non-LOAD types\r
if(phtab[i].p_type != PT_LOAD)\r
continue;\r
iPageCount += ((phtab[i].p_vaddr&0xFFF) + phtab[i].p_memsz + 0xFFF) >> 12;\r
- LOG("phtab[%i] = {VAddr:0x%llx, MemSize:0x%llx}\n",\r
+ LOG("phtab[%i] = {p_vaddr:0x%llx, p_memsz:0x%llx}\n",\r
i, (long long)phtab[i].p_vaddr, (long long)phtab[i].p_memsz);\r
}\r
\r
// Ignore non-LOAD types\r
if(phtab[i].p_type != PT_LOAD) continue;\r
\r
- LOG("phtab[%i] = PT_LOAD {Adj VAddr:0x%llx, Offset:0x%llx, FileSize:0x%llx, MemSize:0x%llx}\n",\r
+ LOG("phtab[%i] = PT_LOAD {Adj p_vaddr:0x%llx, p_offset:0x%llx, p_filesz:0x%llx, p_memsz:0x%llx}\n",\r
i,\r
(long long)phtab[i].p_vaddr+baseDiff, (long long)phtab[i].p_offset,\r
(long long)phtab[i].p_filesz, (long long)phtab[i].p_memsz\r