#include <stdarg.h>
#include <string.h>
#include <stddef.h>
+#include <unistd.h>
#include "request.h"
#define DEBUG(str, x...) Debug(str, x)
int direction = 0; // 0: Invalid, 1: Out, 2: In, 3: Out
char *str;
int len;
-
+
// Eat whitespace
while(*ArgTypes && *ArgTypes == ' ') ArgTypes ++;
if( *ArgTypes == '\0' ) return ArgTypes;
+// DEBUG("ArgTypes = '%s'", ArgTypes);
+
// Get direction
switch(*ArgTypes)
{
break;
// Data (special handling)
case 'd':
- len = va_arg(*Args, int);
+ len = va_arg(*Args, size_t);
str = va_arg(*Args, char*);
// Save the pointer for later
// Create parameter block
Dest->Type = ARG_TYPE_DATA;
- Dest->Length = len;
+ Dest->Length = str ? len : 0;
Dest->Flags = 0;
if( direction & 2 )
Dest->Flags |= ARG_FLAG_RETURN;
// Has data?
if( direction & 1 )
{
- if( DataDest )
+ if( DataDest && str )
memcpy(DataDest, str, len);
}
else
free( req );
free( retPtrs );
- DEBUG(": %llx", retValue);
+ DEBUG(": %i 0x%llx", SyscallID, retValue);
return retValue;
}
gaSyscall_LocalFPs[FD] = NULL;
}
-size_t native_read(int FD, size_t Bytes, void *Dest)
+size_t native_read(int FD, void *Dest, size_t Bytes)
{
return fread( Dest, Bytes, 1, gaSyscall_LocalFPs[FD] );
}
-size_t native_write(int FD, size_t Bytes, const void *Src)
+size_t native_write(int FD, const void *Src, size_t Bytes)
{
return fwrite( Src, Bytes, 1, gaSyscall_LocalFPs[FD] );
}
{
return ftell( gaSyscall_LocalFPs[FD] );
}
+
+int native_execve(const char *filename, const char *const argv[], const char *const envp[])
+{
+ int ret;
+ ret = execve(filename, argv, envp);
+ perror("native_execve");
+ return ret;
+}