Skip to content

Commit

Permalink
Fixed crash on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Electric1447 committed Jun 15, 2020
1 parent d09b063 commit 81588fc
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include("${VITASDK}/share/vita.cmake" REQUIRED)

set(VITA_APP_NAME "EasyVPK")
set(VITA_TITLEID "ESVPK0009")
set(VITA_VERSION "01.20")
set(VITA_VERSION "01.21")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-psabi -std=c++17 -fpermissive")
Expand Down
2 changes: 1 addition & 1 deletion sce_sys/livearea/contents/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<frame id="frame4">
<liveitem>
<text align="left" text-align="left" word-wrap="off" ellipsis="on">
<str size="18" color="#ffffff" shadow="on">v1.2.0</str>
<str size="18" color="#ffffff" shadow="on">v1.2.1</str>
</text>
</liveitem>
</frame>
Expand Down
17 changes: 8 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static int callback(void *data, int argc, char **argv, char **column_name) {
return 0;
}

void initSceAppUtil()
{
void initSceAppUtil() {

// Init SceAppUtil
SceAppUtilInitParam init_param;
SceAppUtilBootParam boot_param;
Expand Down Expand Up @@ -65,9 +65,8 @@ int getAppData(vector<AppInfo> &ret) {
sqlite3_rw_init();

int rc = sqlite3_open_v2("ur0:shell/db/app.db", &db, SQLITE_OPEN_READONLY, NULL);
if(rc != SQLITE_OK) {
if (rc != SQLITE_OK)
return -1;
}

sqlite3_exec(db, "SELECT titleId, title, iconPath FROM tbl_appinfo_icon WHERE NOT titleId=\"NULL\" ORDER BY title ASC", callback, &ret, NULL);

Expand All @@ -92,7 +91,7 @@ int main() {

httpInit();
netInit();
curlDownload("http://rinnegatamante.it/vitadb/list_hbs_json.php", "ux0:data/Easy_VPK/vpks.json");
curlDownload("https://vitadb.rinnegatamante.it/list_hbs_json.json", "ux0:data/Easy_VPK/vpks.json");

SharedData sharedData;

Expand All @@ -115,10 +114,10 @@ int main() {

vita2d_draw_texture(bgIMG, 0, 0);

if (pad.buttons != SCE_CTRL_CROSS) sharedData.blockCross = false;
if (pad.buttons != SCE_CTRL_CROSS ) sharedData.blockCross = false;
if (pad.buttons != SCE_CTRL_SQUARE) sharedData.blockSquare = false;
if (pad.buttons != SCE_CTRL_CIRCLE) sharedData.blockCircle = false;
if (pad.buttons != SCE_CTRL_START) sharedData.blockStart = false;


if (sharedData.scene == 0) listView.draw(sharedData, pad.buttons);

Expand All @@ -140,11 +139,11 @@ int main() {
vita2d_free_font(sharedData.font);
vita2d_free_texture(bgIMG);

for (int i=0; i<sharedData.appData.size();i++)
for (int i = 0; i < sharedData.appData.size(); i++)
if (sharedData.appData[i].icon != NULL)
vita2d_free_texture(sharedData.appData[i].icon);

for (int i=0;i<sharedData.screenshots.size();i++)
for (int i = 0; i < sharedData.screenshots.size(); i++)
if (sharedData.screenshots[i] != NULL)
vita2d_free_texture(sharedData.screenshots[i]);

Expand Down
5 changes: 2 additions & 3 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ class AppInfo {
struct SharedData {
int scene = 0;
int cursorY = 0;
bool blockCross = false;
bool blockCross = false;
bool blockSquare = false;
bool blockCircle = false;
bool blockStart = false;
bool initDetail = true;
bool initDetail = true;
int dl_type_sd = 0; // VPK
string vpkDownloadPath = "ux0:VPK/";
vector<vita2d_texture *> screenshots;
Expand Down
12 changes: 5 additions & 7 deletions src/net/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void curlDownload(const char *url, const char *dest) {
if(curl) {
curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
Expand All @@ -86,7 +87,7 @@ void curlDownload(const char *url, const char *dest) {
}

std::string curlDownloadKeepName(char const*const url, std::string dst) {
CURL *curl;
CURL *curl;

SceUID file = sceIoOpen("ux0:data/Easy_VPK/plugin.tmp", SCE_O_CREAT | SCE_O_WRONLY, 0777);
SceUID head = sceIoOpen("ux0:data/Easy_VPK/head.tmp", SCE_O_CREAT | SCE_O_WRONLY, 0777);
Expand Down Expand Up @@ -115,18 +116,15 @@ std::string curlDownloadKeepName(char const*const url, std::string dst) {

std::string header = Filesystem::readFile("ux0:data/Easy_VPK/head.tmp");

if(header.find("filename=\"") != string::npos) {
if (header.find("filename=\"") != string::npos) {
header = header.substr(header.find("filename=\"")+10);

header = header.substr(0, header.find("\""));
}
else if (header.find("location: ") != string::npos) {
} else if (header.find("location: ") != string::npos) {
header = header.substr(header.find("location: ")+10);
header = header.substr(0, header.find("\n")-1);

while(header.find("/") != string::npos) {
while (header.find("/") != string::npos)
header = header.substr(header.find("/")+1);
}
}

Filesystem::copyFile("ux0:data/Easy_VPK/plugin.tmp", dst+header);
Expand Down
38 changes: 23 additions & 15 deletions src/screens/popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ char *bytes_string;
static CURL *curl_handle = NULL;


static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
{
if (abort_download) return -1;
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) {

if (abort_download)
return -1;

downloaded_bytes += size * nmemb;
return fwrite(ptr, size, nmemb, fh);
}

static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata)
{
static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata) {
if (total_bytes == 0xFFFFFFFF) {
char *ptr = strcasestr(buffer, "Content-Length");
if (ptr != NULL) {
Expand All @@ -81,12 +83,13 @@ static size_t header_cb(char *buffer, size_t size, size_t nitems, void *userdata
abort_download = 1;
}
}

return nitems * size;
}

static char asyncUrl[512];
static void resumeDownload()
{
static void resumeDownload() {
curl_easy_reset(curl_handle);
curl_easy_setopt(curl_handle, CURLOPT_URL, asyncUrl);
curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L);
Expand All @@ -103,11 +106,14 @@ static void resumeDownload()
curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, bytes_string); // Dummy
curl_easy_setopt(curl_handle, CURLOPT_RESUME_FROM, downloaded_bytes);
curl_easy_setopt(curl_handle, CURLOPT_BUFFERSIZE, 524288);

struct curl_slist *headerchunk = NULL;

headerchunk = curl_slist_append(headerchunk, "Accept: */*");
headerchunk = curl_slist_append(headerchunk, "Content-Type: application/json");
headerchunk = curl_slist_append(headerchunk, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
headerchunk = curl_slist_append(headerchunk, "Content-Length: 0");

curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headerchunk);
curl_easy_perform(curl_handle);
}
Expand Down Expand Up @@ -180,7 +186,7 @@ static int downloader_main(unsigned int args, void* arg) {
sprintf(base_dir, dl_dir.c_str());

vita2d_init();
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
vita2d_set_clear_color(RGBA8(0, 0, 0, 255));

pgf = vita2d_load_default_pgf();

Expand Down Expand Up @@ -221,17 +227,16 @@ static int downloader_main(unsigned int args, void* arg) {
launchDownload(d_url.c_str());

if (state > DOWNLOADING) {
//if (state >= FINISHED) vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Press X to exit.");
if (state >= FINISHED) {
if (install_state) vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Finished!\nPress O to exit.");
else vita2d_pgf_draw_textf(pgf, 20, 400, RGBA8(255,255,255,255), 1.0f, "Press X to install. (May take several minutes)\nPress O to Exit");
}

if (state < MISSING)
vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(0,255,0,255), 1.0f, "Pack downloaded successfully! (%.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)]);
vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(0,255,0,255), 1.0f, "Files downloaded successfully! (%.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)]);

if (state < FINISHED) {
vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Extracting pack, please wait!");
vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Extracting files, please wait!");
vita2d_pgf_draw_textf(pgf, 20, 300, RGBA8(255,255,255,255), 1.0f, "File: %lu / %lu", zip_idx, zip_total);
vita2d_pgf_draw_textf(pgf, 20, 320, RGBA8(255,255,255,255), 1.0f, "Filename: %s", fname);
vita2d_pgf_draw_textf(pgf, 20, 340, RGBA8(255,255,255,255), 1.0f, "Filesize: (%.2f %s / %.2f %s)", format(curr_extracted_bytes), sizes[quota(curr_extracted_bytes)], format(file_info.uncompressed_size), sizes[quota(file_info.uncompressed_size)]);
Expand Down Expand Up @@ -262,8 +267,9 @@ static int downloader_main(unsigned int args, void* arg) {
unzGetCurrentFileInfo(zipfile, &file_info, fname, 512, NULL, 0, NULL, 0);
sprintf(filename, "%s%s", base_dir, fname);
const size_t filename_length = strlen(filename);
if (filename[filename_length - 1] == '/') sceIoMkdir(filename, 0777);
else {
if (filename[filename_length - 1] == '/') {
sceIoMkdir(filename, 0777);
} else {
unzOpenCurrentFile(zipfile);
f = fopen(filename, "wb");
extract_started = 1;
Expand Down Expand Up @@ -299,8 +305,10 @@ static int downloader_main(unsigned int args, void* arg) {
} else if (state == ERROR) {
vita2d_pgf_draw_text(pgf, 20, 200, RGBA8(255,0,0,255), 1.0f, "ERROR: Not enough free space on ux0...");
vita2d_pgf_draw_textf(pgf, 20, 220, RGBA8(255,255,255,255), 1.0f, "Please free %.2f %s and restart this core!", format(total_bytes * 2 - free_storage), sizes[quota(total_bytes * 2 - free_storage)]);
} else if (state == FINISHED) vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(0,255,0,255), 1.0f, "Pack extracted succesfully!");
} else vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(255,255,255,255), 1.0f, "Downloading pack, please wait. (%.2f %s / %.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)], format(total_bytes), sizes[quota(total_bytes)]);
} else if (state == FINISHED) {
vita2d_pgf_draw_text(pgf, 20, 220, RGBA8(0,255,0,255), 1.0f, "Files extracted succesfully!");
}
} else vita2d_pgf_draw_textf(pgf, 20, 200, RGBA8(255,255,255,255), 1.0f, "Downloading files, please wait. (%.2f %s / %.2f %s)", format(downloaded_bytes), sizes[quota(downloaded_bytes)], format(total_bytes), sizes[quota(total_bytes)]);

vita2d_end_drawing();
vita2d_swap_buffers();
Expand Down
11 changes: 0 additions & 11 deletions src/utils/vitaPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@
#include <psp2/promoterutil.h>
#include <psp2/sysmodule.h>

#define VHBB_DATA "ux0:/data/VitaHbBrowser"
#define VHBB_RESOURCES "ux0:/app/ESVPK0009/resources"


#define ntohl __builtin_bswap32

#define UPDATER_SRC_EBOOT_PATH VHBB_RESOURCES "/updater/eboot.bin"
#define UPDATER_SRC_SFO_PATH VHBB_RESOURCES "/updater/param.sfo"

#define UPDATER_DST_EBOOT_PATH PACKAGE_TEMP_FOLDER "eboot.bin"
#define UPDATER_DST_SFO_DIR PACKAGE_TEMP_FOLDER "sce_sys/"
#define UPDATER_DST_SFO_PATH PACKAGE_TEMP_FOLDER "sce_sys/param.sfo"

extern unsigned char _binary_assets_head_bin_start;
extern unsigned char _binary_assets_head_bin_size;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/vitaPackage.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VitaPackage{

class UpdaterPackage : private VitaPackage {
public:
UpdaterPackage() : VitaPackage("VHBBUpdater") {};
UpdaterPackage() : VitaPackage("EasyVPKUpdater") {};

int InstallUpdater();
};
Expand Down

0 comments on commit 81588fc

Please sign in to comment.