Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Princess of Sleeping authored Apr 18, 2018
1 parent 44c2cf1 commit 2372449
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 290 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include("${VITASDK}/share/vita.cmake" REQUIRED)
set(VITA_APP_NAME "PUP-Extractor")
set(VITA_TITLEID "PSP2PUP00")

set(VITA_VERSION "01.00")
set(VITA_VERSION "01.30")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
Expand All @@ -25,6 +25,7 @@ set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1")

add_executable(${PROJECT_NAME}
src/main.c
src/ctrl.c
src/graphics.c
src/font.c
src/file_io.c
Expand All @@ -34,19 +35,16 @@ add_executable(${PROJECT_NAME}

target_link_libraries(${PROJECT_NAME}

SceCtrl_stub
SceDisplay_stub
SceGxm_stub
SceCtrl_stub
SceSysmodule_stub
SceCtrl_stub

)


vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE)



vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} eboot.bin
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
Expand Down
54 changes: 54 additions & 0 deletions src/ctrl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "main.h"

int get_key(int type) {


SceCtrlData pad;

if(type == 0){

while (1) {
sceCtrlPeekBufferPositive(0, &pad, 1);

if (pad.buttons != 0)
return pad.buttons;
}

}else{

while (1) {
sceCtrlPeekBufferPositive(0, &pad, 1);
if(pad.buttons == 0){
break;
}
}

}

return 0;

}


void press_next(void) {

printf("Press any key to next this application.\n\n");

get_key(1);
get_key(0);
get_key(1);

}


void press_exit(void) {

printf("Press any key to exit this application.\n\n");

get_key(1);
get_key(0);
get_key(1);

sceKernelExitProcess(0);

}
98 changes: 39 additions & 59 deletions src/file_io.c
Original file line number Diff line number Diff line change
@@ -1,111 +1,91 @@

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <psp2/io/dirent.h>
#include <psp2/io/fcntl.h>
#include <psp2/io/stat.h>


#include "main.h"

char pup_buffer[0x20000];

int scePlayStartionUpdatePackageExtractFiles(char *pup_dec_dir, SceUID file_check, int i, SceUInt32 file_count, void *header){

int SfcExtractPupFiles(pup_dec_dir, file_check, i, file_count, header_buffer){

const uint32_t *header_buffer_u32t;

header_buffer_u32t = header_buffer;
char write_file_name[0x100];
char write_file_path[0x200];

uint32_t base_addr1 = 0x80 + (0x20 * i);
uint32_t base_addr2 = (0x80 + (0x20 * file_count)) + (0x40 * i);

int base_addr1 = 0x80 + (0x20 * i);
int base_addr2 = (0x80 + (0x20 * file_count)) + (0x40 * i);
ScePlayStartionUpdatePackageHeader2 header2;
ScePlayStartionUpdatePackageHeader3 header3;

sceIoPread(file_check, &header2, sizeof(ScePlayStartionUpdatePackageHeader2), base_addr1);
sceIoPread(file_check, &header3, sizeof(ScePlayStartionUpdatePackageHeader3), base_addr2);

printf("File Count : %d / %d\n\n", (i+1), file_count);


int file_entry_id = header_buffer_u32t[base_addr1 / 4];
int entry_file_name = GetFileEntryID(file_entry_id);
printf("FileEntry%02d : %s\n\n",i, entry_file_name);
sceGetPlayStartionUpdatePackageFileEntryId(write_file_name, header2.entry_id);
printf("FileEntry%02d : %s\n\n", i, write_file_name);

printf("Data Offset : 0x%X\n\n", header2.data_offset);

int data_offset = header_buffer_u32t[(base_addr1 + 0x8) / 4];
printf("Data Offset : 0x%X\n\n",data_offset);
printf("Data Length : 0x%X / %dByte\n\n", header2.data_length, header2.data_length);

printf("File Index : %d\n\n", header3.index);

int data_length = header_buffer_u32t[(base_addr1 + 0x10) / 4];
printf("Data Length : 0x%X / %dByte\n\n",data_length,data_length);
printf("File Hash :");

for(int shi=0;shi<sizeof(header3.hash);shi++)printf(" %02X", header3.hash[shi]);

int file_index = header_buffer_u32t[base_addr2 / 4];
printf("File Index : %d\n\n",file_index);

printf("\n\n");


char write_file_name[0x100];
sprintf(write_file_name, "%s%s", pup_dec_dir, entry_file_name);
sprintf(write_file_path, "%s%s", pup_dec_dir, write_file_name);

printf("open write file ... ");

int fd = sceIoOpen(write_file_name, SCE_O_TRUNC | SCE_O_CREAT | SCE_O_WRONLY, 0777);

int pup_buffer = malloc(data_length);
int fd = sceIoOpen(write_file_path, SCE_O_TRUNC | SCE_O_CREAT | SCE_O_WRONLY, 0777);


if(fd >= 0){
if(fd < 0){

printf(" Success.(%s)\n\n",write_file_name);

printf("Read File Offset ... ");

int sipr = sceIoPread(file_check, pup_buffer, data_length, data_offset);
printf("Failed.");

if(sipr >= 0){
return 0;

printf("Success.\n\n");
}

printf("File Write ... ");
printf(" Success.(%s)\n\n", write_file_path);

int siw = sceIoWrite(fd, pup_buffer, data_length);

if(siw == data_length){
printf("File Write ... ");

printf(" Success.\n\n");

printf("File Close ... ");

int sic = sceIoClose(fd);
uint32_t plus_address = 0x0, read_size = sizeof(pup_buffer);

if(sic >= 0){
do {

printf(" Success.");
if((plus_address + sizeof(pup_buffer)) > header2.data_length){

}else{
read_size = (plus_address + sizeof(pup_buffer)) - header2.data_length;

printf("Failed.");
read_size = sizeof(pup_buffer) - read_size;

}
}

}else{
int sipr = sceIoPread(file_check, pup_buffer, read_size, header2.data_offset + plus_address);

printf("Failed.");
sceIoWrite(fd, pup_buffer, sipr);

}
plus_address += sizeof(pup_buffer);

}else{
} while (plus_address < header2.data_length);

printf("Failed.");
printf(" Success.\n\n");

}

}else{

printf("Failed.");
sceIoClose(fd);

}

free(pup_buffer);
return 0;

}
Loading

0 comments on commit 2372449

Please sign in to comment.