Skip to content

Commit

Permalink
Fixed shellexec and memory-related system call implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Mar 10, 2024
1 parent 0387a76 commit 442ede1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/rishka_syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,20 @@ unsigned long rishka_syscall_sys_millis() {
return millis();
}

int rishka_syscall_sys_shellexec(RishkaVM* parent_vm) {
int64_t rishka_syscall_sys_shellexec(RishkaVM* parent_vm) {
RishkaVM* child_vm = new RishkaVM();

char* program = parent_vm->getPointerParam<char*>(0);
int argc = parent_vm->getParam<int>(1);
char** argv = parent_vm->getPointerParam<char**>(2);

child_vm->initialize(parent_vm->getStream());
if(!child_vm->loadFile(program))
if(!child_vm->loadFile(program)) {
child_vm->reset();
delete child_vm;

return -1;
}

child_vm->run(argc, argv);
child_vm->reset();
Expand Down Expand Up @@ -293,15 +297,15 @@ void rishka_syscall_mem_calloc(RishkaVM* vm) {
size_t num = vm->getParam<size_t>(1);
size_t size = vm->getParam<size_t>(2);

dest = calloc(num, size);
dest = ps_calloc(num, size);
}

void rishka_syscall_mem_realloc(RishkaVM* vm) {
void* dest = vm->getPointerParam<void*>(0);
void* ptr = vm->getPointerParam<void*>(1);
size_t size = vm->getParam<size_t>(2);

dest = realloc(ptr, size);
dest = ps_realloc(ptr, size);
}

void rishka_syscall_mem_free(RishkaVM* vm) {
Expand Down
2 changes: 1 addition & 1 deletion src/rishka_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ uint64_t rishka_syscall_io_get_timeout(RishkaVM* vm);
void rishka_syscall_sys_delay(RishkaVM* vm);
unsigned long rishka_syscall_sys_micros();
unsigned long rishka_syscall_sys_millis();
int rishka_syscall_sys_shellexec(RishkaVM* parent_vm);
int64_t rishka_syscall_sys_shellexec(RishkaVM* parent_vm);
void rishka_syscall_sys_exit(RishkaVM* vm);
uint32_t rishka_syscall_sys_infos(RishkaVM* vm);
long rishka_syscall_sys_infon(RishkaVM* vm);
Expand Down

0 comments on commit 442ede1

Please sign in to comment.