First try to get promoting working

This commit is contained in:
Carlos Ballesteros Velasco 2016-09-04 16:41:00 +02:00
parent 2efcd98b21
commit 006d4979ea
5 changed files with 87 additions and 28 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
*.o
*.a
/eboot.bin
*.elf
*.sfo
*.velf
*.vpk

40
main.c
View File

@ -961,7 +961,8 @@ int dialogSteps() {
case DIALOG_STEP_INSTALL_CONFIRMED:
if (msg_result == MESSAGE_DIALOG_RESULT_RUNNING) {
InstallArguments args;
InstallArguments args = {0};
args.assisted = 1;
if(install_list.length > 0) {
FileListEntry *entryInstallList = install_list.head;
snprintf(installListPath, MAX_PATH_LENGTH, "%s%s", install_list.path, entryInstallList->name);
@ -1055,6 +1056,7 @@ void fileBrowserMenuCtrl() {
ftpvita_add_device(mount_points[i]);
}
}
ftpvita_ext_add_custom_command("PROM", ftpvita_PROM);
}
// Lock power timers
@ -1369,6 +1371,42 @@ void getNetInfo() {
}
}
void ftpvita_PROM_done(void *_client) {
}
void ftpvita_PROM(ftpvita_client_info_t *client) {
char cmd[64];
char path[MAX_PATH_LENGTH];
sscanf(client->recv_buffer, "%s %s", cmd, path);
InstallArguments args = {0};
args.file = path;
args.assisted = 0;
args.completed_callback_arg = client;
args.completed_callback = ftpvita_PROM_done;
SceUID thid = sceKernelCreateThread("install_thread", (SceKernelThreadEntry)install_thread, 0x40, 0x10000, 0, 0, NULL);
if (thid >= 0) {
sceKernelStartThread(thid, sizeof(InstallArguments), &args);
int stat = 0;
SceUInt timeout = 500 * 1000 * 1000; // 500 milliseconds
// TRY TO KEEP-ALIVE!
ftpvita_ext_client_send_ctrl_msg(client, "200 ");
while (sceKernelWaitThreadEnd(thid, &stat, &timeout) != 0) {
ftpvita_ext_client_send_ctrl_msg(client, ".");
}
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL, language_container[FTP_SERVER], vita_ip, vita_port);
dialog_step = DIALOG_STEP_FTP;
// Send EOL
ftpvita_ext_client_send_ctrl_msg(client, "\r\n");
}
}
int main(int argc, const char *argv[]) {
// Init VitaShell
initVitaShell();

3
main.h
View File

@ -197,5 +197,8 @@ void drawShellInfo(char *path);
int isInArchive();
void ftpvita_PROM(ftpvita_client_info_t *client);
void install_unassisted_sync(char *path);
#endif

View File

@ -208,6 +208,7 @@ int makeHeadBin() {
int install_thread(SceSize args_size, InstallArguments *args) {
SceUID thid = -1;
int assisted = args->assisted;
// Lock power timers
powerLock();
@ -229,36 +230,38 @@ int install_thread(SceSize args_size, InstallArguments *args) {
}
// Check permissions
char path[MAX_PATH_LENGTH];
snprintf(path, MAX_PATH_LENGTH, "%s/eboot.bin", args->file);
SceUID fd = archiveFileOpen(path, SCE_O_RDONLY, 0);
if (fd >= 0) {
char buffer[0x88];
archiveFileRead(fd, buffer, sizeof(buffer));
archiveFileClose(fd);
if (assisted) {
char path[MAX_PATH_LENGTH];
snprintf(path, MAX_PATH_LENGTH, "%s/eboot.bin", args->file);
SceUID fd = archiveFileOpen(path, SCE_O_RDONLY, 0);
if (fd >= 0) {
char buffer[0x88];
archiveFileRead(fd, buffer, sizeof(buffer));
archiveFileClose(fd);
// Team molecule's request: Full permission access warning
uint64_t authid = *(uint64_t *)(buffer + 0x80);
if (authid == 0x2F00000000000001 || authid == 0x2F00000000000003) {
closeWaitDialog();
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_WARNING]);
dialog_step = DIALOG_STEP_INSTALL_WARNING;
// Wait for response
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
sceKernelDelayThread(1000);
}
// Cancelled
if (dialog_step == DIALOG_STEP_CANCELLED) {
// Team molecule's request: Full permission access warning
uint64_t authid = *(uint64_t *)(buffer + 0x80);
if (authid == 0x2F00000000000001 || authid == 0x2F00000000000003) {
closeWaitDialog();
goto EXIT;
}
// Init again
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALLING;
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_YESNO, language_container[INSTALL_WARNING]);
dialog_step = DIALOG_STEP_INSTALL_WARNING;
// Wait for response
while (dialog_step == DIALOG_STEP_INSTALL_WARNING) {
sceKernelDelayThread(1000);
}
// Cancelled
if (dialog_step == DIALOG_STEP_CANCELLED) {
closeWaitDialog();
goto EXIT;
}
// Init again
initMessageDialog(MESSAGE_DIALOG_PROGRESS_BAR, language_container[INSTALLING]);
dialog_step = DIALOG_STEP_INSTALLING;
}
}
}
@ -311,6 +314,7 @@ int install_thread(SceSize args_size, InstallArguments *args) {
dialog_step = DIALOG_STEP_INSTALLED;
EXIT:
if (thid >= 0)
sceKernelWaitThreadEnd(thid, NULL, NULL);
@ -318,5 +322,9 @@ EXIT:
// Unlock power timers
powerUnlock();
if (args->completed_callback != NULL) {
args->completed_callback(args->completed_callback_arg);
}
return sceKernelExitDeleteThread(0);
}

View File

@ -27,6 +27,9 @@
typedef struct {
char *file;
int assisted;
void *completed_callback_arg;
void (*completed_callback)(void*);
} InstallArguments;
int promote(char *path);