From faf17232932d4aff1b266eb21325aa5e7d341321 Mon Sep 17 00:00:00 2001 From: entriphy <1747088+entriphy@users.noreply.github.com> Date: Mon, 15 Jul 2024 01:19:01 -0700 Subject: [PATCH] vt: Decompile vtutil.c --- CMakeLists.txt | 2 +- src/vtusr/vtutil.c | 37 ++++++++++++++++++++++++++++++++++++- src/vtusr/vtutil.h | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f902892..2673ddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ set_target_properties(PS2_CRT0 PROPERTIES OUTPUT_NAME "crt0.o") set(EXECUTABLES) # C files -set(SUBDIRS abe harada hato hoshino kazuya nakano okanoyo taka take okanoyo/debug vtusr/taro okanoyo/linux) +set(SUBDIRS abe harada hato hoshino kazuya nakano okanoyo taka take okanoyo/debug vtusr vtusr/taro okanoyo/linux) foreach (SUBDIR IN LISTS SUBDIRS) file(GLOB files src/${SUBDIR}/*.c) foreach (file ${files}) diff --git a/src/vtusr/vtutil.c b/src/vtusr/vtutil.c index 776780c..65e8af3 100644 --- a/src/vtusr/vtutil.c +++ b/src/vtusr/vtutil.c @@ -1,5 +1,40 @@ +#include #include "vtusr/vtutil.h" +#include "okanoyo/okio.h" + +u128* vtFileRead(char *name) { + s32 fd; + s32 size; + u128 *buf; + char tmp; + s32 status; + + fd = sceOpen(name, SCE_RDONLY); + if (fd < 0) { + printf("can't open [%s]\n", name); + return NULL; + } + + size = sceLseek(fd, 0, SEEK_END); + sceLseek(fd, 0, SEEK_SET); + buf = getBuff(1, size, &tmp, &status); + if (sceRead(fd, buf, size) < 0) { + printf("load failed [%s]\n", name); + return NULL; + } else { + printf("load sucees %d byte\n", size); // sucees + sceClose(fd); + return buf; + } +} void* vtGetBuf64(u32 size) { - // TODO + char tmp; + s32 status; + void *buf; + + buf = getBuff(1, size + 0x3F, &tmp, &status); + buf = (void *)(((u32)buf - 1) & ~0x3F); + buf = (void *)((u8 *)buf + 0x40); + return buf; } \ No newline at end of file diff --git a/src/vtusr/vtutil.h b/src/vtusr/vtutil.h index 33a2769..bd84ec4 100644 --- a/src/vtusr/vtutil.h +++ b/src/vtusr/vtutil.h @@ -3,6 +3,7 @@ #include "common.h" +extern u128* vtFileRead(char *name); extern void* vtGetBuf64(u32 size); #endif \ No newline at end of file