├── QuickInstallerVITA
├── pkg
│ └── sce_sys
│ │ ├── icon0.png
│ │ └── livearea
│ │ └── contents
│ │ ├── bg.png
│ │ ├── startup.png
│ │ └── template.xml
├── bm.h
├── libpromoter
│ ├── libScePromoterUtil_stub.a
│ ├── Makefile
│ └── promoterutil.h
├── global.h
├── sysmodule_internal.h
├── package_installer.h
├── draw.h
├── sha1.h
├── archive.h
├── sfo.h
├── bm.c
├── Makefile
├── utils.h
├── sfo.c
├── file.h
├── sha1.c
├── utils.c
├── minizip
│ ├── crypt.h
│ ├── ioapi.h
│ ├── zip.h
│ ├── ioapi.c
│ └── unzip.h
├── draw.c
├── base_head_bin.h
├── main.c
├── package_installer.c
├── font.c
├── archive.c
└── file.c
├── QuickInstallerPC
├── Libs
│ └── ICSharpCode.SharpZipLib.dll
├── QuickInstallerPC
│ ├── app.config
│ ├── ZipUtil.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QuickInstallerPC.csproj
│ └── Program.cs
├── Makefile
└── QuickInstallerPC.sln
├── README.md
├── .gitignore
└── LICENSE
/QuickInstallerVITA/pkg/sce_sys/icon0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nunatica/QuickInstaller/HEAD/QuickInstallerVITA/pkg/sce_sys/icon0.png
--------------------------------------------------------------------------------
/QuickInstallerVITA/bm.h:
--------------------------------------------------------------------------------
1 | #ifndef __BM_H__
2 | #define __BM_H__
3 |
4 | char * boyer_moore(const char *haystack, const char *needle);
5 |
6 | #endif
--------------------------------------------------------------------------------
/QuickInstallerPC/Libs/ICSharpCode.SharpZipLib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nunatica/QuickInstaller/HEAD/QuickInstallerPC/Libs/ICSharpCode.SharpZipLib.dll
--------------------------------------------------------------------------------
/QuickInstallerVITA/libpromoter/libScePromoterUtil_stub.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nunatica/QuickInstaller/HEAD/QuickInstallerVITA/libpromoter/libScePromoterUtil_stub.a
--------------------------------------------------------------------------------
/QuickInstallerVITA/pkg/sce_sys/livearea/contents/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nunatica/QuickInstaller/HEAD/QuickInstallerVITA/pkg/sce_sys/livearea/contents/bg.png
--------------------------------------------------------------------------------
/QuickInstallerVITA/pkg/sce_sys/livearea/contents/startup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nunatica/QuickInstaller/HEAD/QuickInstallerVITA/pkg/sce_sys/livearea/contents/startup.png
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/global.h:
--------------------------------------------------------------------------------
1 | #ifndef __GLOBAL_H__
2 | #define __GLOBAL_H__
3 |
4 | #define HOME_PATH "home"
5 | #define DIR_UP ".."
6 |
7 | #define BIG_BUFFER_SIZE 16 * 1024 * 1024
8 | #define SCE_ERROR_ERRNO_EEXIST 0x80010011
9 |
10 | #define MIN(p, q) (p < q ? p : q)
11 | #define MAX(p, q) (p > q ? p : q)
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/libpromoter/Makefile:
--------------------------------------------------------------------------------
1 | TARGET_LIB=libScePromoterUtil_stub.a
2 |
3 | $(TARGET_LIB): promoterutil.json
4 | -rm -rf build_lib
5 | mkdir build_lib
6 | vita-libs-gen $< build_lib
7 | cd build_lib && make
8 | mv build_lib/$(TARGET_LIB) $(TARGET_LIB)
9 | rm -rf build_lib
10 |
11 | clean:
12 | rm $(TARGET_LIB)
13 |
--------------------------------------------------------------------------------
/QuickInstallerPC/Makefile:
--------------------------------------------------------------------------------
1 | NAME := QuickInstallerPC
2 |
3 | TK_COMMA:= ,
4 | TK_EMPTY:=
5 | TK_SPACE:= $(TK_EMPTY) $(TK_EMPTY)
6 |
7 | SHELL := /bin/bash
8 | CSC := mcs
9 | SRC_FILES := $(wildcard QuickInstallerPC/*.cs)
10 | LIB_FILES := $(wildcard Libs/*.dll)
11 | LIB_FILES += System System.Core
12 | LIB_FILES_LINK := $(subst $(TK_SPACE),$(TK_COMMA),$(LIB_FILES))
13 |
14 | all: $(SRC_FILES)
15 | $(CSC) -out:$(NAME).exe -sdk:4.5 -warn:4 -r:$(LIB_FILES_LINK) $(SRC_FILES)
16 |
17 | .PHONY: clean
18 |
19 | clean:
20 | rm -f $(NAME).exe
21 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/libpromoter/promoterutil.h:
--------------------------------------------------------------------------------
1 | #ifndef _PSP2_PROMOTERUTIL_H_
2 | #define _PSP2_PROMOTERUTIL_H_
3 |
4 | #include
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef struct ScePromoterUtilityLAUpdate {
11 | char titleid[12]; // target app
12 | char path[128]; // directory of extracted LA update data
13 | } ScePromoterUtilityLAUpdate;
14 |
15 | int scePromoterUtilityInit(void);
16 | int scePromoterUtilityExit(void);
17 | int scePromoterUtilityDeletePkg(void *unk);
18 | int scePromoterUtilityUpdateLiveArea(ScePromoterUtilityLAUpdate *args);
19 | int scePromoterUtilityPromotePkg(char *path, int unk);
20 | int scePromoterUtilityPromotePkgWithRif(const char *path, int unk);
21 | int scePromoterUtilityGetState(int *state);
22 | int scePromoterUtilityGetResult(int *res);
23 |
24 | #ifdef __cplusplus
25 | }
26 | #endif
27 |
28 | #endif /* _PSP2_PROMOTERUTIL_H_ */
--------------------------------------------------------------------------------
/QuickInstallerVITA/sysmodule_internal.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief Header file which defines system modules related variables and functions
4 | *
5 | * Copyright (C) 2015 PSP2SDK Project
6 | *
7 | * This Source Code Form is subject to the terms of the Mozilla Public
8 | * License, v. 2.0. If a copy of the MPL was not distributed with this
9 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 | */
11 |
12 | #ifndef _PSP2_SYSMODULE_INTERNAL_H_
13 | #define _PSP2_SYSMODULE_INTERNAL_H_
14 |
15 | #include
16 | #include
17 |
18 | #ifdef __cplusplus
19 | extern "C" {
20 | #endif
21 |
22 | /* module IDs */
23 | enum {
24 | SCE_SYSMODULE_PROMOTER_UTIL = 0x80000024
25 | };
26 |
27 | int sceSysmoduleLoadModuleInternal(SceUInt32 id);
28 | int sceSysmoduleUnloadModuleInternal(SceUInt32 id);
29 | int sceSysmoduleIsLoadedInternal(SceUInt32 id);
30 | int sceSysmoduleLoadModuleInternalWithArg(uint32_t, size_t, uint32_t*, uint32_t*);
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 | #endif /* _PSP2_SYSMODULE_INTERNAL_H_ */
37 |
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickInstallerPC", "QuickInstallerPC\QuickInstallerPC.csproj", "{DDEFE6FD-E6C0-466B-89B4-260781990579}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {DDEFE6FD-E6C0-466B-89B4-260781990579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {DDEFE6FD-E6C0-466B-89B4-260781990579}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {DDEFE6FD-E6C0-466B-89B4-260781990579}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {DDEFE6FD-E6C0-466B-89B4-260781990579}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/pkg/sce_sys/livearea/contents/template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | bg.png
6 |
7 |
8 |
9 | startup.png
10 |
11 |
12 |
13 |
14 |
15 | VitaShell
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | by TheFloW
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | v0.95
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/package_installer.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __PACKAGE_INSTALLER_H__
20 | #define __PACKAGE_INSTALLER_H__
21 |
22 | #define ntohl __builtin_bswap32
23 |
24 | #define PACKAGE_PARENT "ux0:ptmp"
25 | #define PACKAGE_DIR PACKAGE_PARENT "/pkg"
26 | #define HEAD_BIN PACKAGE_DIR "/sce_sys/package/head.bin"
27 |
28 | #include "archive.h"
29 |
30 | int promote(char *path);
31 | int makeHeadBin();
32 |
33 | int installPackage(char *file, FileProcessParam* param);
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/draw.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 Sergi Granell (xerpi)
3 | */
4 |
5 | #ifndef DRAW_H
6 | #define DRAW_H
7 |
8 | #include
9 |
10 | #define RGBA8(r, g, b, a) ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0))
11 |
12 | #define SCREEN_W 960
13 | #define SCREEN_H 544
14 |
15 | #define RED RGBA8(255, 0, 0, 255)
16 | #define GREEN RGBA8(0, 255, 0, 255)
17 | #define BLUE RGBA8(0, 0, 255, 255)
18 | #define CYAN RGBA8(0, 255, 255, 255)
19 | #define LIME RGBA8(50, 205, 50, 255)
20 | #define PURP RGBA8(147, 112, 219, 255)
21 | #define WHITE RGBA8(255, 255, 255, 255)
22 | #define BLACK RGBA8(0, 0, 0, 255)
23 |
24 | void init_video();
25 | void end_video();
26 | void swap_buffers();
27 | void clear_screen();
28 | void draw_pixel(uint32_t x, uint32_t y, uint32_t color);
29 | void draw_rectangle(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color);
30 | void draw_circle(uint32_t x, uint32_t y, uint32_t radius, uint32_t color);
31 |
32 | void font_draw_char(int x, int y, uint32_t color, char c);
33 | void font_draw_string(int x, int y, uint32_t color, const char *string);
34 | void font_draw_stringf(int x, int y, uint32_t color, const char *s, ...);
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QuickInstaller
2 | QuickInstaller is simple ps vita tool which let you install vpk via qcma.
3 |
4 | ## Requirements ##
5 | - Windows & .NET Framework 4.5 or above. (OS X and Linux are not officialy supported yet. feel free to test via mono.)
6 | - QCMA https://codestation.github.io/qcma/
7 |
8 | ## Instructions ##
9 | - Create a directory named WHATEVER.
10 | - Extract QuickInstaller to WHATEVER.
11 | - Turn on VitaShell.
12 | - Copy and Install QuickInstaller.vpk on your ps vita.
13 | - Create a directory named 'vpk' in WHATEVER.
14 | - Put vpks into 'vpk' directory.
15 | - Run QuickInstallerPC.exe
16 | - Turn on QCMA.
17 | - Open settings and set video folder as WHATEVER/mp4.
18 | - Refresh QCMA database.
19 | - Plug cable and connect.
20 | - Run cma app and copy mp4 files to ps vita.
21 | - Run QuickInstaller app.
22 | - Wait for 'done.' is showing up. (or fail)
23 |
24 | ## Known Issues ##
25 | - Mai dumps are not supported yet.
26 | - Can be slow if vpk contains a lot of small files.
27 |
28 | ## Trouble shooting ##
29 | - Failed to convert vpk to mp4: extract manually and put directory into 'vpk' instead of vpk file.
30 | - Failed to copy mp4 files: remove every directories in ux0:video and try again.
31 | - Failed to install package: content might be broken.
32 |
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC/ZipUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Threading;
7 | using ICSharpCode.SharpZipLib.Zip;
8 |
9 | namespace LocalLib
10 | {
11 | static class ZipUtil
12 | {
13 | static readonly FastZip handle;
14 |
15 | static ZipUtil ()
16 | {
17 | handle = new FastZip();
18 | handle.CompressionMethod = CompressionMethod.Stored;
19 | }
20 |
21 | #if false
22 | public static void ExtractToDirectory(string zip, string dir)
23 | {
24 | ZipFile.ExtractToDirectory(zip, dir, Encoding.UTF8);
25 | }
26 |
27 | public static void CreateFromDirectory(string dir, string zip)
28 | {
29 | ZipFile.CreateFromDirectory(dir, zip, CompressionLevel.Fastest, false, Encoding.UTF8);
30 | }
31 | #endif
32 |
33 | public static void ExtractToDirectory(string zip, string dir)
34 | {
35 | handle.ExtractZip(zip, dir, null);
36 | }
37 |
38 | public static void CreateFromDirectory(string dir, string zip)
39 | {
40 | handle.CreateZip(zip, dir, true, null);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/QuickInstallerVITA/sha1.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Filename: sha1.h
3 | * Author: Brad Conte (brad AT bradconte.com)
4 | * Copyright:
5 | * Disclaimer: This code is presented "as is" without any guarantees.
6 | * Details: Defines the API for the corresponding SHA1 implementation.
7 | *********************************************************************/
8 |
9 | #ifndef SHA1_H
10 | #define SHA1_H
11 |
12 | /*************************** HEADER FILES ***************************/
13 | #include
14 | #include
15 |
16 | /****************************** MACROS ******************************/
17 | #define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest
18 |
19 | /**************************** DATA TYPES ****************************/
20 | typedef uint8_t BYTE; // 8-bit byte
21 | typedef uint32_t WORD; // 32-bit word, change to "long" for 16-bit machines
22 |
23 | typedef struct {
24 | BYTE data[64];
25 | WORD datalen;
26 | unsigned long long bitlen;
27 | WORD state[5];
28 | WORD k[4];
29 | } SHA1_CTX;
30 |
31 | /*********************** FUNCTION DECLARATIONS **********************/
32 | void sha1_init(SHA1_CTX *ctx);
33 | void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len);
34 | void sha1_final(SHA1_CTX *ctx, BYTE hash[]);
35 |
36 | #endif // SHA1_H
37 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/archive.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __ARCHIVE_H__
20 | #define __ARCHIVE_H__
21 |
22 | #include "file.h"
23 |
24 | #include
25 |
26 | #define ARCHIVE_FD 0x12345678
27 |
28 | int fileListGetArchiveEntries(FileList *list, char *path);
29 |
30 | int getArchivePathInfo(char *path, uint64_t *size, uint32_t *folders, uint32_t *files);
31 | int extractArchivePath(char *src, char *dst, FileProcessParam *param);
32 |
33 | int archiveFileGetstat(const char *file, SceIoStat *stat);
34 | int archiveFileOpen(const char *file, int flags, SceMode mode);
35 | int archiveFileRead(SceUID fd, void *data, SceSize size);
36 | int archiveFileClose(SceUID fd);
37 |
38 | int ReadArchiveFile(char *file, void *buf, int size);
39 |
40 | int archiveClose();
41 | int archiveOpen(char *file);
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("QuickInstallerPC")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("QuickInstallerPC")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ddefe6fd-e6c0-466b-89b4-260781990579")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/sfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 |
20 | #ifndef __SFO_H__
21 | #define __SFO_H__
22 |
23 | #define SFO_MAGIC 0x46535000
24 |
25 | #define PSF_TYPE_BIN 0
26 | #define PSF_TYPE_STR 2
27 | #define PSF_TYPE_VAL 4
28 |
29 | typedef struct SfoHeader {
30 | uint32_t magic;
31 | uint32_t version;
32 | uint32_t keyofs;
33 | uint32_t valofs;
34 | uint32_t count;
35 | } __attribute__((packed)) SfoHeader;
36 |
37 | typedef struct SfoEntry {
38 | uint16_t nameofs;
39 | uint8_t alignment;
40 | uint8_t type;
41 | uint32_t valsize;
42 | uint32_t totalsize;
43 | uint32_t dataofs;
44 | } __attribute__((packed)) SfoEntry;
45 |
46 | int getSfoValue(void *buffer, char *name, uint32_t *value);
47 | int getSfoString(void *buffer, char *name, char *string, int length);
48 | int setSfoValue(void *buffer, char *name, uint32_t value);
49 | int setSfoString(void *buffer, char *name, char *string);
50 |
51 | int SFOReader(char *file);
52 |
53 | #endif
--------------------------------------------------------------------------------
/QuickInstallerVITA/bm.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | const char * boyer_moore(const char *haystack, const char *needle) {
8 | size_t plen = strlen(needle), slen = strlen(haystack);
9 |
10 | if (plen > slen) {
11 | return NULL;
12 | }
13 |
14 | int skip[UCHAR_MAX+1];
15 | int i, j, k, * next;
16 |
17 | /* calc skip table („bad rule“) */
18 | for (i = 0; i <= UCHAR_MAX; i++) {
19 | skip[i] = plen;
20 | }
21 |
22 | for (i = 0; i < plen; i++) {
23 | skip[tolower((unsigned char)needle[i])] = plen - i - 1;
24 | }
25 |
26 |
27 | /* calc next table („good rule“) */
28 | next = (int*)malloc((plen+1) * sizeof(int));
29 |
30 | for (j = 0; j <= plen; j++) {
31 | for (i = plen - 1; i >= 1; i--) {
32 | for (k = 1; k <= j; k++) {
33 | if (i - k < 0) {
34 | break;
35 | }
36 | if (tolower((unsigned char)needle[plen - k]) != tolower((unsigned char)needle[i - k])) {
37 | goto nexttry;
38 | }
39 | }
40 | goto matched;
41 | nexttry:
42 | ;
43 | }
44 | matched:
45 | next[j] = plen - i;
46 | }
47 |
48 | plen--;
49 | i = plen; /* position of last p letter in s */
50 |
51 | while (i < slen) {
52 | j = 0; /* matched letter count */
53 | while (j <= plen) {
54 | if (tolower((unsigned char)haystack[i - j]) == tolower((unsigned char)needle[plen - j])) {
55 | j++;
56 | } else {
57 | i += skip[tolower((unsigned char)haystack[i - j])] > next[j] ? skip[tolower((unsigned char)haystack[i - j])] - j : next[j];
58 | goto newi;
59 | }
60 | }
61 | free(next);
62 | return haystack + i - plen;
63 | newi:
64 | ;
65 | }
66 | free(next);
67 | return NULL;
68 | }
--------------------------------------------------------------------------------
/QuickInstallerVITA/Makefile:
--------------------------------------------------------------------------------
1 | TITLE_ID = QUICKINST
2 | TARGET = QuickInstaller
3 | OBJS = main.o draw.o font.o bm.o utils.o file.o archive.o sha1.o sfo.o \
4 | package_installer.o \
5 | minizip/zip.o minizip/unzip.o minizip/ioapi.o
6 |
7 | LIBS = -lvita2d -lpng -ljpeg -lz -lm -lc \
8 | -lSceAppMgr_stub -lSceAppUtil_stub -lSceCommonDialog_stub \
9 | -lSceCtrl_stub -lSceDisplay_stub -lSceGxm_stub -lSceIme_stub \
10 | -lSceHttp_stub -lSceKernel_stub -lSceNet_stub -lSceNetCtl_stub \
11 | -lSceSsl_stub -lSceSysmodule_stub -lScePower_stub -lScePgf_stub \
12 | libpromoter/libScePromoterUtil_stub.a
13 |
14 | PREFIX = arm-vita-eabi
15 | CC = $(PREFIX)-gcc
16 | CXX = $(PREFIX)-g++
17 | CFLAGS = -Wl,-q -Wall -O3 -Wno-unused-variable -Wno-unused-but-set-variable -std=c11
18 | CXXFLAGS = $(CFLAGS) -std=c++11 -fno-rtti -fno-exceptions
19 | ASFLAGS = $(CFLAGS)
20 |
21 | all: $(TARGET).vpk
22 |
23 | %.vpk: eboot.bin
24 | vita-mksfoex -d PARENTAL_LEVEL=1 -s APP_VER=01.00 -s TITLE_ID=$(TITLE_ID) "$(TARGET)" param.sfo
25 | vita-pack-vpk -s param.sfo -b eboot.bin \
26 | --add pkg/sce_sys/icon0.png=sce_sys/icon0.png \
27 | --add pkg/sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \
28 | --add pkg/sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \
29 | --add pkg/sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
30 | $(TARGET).vpk
31 |
32 | eboot.bin: $(TARGET).velf
33 | vita-make-fself $< $@
34 |
35 | %.velf: %.elf
36 | vita-elf-create $< $@ localdb.json
37 |
38 | $(TARGET).elf: $(OBJS)
39 | $(CC) $(CFLAGS) $^ $(LIBS) -o $@
40 |
41 | %.o: %.png
42 | $(PREFIX)-ld -r -b binary -o $@ $^
43 | %.o: %.txt
44 | $(PREFIX)-ld -r -b binary -o $@ $^
45 | %.o: %.bin
46 | $(PREFIX)-ld -r -b binary -o $@ $^
47 |
48 | sfo:
49 | vita-mksfoex -d PARENTAL_LEVEL=1 -s APP_VER=01.00 -s TITLE_ID=$(TITLE_ID) "$(TARGET)" param.sfo
50 |
51 | clean:
52 | @rm -rf $(TARGET).vpk $(TARGET).velf $(TARGET).elf $(OBJS) \
53 | eboot.bin param.sfo
54 |
55 | vpksend: $(TARGET).vpk
56 | curl -T $(TARGET).vpk ftp://$(PSVITAIP):1337/ux0:/
57 | @echo "Sent."
58 |
59 | send: eboot.bin
60 | curl -T eboot.bin ftp://$(PSVITAIP):1337/ux0:/app/$(TITLE_ID)/
61 | @echo "Sent."
62 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __UTILS_H__
20 | #define __UTILS_H__
21 |
22 | #include
23 |
24 | #define align_mem(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
25 | #define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10)
26 | //#define abs(x) ((x) < 0 ? (-x) : (x))
27 |
28 | #define ALIGN_CENTER(a, b) ((a - b) / 2)
29 | #define ALIGN_LEFT(x, w) (x - w)
30 |
31 | #define ANALOG_CENTER 128
32 | #define ANALOG_THRESHOLD 64
33 | #define ANALOG_SENSITIVITY 16
34 |
35 | enum {
36 | SCE_CTRL_RIGHT_ANALOG_UP = 0x0020000,
37 | SCE_CTRL_RIGHT_ANALOG_RIGHT = 0x0040000,
38 | SCE_CTRL_RIGHT_ANALOG_DOWN = 0x0080000,
39 | SCE_CTRL_RIGHT_ANALOG_LEFT = 0x0100000,
40 |
41 | SCE_CTRL_LEFT_ANALOG_UP = 0x0200000,
42 | SCE_CTRL_LEFT_ANALOG_RIGHT = 0x0400000,
43 | SCE_CTRL_LEFT_ANALOG_DOWN = 0x0800000,
44 | SCE_CTRL_LEFT_ANALOG_LEFT = 0x1000000,
45 | /*
46 | SCE_CTRL_ENTER = 0x2000000,
47 | SCE_CTRL_CANCEL = 0x4000000,
48 | */
49 | };
50 |
51 | extern SceCtrlData pad;
52 | extern uint32_t old_buttons, current_buttons, pressed_buttons, hold_buttons, hold2_buttons, released_buttons;
53 |
54 | void initPowerTickThread();
55 | void powerLock();
56 | void powerUnlock();
57 |
58 | void readPad();
59 | int holdButtons(SceCtrlData *pad, uint32_t buttons, uint64_t time);
60 |
61 | int hasEndSlash(char *path);
62 | int removeEndSlash(char *path);
63 | int addEndSlash(char *path);
64 |
65 | void getSizeString(char *string, uint64_t size);
66 | void getDateString(char *string, int date_format, SceDateTime *time);
67 | void getTimeString(char *string, int time_format, SceDateTime *time);
68 |
69 | int randomNumber(int low, int high);
70 |
71 | int debugPrintf(char *text, ...);
72 |
73 | int launchAppByUriExit(char *titleid);
74 |
75 | char *strcasestr(const char *haystack, const char *needle);
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/sfo.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "global.h"
23 | #include "archive.h"
24 | #include "file.h"
25 | #include "utils.h"
26 | #include "sfo.h"
27 |
28 | int getSfoValue(void *buffer, char *name, uint32_t *value) {
29 | SfoHeader *header = (SfoHeader *)buffer;
30 | SfoEntry *entries = (SfoEntry *)((uint32_t)buffer + sizeof(SfoHeader));
31 |
32 | if (header->magic != SFO_MAGIC)
33 | return -1;
34 |
35 | int i;
36 | for (i = 0; i < header->count; i++) {
37 | if (strcmp(buffer + header->keyofs + entries[i].nameofs, name) == 0) {
38 | *value = *(uint32_t *)(buffer + header->valofs + entries[i].dataofs);
39 | return 0;
40 | }
41 | }
42 |
43 | return -2;
44 | }
45 |
46 | int getSfoString(void *buffer, char *name, char *string, int length) {
47 | SfoHeader *header = (SfoHeader *)buffer;
48 | SfoEntry *entries = (SfoEntry *)((uint32_t)buffer + sizeof(SfoHeader));
49 |
50 | if (header->magic != SFO_MAGIC)
51 | return -1;
52 |
53 | int i;
54 | for (i = 0; i < header->count; i++) {
55 | if (strcmp(buffer + header->keyofs + entries[i].nameofs, name) == 0) {
56 | memset(string, 0, length);
57 | strncpy(string, buffer + header->valofs + entries[i].dataofs, length);
58 | string[length - 1] = '\0';
59 | return 0;
60 | }
61 | }
62 |
63 | return -2;
64 | }
65 |
66 | int setSfoValue(void *buffer, char *name, uint32_t value) {
67 | SfoHeader *header = (SfoHeader *)buffer;
68 | SfoEntry *entries = (SfoEntry *)((uint32_t)buffer + sizeof(SfoHeader));
69 |
70 | if (header->magic != SFO_MAGIC)
71 | return -1;
72 |
73 | int i;
74 | for (i = 0; i < header->count; i++) {
75 | if (strcmp(buffer + header->keyofs + entries[i].nameofs, name) == 0) {
76 | *(uint32_t *)(buffer + header->valofs + entries[i].dataofs) = value;
77 | return 0;
78 | }
79 | }
80 |
81 | return -2;
82 | }
83 |
84 | int setSfoString(void *buffer, char *name, char *string) {
85 | SfoHeader *header = (SfoHeader *)buffer;
86 | SfoEntry *entries = (SfoEntry *)((uint32_t)buffer + sizeof(SfoHeader));
87 |
88 | if (header->magic != SFO_MAGIC)
89 | return -1;
90 |
91 | int i;
92 | for (i = 0; i < header->count; i++) {
93 | if (strcmp(buffer + header->keyofs + entries[i].nameofs, name) == 0) {
94 | strcpy(buffer + header->valofs + entries[i].dataofs, string);
95 | return 0;
96 | }
97 | }
98 |
99 | return -2;
100 | }
101 |
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC/QuickInstallerPC.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DDEFE6FD-E6C0-466B-89B4-260781990579}
8 | Exe
9 | Properties
10 | QuickInstallerPC
11 | QuickInstallerPC
12 | v4.5
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 | False
40 | ..\Libs\ICSharpCode.SharpZipLib.dll
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/file.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __FILE_H__
20 | #define __FILE_H__
21 |
22 | #include
23 |
24 | #include
25 |
26 | #define MAX_PATH_LENGTH 1024
27 | #define MAX_NAME_LENGTH 256
28 | #define MAX_SHORT_NAME_LENGTH 64
29 | #define MAX_MOUNT_POINT_LENGTH 16
30 |
31 | #define TRANSFER_SIZE 64 * 1024
32 |
33 | enum FileTypes {
34 | FILE_TYPE_UNKNOWN,
35 | FILE_TYPE_BMP,
36 | FILE_TYPE_INI,
37 | FILE_TYPE_JPEG,
38 | FILE_TYPE_MP3,
39 | FILE_TYPE_PNG,
40 | FILE_TYPE_SFO,
41 | FILE_TYPE_TXT,
42 | FILE_TYPE_VPK,
43 | FILE_TYPE_XML,
44 | FILE_TYPE_ZIP,
45 | };
46 |
47 | enum FileSortFlags {
48 | SORT_NONE,
49 | SORT_BY_NAME_AND_FOLDER,
50 | };
51 |
52 | enum FileMoveFlags {
53 | MOVE_INTEGRATE = 0x1, // Integrate directories
54 | MOVE_REPLACE = 0x2, // Replace files
55 | };
56 |
57 | typedef struct {
58 | uint64_t *value;
59 | uint64_t max;
60 | void (* SetProgress)(uint64_t value, uint64_t max);
61 | int (* cancelHandler)();
62 | } FileProcessParam;
63 |
64 | typedef struct FileListEntry {
65 | struct FileListEntry *next;
66 | struct FileListEntry *previous;
67 | char name[MAX_NAME_LENGTH];
68 | int name_length;
69 | int is_folder;
70 | int type;
71 | SceOff size;
72 | SceDateTime time;
73 | int reserved[16];
74 | } FileListEntry;
75 |
76 | typedef struct {
77 | FileListEntry *head;
78 | FileListEntry *tail;
79 | int length;
80 | char path[MAX_PATH_LENGTH];
81 | int files;
82 | int folders;
83 | } FileList;
84 |
85 | int allocateReadFile(char *file, void **buffer);
86 | int ReadFile(char *file, void *buf, int size);
87 | int WriteFile(char *file, void *buf, int size);
88 |
89 | int getFileSize(char *pInputFileName);
90 | int getFileSha1(char *pInputFileName, uint8_t *pSha1Out, FileProcessParam *param);
91 | int getPathInfo(char *path, uint64_t *size, uint32_t *folders, uint32_t *files);
92 | int removePath(char *path, FileProcessParam *param);
93 | int copyFile(char *src_path, char *dst_path, FileProcessParam *param);
94 | int copyPath(char *src_path, char *dst_path, FileProcessParam *param);
95 | int movePath(char *src_path, char *dst_path, int flags, FileProcessParam *param);
96 |
97 | int getFileType(char *file);
98 |
99 | int getNumberMountPoints();
100 | char **getMountPoints();
101 |
102 | FileListEntry *fileListFindEntry(FileList *list, char *name);
103 | FileListEntry *fileListGetNthEntry(FileList *list, int n);
104 | int fileListGetNumberByName(FileList *list, char *name);
105 |
106 | void fileListAddEntry(FileList *list, FileListEntry *entry, int sort);
107 | int fileListRemoveEntry(FileList *list, FileListEntry *entry);
108 | int fileListRemoveEntryByName(FileList *list, char *name);
109 |
110 | void fileListEmpty(FileList *list);
111 |
112 | int fileListGetEntries(FileList *list, char *path);
113 |
114 | #endif
115 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/sha1.c:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Filename: sha1.c
3 | * Author: Brad Conte (brad AT bradconte.com)
4 | * Copyright:
5 | * Disclaimer: This code is presented "as is" without any guarantees.
6 | * Details: Implementation of the SHA1 hashing algorithm.
7 | Algorithm specification can be found here:
8 | * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
9 | This implementation uses little endian byte order.
10 | *********************************************************************/
11 |
12 | /*************************** HEADER FILES ***************************/
13 | #include
14 | #include
15 | #include "sha1.h"
16 |
17 | /****************************** MACROS ******************************/
18 | #define ROTLEFT(a, b) ((a << b) | (a >> (32 - b)))
19 |
20 | /*********************** FUNCTION DEFINITIONS ***********************/
21 | void sha1_transform(SHA1_CTX *ctx, const BYTE data[])
22 | {
23 | WORD a, b, c, d, e, i, j, t, m[80];
24 |
25 | for (i = 0, j = 0; i < 16; ++i, j += 4)
26 | m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]);
27 | for ( ; i < 80; ++i) {
28 | m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]);
29 | m[i] = (m[i] << 1) | (m[i] >> 31);
30 | }
31 |
32 | a = ctx->state[0];
33 | b = ctx->state[1];
34 | c = ctx->state[2];
35 | d = ctx->state[3];
36 | e = ctx->state[4];
37 |
38 | for (i = 0; i < 20; ++i) {
39 | t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i];
40 | e = d;
41 | d = c;
42 | c = ROTLEFT(b, 30);
43 | b = a;
44 | a = t;
45 | }
46 | for ( ; i < 40; ++i) {
47 | t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i];
48 | e = d;
49 | d = c;
50 | c = ROTLEFT(b, 30);
51 | b = a;
52 | a = t;
53 | }
54 | for ( ; i < 60; ++i) {
55 | t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d)) + e + ctx->k[2] + m[i];
56 | e = d;
57 | d = c;
58 | c = ROTLEFT(b, 30);
59 | b = a;
60 | a = t;
61 | }
62 | for ( ; i < 80; ++i) {
63 | t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i];
64 | e = d;
65 | d = c;
66 | c = ROTLEFT(b, 30);
67 | b = a;
68 | a = t;
69 | }
70 |
71 | ctx->state[0] += a;
72 | ctx->state[1] += b;
73 | ctx->state[2] += c;
74 | ctx->state[3] += d;
75 | ctx->state[4] += e;
76 | }
77 |
78 | void sha1_init(SHA1_CTX *ctx)
79 | {
80 | ctx->datalen = 0;
81 | ctx->bitlen = 0;
82 | ctx->state[0] = 0x67452301;
83 | ctx->state[1] = 0xEFCDAB89;
84 | ctx->state[2] = 0x98BADCFE;
85 | ctx->state[3] = 0x10325476;
86 | ctx->state[4] = 0xc3d2e1f0;
87 | ctx->k[0] = 0x5a827999;
88 | ctx->k[1] = 0x6ed9eba1;
89 | ctx->k[2] = 0x8f1bbcdc;
90 | ctx->k[3] = 0xca62c1d6;
91 | }
92 |
93 | void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len)
94 | {
95 | size_t i;
96 |
97 | for (i = 0; i < len; ++i) {
98 | ctx->data[ctx->datalen] = data[i];
99 | ctx->datalen++;
100 | if (ctx->datalen == 64) {
101 | sha1_transform(ctx, ctx->data);
102 | ctx->bitlen += 512;
103 | ctx->datalen = 0;
104 | }
105 | }
106 | }
107 |
108 | void sha1_final(SHA1_CTX *ctx, BYTE hash[])
109 | {
110 | WORD i;
111 |
112 | i = ctx->datalen;
113 |
114 | // Pad whatever data is left in the buffer.
115 | if (ctx->datalen < 56) {
116 | ctx->data[i++] = 0x80;
117 | while (i < 56)
118 | ctx->data[i++] = 0x00;
119 | }
120 | else {
121 | ctx->data[i++] = 0x80;
122 | while (i < 64)
123 | ctx->data[i++] = 0x00;
124 | sha1_transform(ctx, ctx->data);
125 | memset(ctx->data, 0, 56);
126 | }
127 |
128 | // Append to the padding the total message's length in bits and transform.
129 | ctx->bitlen += ctx->datalen * 8;
130 | ctx->data[63] = ctx->bitlen;
131 | ctx->data[62] = ctx->bitlen >> 8;
132 | ctx->data[61] = ctx->bitlen >> 16;
133 | ctx->data[60] = ctx->bitlen >> 24;
134 | ctx->data[59] = ctx->bitlen >> 32;
135 | ctx->data[58] = ctx->bitlen >> 40;
136 | ctx->data[57] = ctx->bitlen >> 48;
137 | ctx->data[56] = ctx->bitlen >> 56;
138 | sha1_transform(ctx, ctx->data);
139 |
140 | // Since this implementation uses little endian byte ordering and MD uses big endian,
141 | // reverse all the bytes when copying the final state to the output hash.
142 | for (i = 0; i < 4; ++i) {
143 | hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
144 | hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
145 | hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
146 | hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
147 | hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/utils.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include "file.h"
20 | #include "utils.h"
21 | #include "bm.h"
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include
28 | #include
29 |
30 | SceCtrlData pad;
31 | uint32_t old_buttons, current_buttons, pressed_buttons, hold_buttons, hold2_buttons, released_buttons;
32 |
33 | static int netdbg_sock = -1;
34 | static void *net_memory = NULL;
35 | static int net_init = -1;
36 |
37 | static int lock_power = 0;
38 |
39 | static uint64_t wallpaper_time_start = 0;
40 | static int wallpaper_random_delay = 0;
41 | static float wallpaper_alpha = 255.0f;
42 |
43 | int power_tick_thread(SceSize args, void *argp) {
44 | while (1) {
45 | if (lock_power > 0) {
46 | sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND);
47 | }
48 |
49 | sceKernelDelayThread(10 * 1000 * 1000);
50 | }
51 |
52 | return 0;
53 | }
54 |
55 | void initPowerTickThread() {
56 | SceUID thid = sceKernelCreateThread("power_tick_thread", power_tick_thread, 0x10000100, 0x40000, 0, 0, NULL);
57 | if (thid >= 0)
58 | sceKernelStartThread(thid, 0, NULL);
59 | }
60 |
61 | void powerLock() {
62 | lock_power++;
63 | }
64 |
65 | void powerUnlock() {
66 | lock_power--;
67 | if (lock_power < 0) lock_power = 0;
68 | }
69 |
70 | void readPad() {
71 | static int hold_n = 0, hold2_n = 0;
72 |
73 | memset(&pad, 0, sizeof(SceCtrlData));
74 | sceCtrlPeekBufferPositive(0, &pad, 1);
75 |
76 | if (pad.ly < ANALOG_CENTER - ANALOG_THRESHOLD) {
77 | pad.buttons |= SCE_CTRL_LEFT_ANALOG_UP;
78 | } else if (pad.ly > ANALOG_CENTER + ANALOG_THRESHOLD) {
79 | pad.buttons |= SCE_CTRL_LEFT_ANALOG_DOWN;
80 | }
81 |
82 | if (pad.lx < ANALOG_CENTER - ANALOG_THRESHOLD) {
83 | pad.buttons |= SCE_CTRL_LEFT_ANALOG_LEFT;
84 | } else if (pad.lx > ANALOG_CENTER + ANALOG_THRESHOLD) {
85 | pad.buttons |= SCE_CTRL_LEFT_ANALOG_RIGHT;
86 | }
87 |
88 | if (pad.ry < ANALOG_CENTER - ANALOG_THRESHOLD) {
89 | pad.buttons |= SCE_CTRL_RIGHT_ANALOG_UP;
90 | } else if (pad.ry > ANALOG_CENTER + ANALOG_THRESHOLD) {
91 | pad.buttons |= SCE_CTRL_RIGHT_ANALOG_DOWN;
92 | }
93 |
94 | if (pad.rx < ANALOG_CENTER - ANALOG_THRESHOLD) {
95 | pad.buttons |= SCE_CTRL_RIGHT_ANALOG_LEFT;
96 | } else if (pad.rx > ANALOG_CENTER + ANALOG_THRESHOLD) {
97 | pad.buttons |= SCE_CTRL_RIGHT_ANALOG_RIGHT;
98 | }
99 |
100 | current_buttons = pad.buttons;
101 | pressed_buttons = current_buttons & ~old_buttons;
102 | hold_buttons = pressed_buttons;
103 | hold2_buttons = pressed_buttons;
104 | released_buttons = ~current_buttons & old_buttons;
105 |
106 | if (old_buttons == current_buttons) {
107 | hold_n++;
108 | if (hold_n >= 10) {
109 | hold_buttons = current_buttons;
110 | hold_n = 6;
111 | }
112 |
113 | hold2_n++;
114 | if (hold2_n >= 10) {
115 | hold2_buttons = current_buttons;
116 | hold2_n = 10;
117 | }
118 | } else {
119 | hold_n = 0;
120 | hold2_n = 0;
121 | old_buttons = current_buttons;
122 | }
123 | }
124 |
125 | int holdButtons(SceCtrlData *pad, uint32_t buttons, uint64_t time) {
126 | if ((pad->buttons & buttons) == buttons) {
127 | uint64_t time_start = sceKernelGetProcessTimeWide();
128 |
129 | while ((pad->buttons & buttons) == buttons) {
130 | sceKernelDelayThread(10 * 1000);
131 | sceCtrlPeekBufferPositive(0, pad, 1);
132 |
133 | if ((sceKernelGetProcessTimeWide() - time_start) >= time) {
134 | return 1;
135 | }
136 | }
137 | }
138 |
139 | return 0;
140 | }
141 |
142 | int hasEndSlash(char *path) {
143 | return path[strlen(path) - 1] == '/';
144 | }
145 |
146 | int removeEndSlash(char *path) {
147 | int len = strlen(path);
148 |
149 | if (path[len - 1] == '/') {
150 | path[len - 1] = '\0';
151 | return 1;
152 | }
153 |
154 | return 0;
155 | }
156 |
157 | int addEndSlash(char *path) {
158 | int len = strlen(path);
159 | if (len < MAX_PATH_LENGTH - 2) {
160 | if (path[len - 1] != '/') {
161 | strcat(path, "/");
162 | return 1;
163 | }
164 | }
165 |
166 | return 0;
167 | }
168 |
169 | void getSizeString(char *string, uint64_t size) {
170 | double double_size = (double)size;
171 |
172 | int i = 0;
173 | static char *units[] = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
174 | while (double_size >= 1024.0f) {
175 | double_size /= 1024.0f;
176 | i++;
177 | }
178 |
179 | sprintf(string, "%.*f %s", (i == 0) ? 0 : 2, double_size, units[i]);
180 | }
181 |
182 | int randomNumber(int low, int high) {
183 | return rand() % (high - low + 1) + low;
184 | }
185 |
186 | char *strcasestr(const char *haystack, const char *needle) {
187 | return boyer_moore(haystack, needle);
188 | }
189 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
254 | # Makefile objects
255 | *.o
256 | *.elf
257 | *.velf
258 | *.bin
259 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/minizip/crypt.h:
--------------------------------------------------------------------------------
1 | /* crypt.h -- base code for traditional PKWARE encryption
2 | Version 1.01e, February 12th, 2005
3 |
4 | Copyright (C) 1998-2005 Gilles Vollant
5 | Modifications for Info-ZIP crypting
6 | Copyright (C) 2003 Terry Thorsen
7 |
8 | This code is a modified version of crypting code in Info-ZIP distribution
9 |
10 | Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
11 |
12 | See the Info-ZIP LICENSE file version 2000-Apr-09 or later for terms of use
13 | which also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
14 |
15 | The encryption/decryption parts of this source code (as opposed to the
16 | non-echoing password parts) were originally written in Europe. The
17 | whole source package can be freely distributed, including from the USA.
18 | (Prior to January 2000, re-export from the US was a violation of US law.)
19 |
20 | This encryption code is a direct transcription of the algorithm from
21 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This
22 | file (appnote.txt) is distributed with the PKZIP program (even in the
23 | version without encryption capabilities).
24 |
25 | If you don't need crypting in your application, just define symbols
26 | NOCRYPT and NOUNCRYPT.
27 |
28 | Mar 8th, 2016 - Lucio Cosmo
29 | Fixed support for 64bit builds for archives with "PKWARE" password.
30 | Changed long, unsigned long, unsigned to unsigned int in
31 | access functions to crctables and pkeys
32 |
33 | */
34 |
35 | #define CRC32(c, b) ((*(pcrc_32_tab+(((unsigned int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
36 |
37 | /***********************************************************************
38 | * Return the next byte in the pseudo-random sequence
39 | */
40 | static int decrypt_byte(unsigned int* pkeys)
41 | {
42 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
43 | * unpredictable manner on 16-bit systems; not a problem
44 | * with any known compiler so far, though */
45 |
46 | temp = ((unsigned int)(*(pkeys+2)) & 0xffff) | 2;
47 | return (unsigned int)(((temp * (temp ^ 1)) >> 8) & 0xff);
48 | }
49 |
50 | /***********************************************************************
51 | * Update the encryption keys with the next byte of plain text
52 | */
53 | static int update_keys(unsigned int* pkeys,const unsigned int* pcrc_32_tab,int c)
54 | {
55 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
56 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
57 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
58 | {
59 | register int keyshift = (int)((*(pkeys+1)) >> 24);
60 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
61 | }
62 | return c;
63 | }
64 |
65 |
66 | /***********************************************************************
67 | * Initialize the encryption keys and the random header according to
68 | * the given password.
69 | */
70 | static void init_keys(const char* passwd,unsigned int* pkeys,const unsigned int* pcrc_32_tab)
71 | {
72 | *(pkeys+0) = 305419896L;
73 | *(pkeys+1) = 591751049L;
74 | *(pkeys+2) = 878082192L;
75 | while (*passwd != 0)
76 | {
77 | update_keys(pkeys,pcrc_32_tab,(int)*passwd);
78 | passwd++;
79 | }
80 | }
81 |
82 | #define zdecode(pkeys,pcrc_32_tab,c) \
83 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys)))
84 |
85 | #define zencode(pkeys,pcrc_32_tab,c,t) \
86 | (t=decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
87 |
88 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
89 |
90 | #define RAND_HEAD_LEN 12
91 | /* "last resort" source for second part of crypt seed pattern */
92 | # ifndef ZCR_SEED2
93 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */
94 | # endif
95 |
96 | static int crypthead(const char* passwd, /* password string */
97 | unsigned char* buf, /* where to write header */
98 | int bufSize,
99 | unsigned int* pkeys,
100 | const unsigned int* pcrc_32_tab,
101 | unsigned int crcForCrypting)
102 | {
103 | int n; /* index in random header */
104 | int t; /* temporary */
105 | int c; /* random byte */
106 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */
107 | static unsigned calls = 0; /* ensure different random header each time */
108 |
109 | if (bufSize < RAND_HEAD_LEN)
110 | return 0;
111 |
112 | /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
113 | * output of rand() to get less predictability, since rand() is
114 | * often poorly implemented.
115 | */
116 | if (++calls == 1)
117 | {
118 | srand((unsigned)(time(NULL) ^ ZCR_SEED2));
119 | }
120 | init_keys(passwd, pkeys, pcrc_32_tab);
121 | for (n = 0; n < RAND_HEAD_LEN-2; n++)
122 | {
123 | c = (rand() >> 7) & 0xff;
124 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
125 | }
126 | /* Encrypt random header (last two bytes is high word of crc) */
127 | init_keys(passwd, pkeys, pcrc_32_tab);
128 | for (n = 0; n < RAND_HEAD_LEN-2; n++)
129 | {
130 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
131 | }
132 | buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
133 | buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
134 | return n;
135 | }
136 |
137 | #endif
138 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/draw.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 Sergi Granell (xerpi)
3 | */
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "draw.h"
12 | #include "utils.h"
13 |
14 | extern const unsigned char msx_font[];
15 |
16 | static SceDisplayFrameBuf fb[2];
17 | static SceUID fb_memuid[2];
18 | static int cur_fb = 0;
19 |
20 | void *gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int attribs, SceUID *uid)
21 | {
22 | void *mem;
23 |
24 | if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
25 | size = align_mem(size, 256*1024);
26 | } else {
27 | size = align_mem(size, 4*1024);
28 | }
29 |
30 | *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
31 |
32 | if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
33 | return NULL;
34 |
35 | if (sceGxmMapMemory(mem, size, attribs) < 0)
36 | return NULL;
37 |
38 | return mem;
39 | }
40 |
41 | void gpu_free(SceUID uid)
42 | {
43 | void *mem = NULL;
44 | if (sceKernelGetMemBlockBase(uid, &mem) < 0)
45 | return;
46 | sceGxmUnmapMemory(mem);
47 | sceKernelFreeMemBlock(uid);
48 | }
49 |
50 | void init_video()
51 | {
52 | int ret;
53 |
54 | SceGxmInitializeParams params;
55 |
56 | params.flags = 0x0;
57 | params.displayQueueMaxPendingCount = 0x2; //Double buffering
58 | params.displayQueueCallback = 0x0;
59 | params.displayQueueCallbackDataSize = 0x0;
60 | params.parameterBufferSize = (16 * 1024 * 1024);
61 |
62 | /* Initialize the GXM */
63 | ret = sceGxmInitialize(¶ms);
64 | printf("sceGxmInitialize(): 0x%08X\n", ret);
65 |
66 | /* Setup framebuffers */
67 | fb[0].size = sizeof(fb[0]);
68 | fb[0].pitch = SCREEN_W;
69 | fb[0].pixelformat = SCE_DISPLAY_PIXELFORMAT_A8B8G8R8;
70 | fb[0].width = SCREEN_W;
71 | fb[0].height = SCREEN_H;
72 |
73 | fb[1].size = sizeof(fb[1]);
74 | fb[1].pitch = SCREEN_W;
75 | fb[1].pixelformat = SCE_DISPLAY_PIXELFORMAT_A8B8G8R8;
76 | fb[1].width = SCREEN_W;
77 | fb[1].height = SCREEN_H;
78 |
79 | /* Allocate memory for the framebuffers */
80 | fb[0].base = gpu_alloc(SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
81 | SCREEN_W * SCREEN_H * 4, SCE_GXM_MEMORY_ATTRIB_RW, &fb_memuid[0]);
82 |
83 | if (fb[0].base == NULL) {
84 | printf("Could not allocate memory for fb[0]. %p", fb[0].base);
85 | return;
86 | }
87 |
88 | fb[1].base = gpu_alloc(SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
89 | SCREEN_W * SCREEN_H * 4, SCE_GXM_MEMORY_ATTRIB_RW, &fb_memuid[1]);
90 |
91 | if (fb[1].base == NULL) {
92 | printf("Could not allocate memory for fb[1]. %p", fb[1].base);
93 | return;
94 | }
95 |
96 | /* Display the framebuffer 0 */
97 | cur_fb = 0;
98 | swap_buffers();
99 |
100 | printf(
101 | "\nframebuffer 0:\n"
102 | "\tsize: 0x%08X\n"
103 | "\tbase: 0x%08X\n"
104 | "\tpitch: 0x%08X\n"
105 | "\tpixelformat: 0x%08X\n"
106 | "\twidth: 0x%08X\n"
107 | "\theight 0x%08X\n",
108 | fb[0].size, (uintptr_t)fb[0].base,
109 | fb[0].pitch, fb[0].pixelformat, fb[0].width, fb[0].height);
110 |
111 | printf(
112 | "\nframebuffer 1:\n"
113 | "\tsize: 0x%08X\n"
114 | "\tbase: 0x%08X\n"
115 | "\tpitch: 0x%08X\n"
116 | "\tpixelformat: 0x%08X\n"
117 | "\twidth: 0x%08X\n"
118 | "\theight 0x%08X\n",
119 | fb[1].size, (uintptr_t)fb[1].base,
120 | fb[1].pitch, fb[1].pixelformat, fb[1].width, fb[1].height);
121 | }
122 |
123 | void end_video()
124 | {
125 | gpu_free(fb_memuid[0]);
126 | gpu_free(fb_memuid[1]);
127 | sceGxmTerminate();
128 | }
129 |
130 | void swap_buffers()
131 | {
132 | sceDisplaySetFrameBuf(&fb[cur_fb], SCE_DISPLAY_SETBUF_NEXTFRAME);
133 | cur_fb ^= 1;
134 | }
135 |
136 | void clear_screen()
137 | {
138 | //white
139 | //memset(fb[cur_fb].base, 0xFF, SCREEN_W*SCREEN_H*4);
140 |
141 | //black
142 | memset(fb[cur_fb].base, 0x0, SCREEN_W*SCREEN_H*4);
143 | }
144 |
145 | void draw_pixel(uint32_t x, uint32_t y, uint32_t color)
146 | {
147 | ((uint32_t *)fb[cur_fb].base)[x + y*fb[cur_fb].pitch] = color;
148 | }
149 |
150 | void draw_rectangle(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color)
151 | {
152 | int i, j;
153 | for (i = 0; i < h; i++) {
154 | for (j = 0; j < w; j++) {
155 | ((uint32_t *)fb[cur_fb].base)[(x + j) + (y + i)*fb[cur_fb].pitch] = color;
156 | }
157 | }
158 | }
159 |
160 | void draw_circle(uint32_t x, uint32_t y, uint32_t radius, uint32_t color)
161 | {
162 | int r2 = radius * radius;
163 | int area = r2 << 2;
164 | int rr = radius << 1;
165 |
166 | int i;
167 | for (i = 0; i < area; i++) {
168 | int tx = (i % rr) - radius;
169 | int ty = (i / rr) - radius;
170 |
171 | if (tx * tx + ty * ty <= r2) {
172 | draw_pixel(x + tx, y + ty, color);
173 | }
174 | }
175 | }
176 |
177 | void font_draw_char(int x, int y, uint32_t color, char c)
178 | {
179 | unsigned char *font = (unsigned char *)(msx_font + (c - (uint32_t)' ') * 8);
180 | int i, j, pos_x, pos_y;
181 | for (i = 0; i < 8; ++i) {
182 | pos_y = y + i*2;
183 | for (j = 0; j < 8; ++j) {
184 | pos_x = x + j*2;
185 | if ((*font & (128 >> j))) {
186 | draw_pixel(pos_x + 0, pos_y + 0, color);
187 | draw_pixel(pos_x + 1, pos_y + 0, color);
188 | draw_pixel(pos_x + 0, pos_y + 1, color);
189 | draw_pixel(pos_x + 1, pos_y + 1, color);
190 | }
191 | }
192 | ++font;
193 | }
194 | }
195 |
196 | void font_draw_string(int x, int y, uint32_t color, const char *string)
197 | {
198 | if (string == NULL) return;
199 |
200 | int startx = x;
201 | const char *s = string;
202 |
203 | while (*s) {
204 | if (*s == '\n') {
205 | x = startx;
206 | y += 16;
207 | } else if (*s == ' ') {
208 | x += 16;
209 | } else if(*s == '\t') {
210 | x += 16*4;
211 | } else {
212 | font_draw_char(x, y, color, *s);
213 | x += 16;
214 | }
215 | ++s;
216 | }
217 | }
218 |
219 | void font_draw_stringf(int x, int y, uint32_t color, const char *s, ...)
220 | {
221 | char buf[256];
222 | va_list argptr;
223 | va_start(argptr, s);
224 | vsnprintf(buf, sizeof(buf), s, argptr);
225 | va_end(argptr);
226 | font_draw_string(x, y, color, buf);
227 | }
228 |
229 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/base_head_bin.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | unsigned char base_head_bin[] = {
20 | 0x7f, 0x50, 0x4b, 0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x80,
21 | 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x03,
22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
23 | 0x00, 0x00, 0x0a, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10,
24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | 0xa6, 0x89, 0x94, 0x38, 0x19, 0xf2, 0xdd, 0x05, 0x87, 0x94, 0xb0, 0xb6,
29 | 0x7f, 0xc9, 0x30, 0x76, 0xdc, 0x2f, 0x22, 0xf2, 0x25, 0x40, 0xc6, 0xdf,
30 | 0x94, 0xcb, 0xb7, 0x78, 0xf8, 0xa2, 0x54, 0x95, 0x8c, 0xe6, 0xfd, 0x74,
31 | 0x81, 0x0c, 0xf7, 0x9d, 0x47, 0xb2, 0x86, 0x60, 0x3c, 0x2e, 0x00, 0xbb,
32 | 0xa2, 0x07, 0x59, 0x51, 0xe7, 0x95, 0xa4, 0xed, 0x83, 0x50, 0x35, 0xbc,
33 | 0x65, 0x63, 0xfe, 0x70, 0x8b, 0xab, 0x0c, 0x49, 0x73, 0x9d, 0xa3, 0xc9,
34 | 0x1f, 0x74, 0x48, 0x22, 0x70, 0x93, 0xfc, 0xe9, 0x40, 0xca, 0x74, 0x97,
35 | 0xba, 0xf1, 0xde, 0x1c, 0xaa, 0x67, 0xb7, 0x41, 0x78, 0xd7, 0x15, 0x68,
36 | 0x7f, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40,
37 | 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x10,
38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xe0, 0x00, 0x00, 0x00, 0x00,
39 | 0xc0, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00,
40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
42 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0xa2, 0xcb, 0x21,
43 | 0x8b, 0x37, 0x06, 0x2d, 0x3e, 0x05, 0xfa, 0x11, 0x72, 0x72, 0x88, 0x85,
44 | 0xc9, 0x7b, 0x03, 0x99, 0xa0, 0x70, 0x9c, 0xf8, 0xcf, 0x9d, 0x41, 0x01,
45 | 0xd6, 0x17, 0x9f, 0xd3, 0x57, 0x79, 0x67, 0xf9, 0xb6, 0xf8, 0x56, 0x3d,
46 | 0xca, 0xfc, 0xa1, 0x98, 0xe2, 0xc7, 0xcf, 0xd6, 0x2e, 0x1b, 0xd6, 0x1b,
47 | 0xbe, 0x6f, 0xc1, 0x92, 0xbe, 0xe0, 0xb3, 0xc2, 0xe5, 0x65, 0x5a, 0x45,
48 | 0xd9, 0x88, 0xb4, 0x97, 0x5e, 0x16, 0x31, 0x3d, 0xa2, 0x3e, 0x16, 0xae,
49 | 0xd4, 0xb7, 0xd5, 0x36, 0xe3, 0xac, 0x80, 0x8f, 0x18, 0xfe, 0xad, 0x1a,
50 | 0x85, 0x20, 0xce, 0xee, 0xda, 0x5d, 0xb7, 0x95, 0x46, 0x34, 0xcc, 0x49,
51 | 0x52, 0x09, 0xf6, 0xeb, 0xa5, 0x0a, 0xe5, 0x7c, 0xb5, 0x7f, 0xaf, 0x6f,
52 | 0x4c, 0x06, 0x8c, 0xe4, 0xd8, 0x5a, 0x03, 0xaf, 0x92, 0x4e, 0x95, 0x5b,
53 | 0xbc, 0xe0, 0xc2, 0xac, 0xff, 0x12, 0x95, 0x31, 0x92, 0xad, 0x06, 0xe8,
54 | 0x17, 0x2c, 0xb1, 0xdc, 0x36, 0xa4, 0xc3, 0x9b, 0xe2, 0x3e, 0x2b, 0xec,
55 | 0x65, 0x53, 0xeb, 0x58, 0x84, 0x49, 0x09, 0x0b, 0xf4, 0xc6, 0xb4, 0x02,
56 | 0x70, 0xf3, 0x64, 0x58, 0x75, 0x14, 0x00, 0xf8, 0x68, 0x88, 0x46, 0x7e,
57 | 0x5c, 0xbc, 0xbe, 0x8b, 0x5f, 0xac, 0xe0, 0xe4, 0xa6, 0xf5, 0x77, 0xdd,
58 | 0xd9, 0xe5, 0xaf, 0x05, 0xf0, 0x5d, 0xae, 0x22, 0x7f, 0xb4, 0xd1, 0x1c,
59 | 0x7f, 0xcc, 0x3e, 0x98, 0x55, 0xb9, 0x69, 0xd2, 0xd2, 0x10, 0x55, 0x45,
60 | 0x4b, 0x3c, 0x95, 0x70, 0xb7, 0xc3, 0xdb, 0xfe, 0x23, 0xaf, 0xcd, 0x27,
61 | 0xa2, 0xd3, 0xac, 0x8c, 0x11, 0x09, 0xbf, 0xf6, 0xb2, 0x01, 0x62, 0x09,
62 | 0xc1, 0xda, 0xfd, 0xa7, 0x47, 0xa9, 0x48, 0xf4, 0x46, 0x26, 0x06, 0xf2,
63 | 0x76, 0x4d, 0xfe, 0x6f, 0x3f, 0x10, 0xb0, 0x1c, 0x1a, 0xde, 0x73, 0x8b,
64 | 0x14, 0x73, 0x3c, 0x39, 0xb6, 0xc6, 0x1b, 0xa1, 0x65, 0x99, 0xb8, 0x33,
65 | 0xac, 0xb8, 0x16, 0xb4, 0xe6, 0xa5, 0xec, 0x02, 0x0b, 0x5b, 0x70, 0x23,
66 | 0xeb, 0x24, 0x1a, 0xf7, 0x8c, 0xda, 0x55, 0x96, 0xdd, 0x4b, 0x1c, 0x85,
67 | 0x83, 0x49, 0x01, 0xb2, 0x39, 0xbc, 0x31, 0x3b, 0xe8, 0xf1, 0x5a, 0x49,
68 | 0xcc, 0xcf, 0x0f, 0x85, 0x5f, 0x54, 0x79, 0xe8, 0x31, 0x8d, 0x57, 0x1b,
69 | 0xb1, 0xc2, 0x93, 0x87, 0xe2, 0xe6, 0x56, 0xcf, 0x92, 0x51, 0xfc, 0x49,
70 | 0x94, 0xcd, 0xb5, 0x04, 0x1b, 0x04, 0x47, 0xf7, 0xb4, 0xd2, 0x67, 0x31,
71 | 0x54, 0xf0, 0xad, 0x3a, 0xd4, 0x25, 0x8c, 0xed, 0xe9, 0x9b, 0x12, 0xfc,
72 | 0x47, 0x1c, 0xfc, 0x6e, 0x81, 0x29, 0x8b, 0x39, 0xab, 0xbb, 0xf0, 0x35,
73 | 0x00, 0x87, 0x88, 0x87, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04,
74 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
75 | 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04,
76 | 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08,
77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00, 0x05,
78 | 0x00, 0x00, 0x00, 0x04, 0x19, 0x67, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08,
79 | 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 | 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
81 | 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x28,
82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x1a, 0x92, 0x07, 0x04,
83 | 0x61, 0x0c, 0x9d, 0x14, 0x55, 0x8e, 0x17, 0x74, 0xb6, 0x44, 0xd2, 0x5c,
84 | 0x93, 0xf3, 0xc1, 0x58, 0x0f, 0x91, 0x22, 0x2f, 0xfd, 0xb4, 0x42, 0xaa,
85 | 0x64, 0xfc, 0x8a, 0xd0, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x48,
86 | 0x00, 0x00, 0x05, 0x90, 0x00, 0x00, 0x03, 0x20, 0x00, 0x00, 0x00, 0x00,
87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
88 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 | 0x00, 0x00, 0x00, 0x00, 0xbe, 0x9a, 0x07, 0x26, 0x1a, 0x91, 0xd6, 0x35,
90 | 0x93, 0xcd, 0x59, 0xf4, 0x13, 0x23, 0x34, 0x05, 0x5b, 0xc4, 0xf5, 0xc3,
91 | 0x31, 0xf3, 0xf9, 0xf1, 0x7e, 0xdb, 0x7f, 0x53, 0x0f, 0x1a, 0x0a, 0x79,
92 | 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0x30,
93 | 0x00, 0x00, 0x00, 0x60, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x2a, 0xa0, 0xf7,
95 | 0x3a, 0x41, 0x84, 0x7c, 0xb8, 0x66, 0x43, 0x7b, 0xca, 0xcd, 0x68, 0x5e,
96 | 0x44, 0xab, 0xd9, 0x85, 0xc9, 0x6b, 0xad, 0x33, 0xa9, 0xbc, 0x88, 0xc6,
97 | 0x75, 0xc5, 0x23, 0x9e, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x28,
98 | 0x01, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
101 | 0x00, 0x00, 0x00, 0x00, 0x7a, 0xfe, 0xf5, 0x79, 0x30, 0xaf, 0x76, 0xe0,
102 | 0x46, 0xfc, 0x75, 0xdf, 0x08, 0x4e, 0xb8, 0x45, 0x3d, 0x4f, 0xcb, 0xf4,
103 | 0x3d, 0x9b, 0xfa, 0x5f, 0x61, 0x99, 0x6a, 0xde, 0x9c, 0x2e, 0x1a, 0x9c,
104 | 0x19, 0x15, 0x10, 0x1d, 0x71, 0xe6, 0xc0, 0x5a, 0x84, 0x3d, 0x20, 0xe8,
105 | 0xae, 0x1e, 0x1c, 0x71, 0x94, 0xee, 0xbc, 0x73, 0x4d, 0x2c, 0x46, 0xbf,
106 | 0x3c, 0xf3, 0x5b, 0x30, 0x3a, 0xc3, 0x18, 0x20, 0xff, 0xff, 0xff, 0xff,
107 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
108 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
109 | 0xff, 0xff, 0xff, 0xff
110 | };
--------------------------------------------------------------------------------
/QuickInstallerVITA/minizip/ioapi.h:
--------------------------------------------------------------------------------
1 | /* ioapi.h -- IO base function header for compress/uncompress .zip
2 | part of the MiniZip project
3 |
4 | Copyright (C) 1998-2010 Gilles Vollant
5 | http://www.winimage.com/zLibDll/minizip.html
6 | Modifications for Zip64 support
7 | Copyright (C) 2009-2010 Mathias Svensson
8 | http://result42.com
9 |
10 | This program is distributed under the terms of the same license as zlib.
11 | See the accompanying LICENSE file for the full text of the license.
12 | */
13 |
14 | #ifndef _ZLIBIOAPI64_H
15 | #define _ZLIBIOAPI64_H
16 |
17 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
18 | # ifndef __USE_FILE_OFFSET64
19 | # define __USE_FILE_OFFSET64
20 | # endif
21 | # ifndef __USE_LARGEFILE64
22 | # define __USE_LARGEFILE64
23 | # endif
24 | # ifndef _LARGEFILE64_SOURCE
25 | # define _LARGEFILE64_SOURCE
26 | # endif
27 | # ifndef _FILE_OFFSET_BIT
28 | # define _FILE_OFFSET_BIT 64
29 | # endif
30 | #endif
31 |
32 | #include
33 | #include
34 | #include "zlib.h"
35 |
36 | #if defined(USE_FILE32API)
37 | # define fopen64 fopen
38 | # define ftello64 ftell
39 | # define fseeko64 fseek
40 | #else
41 | # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
42 | # define fopen64 fopen
43 | # define ftello64 ftello
44 | # define fseeko64 fseeko
45 | # endif
46 | # ifdef _MSC_VER
47 | # define fopen64 fopen
48 | # if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
49 | # define ftello64 _ftelli64
50 | # define fseeko64 _fseeki64
51 | # else /* old MSC */
52 | # define ftello64 ftell
53 | # define fseeko64 fseek
54 | # endif
55 | # endif
56 | #endif
57 |
58 | /* a type choosen by DEFINE */
59 | #ifdef HAVE_64BIT_INT_CUSTOM
60 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
61 | #else
62 | # ifdef HAVE_STDINT_H
63 | # include "stdint.h"
64 | typedef uint64_t ZPOS64_T;
65 | # else
66 | # if defined(_MSC_VER) || defined(__BORLANDC__)
67 | typedef unsigned __int64 ZPOS64_T;
68 | # else
69 | typedef unsigned long long int ZPOS64_T;
70 | # endif
71 | # endif
72 | #endif
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 | #define ZLIB_FILEFUNC_SEEK_CUR (1)
79 | #define ZLIB_FILEFUNC_SEEK_END (2)
80 | #define ZLIB_FILEFUNC_SEEK_SET (0)
81 |
82 | #define ZLIB_FILEFUNC_MODE_READ (1)
83 | #define ZLIB_FILEFUNC_MODE_WRITE (2)
84 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
85 | #define ZLIB_FILEFUNC_MODE_EXISTING (4)
86 | #define ZLIB_FILEFUNC_MODE_CREATE (8)
87 |
88 | #ifndef ZCALLBACK
89 | # if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
90 | defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
91 | # define ZCALLBACK CALLBACK
92 | # else
93 | # define ZCALLBACK
94 | # endif
95 | #endif
96 |
97 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
98 | typedef voidpf (ZCALLBACK *opendisk_file_func) OF((voidpf opaque, voidpf stream, int number_disk, int mode));
99 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
100 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
101 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
102 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
103 |
104 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
105 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
106 |
107 | /* here is the "old" 32 bits structure structure */
108 | typedef struct zlib_filefunc_def_s
109 | {
110 | open_file_func zopen_file;
111 | opendisk_file_func zopendisk_file;
112 | read_file_func zread_file;
113 | write_file_func zwrite_file;
114 | tell_file_func ztell_file;
115 | seek_file_func zseek_file;
116 | close_file_func zclose_file;
117 | testerror_file_func zerror_file;
118 | voidpf opaque;
119 | } zlib_filefunc_def;
120 |
121 | typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
122 | typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
123 | typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
124 | typedef voidpf (ZCALLBACK *opendisk64_file_func)OF((voidpf opaque, voidpf stream, int number_disk, int mode));
125 |
126 | typedef struct zlib_filefunc64_def_s
127 | {
128 | open64_file_func zopen64_file;
129 | opendisk64_file_func zopendisk64_file;
130 | read_file_func zread_file;
131 | write_file_func zwrite_file;
132 | tell64_file_func ztell64_file;
133 | seek64_file_func zseek64_file;
134 | close_file_func zclose_file;
135 | testerror_file_func zerror_file;
136 | voidpf opaque;
137 | } zlib_filefunc64_def;
138 |
139 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
140 | void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
141 |
142 | /* now internal definition, only for zip.c and unzip.h */
143 | typedef struct zlib_filefunc64_32_def_s
144 | {
145 | zlib_filefunc64_def zfile_func64;
146 | open_file_func zopen32_file;
147 | opendisk_file_func zopendisk32_file;
148 | tell_file_func ztell32_file;
149 | seek_file_func zseek32_file;
150 | } zlib_filefunc64_32_def;
151 |
152 | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
153 | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
154 | /*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))*/
155 | /*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))*/
156 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
157 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
158 |
159 | voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
160 | voidpf call_zopendisk64 OF((const zlib_filefunc64_32_def* pfilefunc, voidpf filestream, int number_disk, int mode));
161 | long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
162 | ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
163 |
164 | void fill_zlib_filefunc64_32_def_from_filefunc32 OF((zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32));
165 |
166 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
167 | #define ZOPENDISK64(filefunc,filestream,diskn,mode) (call_zopendisk64((&(filefunc)),(filestream),(diskn),(mode)))
168 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
169 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
170 |
171 | #ifdef __cplusplus
172 | }
173 | #endif
174 |
175 | #endif
176 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #include "global.h"
19 | #include "draw.h"
20 | #include "file.h"
21 | #include "package_installer.h"
22 |
23 | #define TEXTBUF_ROWS 24
24 | #define TEXTBUF_COLS 0x100
25 |
26 | #define PATHBUF_LEN 0x100
27 |
28 | #define print_textbuf(__format__, ...) \
29 | do { \
30 | sprintf(textbuf_data + textbuf_index * TEXTBUF_COLS, __format__, ##__VA_ARGS__); \
31 | textbuf_index = (textbuf_index + 1) % TEXTBUF_ROWS; \
32 | } while(0)
33 |
34 | /*
35 | #define print_textbuf(__format__, ...) \
36 | do { \
37 | printf(__format__, ##__VA_ARGS__); \
38 | putchar('\n'); \
39 | } while(0)
40 | */
41 |
42 | typedef struct {
43 | char src[PATHBUF_LEN];
44 | char dst[PATHBUF_LEN];
45 | char header[4];
46 | } data_info;
47 |
48 | typedef struct {
49 | char buf[PATHBUF_LEN];
50 | } path_info;
51 |
52 | FileProcessParam progress_param;
53 |
54 | static int textbuf_index = 0;
55 | static char textbuf_data[TEXTBUF_COLS * TEXTBUF_ROWS] = {0};
56 |
57 | static data_info* data_info_arr;
58 | static int data_info_cnt = 0;
59 |
60 | static uint8_t hexchar2uint(char c) {
61 | if(c >= '0' && c <= '9') return c - '0';
62 | if(c >= 'A' && c <= 'F') return c - 'A' + 10;
63 | if(c >= 'a' && c <= 'f') return c - 'a' + 10;
64 | return 0xFF;
65 | }
66 |
67 | static uint32_t read_data_index(char* filename) {
68 | return
69 | (hexchar2uint(filename[3]) << 12) |
70 | (hexchar2uint(filename[4]) << 8) |
71 | (hexchar2uint(filename[5]) << 4) |
72 | (hexchar2uint(filename[6]) << 0);
73 | }
74 |
75 | static int load_meta(char* path) {
76 | char* buf = NULL;
77 | int len = allocateReadFile(path, (void**)&buf);
78 | //print_textbuf("load_meta: %s, %d", path, len);
79 | if(len < 0) return -1;
80 |
81 | int cnt = 0;
82 | int step = 0;
83 | int v = 0;
84 | char header_buf[8] = {0};
85 | for(int u = 0; u < len; ++u) {
86 | char c = buf[u];
87 |
88 | switch(c) {
89 | case '\r':
90 | continue;
91 | case '\n':
92 | for(v = 0; v < 4; ++v) {
93 | data_info_arr[cnt].header[v] =
94 | (hexchar2uint(header_buf[v << 1]) << 4) |
95 | hexchar2uint(header_buf[(v << 1) + 1])
96 | ;
97 | }
98 | step = 0;
99 | v = 0;
100 | ++cnt;
101 | break;
102 | case ' ':
103 | data_info_arr[cnt].dst[v] = 0; //null terminate.
104 | step = 1;
105 | v = 0;
106 | break;
107 | default:
108 | if((uint32_t)c >= 0x80) continue;
109 | if(step == 0)
110 | data_info_arr[cnt].dst[v++] = c;
111 | else
112 | header_buf[v++] = c;
113 | break;
114 | }
115 | }
116 |
117 | //for(int u = 0; u < cnt; ++u)
118 | // print_textbuf("#%s %x", data_info_arr[u].dst, *(uint32_t*)data_info_arr[u].header);
119 |
120 | free(buf);
121 | return cnt;
122 | }
123 |
124 | static int process_data(char* path, uint32_t index) {
125 | if(data_info_arr[index].src[0]) return -1; //duplicated entry.
126 |
127 | strcpy(data_info_arr[index].src, path);
128 | return 0;
129 | }
130 |
131 | static int overwrite_file(char *file, void *buf, int size) {
132 | SceUID fd = sceIoOpen(file, SCE_O_WRONLY, 0777);
133 | if (fd < 0) return -1;
134 |
135 | sceIoLseek(fd, 0, SEEK_SET);
136 | int written = sceIoWrite(fd, buf, size);
137 | sceIoClose(fd);
138 |
139 | return written;
140 | }
141 |
142 | static int resolve_meta(int index) {
143 | data_info* t = data_info_arr + index;
144 |
145 | if(overwrite_file(t->src, t->header, 4) == -1) {
146 | print_textbuf("Failed to overwrite header.");
147 | return -1;
148 | }
149 |
150 | if(sceIoRename(t->src, t->dst)) {
151 | print_textbuf("Failed to move file.");
152 | return -1;
153 | }
154 |
155 | return 0;
156 | }
157 |
158 | static void main_worker_impl() {
159 | data_info_arr = calloc(0x1000, sizeof(data_info));
160 |
161 | FileList p, q;
162 | memset(&p, 0, sizeof(FileList));
163 | memset(&q, 0, sizeof(FileList));
164 | strcpy(p.path, "ux0:video/");
165 |
166 | if (fileListGetEntries(&p, p.path)) {
167 | print_textbuf("Failed to get list.");
168 | return;
169 | }
170 |
171 | FileListEntry* m = p.head;
172 | if (p.length == 1) {
173 | print_textbuf("Files not found.");
174 | return;
175 | }
176 |
177 | //skip parent directory.
178 | m = m->next;
179 |
180 | print_textbuf("Searching files...");
181 | while (1) {
182 | //print_textbuf("dir: %s", m->name);
183 |
184 | fileListEmpty(&q);
185 | strcpy(q.path, p.path);
186 | strcpy(q.path + 10, m->name);
187 | //print_textbuf("dir-full: %s", q.path);
188 |
189 | if (!fileListGetEntries(&q, q.path) && q.length > 1) {
190 | FileListEntry* n = q.head;
191 |
192 | //skip parent directory.
193 | n = n->next;
194 |
195 | while(1) {
196 | char path[PATHBUF_LEN] = {0};
197 | sprintf(path, "%s%s", q.path, n->name);
198 | //print_textbuf("file: %s", path);
199 |
200 | if(!memcmp(n->name, "qd_", 3)) {
201 | //print_textbuf("Found data file: %s", path);
202 | if(process_data(path, read_data_index(n->name))) {
203 | print_textbuf("Duplicated file is found.");
204 | return;
205 | }
206 | } else if(!memcmp(n->name, "qinst_", 6)) {
207 | print_textbuf("Installing %s...", path);
208 | if(installPackage(path, &progress_param)) {
209 | print_textbuf("Failed to install package.");
210 | return;
211 | }
212 | *progress_param.value = progress_param.max;
213 | removePath(path, NULL);
214 | } else if(!memcmp(n->name, "qmeta.mp4", 9)) {
215 | print_textbuf("Loading meta from %s...", path);
216 | data_info_cnt = load_meta(path);
217 | if(data_info_cnt < 0) {
218 | print_textbuf("Failed to load meta.");
219 | return;
220 | }
221 | removePath(path, NULL);
222 | }
223 |
224 | if(n == q.tail) break;
225 | n = n->next;
226 | }
227 | }
228 |
229 | if(m == p.tail) break;
230 | m = m->next;
231 | }
232 |
233 | print_textbuf("Resolving meta...");
234 | for(int u = 0; u < data_info_cnt; ++u) {
235 | if(resolve_meta(u)) {
236 | print_textbuf("Failed to resolve.");
237 | print_textbuf("src: %s", data_info_arr[u].src);
238 | print_textbuf("dst: %s", data_info_arr[u].dst);
239 | return;
240 | }
241 | }
242 |
243 | print_textbuf("Done.");
244 | }
245 |
246 | #if 0
247 | static void main_worker_impl() {
248 | print_textbuf("main_worker_impl");
249 | print_textbuf("Installing VPK...");
250 | int result = installPackage("ux0:homebrew/mgba.vpk");
251 | if(result)
252 | print_textbuf("Failed with code: %d.", result);
253 | else
254 | print_textbuf("Done.");
255 | }
256 | #endif
257 |
258 | static int main_worker(SceSize args, void* p) {
259 | main_worker_impl();
260 | return sceKernelExitDeleteThread(0);
261 | }
262 |
263 | static void begin_working_thread() {
264 | SceUID thid = sceKernelCreateThread("mythread", main_worker, 0x10000100, 0x10000, 0, 0, NULL);
265 | if (thid >= 0) sceKernelStartThread(thid, 0, NULL);
266 | }
267 |
268 | static void rendering_loop() {
269 |
270 | /* Input variables */
271 | SceCtrlData pad;
272 |
273 | while (1) {
274 | clear_screen();
275 |
276 | /* Read controls and touchscreen */
277 | sceCtrlPeekBufferPositive(0, &pad, 1);
278 |
279 | font_draw_string(10, 10, RGBA8(0x80, 0xFF, 0xFF, 0xFF), "Quick Installer");
280 |
281 | uint64_t prog = (*progress_param.value * 100) / progress_param.max;
282 | if(prog < 100) {
283 | font_draw_stringf(900, 10, RGBA8(0xFF, 0x80, 0x00, 0xFF), "%2d%%", prog);
284 | }
285 |
286 | for (int u = 0; u < TEXTBUF_ROWS; ++u) {
287 | int row = (u + textbuf_index) % TEXTBUF_ROWS;
288 | if(u == (TEXTBUF_ROWS - 1))
289 | font_draw_string(10, 56 + u * 20, RGBA8(0xFF, 0xFF, 0x80, 0xFF), textbuf_data + row * TEXTBUF_COLS);
290 | else
291 | font_draw_string(10, 56 + u * 20, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), textbuf_data + row * TEXTBUF_COLS);
292 | }
293 |
294 | swap_buffers();
295 | sceDisplayWaitVblankStart();
296 | }
297 | }
298 |
299 | int main() {
300 | progress_param.value = malloc(sizeof(uint64_t));
301 | *progress_param.value = 1;
302 | progress_param.max = 1;
303 | progress_param.SetProgress = NULL;
304 | progress_param.cancelHandler = NULL;
305 |
306 | init_video();
307 | begin_working_thread();
308 | rendering_loop();
309 | end_video();
310 | sceKernelExitProcess(0);
311 | return 0;
312 | }
313 |
--------------------------------------------------------------------------------
/QuickInstallerPC/QuickInstallerPC/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Threading;
7 | using LocalLib;
8 |
9 | namespace QuickInstallerPC
10 | {
11 | static class Program
12 | {
13 | const int FileSizeThreshold = 5 * 1024 * 1024;
14 |
15 | static byte[] header_buf = new byte[4];
16 | static byte[] header_dummy = new byte[] { 0, 0, 0, 0 };
17 |
18 | static string path_work = null;
19 | static string path_mp4 = null;
20 | static string path_vpk = null;
21 | static string app_id = null;
22 |
23 | static int data_count = 0;
24 | static int inst_count = 0;
25 |
26 | static List meta_record = new List();
27 |
28 | static string ConvertBinaryToHex(byte[] arr)
29 | {
30 | var sb = new StringBuilder();
31 | foreach (var t in arr)
32 | sb.AppendFormat("{0:X2}", t);
33 | return sb.ToString();
34 | }
35 |
36 | static void ProcessSafeMode(string path)
37 | {
38 | using(var fs = new FileStream(path, FileMode.Open))
39 | {
40 | fs.Position = 0x80;
41 |
42 | if (fs.ReadByte() == 1)
43 | {
44 | fs.Position--;
45 | fs.WriteByte(2);
46 | Console.WriteLine("Converted as safe mode: " + path);
47 | }
48 | }
49 | }
50 |
51 | static void ProcessEachFile(string dir)
52 | {
53 | //Console.WriteLine("Working directory: " + dir.Substring(Environment.CurrentDirectory.Length));
54 | int remaining_entry = 0;
55 |
56 | foreach (var d in Directory.GetDirectories(dir))
57 | {
58 | ProcessEachFile(d);
59 | remaining_entry += 1;
60 | }
61 |
62 | foreach (var f in Directory.GetFiles(dir))
63 | {
64 | if (f.Contains("eboot.bin"))
65 | {
66 | ProcessSafeMode(f);
67 | return;
68 | }
69 |
70 | var info = new FileInfo(f);
71 | if (info.Length > FileSizeThreshold)
72 | {
73 | using (var fs = new FileStream(f, FileMode.Open))
74 | {
75 | fs.Seek(0, SeekOrigin.Begin);
76 | fs.Read(header_buf, 0, 4);
77 | fs.Seek(0, SeekOrigin.Begin);
78 | fs.Write(header_dummy, 0, 4);
79 | }
80 |
81 | //Console.WriteLine("Processing: " + f.Substring(path_vpk.Length + 1));
82 | var key = "qd_" + data_count.ToString("X4") + ".mp4";
83 | var p = path_mp4 + Path.DirectorySeparatorChar + key;
84 | File.Move(f, p);
85 | var record = "ux0:app/" + app_id + "/" + f.Substring(path_work.Length + 1).Replace('\\', '/') + " " + ConvertBinaryToHex(header_buf);
86 | meta_record.Add(record);
87 | ++data_count;
88 | }
89 | else
90 | remaining_entry += 1;
91 | }
92 |
93 | if(remaining_entry == 0)
94 | {
95 | string path = null;
96 | for (int u = 0; u < 10; ++u) {
97 | path = dir + Path.DirectorySeparatorChar + "qinstph" + u;
98 | if (File.Exists(path))
99 | path = null;
100 | else
101 | break;
102 | }
103 |
104 | if (path == null) throw new Exception("Failed to create placeholder.");
105 |
106 | using (var fs = new FileStream(path, FileMode.CreateNew))
107 | {
108 | fs.Write(header_dummy, 0, 4);
109 | }
110 | }
111 | }
112 |
113 | static void ProcessWork()
114 | {
115 | byte[] info = null;
116 | using (var fs = new FileStream(path_work + Path.DirectorySeparatorChar + "sce_sys" + Path.DirectorySeparatorChar + "param.sfo", FileMode.Open))
117 | {
118 | using (var buf = new MemoryStream())
119 | {
120 | fs.Seek(-20, SeekOrigin.End);
121 | fs.CopyTo(buf);
122 | info = buf.ToArray();
123 | }
124 | }
125 |
126 | app_id = Encoding.ASCII.GetString(info, 0, 9);
127 | Console.WriteLine("App Id: " + app_id);
128 |
129 | Console.WriteLine("Processing...");
130 | Directory.Delete(path_work + Path.DirectorySeparatorChar + "sce_sys" + Path.DirectorySeparatorChar + "manual", true);
131 | foreach (var d in Directory.GetDirectories(path_work))
132 | {
133 | if (d.Contains("sce_module")) continue;
134 | if (d.Contains("sce_sys")) continue;
135 | ProcessEachFile(d);
136 | }
137 |
138 | Console.WriteLine("Packing...");
139 | ZipUtil.CreateFromDirectory(path_work, path_mp4 + Path.DirectorySeparatorChar + "qinst_" + inst_count.ToString("X2") + ".mp4");
140 |
141 | ++inst_count;
142 | }
143 |
144 | static void ProcessDirectory(string dir)
145 | {
146 | if (Directory.Exists(path_work))
147 | {
148 | Console.WriteLine("Removing temporary folder...");
149 | Directory.Delete(path_work, true);
150 | while (Directory.Exists(path_work)) { Thread.Sleep(100); }
151 | }
152 |
153 | new DirectoryInfo(dir).MoveTo(path_work);
154 | while (!Directory.Exists(path_work)) { Thread.Sleep(100); }
155 |
156 | ProcessWork();
157 | }
158 |
159 | static void ProcessVPK(string vpk)
160 | {
161 | var ext = vpk.Substring(vpk.Length - 3).ToLower();
162 | if (ext != "vpk") return;
163 |
164 | Console.WriteLine("Found vpk: " + vpk.Substring(vpk.LastIndexOf(Path.DirectorySeparatorChar) + 1));
165 |
166 | if (Directory.Exists(path_work))
167 | {
168 | Console.WriteLine("Removing temporary folder...");
169 | Directory.Delete(path_work, true);
170 | while(Directory.Exists(path_work)) { Thread.Sleep(100); }
171 | }
172 |
173 | Directory.CreateDirectory(path_work);
174 | while (!Directory.Exists(path_work)) { Thread.Sleep(100); }
175 |
176 | Console.WriteLine("Extracting...");
177 | ZipUtil.ExtractToDirectory(vpk, path_work);
178 |
179 | ProcessWork();
180 | }
181 |
182 | static void Main(string[] args)
183 | {
184 | path_work = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "work";
185 | path_mp4 = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "mp4";
186 | path_vpk = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "vpk";
187 |
188 | if (!Directory.Exists(path_vpk))
189 | {
190 | Console.WriteLine("Directory vpk is not found.");
191 | return;
192 | }
193 |
194 | if (Directory.Exists(path_mp4))
195 | {
196 | Directory.Delete(path_mp4, true);
197 | while (Directory.Exists(path_mp4)) { Thread.Sleep(100); }
198 | }
199 |
200 | Directory.CreateDirectory(path_mp4);
201 | while (!Directory.Exists(path_mp4)) { Thread.Sleep(100); }
202 |
203 | foreach (var t in Directory.GetFiles(path_vpk))
204 | ProcessVPK(t);
205 | foreach (var t in Directory.GetDirectories(path_vpk))
206 | ProcessDirectory(t);
207 |
208 | if (Directory.Exists(path_work))
209 | {
210 | Console.WriteLine("Removing temporary folder...");
211 | Directory.Delete(path_work, true);
212 | while (Directory.Exists(path_work)) { Thread.Sleep(100); }
213 |
214 | using (var fs = new FileStream(path_mp4 + Path.DirectorySeparatorChar + "qmeta.mp4", FileMode.CreateNew))
215 | {
216 | using (var writer = new StreamWriter(fs, new UTF8Encoding(false)))
217 | {
218 | foreach (var t in meta_record)
219 | {
220 | writer.WriteLine(t);
221 | }
222 | }
223 | }
224 | }
225 |
226 | Console.WriteLine("Press any key to exit.");
227 | Console.ReadKey(true);
228 | }
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/package_installer.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include "package_installer.h"
27 | #include "archive.h"
28 | #include "file.h"
29 | #include "utils.h"
30 | #include "sfo.h"
31 | #include "sha1.h"
32 | #include "sysmodule_internal.h"
33 | #include "libpromoter/promoterutil.h"
34 |
35 | #include "base_head_bin.h"
36 |
37 | void loadScePaf() {
38 | uint32_t ptr[0x100] = { 0 };
39 | ptr[0] = 0;
40 | ptr[1] = (uint32_t)&ptr[0];
41 | uint32_t scepaf_argp[] = { 0x400000, 0xEA60, 0x40000, 0, 0 };
42 | sceSysmoduleLoadModuleInternalWithArg(0x80000008, sizeof(scepaf_argp), scepaf_argp, ptr);
43 | }
44 |
45 | int patchRetailContents() {
46 | int res;
47 |
48 | SceIoStat stat;
49 | memset(&stat, 0, sizeof(SceIoStat));
50 | res = sceIoGetstat(PACKAGE_DIR "/sce_sys/retail/livearea", &stat);
51 | if (res < 0)
52 | return res;
53 |
54 | res = sceIoRename(PACKAGE_DIR "/sce_sys/livearea", PACKAGE_DIR "/sce_sys/livearea_org");
55 | if (res < 0)
56 | return res;
57 |
58 | res = sceIoRename(PACKAGE_DIR "/sce_sys/retail/livearea", PACKAGE_DIR "/sce_sys/livearea");
59 | if (res < 0)
60 | return res;
61 |
62 | return 0;
63 | }
64 |
65 | int restoreRetailContents(char *titleid) {
66 | int res;
67 | char src_path[128], dst_path[128];
68 |
69 | sprintf(src_path, "ux0:app/%s/sce_sys/livearea", titleid);
70 | sprintf(dst_path, "ux0:app/%s/sce_sys/retail/livearea", titleid);
71 | res = sceIoRename(src_path, dst_path);
72 | if (res < 0)
73 | return res;
74 |
75 | sprintf(src_path, "ux0:app/%s/sce_sys/livearea_org", titleid);
76 | sprintf(dst_path, "ux0:app/%s/sce_sys/livearea", titleid);
77 | res = sceIoRename(src_path, dst_path);
78 | if (res < 0)
79 | return res;
80 |
81 | return 0;
82 | }
83 |
84 | int promoteUpdate(char *path, char *titleid, char *category, void *sfo_buffer, int sfo_size) {
85 | int res;
86 |
87 | // Update installation
88 | if (strcmp(category, "gp") == 0) {
89 | // Change category to 'gd'
90 | setSfoString(sfo_buffer, "CATEGORY", "gd");
91 | WriteFile(PACKAGE_DIR "/sce_sys/param.sfo", sfo_buffer, sfo_size);
92 |
93 | // App path
94 | char app_path[MAX_PATH_LENGTH];
95 | snprintf(app_path, MAX_PATH_LENGTH, "ux0:app/%s", titleid);
96 |
97 | /*
98 | Without the following trick, the livearea won't be updated and the game will even crash
99 | */
100 |
101 | // Integrate patch to app
102 | res = movePath(path, app_path, MOVE_INTEGRATE | MOVE_REPLACE, NULL);
103 | if (res < 0)
104 | return res;
105 |
106 | // Move app to promotion directory
107 | res = movePath(app_path, path, 0, NULL);
108 | if (res < 0)
109 | return res;
110 | }
111 |
112 | return 0;
113 | }
114 |
115 | int promote(char *path) {
116 | int res;
117 |
118 | // Read param.sfo
119 | void *sfo_buffer = NULL;
120 | int sfo_size = allocateReadFile(PACKAGE_DIR "/sce_sys/param.sfo", &sfo_buffer);
121 | if (sfo_size < 0)
122 | return sfo_size;
123 |
124 | // Get titleid
125 | char titleid[12];
126 | getSfoString(sfo_buffer, "TITLE_ID", titleid, sizeof(titleid));
127 |
128 | // Get category
129 | char category[4];
130 | getSfoString(sfo_buffer, "CATEGORY", category, sizeof(category));
131 |
132 | // Promote update
133 | promoteUpdate(path, titleid, category, sfo_buffer, sfo_size);
134 |
135 | // Free sfo buffer
136 | free(sfo_buffer);
137 |
138 | // Patch to use retail contents so the game is not shown as test version
139 | int patch_retail_contents = patchRetailContents();
140 |
141 | loadScePaf();
142 |
143 | res = sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_PROMOTER_UTIL);
144 | if (res < 0)
145 | return res;
146 |
147 | res = scePromoterUtilityInit();
148 | if (res < 0)
149 | return res;
150 |
151 | res = scePromoterUtilityPromotePkg(path, 0);
152 | if (res < 0)
153 | return res;
154 |
155 | int state = 0;
156 | do {
157 | res = scePromoterUtilityGetState(&state);
158 | if (res < 0)
159 | return res;
160 |
161 | sceKernelDelayThread(100 * 1000);
162 | } while (state);
163 |
164 | int result = 0;
165 | res = scePromoterUtilityGetResult(&result);
166 | if (res < 0)
167 | return res;
168 |
169 | res = scePromoterUtilityExit();
170 | if (res < 0)
171 | return res;
172 |
173 | res = sceSysmoduleUnloadModuleInternal(SCE_SYSMODULE_PROMOTER_UTIL);
174 | if (res < 0)
175 | return res;
176 |
177 | // Restore
178 | if (patch_retail_contents >= 0)
179 | restoreRetailContents(titleid);
180 |
181 | // Using the promoteUpdate trick, we get 0x80870005 as result, but it installed correctly though, so return ok
182 | return result == 0x80870005 ? 0 : result;
183 | }
184 |
185 | void fpkg_hmac(const uint8_t *data, unsigned int len, uint8_t hmac[16]) {
186 | SHA1_CTX ctx;
187 | uint8_t sha1[20];
188 | uint8_t buf[64];
189 |
190 | sha1_init(&ctx);
191 | sha1_update(&ctx, data, len);
192 | sha1_final(&ctx, sha1);
193 |
194 | memset(buf, 0, 64);
195 | memcpy(&buf[0], &sha1[4], 8);
196 | memcpy(&buf[8], &sha1[4], 8);
197 | memcpy(&buf[16], &sha1[12], 4);
198 | buf[20] = sha1[16];
199 | buf[21] = sha1[1];
200 | buf[22] = sha1[2];
201 | buf[23] = sha1[3];
202 | memcpy(&buf[24], &buf[16], 8);
203 |
204 | sha1_init(&ctx);
205 | sha1_update(&ctx, buf, 64);
206 | sha1_final(&ctx, sha1);
207 | memcpy(hmac, sha1, 16);
208 | }
209 |
210 | int makeHeadBin() {
211 | uint8_t hmac[16];
212 | uint32_t off;
213 | uint32_t len;
214 | uint32_t out;
215 |
216 | // head.bin must not be present
217 | SceIoStat stat;
218 | memset(&stat, 0, sizeof(SceIoStat));
219 | if (sceIoGetstat(HEAD_BIN, &stat) >= 0)
220 | return -1;
221 |
222 | // Read param.sfo
223 | void *sfo_buffer = NULL;
224 | int res = allocateReadFile(PACKAGE_DIR "/sce_sys/param.sfo", &sfo_buffer);
225 | if (res < 0)
226 | return res;
227 |
228 | // Get title id
229 | char titleid[12];
230 | memset(titleid, 0, sizeof(titleid));
231 | getSfoString(sfo_buffer, "TITLE_ID", titleid, sizeof(titleid));
232 |
233 | // Enforce TITLE_ID format
234 | if (strlen(titleid) != 9)
235 | return -2;
236 |
237 | // Get content id
238 | char contentid[48];
239 | memset(contentid, 0, sizeof(contentid));
240 | getSfoString(sfo_buffer, "CONTENT_ID", contentid, sizeof(contentid));
241 |
242 | // Free sfo buffer
243 | free(sfo_buffer);
244 |
245 | // Allocate head.bin buffer
246 | uint8_t *head_bin = malloc(sizeof(base_head_bin));
247 | memcpy(head_bin, base_head_bin, sizeof(base_head_bin));
248 |
249 | // Write full title id
250 | char full_title_id[48];
251 | snprintf(full_title_id, sizeof(full_title_id), "EP9000-%s_00-XXXXXXXXXXXXXXXX", titleid);
252 | strncpy((char *)&head_bin[0x30], strlen(contentid) > 0 ? contentid : full_title_id, 48);
253 |
254 | // hmac of pkg header
255 | len = ntohl(*(uint32_t *)&head_bin[0xD0]);
256 | fpkg_hmac(&head_bin[0], len, hmac);
257 | memcpy(&head_bin[len], hmac, 16);
258 |
259 | // hmac of pkg info
260 | off = ntohl(*(uint32_t *)&head_bin[0x8]);
261 | len = ntohl(*(uint32_t *)&head_bin[0x10]);
262 | out = ntohl(*(uint32_t *)&head_bin[0xD4]);
263 | fpkg_hmac(&head_bin[off], len - 64, hmac);
264 | memcpy(&head_bin[out], hmac, 16);
265 |
266 | // hmac of everything
267 | len = ntohl(*(uint32_t *)&head_bin[0xE8]);
268 | fpkg_hmac(&head_bin[0], len, hmac);
269 | memcpy(&head_bin[len], hmac, 16);
270 |
271 | // Make dir
272 | sceIoMkdir(PACKAGE_DIR "/sce_sys/package", 0777);
273 |
274 | // Write head.bin
275 | WriteFile(HEAD_BIN, head_bin, sizeof(base_head_bin));
276 |
277 | free(head_bin);
278 |
279 | return 0;
280 | }
281 |
282 | int installPackage(char* file, FileProcessParam* param) {
283 | int res;
284 |
285 | // Recursively clean up package_temp directory
286 | removePath(PACKAGE_PARENT, NULL);
287 | sceIoMkdir(PACKAGE_PARENT, 0777);
288 |
289 | // Open archive
290 | res = archiveOpen(file);
291 | if (res < 0)
292 | return res;
293 |
294 | // Src path
295 | char src_path[MAX_PATH_LENGTH];
296 | strcpy(src_path, file);
297 | addEndSlash(src_path);
298 |
299 | // Extract process
300 | if(param) {
301 | uint64_t size;
302 | uint32_t folders;
303 | uint32_t files;
304 | getArchivePathInfo(src_path, &size, &folders, &files);
305 |
306 | uint32_t count = size + folders;
307 | param->max = count > 0 ? count : 1;
308 | }
309 |
310 | res = extractArchivePath(src_path, PACKAGE_DIR "/", param);
311 | if (res < 0)
312 | return res;
313 |
314 | // Close archive
315 | res = archiveClose();
316 | if (res < 0)
317 | return res;
318 |
319 | // Make head.bin
320 | res = makeHeadBin();
321 | if (res < 0)
322 | return res;
323 |
324 | // Promote
325 | res = promote(PACKAGE_DIR);
326 | if (res < 0)
327 | return res;
328 |
329 | return 0;
330 | }
331 |
332 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/font.c:
--------------------------------------------------------------------------------
1 | /*
2 | * PSP Software Development Kit - http://www.pspdev.org
3 | * -----------------------------------------------------------------------
4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 | *
6 | * font.c - Debug Font.
7 | *
8 | * Copyright (c) 2005 Marcus R. Brown
9 | * Copyright (c) 2005 James Forshaw
10 | * Copyright (c) 2005 John Kelley
11 | *
12 | * $Id: font.c 540 2005-07-08 19:35:10Z warren $
13 | */
14 |
15 | const unsigned char msx_font[] __attribute((aligned(4))) =
16 | /*"\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c"
17 | "\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00"
18 | "\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00"
19 | "\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00"
20 | "\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00"
21 | "\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70"
22 | "\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0"
23 | "\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00"
24 | "\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00"
25 | "\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10"
26 | "\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10"
27 | "\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00"
28 | "\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10"
29 | "\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00"
30 | "\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80"
31 | "\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00"*/
32 | "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00"
33 | "\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00"
34 | "\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00"
35 | "\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00"
36 | "\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00"
37 | "\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00"
38 | "\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00"
39 | "\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00"
40 | "\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00"
41 | "\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00"
42 | "\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00"
43 | "\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00"
44 | "\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00"
45 | "\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40"
46 | "\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00"
47 | "\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00"
48 | "\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00"
49 | "\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00"
50 | "\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00"
51 | "\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00"
52 | "\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00"
53 | "\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00"
54 | "\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00"
55 | "\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00"
56 | "\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00"
57 | "\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00"
58 | "\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00"
59 | "\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00"
60 | "\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00"
61 | "\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00"
62 | "\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00"
63 | "\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00"
64 | "\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00"
65 | "\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00"
66 | "\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00"
67 | "\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70"
68 | "\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00"
69 | "\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00"
70 | "\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00"
71 | "\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00"
72 | "\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08"
73 | "\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00"
74 | "\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00"
75 | "\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00"
76 | "\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70"
77 | "\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00"
78 | "\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00"
79 | "\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00"
80 | "\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00"
81 | /*"\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00"
82 | "\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00"
83 | "\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60"
84 | "\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00"
85 | "\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00"
86 | "\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00"
87 | "\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00"
88 | "\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00"
89 | "\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00"
90 | "\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00"
91 | "\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00"
92 | "\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00"
93 | "\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20"
94 | "\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00"
95 | "\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40"
96 | "\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00"
97 | "\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00"
98 | "\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00"
99 | "\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0"
100 | "\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00"
101 | "\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c"
102 | "\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00"
103 | "\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00"
104 | "\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00"
105 | "\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00"
106 | "\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00"
107 | "\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00"
108 | "\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20"
109 | "\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00"
110 | "\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00"
111 | "\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70"
112 | "\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f"
113 | "\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00"
114 | "\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00"
115 | "\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0"
116 | "\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03"
117 | "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88"
118 | "\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00"
119 | "\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00"
120 | "\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff"
121 | "\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00"
122 | "\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00"
123 | "\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc"
124 | "\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00"
125 | "\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff"
126 | "\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0"
127 | "\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00"
128 | "\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0"
129 | "\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00"
130 | "\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00"
131 | "\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00"
132 | "\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00"
133 | "\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20"
134 | "\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00"
135 | "\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00"
136 | "\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00"
137 | "\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00"
138 | "\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40"
139 | "\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00"
140 | "\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00"
141 | "\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00"
142 | "\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00"
143 | "\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00"*/;
144 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/minizip/zip.h:
--------------------------------------------------------------------------------
1 | /* zip.h -- IO on .zip files using zlib
2 | Version 1.1, February 14h, 2010
3 | part of the MiniZip project
4 |
5 | Copyright (C) 1998-2010 Gilles Vollant
6 | http://www.winimage.com/zLibDll/minizip.html
7 | Modifications for Zip64 support
8 | Copyright (C) 2009-2010 Mathias Svensson
9 | http://result42.com
10 |
11 | This program is distributed under the terms of the same license as zlib.
12 | See the accompanying LICENSE file for the full text of the license.
13 | */
14 |
15 | #ifndef _ZIP_H
16 | #define _ZIP_H
17 |
18 | #ifdef __cplusplus
19 | extern "C" {
20 | #endif
21 |
22 | #ifndef _ZLIB_H
23 | # include "zlib.h"
24 | #endif
25 |
26 | #ifndef _ZLIBIOAPI_H
27 | # include "ioapi.h"
28 | #endif
29 |
30 | #ifdef HAVE_BZIP2
31 | # include "bzlib.h"
32 | #endif
33 |
34 | #define Z_BZIP2ED 12
35 |
36 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
37 | /* like the STRICT of WIN32, we define a pointer that cannot be converted
38 | from (void*) without cast */
39 | typedef struct TagzipFile__ { int unused; } zipFile__;
40 | typedef zipFile__ *zipFile;
41 | #else
42 | typedef voidp zipFile;
43 | #endif
44 |
45 | #define ZIP_OK (0)
46 | #define ZIP_EOF (0)
47 | #define ZIP_ERRNO (Z_ERRNO)
48 | #define ZIP_PARAMERROR (-102)
49 | #define ZIP_BADZIPFILE (-103)
50 | #define ZIP_INTERNALERROR (-104)
51 |
52 | #ifndef DEF_MEM_LEVEL
53 | # if MAX_MEM_LEVEL >= 8
54 | # define DEF_MEM_LEVEL 8
55 | # else
56 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL
57 | # endif
58 | #endif
59 | /* default memLevel */
60 |
61 | /* tm_zip contain date/time info */
62 | typedef struct tm_zip_s
63 | {
64 | uInt tm_sec; /* seconds after the minute - [0,59] */
65 | uInt tm_min; /* minutes after the hour - [0,59] */
66 | uInt tm_hour; /* hours since midnight - [0,23] */
67 | uInt tm_mday; /* day of the month - [1,31] */
68 | uInt tm_mon; /* months since January - [0,11] */
69 | uInt tm_year; /* years - [1980..2044] */
70 | } tm_zip;
71 |
72 | typedef struct
73 | {
74 | tm_zip tmz_date; /* date in understandable format */
75 | uLong dosDate; /* if dos_date == 0, tmu_date is used */
76 | uLong internal_fa; /* internal file attributes 2 bytes */
77 | uLong external_fa; /* external file attributes 4 bytes */
78 | } zip_fileinfo;
79 |
80 | #define APPEND_STATUS_CREATE (0)
81 | #define APPEND_STATUS_CREATEAFTER (1)
82 | #define APPEND_STATUS_ADDINZIP (2)
83 |
84 | /***************************************************************************/
85 | /* Writing a zip file */
86 |
87 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
88 | extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
89 | /* Create a zipfile.
90 |
91 | pathname should contain the full pathname (by example, on a Windows XP computer
92 | "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
93 |
94 | return NULL if zipfile cannot be opened
95 | return zipFile handle if no error
96 |
97 | If the file pathname exist and append == APPEND_STATUS_CREATEAFTER, the zip
98 | will be created at the end of the file. (useful if the file contain a self extractor code)
99 | If the file pathname exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing
100 | zip (be sure you don't add file that doesn't exist)
101 |
102 | NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile,
103 | you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
104 | the file you did not want delete. */
105 |
106 | extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, const char ** globalcomment,
107 | zlib_filefunc_def* pzlib_filefunc_def));
108 |
109 | extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, int append, const char ** globalcomment,
110 | zlib_filefunc64_def* pzlib_filefunc_def));
111 |
112 | extern zipFile ZEXPORT zipOpen3 OF((const char *pathname, int append, ZPOS64_T disk_size,
113 | const char ** globalcomment, zlib_filefunc_def* pzlib_filefunc_def));
114 | /* Same as zipOpen2 but allows specification of spanned zip size */
115 |
116 | extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append, ZPOS64_T disk_size,
117 | const char ** globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
118 |
119 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
120 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
121 | uInt size_extrafield_global, const char* comment, int method, int level));
122 | /* Open a file in the ZIP for writing.
123 |
124 | filename : the filename in zip (if NULL, '-' without quote will be used
125 | *zipfi contain supplemental information
126 | extrafield_local buffer to store the local header extra field data, can be NULL
127 | size_extrafield_local size of extrafield_local buffer
128 | extrafield_global buffer to store the global header extra field data, can be NULL
129 | size_extrafield_global size of extrafield_local buffer
130 | comment buffer for comment string
131 | method contain the compression method (0 for store, Z_DEFLATED for deflate)
132 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
133 | zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
134 | this MUST be '1' if the uncompressed size is >= 0xffffffff. */
135 |
136 | extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
137 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
138 | uInt size_extrafield_global, const char* comment, int method, int level, int zip64));
139 | /* Same as zipOpenNewFileInZip with zip64 support */
140 |
141 | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
142 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
143 | uInt size_extrafield_global, const char* comment, int method, int level, int raw));
144 | /* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
145 |
146 | extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
147 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
148 | uInt size_extrafield_global, const char* comment, int method, int level, int raw, int zip64));
149 | /* Same as zipOpenNewFileInZip3 with zip64 support */
150 |
151 | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
152 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
153 | uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
154 | int strategy, const char* password, uLong crcForCrypting));
155 | /* Same as zipOpenNewFileInZip2, except
156 | windowBits, memLevel, strategy : see parameter strategy in deflateInit2
157 | password : crypting password (NULL for no crypting)
158 | crcForCrypting : crc of file to compress (needed for crypting) */
159 |
160 | extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
161 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
162 | uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
163 | int strategy, const char* password, uLong crcForCrypting, int zip64));
164 | /* Same as zipOpenNewFileInZip3 with zip64 support */
165 |
166 | extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
167 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
168 | uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
169 | int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase));
170 | /* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
171 |
172 | extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
173 | const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
174 | uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
175 | int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64));
176 | /* Same as zipOpenNewFileInZip4 with zip64 support */
177 |
178 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, const void* buf, unsigned len));
179 | /* Write data in the zipfile */
180 |
181 | extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
182 | /* Close the current file in the zipfile */
183 |
184 | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32));
185 | extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, ZPOS64_T uncompressed_size, uLong crc32));
186 | /* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
187 | uncompressed_size and crc32 are value for the uncompressed size */
188 |
189 | extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment));
190 | /* Close the zipfile */
191 |
192 | extern int ZEXPORT zipClose_64 OF((zipFile file, const char* global_comment));
193 |
194 | extern int ZEXPORT zipClose2_64 OF((zipFile file, const char* global_comment, uLong versionMadeBy));
195 | /* Same as zipClose_64 except versionMadeBy field */
196 |
197 | /***************************************************************************/
198 |
199 | #ifdef __cplusplus
200 | }
201 | #endif
202 |
203 | #endif /* _ZIP_H */
204 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/archive.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 |
21 | #include
22 |
23 | #include "global.h"
24 | #include "archive.h"
25 | #include "file.h"
26 | #include "utils.h"
27 |
28 | #include "minizip/unzip.h"
29 |
30 | static int archive_path_start = 0;
31 | static unzFile uf = NULL;
32 | static FileList archive_list;
33 |
34 | int fileListGetArchiveEntries(FileList *list, char *path) {
35 | int res;
36 |
37 | if (!uf)
38 | return -1;
39 |
40 | FileListEntry *entry = malloc(sizeof(FileListEntry));
41 | strcpy(entry->name, DIR_UP);
42 | entry->name_length = strlen(entry->name);
43 | entry->is_folder = 1;
44 | entry->type = FILE_TYPE_UNKNOWN;
45 | fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER);
46 |
47 | char *archive_path = path + archive_path_start;
48 | int name_length = strlen(archive_path);
49 |
50 | FileListEntry *archive_entry = archive_list.head;
51 |
52 | int i;
53 | for (i = 0; i < archive_list.length; i++) {
54 | if (archive_entry->name_length >= name_length && strncasecmp(archive_entry->name, archive_path, name_length) == 0) { // Needs a / at end
55 | char *p = strchr(archive_entry->name + name_length, '/'); // it's a sub-directory if it has got a slash
56 |
57 | if (p)
58 | *p = '\0';
59 |
60 | char name[MAX_PATH_LENGTH];
61 | strcpy(name, archive_entry->name + name_length);
62 | if (p) {
63 | addEndSlash(name);
64 | }
65 |
66 | if (strlen(name) > 0 && !fileListFindEntry(list, name)) {
67 | FileListEntry *entry = malloc(sizeof(FileListEntry));
68 |
69 | strcpy(entry->name, archive_entry->name + name_length);
70 |
71 | if (p) {
72 | addEndSlash(entry->name);
73 | entry->is_folder = 1;
74 | entry->type = FILE_TYPE_UNKNOWN;
75 | list->folders++;
76 | } else {
77 | entry->is_folder = 0;
78 | entry->type = getFileType(entry->name);
79 | list->files++;
80 | }
81 |
82 | entry->name_length = strlen(entry->name);
83 | entry->size = archive_entry->size;
84 |
85 | memcpy(&entry->time, &archive_entry->time, sizeof(SceDateTime));
86 |
87 | fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER);
88 | }
89 |
90 | if (p)
91 | *p = '/';
92 | }
93 |
94 | // Next
95 | archive_entry = archive_entry->next;
96 | }
97 |
98 | return 0;
99 | }
100 |
101 | int getArchivePathInfo(char *path, uint64_t *size, uint32_t *folders, uint32_t *files) {
102 | if (!uf)
103 | return -1;
104 |
105 | SceIoStat stat;
106 | memset(&stat, 0, sizeof(SceIoStat));
107 | if (archiveFileGetstat(path, &stat) < 0) {
108 | FileList list;
109 | memset(&list, 0, sizeof(FileList));
110 | fileListGetArchiveEntries(&list, path);
111 |
112 | FileListEntry *entry = list.head->next; // Ignore ..
113 |
114 | int i;
115 | for (i = 0; i < list.length - 1; i++) {
116 | char *new_path = malloc(strlen(path) + strlen(entry->name) + 2);
117 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s", path, entry->name);
118 |
119 | getArchivePathInfo(new_path, size, folders, files);
120 |
121 | free(new_path);
122 |
123 | entry = entry->next;
124 | }
125 |
126 | if (folders)
127 | (*folders)++;
128 |
129 | fileListEmpty(&list);
130 | } else {
131 | if (size)
132 | (*size) += stat.st_size;
133 |
134 | if (files)
135 | (*files)++;
136 | }
137 |
138 | return 0;
139 | }
140 |
141 | int extractArchivePath(char *src, char *dst, FileProcessParam *param) {
142 | if (!uf)
143 | return -1;
144 |
145 | SceIoStat stat;
146 | memset(&stat, 0, sizeof(SceIoStat));
147 | if (archiveFileGetstat(src, &stat) < 0) {
148 | FileList list;
149 | memset(&list, 0, sizeof(FileList));
150 | fileListGetArchiveEntries(&list, src);
151 |
152 | int ret = sceIoMkdir(dst, 0777);
153 | if (ret < 0 && ret != SCE_ERROR_ERRNO_EEXIST) {
154 | fileListEmpty(&list);
155 | return ret;
156 | }
157 |
158 | if (param) {
159 | if (param->value)
160 | (*param->value)++;
161 |
162 | if (param->SetProgress)
163 | param->SetProgress(param->value ? *param->value : 0, param->max);
164 |
165 | if (param->cancelHandler && param->cancelHandler()) {
166 | fileListEmpty(&list);
167 | return 0;
168 | }
169 | }
170 |
171 | FileListEntry *entry = list.head->next; // Ignore ..
172 |
173 | int i;
174 | for (i = 0; i < list.length - 1; i++) {
175 | char *src_path = malloc(strlen(src) + strlen(entry->name) + 2);
176 | snprintf(src_path, MAX_PATH_LENGTH, "%s%s", src, entry->name);
177 |
178 | char *dst_path = malloc(strlen(dst) + strlen(entry->name) + 2);
179 | snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", dst, entry->name);
180 |
181 | int ret = extractArchivePath(src_path, dst_path, param);
182 |
183 | free(dst_path);
184 | free(src_path);
185 |
186 | if (ret <= 0) {
187 | fileListEmpty(&list);
188 | return ret;
189 | }
190 |
191 | entry = entry->next;
192 | }
193 |
194 | fileListEmpty(&list);
195 | } else {
196 | SceUID fdsrc = archiveFileOpen(src, SCE_O_RDONLY, 0);
197 | if (fdsrc < 0)
198 | return fdsrc;
199 |
200 | SceUID fddst = sceIoOpen(dst, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
201 | if (fddst < 0) {
202 | archiveFileClose(fdsrc);
203 | return fddst;
204 | }
205 |
206 | void *buf = malloc(TRANSFER_SIZE);
207 |
208 | int read;
209 | while ((read = archiveFileRead(fdsrc, buf, TRANSFER_SIZE)) > 0) {
210 | int res = sceIoWrite(fddst, buf, read);
211 | if (res < 0) {
212 | free(buf);
213 |
214 | sceIoClose(fddst);
215 | archiveFileClose(fdsrc);
216 |
217 | return res;
218 | }
219 |
220 | if (param) {
221 | if (param->value)
222 | (*param->value) += read;
223 |
224 | if (param->SetProgress)
225 | param->SetProgress(param->value ? *param->value : 0, param->max);
226 |
227 | if (param->cancelHandler && param->cancelHandler()) {
228 | free(buf);
229 |
230 | sceIoClose(fddst);
231 | archiveFileClose(fdsrc);
232 |
233 | return 0;
234 | }
235 | }
236 | }
237 |
238 | free(buf);
239 |
240 | sceIoClose(fddst);
241 | archiveFileClose(fdsrc);
242 | }
243 |
244 | return 1;
245 | }
246 |
247 | int archiveFileGetstat(const char *file, SceIoStat *stat) {
248 | if (!uf)
249 | return -1;
250 |
251 | const char *archive_path = file + archive_path_start;
252 | int name_length = strlen(archive_path);
253 |
254 | // Is directory
255 | if (archive_path[name_length - 1] == '/')
256 | return -1;
257 |
258 | FileListEntry *archive_entry = archive_list.head;
259 |
260 | int i;
261 | for (i = 0; i < archive_list.length; i++) {
262 | if (archive_entry->name_length == name_length && strcasecmp(archive_entry->name, archive_path) == 0) {
263 | if (stat) {
264 | //stat->st_mode =
265 | //stat->st_attr =
266 | stat->st_size = archive_entry->size;
267 | memcpy(&stat->st_ctime, &archive_entry->time, sizeof(SceDateTime));
268 | memcpy(&stat->st_atime, &archive_entry->time, sizeof(SceDateTime));
269 | memcpy(&stat->st_mtime, &archive_entry->time, sizeof(SceDateTime));
270 | }
271 |
272 | return 0;
273 | }
274 |
275 | // Next
276 | archive_entry = archive_entry->next;
277 | }
278 |
279 | return -1;
280 | }
281 |
282 | int archiveFileOpen(const char *file, int flags, SceMode mode) {
283 | int res;
284 |
285 | if (!uf)
286 | return -1;
287 |
288 | const char *archive_path = file + archive_path_start;
289 | int name_length = strlen(archive_path);
290 |
291 | FileListEntry *archive_entry = archive_list.head;
292 |
293 | int i;
294 | for (i = 0; i < archive_list.length; i++) {
295 | if (archive_entry->name_length == name_length && strcasecmp(archive_entry->name, archive_path) == 0) {
296 | // Set pos
297 | unzGoToFilePos64(uf, (unz64_file_pos *)&archive_entry->reserved);
298 |
299 | // Open
300 | res = unzOpenCurrentFile(uf);
301 | if (res < 0)
302 | return res;
303 |
304 | return ARCHIVE_FD;
305 | }
306 |
307 | // Next
308 | archive_entry = archive_entry->next;
309 | }
310 |
311 | return -1;
312 | }
313 |
314 | int archiveFileRead(SceUID fd, void *data, SceSize size) {
315 | if (!uf || fd != ARCHIVE_FD)
316 | return -1;
317 |
318 | return unzReadCurrentFile(uf, data, size);
319 | }
320 |
321 | int archiveFileClose(SceUID fd) {
322 | if (!uf || fd != ARCHIVE_FD)
323 | return -1;
324 |
325 | return unzCloseCurrentFile(uf);
326 | }
327 |
328 | int ReadArchiveFile(char *file, void *buf, int size) {
329 | SceUID fd = archiveFileOpen(file, SCE_O_RDONLY, 0);
330 | if (fd < 0)
331 | return fd;
332 |
333 | int read = archiveFileRead(fd, buf, size);
334 | archiveFileClose(fd);
335 | return read;
336 | }
337 |
338 | int archiveClose() {
339 | if (!uf)
340 | return -1;
341 |
342 | fileListEmpty(&archive_list);
343 |
344 | unzClose(uf);
345 | uf = NULL;
346 |
347 | return 0;
348 | }
349 |
350 | int archiveOpen(char *file) {
351 | // Start position of the archive path
352 | archive_path_start = strlen(file) + 1;
353 |
354 | // Close previous zip file first
355 | if (uf)
356 | unzClose(uf);
357 |
358 | // Open zip file
359 | uf = unzOpen64(file);
360 | if (!uf)
361 | return -1;
362 |
363 | // Clear archive list
364 | memset(&archive_list, 0, sizeof(FileList));
365 |
366 | // Go through all files
367 | int res;
368 | char name[MAX_PATH_LENGTH];
369 | unz_file_info64 file_info;
370 |
371 | res = unzGoToFirstFile2(uf, &file_info, name, MAX_PATH_LENGTH, NULL, 0, NULL, 0);
372 | if (res < 0)
373 | return res;
374 |
375 | while (res >= 0) {
376 | FileListEntry *entry = malloc(sizeof(FileListEntry));
377 |
378 | // File info
379 | strcpy(entry->name, name);
380 | entry->is_folder = 0;
381 | entry->name_length = file_info.size_filename;
382 | entry->size = file_info.uncompressed_size;
383 | //sceRtcSetDosTime(&entry->time, file_info.dosDate);
384 |
385 | // Get pos
386 | unzGetFilePos64(uf, (unz64_file_pos *)&entry->reserved);
387 |
388 | // Add entry
389 | fileListAddEntry(&archive_list, entry, SORT_BY_NAME_AND_FOLDER);
390 |
391 | // Next
392 | res = unzGoToNextFile2(uf, &file_info, name, MAX_PATH_LENGTH, NULL, 0, NULL, 0);
393 | }
394 |
395 | return 0;
396 | }
397 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/minizip/ioapi.c:
--------------------------------------------------------------------------------
1 | /* ioapi.h -- IO base function header for compress/uncompress .zip
2 | part of the MiniZip project
3 |
4 | Copyright (C) 1998-2010 Gilles Vollant
5 | http://www.winimage.com/zLibDll/minizip.html
6 | Modifications for Zip64 support
7 | Copyright (C) 2009-2010 Mathias Svensson
8 | http://result42.com
9 |
10 | This program is distributed under the terms of the same license as zlib.
11 | See the accompanying LICENSE file for the full text of the license.
12 | */
13 |
14 | #include
15 |
16 | #include
17 | #include
18 |
19 | #include "ioapi.h"
20 |
21 | voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
22 | {
23 | if (pfilefunc->zfile_func64.zopen64_file != NULL)
24 | return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
25 | return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
26 | }
27 |
28 | voidpf call_zopendisk64 OF((const zlib_filefunc64_32_def* pfilefunc, voidpf filestream, int number_disk, int mode))
29 | {
30 | if (pfilefunc->zfile_func64.zopendisk64_file != NULL)
31 | return (*(pfilefunc->zfile_func64.zopendisk64_file)) (pfilefunc->zfile_func64.opaque,filestream,number_disk,mode);
32 | return (*(pfilefunc->zopendisk32_file))(pfilefunc->zfile_func64.opaque,filestream,number_disk,mode);
33 | }
34 |
35 | long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
36 | {
37 | uLong offsetTruncated;
38 | if (pfilefunc->zfile_func64.zseek64_file != NULL)
39 | return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
40 | offsetTruncated = (uLong)offset;
41 | if (offsetTruncated != offset)
42 | return -1;
43 | return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
44 | }
45 |
46 | ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
47 | {
48 | uLong tell_uLong;
49 | if (pfilefunc->zfile_func64.zseek64_file != NULL)
50 | return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
51 | tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
52 | if ((tell_uLong) == 0xffffffff)
53 | return (ZPOS64_T)-1;
54 | return tell_uLong;
55 | }
56 |
57 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
58 | {
59 | p_filefunc64_32->zfile_func64.zopen64_file = NULL;
60 | p_filefunc64_32->zfile_func64.zopendisk64_file = NULL;
61 | p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
62 | p_filefunc64_32->zopendisk32_file = p_filefunc32->zopendisk_file;
63 | p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
64 | p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
65 | p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
66 | p_filefunc64_32->zfile_func64.ztell64_file = NULL;
67 | p_filefunc64_32->zfile_func64.zseek64_file = NULL;
68 | p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
69 | p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
70 | p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
71 | p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
72 | p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
73 | }
74 |
75 | static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
76 | static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
77 | static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
78 | static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
79 | static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
80 | static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
81 | static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
82 |
83 | typedef struct
84 | {
85 | SceUID fd;
86 | int error;
87 | int filenameLength;
88 | void *filename;
89 | } FILE_IOPOSIX;
90 |
91 | static voidpf file_build_ioposix(SceUID fd, const char *filename)
92 | {
93 | FILE_IOPOSIX *ioposix = NULL;
94 | if (fd < 0)
95 | return NULL;
96 | ioposix = (FILE_IOPOSIX*)malloc(sizeof(FILE_IOPOSIX));
97 | ioposix->fd = fd;
98 | ioposix->error = 0;
99 | ioposix->filenameLength = strlen(filename) + 1;
100 | ioposix->filename = (char*)malloc(ioposix->filenameLength * sizeof(char));
101 | strncpy(ioposix->filename, filename, ioposix->filenameLength);
102 | return (voidpf)ioposix;
103 | }
104 |
105 | static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
106 | {
107 | SceUID fd = -1;
108 | int mode_fopen = 0;
109 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
110 | mode_fopen = SCE_O_RDONLY;
111 | else
112 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
113 | mode_fopen = SCE_O_RDWR;
114 | else
115 | if (mode & ZLIB_FILEFUNC_MODE_CREATE)
116 | mode_fopen = SCE_O_WRONLY | SCE_O_CREAT;
117 |
118 | if ((filename != NULL) && (mode_fopen != 0))
119 | {
120 | fd = sceIoOpen(filename, mode_fopen, 0777);
121 | return file_build_ioposix(fd, filename);
122 | }
123 |
124 | return NULL;
125 | }
126 |
127 | static voidpf ZCALLBACK fopendisk_file_func (voidpf opaque, voidpf stream, int number_disk, int mode)
128 | {
129 | FILE_IOPOSIX *ioposix = NULL;
130 | char *diskFilename = NULL;
131 | voidpf ret = NULL;
132 | int i = 0;
133 |
134 | if (stream == NULL)
135 | return NULL;
136 | ioposix = (FILE_IOPOSIX*)stream;
137 | diskFilename = (char*)malloc(ioposix->filenameLength * sizeof(char));
138 | strncpy(diskFilename, ioposix->filename, ioposix->filenameLength);
139 | for (i = ioposix->filenameLength - 1; i >= 0; i -= 1)
140 | {
141 | if (diskFilename[i] != '.')
142 | continue;
143 | snprintf(&diskFilename[i], ioposix->filenameLength - i, ".z%02d", number_disk + 1);
144 | break;
145 | }
146 | if (i >= 0)
147 | ret = fopen_file_func(opaque, diskFilename, mode);
148 | free(diskFilename);
149 | return ret;
150 | }
151 |
152 | static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
153 | {
154 | FILE_IOPOSIX *ioposix = NULL;
155 | uLong ret;
156 | if (stream == NULL)
157 | return -1;
158 | ioposix = (FILE_IOPOSIX*)stream;
159 | ret = (uLong)sceIoRead(ioposix->fd, buf, (size_t)size);
160 | ioposix->error = (int)ret;
161 | return ret;
162 | }
163 |
164 | static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
165 | {
166 | FILE_IOPOSIX *ioposix = NULL;
167 | uLong ret;
168 | if (stream == NULL)
169 | return -1;
170 | ioposix = (FILE_IOPOSIX*)stream;
171 | ret = (uLong)sceIoWrite(ioposix->fd, buf, (size_t)size);
172 | ioposix->error = (int)ret;
173 | return ret;
174 | }
175 |
176 | static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
177 | {
178 | FILE_IOPOSIX *ioposix = NULL;
179 | long ret = -1;
180 | if (stream == NULL)
181 | return ret;
182 | ioposix = (FILE_IOPOSIX*)stream;
183 | ret = (long)sceIoLseek32(ioposix->fd, 0, SCE_SEEK_CUR);
184 | ioposix->error = (int)ret;
185 | return ret;
186 | }
187 |
188 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
189 | {
190 | FILE_IOPOSIX *ioposix = NULL;
191 | ZPOS64_T ret = -1;
192 | if (stream == NULL)
193 | return ret;
194 | ioposix = (FILE_IOPOSIX*)stream;
195 | ret = (ZPOS64_T)sceIoLseek(ioposix->fd, 0, SCE_SEEK_CUR);
196 | ioposix->error = (int)ret;
197 | return ret;
198 | }
199 |
200 | static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
201 | {
202 | FILE_IOPOSIX *ioposix = NULL;
203 | int fseek_origin = 0;
204 | long ret = 0;
205 |
206 | if (stream == NULL)
207 | return -1;
208 | ioposix = (FILE_IOPOSIX*)stream;
209 |
210 | switch (origin)
211 | {
212 | case ZLIB_FILEFUNC_SEEK_CUR:
213 | fseek_origin = SCE_SEEK_CUR;
214 | break;
215 | case ZLIB_FILEFUNC_SEEK_END:
216 | fseek_origin = SCE_SEEK_END;
217 | break;
218 | case ZLIB_FILEFUNC_SEEK_SET:
219 | fseek_origin = SCE_SEEK_SET;
220 | break;
221 | default:
222 | return -1;
223 | }
224 | if (sceIoLseek32(ioposix->fd, offset, fseek_origin) < 0)
225 | ret = -1;
226 | return ret;
227 | }
228 |
229 | static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
230 | {
231 | FILE_IOPOSIX *ioposix = NULL;
232 | int fseek_origin = 0;
233 | long ret = 0;
234 |
235 | if (stream == NULL)
236 | return -1;
237 | ioposix = (FILE_IOPOSIX*)stream;
238 |
239 | switch (origin)
240 | {
241 | case ZLIB_FILEFUNC_SEEK_CUR:
242 | fseek_origin = SCE_SEEK_CUR;
243 | break;
244 | case ZLIB_FILEFUNC_SEEK_END:
245 | fseek_origin = SCE_SEEK_END;
246 | break;
247 | case ZLIB_FILEFUNC_SEEK_SET:
248 | fseek_origin = SCE_SEEK_SET;
249 | break;
250 | default:
251 | return -1;
252 | }
253 | if (sceIoLseek(ioposix->fd, offset, fseek_origin) < 0)
254 | ret = -1;
255 | return ret;
256 | }
257 |
258 | static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
259 | {
260 | FILE_IOPOSIX *ioposix = NULL;
261 | int ret = -1;
262 | if (stream == NULL)
263 | return ret;
264 | ioposix = (FILE_IOPOSIX*)stream;
265 | if (ioposix->filename != NULL)
266 | free(ioposix->filename);
267 | ret = sceIoClose(ioposix->fd);
268 | ioposix->error = ret;
269 | free(ioposix);
270 | return ret;
271 | }
272 |
273 | static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
274 | {
275 | FILE_IOPOSIX *ioposix = NULL;
276 | int ret = -1;
277 | if (stream == NULL)
278 | return ret;
279 | ioposix = (FILE_IOPOSIX*)stream;
280 | ret = 0;
281 | if (ioposix->error < 0)
282 | ret = ioposix->error & 0xFF;
283 | return ret;
284 | }
285 |
286 | void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
287 | {
288 | pzlib_filefunc_def->zopen_file = fopen_file_func;
289 | pzlib_filefunc_def->zopendisk_file = fopendisk_file_func;
290 | pzlib_filefunc_def->zread_file = fread_file_func;
291 | pzlib_filefunc_def->zwrite_file = fwrite_file_func;
292 | pzlib_filefunc_def->ztell_file = ftell_file_func;
293 | pzlib_filefunc_def->zseek_file = fseek_file_func;
294 | pzlib_filefunc_def->zclose_file = fclose_file_func;
295 | pzlib_filefunc_def->zerror_file = ferror_file_func;
296 | pzlib_filefunc_def->opaque = NULL;
297 | }
298 |
299 | void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
300 | {
301 | pzlib_filefunc_def->zopen64_file = (void (*))fopen_file_func;
302 | pzlib_filefunc_def->zopendisk64_file = fopendisk_file_func;
303 | pzlib_filefunc_def->zread_file = fread_file_func;
304 | pzlib_filefunc_def->zwrite_file = fwrite_file_func;
305 | pzlib_filefunc_def->ztell64_file = ftell64_file_func;
306 | pzlib_filefunc_def->zseek64_file = fseek64_file_func;
307 | pzlib_filefunc_def->zclose_file = fclose_file_func;
308 | pzlib_filefunc_def->zerror_file = ferror_file_func;
309 | pzlib_filefunc_def->opaque = NULL;
310 | }
311 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/minizip/unzip.h:
--------------------------------------------------------------------------------
1 | /* unzip.h -- IO for uncompress .zip files using zlib
2 | Version 1.1, February 14h, 2010
3 | part of the MiniZip project
4 |
5 | Copyright (C) 1998-2010 Gilles Vollant
6 | http://www.winimage.com/zLibDll/minizip.html
7 | Modifications of Unzip for Zip64
8 | Copyright (C) 2007-2008 Even Rouault
9 | Modifications for Zip64 support on both zip and unzip
10 | Copyright (C) 2009-2010 Mathias Svensson
11 | http://result42.com
12 |
13 | This program is distributed under the terms of the same license as zlib.
14 | See the accompanying LICENSE file for the full text of the license.
15 | */
16 |
17 | #ifndef _UNZ_H
18 | #define _UNZ_H
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef _ZLIB_H
25 | #include "zlib.h"
26 | #endif
27 |
28 | #ifndef _ZLIBIOAPI_H
29 | #include "ioapi.h"
30 | #endif
31 |
32 | #ifdef HAVE_BZIP2
33 | #include "bzlib.h"
34 | #endif
35 |
36 | #define Z_BZIP2ED 12
37 |
38 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
39 | /* like the STRICT of WIN32, we define a pointer that cannot be converted
40 | from (void*) without cast */
41 | typedef struct TagunzFile__ { int unused; } unzFile__;
42 | typedef unzFile__ *unzFile;
43 | #else
44 | typedef voidp unzFile;
45 | #endif
46 |
47 | #define UNZ_OK (0)
48 | #define UNZ_END_OF_LIST_OF_FILE (-100)
49 | #define UNZ_ERRNO (Z_ERRNO)
50 | #define UNZ_EOF (0)
51 | #define UNZ_PARAMERROR (-102)
52 | #define UNZ_BADZIPFILE (-103)
53 | #define UNZ_INTERNALERROR (-104)
54 | #define UNZ_CRCERROR (-105)
55 |
56 | /* tm_unz contain date/time info */
57 | typedef struct tm_unz_s
58 | {
59 | uInt tm_sec; /* seconds after the minute - [0,59] */
60 | uInt tm_min; /* minutes after the hour - [0,59] */
61 | uInt tm_hour; /* hours since midnight - [0,23] */
62 | uInt tm_mday; /* day of the month - [1,31] */
63 | uInt tm_mon; /* months since January - [0,11] */
64 | uInt tm_year; /* years - [1980..2044] */
65 | } tm_unz;
66 |
67 | /* unz_global_info structure contain global data about the ZIPfile
68 | These data comes from the end of central dir */
69 | typedef struct unz_global_info64_s
70 | {
71 | ZPOS64_T number_entry; /* total number of entries in the central dir on this disk */
72 | uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
73 | uLong size_comment; /* size of the global comment of the zipfile */
74 | } unz_global_info64;
75 |
76 | typedef struct unz_global_info_s
77 | {
78 | uLong number_entry; /* total number of entries in the central dir on this disk */
79 | uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
80 | uLong size_comment; /* size of the global comment of the zipfile */
81 | } unz_global_info;
82 |
83 | /* unz_file_info contain information about a file in the zipfile */
84 | typedef struct unz_file_info64_s
85 | {
86 | uLong version; /* version made by 2 bytes */
87 | uLong version_needed; /* version needed to extract 2 bytes */
88 | uLong flag; /* general purpose bit flag 2 bytes */
89 | uLong compression_method; /* compression method 2 bytes */
90 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
91 | uLong crc; /* crc-32 4 bytes */
92 | ZPOS64_T compressed_size; /* compressed size 8 bytes */
93 | ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
94 | uLong size_filename; /* filename length 2 bytes */
95 | uLong size_file_extra; /* extra field length 2 bytes */
96 | uLong size_file_comment; /* file comment length 2 bytes */
97 |
98 | uLong disk_num_start; /* disk number start 2 bytes */
99 | uLong internal_fa; /* internal file attributes 2 bytes */
100 | uLong external_fa; /* external file attributes 4 bytes */
101 |
102 | tm_unz tmu_date;
103 | ZPOS64_T disk_offset;
104 | uLong size_file_extra_internal;
105 | } unz_file_info64;
106 |
107 | typedef struct unz_file_info_s
108 | {
109 | uLong version; /* version made by 2 bytes */
110 | uLong version_needed; /* version needed to extract 2 bytes */
111 | uLong flag; /* general purpose bit flag 2 bytes */
112 | uLong compression_method; /* compression method 2 bytes */
113 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
114 | uLong crc; /* crc-32 4 bytes */
115 | uLong compressed_size; /* compressed size 4 bytes */
116 | uLong uncompressed_size; /* uncompressed size 4 bytes */
117 | uLong size_filename; /* filename length 2 bytes */
118 | uLong size_file_extra; /* extra field length 2 bytes */
119 | uLong size_file_comment; /* file comment length 2 bytes */
120 |
121 | uLong disk_num_start; /* disk number start 2 bytes */
122 | uLong internal_fa; /* internal file attributes 2 bytes */
123 | uLong external_fa; /* external file attributes 4 bytes */
124 |
125 | tm_unz tmu_date;
126 | uLong disk_offset;
127 | } unz_file_info;
128 |
129 | /***************************************************************************/
130 | /* Opening and close a zip file */
131 |
132 | extern unzFile ZEXPORT unzOpen OF((const char *path));
133 | extern unzFile ZEXPORT unzOpen64 OF((const void *path));
134 | /* Open a Zip file.
135 |
136 | path should contain the full pathname (by example, on a Windows XP computer
137 | "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
138 | return NULL if zipfile cannot be opened or doesn't exist
139 | return unzFile handle if no error
140 |
141 | NOTE: The "64" function take a const void* pointer, because the path is just the value passed to the
142 | open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
143 | is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* does not describe the reality */
144 |
145 | extern unzFile ZEXPORT unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def));
146 | /* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write operations */
147 | extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, zlib_filefunc64_def* pzlib_filefunc_def));
148 | /* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write 64-bit operations */
149 |
150 | extern int ZEXPORT unzClose OF((unzFile file));
151 | /* Close a ZipFile opened with unzOpen. If there is files inside the .Zip opened with unzOpenCurrentFile,
152 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
153 |
154 | return UNZ_OK if there is no error */
155 |
156 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info));
157 | extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, unz_global_info64 *pglobal_info));
158 | /* Write info about the ZipFile in the *pglobal_info structure.
159 |
160 | return UNZ_OK if no error */
161 |
162 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *comment, uLong comment_size));
163 | /* Get the global comment string of the ZipFile, in the comment buffer.
164 |
165 | uSizeBuf is the size of the szComment buffer.
166 | return the number of byte copied or an error code <0 */
167 |
168 | /***************************************************************************/
169 | /* Reading the content of the current zipfile, you can open it, read data from it, and close it
170 | (you can close it before reading all the file) */
171 |
172 | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
173 | /* Open for reading data the current file in the zipfile.
174 |
175 | return UNZ_OK if no error */
176 |
177 | extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, const char* password));
178 | /* Open for reading data the current file in the zipfile.
179 | password is a crypting password
180 |
181 | return UNZ_OK if no error */
182 |
183 | extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, int* method, int* level, int raw));
184 | /* Same as unzOpenCurrentFile, but open for read raw the file (not uncompress)
185 | if raw==1 *method will receive method of compression, *level will receive level of compression
186 |
187 | NOTE: you can set level parameter as NULL (if you did not want known level,
188 | but you CANNOT set method parameter as NULL */
189 |
190 | extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, int* method, int* level, int raw, const char* password));
191 | /* Same as unzOpenCurrentFile, but takes extra parameter password for encrypted files */
192 |
193 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len));
194 | /* Read bytes from the current file (opened by unzOpenCurrentFile)
195 | buf contain buffer where data must be copied
196 | len the size of buf.
197 |
198 | return the number of byte copied if somes bytes are copied
199 | return 0 if the end of file was reached
200 | return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */
201 |
202 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *filename,
203 | uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
204 | extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
205 | uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
206 | /* Get Info about the current file
207 |
208 | pfile_info if != NULL, the *pfile_info structure will contain somes info about the current file
209 | filename if != NULL, the file name string will be copied in filename
210 | filename_size is the size of the filename buffer
211 | extrafield if != NULL, the extra field information from the central header will be copied in to
212 | extrafield_size is the size of the extraField buffer
213 | comment if != NULL, the comment string of the file will be copied in to
214 | comment_size is the size of the comment buffer */
215 |
216 | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
217 |
218 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len));
219 | /* Read extra field from the current file (opened by unzOpenCurrentFile)
220 | This is the local-header version of the extra field (sometimes, there is
221 | more info in the local-header version than in the central-header)
222 |
223 | if buf == NULL, it return the size of the local extra field
224 | if buf != NULL, len is the size of the buffer, the extra header is copied in buf.
225 |
226 | return number of bytes copied in buf, or (if <0) the error code */
227 |
228 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
229 | /* Close the file in zip opened with unzOpenCurrentFile
230 |
231 | return UNZ_CRCERROR if all the file was read but the CRC is not good */
232 |
233 | /***************************************************************************/
234 | /* Browse the directory of the zipfile */
235 |
236 | typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
237 | typedef int (*unzIteratorFunction)(unzFile file);
238 | typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
239 | uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size);
240 |
241 | extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
242 | /* Set the current file of the zipfile to the first file.
243 |
244 | return UNZ_OK if no error */
245 |
246 | extern int ZEXPORT unzGoToFirstFile2 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
247 | uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
248 | /* Set the current file of the zipfile to the first file and retrieves the current info on success.
249 | Not as seek intensive as unzGoToFirstFile + unzGetCurrentFileInfo.
250 |
251 | return UNZ_OK if no error */
252 |
253 | extern int ZEXPORT unzGoToNextFile OF((unzFile file));
254 | /* Set the current file of the zipfile to the next file.
255 |
256 | return UNZ_OK if no error
257 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
258 |
259 | extern int ZEXPORT unzGoToNextFile2 OF((unzFile file, unz_file_info64 *pfile_info, char *filename,
260 | uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size));
261 | /* Set the current file of the zipfile to the next file and retrieves the current
262 | info on success. Does less seeking around than unzGotoNextFile + unzGetCurrentFileInfo.
263 |
264 | return UNZ_OK if no error
265 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
266 |
267 | extern int ZEXPORT unzLocateFile OF((unzFile file, const char *filename, unzFileNameComparer filename_compare_func));
268 | /* Try locate the file szFileName in the zipfile. For custom filename comparison pass in comparison function.
269 |
270 | return UNZ_OK if the file is found (it becomes the current file)
271 | return UNZ_END_OF_LIST_OF_FILE if the file is not found */
272 |
273 | /***************************************************************************/
274 | /* Raw access to zip file */
275 |
276 | typedef struct unz_file_pos_s
277 | {
278 | uLong pos_in_zip_directory; /* offset in zip file directory */
279 | uLong num_of_file; /* # of file */
280 | } unz_file_pos;
281 |
282 | extern int ZEXPORT unzGetFilePos OF((unzFile file, unz_file_pos* file_pos));
283 | extern int ZEXPORT unzGoToFilePos OF((unzFile file, unz_file_pos* file_pos));
284 |
285 | typedef struct unz64_file_pos_s
286 | {
287 | ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
288 | ZPOS64_T num_of_file; /* # of file */
289 | } unz64_file_pos;
290 |
291 | extern int ZEXPORT unzGetFilePos64 OF((unzFile file, unz64_file_pos* file_pos));
292 | extern int ZEXPORT unzGoToFilePos64 OF((unzFile file, const unz64_file_pos* file_pos));
293 |
294 | extern uLong ZEXPORT unzGetOffset OF((unzFile file));
295 | extern ZPOS64_T ZEXPORT unzGetOffset64 OF((unzFile file));
296 | /* Get the current file offset */
297 |
298 | extern int ZEXPORT unzSetOffset OF((unzFile file, uLong pos));
299 | extern int ZEXPORT unzSetOffset64 OF((unzFile file, ZPOS64_T pos));
300 | /* Set the current file offset */
301 |
302 | extern z_off_t ZEXPORT unztell OF((unzFile file));
303 | extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
304 | /* return current position in uncompressed data */
305 |
306 | extern int ZEXPORT unzseek OF((unzFile file, z_off_t offset, int origin));
307 | extern int ZEXPORT unzseek64 OF((unzFile file, ZPOS64_T offset, int origin));
308 | /* Seek within the uncompressed data if compression method is storage */
309 |
310 | extern int ZEXPORT unzeof OF((unzFile file));
311 | /* return 1 if the end of file was reached, 0 elsewhere */
312 |
313 | /***************************************************************************/
314 |
315 | #ifdef __cplusplus
316 | }
317 | #endif
318 |
319 | #endif /* _UNZ_H */
320 |
--------------------------------------------------------------------------------
/QuickInstallerVITA/file.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2016, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "global.h"
28 | #include "archive.h"
29 | #include "file.h"
30 | #include "utils.h"
31 | #include "sha1.h"
32 |
33 | static char *mount_points[] = {
34 | "app0:",
35 | "gro0:",
36 | "grw0:",
37 | "os0:",
38 | "pd0:",
39 | "sa0:",
40 | "savedata0:",
41 | "tm0:",
42 | "ud0:",
43 | "ur0:",
44 | "ux0:",
45 | "vd0:",
46 | "vs0:",
47 | };
48 |
49 | #define N_MOUNT_POINTS (sizeof(mount_points) / sizeof(char **))
50 |
51 | int allocateReadFile(char *file, void **buffer) {
52 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
53 | if (fd < 0)
54 | return fd;
55 |
56 | int off = sceIoLseek32(fd, 0, SCE_SEEK_CUR);
57 | int size = sceIoLseek32(fd, 0, SCE_SEEK_END);
58 | sceIoLseek(fd, off, SCE_SEEK_SET);
59 |
60 | *buffer = malloc(size);
61 | if (!*buffer) {
62 | sceIoClose(fd);
63 | return -1;
64 | }
65 |
66 | int read = sceIoRead(fd, *buffer, size);
67 | sceIoClose(fd);
68 |
69 | return read;
70 | }
71 |
72 | int ReadFile(char *file, void *buf, int size) {
73 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
74 | if (fd < 0)
75 | return fd;
76 |
77 | int read = sceIoRead(fd, buf, size);
78 |
79 | sceIoClose(fd);
80 | return read;
81 | }
82 |
83 | int WriteFile(char *file, void *buf, int size) {
84 | SceUID fd = sceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
85 | if (fd < 0)
86 | return fd;
87 |
88 | int written = sceIoWrite(fd, buf, size);
89 |
90 | sceIoClose(fd);
91 | return written;
92 | }
93 |
94 | int getFileSize(char *pInputFileName)
95 | {
96 | SceUID fd = sceIoOpen(pInputFileName, SCE_O_RDONLY, 0);
97 | if (fd < 0)
98 | return fd;
99 |
100 | int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);
101 |
102 | sceIoClose(fd);
103 | return fileSize;
104 | }
105 |
106 | int getFileSha1(char *pInputFileName, uint8_t *pSha1Out, FileProcessParam *param) {
107 | // Set up SHA1 context
108 | SHA1_CTX ctx;
109 | sha1_init(&ctx);
110 |
111 | // Open the file to read, else return the error
112 | SceUID fd = sceIoOpen(pInputFileName, SCE_O_RDONLY, 0);
113 | if (fd < 0)
114 | return fd;
115 |
116 | // Open up the buffer for copying data into
117 | void *buf = malloc(TRANSFER_SIZE);
118 |
119 | int read;
120 |
121 | // Actually take the SHA1 sum
122 | while ((read = sceIoRead(fd, buf, TRANSFER_SIZE)) > 0) {
123 | sha1_update(&ctx, buf, read);
124 |
125 | if (param) {
126 | // Defined in io_process.c, check to make sure pointer isn't null before incrementing
127 | if (param->value)
128 | (*param->value)++; // Note: Max value is filesize/TRANSFER_SIZE
129 |
130 | if (param->SetProgress)
131 | param->SetProgress(param->value ? *param->value : 0, param->max);
132 |
133 | // Check to see if param->cancelHandler exists, if so call it and free memory if cancelled
134 | if (param->cancelHandler && param->cancelHandler()) {
135 | free(buf);
136 | sceIoClose(fd);
137 | return 0;
138 | }
139 |
140 | // This is CPU intensive so the progress bar won't refresh unless we sleep
141 | // DIALOG_WAIT seemed too long for this application
142 | // so I set it to 1/2 of a second every 8192 TRANSFER_SIZE blocks
143 | if ((*param->value) % 8192 == 0)
144 | sceKernelDelayThread(500000);
145 | }
146 | }
147 |
148 | // Final iteration of SHA1 sum, dump final value into pSha1Out buffer
149 | sha1_final(&ctx, pSha1Out);
150 |
151 | // Free up file buffer
152 | free(buf);
153 |
154 | // Close file proper
155 | sceIoClose(fd);
156 | return 1;
157 | }
158 |
159 | int getPathInfo(char *path, uint64_t *size, uint32_t *folders, uint32_t *files) {
160 | SceUID dfd = sceIoDopen(path);
161 | if (dfd >= 0) {
162 | int res = 0;
163 |
164 | do {
165 | SceIoDirent dir;
166 | memset(&dir, 0, sizeof(SceIoDirent));
167 |
168 | res = sceIoDread(dfd, &dir);
169 | if (res > 0) {
170 | if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
171 | continue;
172 |
173 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
174 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
175 |
176 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
177 | int ret = getPathInfo(new_path, size, folders, files);
178 | if (ret <= 0) {
179 | free(new_path);
180 | sceIoDclose(dfd);
181 | return ret;
182 | }
183 | } else {
184 | if (size)
185 | (*size) += dir.d_stat.st_size;
186 |
187 | if (files)
188 | (*files)++;
189 | }
190 |
191 | free(new_path);
192 | }
193 | } while (res > 0);
194 |
195 | sceIoDclose(dfd);
196 |
197 | if (folders)
198 | (*folders)++;
199 | } else {
200 | if (size) {
201 | SceIoStat stat;
202 | memset(&stat, 0, sizeof(SceIoStat));
203 |
204 | int res = sceIoGetstat(path, &stat);
205 | if (res < 0)
206 | return res;
207 |
208 | (*size) += stat.st_size;
209 | }
210 |
211 | if (files)
212 | (*files)++;
213 | }
214 |
215 | return 1;
216 | }
217 |
218 | int removePath(char *path, FileProcessParam *param) {
219 | SceUID dfd = sceIoDopen(path);
220 | if (dfd >= 0) {
221 | int res = 0;
222 |
223 | do {
224 | SceIoDirent dir;
225 | memset(&dir, 0, sizeof(SceIoDirent));
226 |
227 | res = sceIoDread(dfd, &dir);
228 | if (res > 0) {
229 | if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
230 | continue;
231 |
232 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
233 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
234 |
235 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
236 | int ret = removePath(new_path, param);
237 | if (ret <= 0) {
238 | free(new_path);
239 | sceIoDclose(dfd);
240 | return ret;
241 | }
242 | } else {
243 | int ret = sceIoRemove(new_path);
244 | if (ret < 0) {
245 | free(new_path);
246 | sceIoDclose(dfd);
247 | return ret;
248 | }
249 |
250 | if (param) {
251 | if (param->value)
252 | (*param->value)++;
253 |
254 | if (param->SetProgress)
255 | param->SetProgress(param->value ? *param->value : 0, param->max);
256 |
257 | if (param->cancelHandler && param->cancelHandler()) {
258 | free(new_path);
259 | sceIoDclose(dfd);
260 | return 0;
261 | }
262 | }
263 | }
264 |
265 | free(new_path);
266 | }
267 | } while (res > 0);
268 |
269 | sceIoDclose(dfd);
270 |
271 | int ret = sceIoRmdir(path);
272 | if (ret < 0)
273 | return ret;
274 |
275 | if (param) {
276 | if (param->value)
277 | (*param->value)++;
278 |
279 | if (param->SetProgress)
280 | param->SetProgress(param->value ? *param->value : 0, param->max);
281 |
282 | if (param->cancelHandler && param->cancelHandler()) {
283 | return 0;
284 | }
285 | }
286 | } else {
287 | int ret = sceIoRemove(path);
288 | if (ret < 0)
289 | return ret;
290 |
291 | if (param) {
292 | if (param->value)
293 | (*param->value)++;
294 |
295 | if (param->SetProgress)
296 | param->SetProgress(param->value ? *param->value : 0, param->max);
297 |
298 | if (param->cancelHandler && param->cancelHandler()) {
299 | return 0;
300 | }
301 | }
302 | }
303 |
304 | return 1;
305 | }
306 |
307 | int copyFile(char *src_path, char *dst_path, FileProcessParam *param) {
308 | // The source and destination paths are identical
309 | if (strcasecmp(src_path, dst_path) == 0) {
310 | return -1;
311 | }
312 |
313 | // The destination is a subfolder of the source folder
314 | int len = strlen(src_path);
315 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
316 | return -2;
317 | }
318 |
319 | SceUID fdsrc = sceIoOpen(src_path, SCE_O_RDONLY, 0);
320 | if (fdsrc < 0)
321 | return fdsrc;
322 |
323 | SceUID fddst = sceIoOpen(dst_path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
324 | if (fddst < 0) {
325 | sceIoClose(fdsrc);
326 | return fddst;
327 | }
328 |
329 | void *buf = malloc(TRANSFER_SIZE);
330 |
331 | int read;
332 | while ((read = sceIoRead(fdsrc, buf, TRANSFER_SIZE)) > 0) {
333 | int res = sceIoWrite(fddst, buf, read);
334 | if (res < 0) {
335 | free(buf);
336 |
337 | sceIoClose(fddst);
338 | sceIoClose(fdsrc);
339 |
340 | return res;
341 | }
342 |
343 | if (param) {
344 | if (param->value)
345 | (*param->value) += read;
346 |
347 | if (param->SetProgress)
348 | param->SetProgress(param->value ? *param->value : 0, param->max);
349 |
350 | if (param->cancelHandler && param->cancelHandler()) {
351 | free(buf);
352 |
353 | sceIoClose(fddst);
354 | sceIoClose(fdsrc);
355 |
356 | return 0;
357 | }
358 | }
359 | }
360 |
361 | free(buf);
362 |
363 | sceIoClose(fddst);
364 | sceIoClose(fdsrc);
365 |
366 | return 1;
367 | }
368 |
369 | int copyPath(char *src_path, char *dst_path, FileProcessParam *param) {
370 | // The source and destination paths are identical
371 | if (strcasecmp(src_path, dst_path) == 0) {
372 | return -1;
373 | }
374 |
375 | // The destination is a subfolder of the source folder
376 | int len = strlen(src_path);
377 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
378 | return -2;
379 | }
380 |
381 | SceUID dfd = sceIoDopen(src_path);
382 | if (dfd >= 0) {
383 | int ret = sceIoMkdir(dst_path, 0777);
384 | if (ret < 0 && ret != SCE_ERROR_ERRNO_EEXIST) {
385 | sceIoDclose(dfd);
386 | return ret;
387 | }
388 |
389 | if (param) {
390 | if (param->value)
391 | (*param->value)++;
392 |
393 | if (param->SetProgress)
394 | param->SetProgress(param->value ? *param->value : 0, param->max);
395 |
396 | if (param->cancelHandler && param->cancelHandler()) {
397 | sceIoDclose(dfd);
398 | return 0;
399 | }
400 | }
401 |
402 | int res = 0;
403 |
404 | do {
405 | SceIoDirent dir;
406 | memset(&dir, 0, sizeof(SceIoDirent));
407 |
408 | res = sceIoDread(dfd, &dir);
409 | if (res > 0) {
410 | if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
411 | continue;
412 |
413 | char *new_src_path = malloc(strlen(src_path) + strlen(dir.d_name) + 2);
414 | snprintf(new_src_path, MAX_PATH_LENGTH, "%s%s%s", src_path, hasEndSlash(src_path) ? "" : "/", dir.d_name);
415 |
416 | char *new_dst_path = malloc(strlen(dst_path) + strlen(dir.d_name) + 2);
417 | snprintf(new_dst_path, MAX_PATH_LENGTH, "%s%s%s", dst_path, hasEndSlash(dst_path) ? "" : "/", dir.d_name);
418 |
419 | int ret = 0;
420 |
421 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
422 | ret = copyPath(new_src_path, new_dst_path, param);
423 | } else {
424 | ret = copyFile(new_src_path, new_dst_path, param);
425 | }
426 |
427 | free(new_dst_path);
428 | free(new_src_path);
429 |
430 | if (ret <= 0) {
431 | sceIoDclose(dfd);
432 | return ret;
433 | }
434 | }
435 | } while (res > 0);
436 |
437 | sceIoDclose(dfd);
438 | } else {
439 | return copyFile(src_path, dst_path, param);
440 | }
441 |
442 | return 1;
443 | }
444 |
445 | int movePath(char *src_path, char *dst_path, int flags, FileProcessParam *param) {
446 | // The source and destination paths are identical
447 | if (strcasecmp(src_path, dst_path) == 0) {
448 | return -1;
449 | }
450 |
451 | // The destination is a subfolder of the source folder
452 | int len = strlen(src_path);
453 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
454 | return -2;
455 | }
456 |
457 | int res = sceIoRename(src_path, dst_path);
458 | if (res == SCE_ERROR_ERRNO_EEXIST && flags & (MOVE_INTEGRATE | MOVE_REPLACE)) {
459 | // Src stat
460 | SceIoStat src_stat;
461 | memset(&src_stat, 0, sizeof(SceIoStat));
462 | res = sceIoGetstat(src_path, &src_stat);
463 | if (res < 0)
464 | return res;
465 |
466 | // Dst stat
467 | SceIoStat dst_stat;
468 | memset(&dst_stat, 0, sizeof(SceIoStat));
469 | res = sceIoGetstat(dst_path, &dst_stat);
470 | if (res < 0)
471 | return res;
472 |
473 | // Is dir
474 | int src_is_dir = SCE_S_ISDIR(src_stat.st_mode);
475 | int dst_is_dir = SCE_S_ISDIR(dst_stat.st_mode);
476 |
477 | // One of them is a file and the other a directory, no replacement or integration possible
478 | if (src_is_dir != dst_is_dir)
479 | return -3;
480 |
481 | // Replace file
482 | if (!src_is_dir && !dst_is_dir && flags & MOVE_REPLACE) {
483 | sceIoRemove(dst_path);
484 |
485 | res = sceIoRename(src_path, dst_path);
486 | if (res < 0)
487 | return res;
488 |
489 | return 1;
490 | }
491 |
492 | // Integrate directory
493 | if (src_is_dir && dst_is_dir && flags & MOVE_INTEGRATE) {
494 | SceUID dfd = sceIoDopen(src_path);
495 | if (dfd < 0)
496 | return dfd;
497 |
498 | int res = 0;
499 |
500 | do {
501 | SceIoDirent dir;
502 | memset(&dir, 0, sizeof(SceIoDirent));
503 |
504 | res = sceIoDread(dfd, &dir);
505 | if (res > 0) {
506 | if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
507 | continue;
508 |
509 | char *new_src_path = malloc(strlen(src_path) + strlen(dir.d_name) + 2);
510 | snprintf(new_src_path, MAX_PATH_LENGTH, "%s%s%s", src_path, hasEndSlash(src_path) ? "" : "/", dir.d_name);
511 |
512 | char *new_dst_path = malloc(strlen(dst_path) + strlen(dir.d_name) + 2);
513 | snprintf(new_dst_path, MAX_PATH_LENGTH, "%s%s%s", dst_path, hasEndSlash(dst_path) ? "" : "/", dir.d_name);
514 |
515 | // Recursive move
516 | int ret = movePath(new_src_path, new_dst_path, flags, param);
517 |
518 | free(new_dst_path);
519 | free(new_src_path);
520 |
521 | if (ret <= 0) {
522 | sceIoDclose(dfd);
523 | return ret;
524 | }
525 | }
526 | } while (res > 0);
527 |
528 | sceIoDclose(dfd);
529 |
530 | // Integrated, now remove this directory
531 | sceIoRmdir(src_path);
532 | }
533 | }
534 |
535 | return 1;
536 | }
537 |
538 | typedef struct {
539 | char *extension;
540 | int type;
541 | } ExtensionType;
542 |
543 | static ExtensionType extension_types[] = {
544 | { ".BMP", FILE_TYPE_BMP },
545 | { ".INI", FILE_TYPE_INI },
546 | { ".JPG", FILE_TYPE_JPEG },
547 | { ".JPEG", FILE_TYPE_JPEG },
548 | { ".MP3", FILE_TYPE_MP3 },
549 | { ".PNG", FILE_TYPE_PNG },
550 | { ".SFO", FILE_TYPE_SFO },
551 | { ".TXT", FILE_TYPE_TXT },
552 | { ".VPK", FILE_TYPE_VPK },
553 | { ".XML", FILE_TYPE_XML },
554 | { ".ZIP", FILE_TYPE_ZIP },
555 | };
556 |
557 | int getFileType(char *file) {
558 | char *p = strrchr(file, '.');
559 | if (p) {
560 | int i;
561 | for (i = 0; i < (sizeof(extension_types) / sizeof(ExtensionType)); i++) {
562 | if (strcasecmp(p, extension_types[i].extension) == 0) {
563 | return extension_types[i].type;
564 | }
565 | }
566 | }
567 |
568 | return FILE_TYPE_UNKNOWN;
569 | }
570 |
571 | int getNumberMountPoints() {
572 | return N_MOUNT_POINTS;
573 | }
574 |
575 | char **getMountPoints() {
576 | return mount_points;
577 | }
578 |
579 | FileListEntry *fileListFindEntry(FileList *list, char *name) {
580 | FileListEntry *entry = list->head;
581 |
582 | int name_length = strlen(name);
583 |
584 | while (entry) {
585 | if (entry->name_length == name_length && strcasecmp(entry->name, name) == 0)
586 | return entry;
587 |
588 | entry = entry->next;
589 | }
590 |
591 | return NULL;
592 | }
593 |
594 | FileListEntry *fileListGetNthEntry(FileList *list, int n) {
595 | FileListEntry *entry = list->head;
596 |
597 | while (n > 0 && entry) {
598 | n--;
599 | entry = entry->next;
600 | }
601 |
602 | if (n != 0)
603 | return NULL;
604 |
605 | return entry;
606 | }
607 |
608 | int fileListGetNumberByName(FileList *list, char *name) {
609 | FileListEntry *entry = list->head;
610 |
611 | int name_length = strlen(name);
612 |
613 | int n = 0;
614 |
615 | while (entry) {
616 | if (entry->name_length == name_length && strcasecmp(entry->name, name) == 0)
617 | break;
618 |
619 | n++;
620 | entry = entry->next;
621 | }
622 |
623 | return n;
624 | }
625 |
626 | void fileListAddEntry(FileList *list, FileListEntry *entry, int sort) {
627 | entry->next = NULL;
628 | entry->previous = NULL;
629 |
630 | if (list->head == NULL) {
631 | list->head = entry;
632 | list->tail = entry;
633 | } else {
634 | if (sort != SORT_NONE) {
635 | FileListEntry *p = list->head;
636 | FileListEntry *previous = NULL;
637 |
638 | while (p) {
639 | // Sort by type
640 | if (entry->is_folder > p->is_folder)
641 | break;
642 |
643 | // '..' is always at first
644 | if (strcmp(entry->name, "..") == 0)
645 | break;
646 |
647 | if (strcmp(p->name, "..") != 0) {
648 | // Get the minimum length without /
649 | int len = MIN(entry->name_length, p->name_length);
650 | if (entry->name[len - 1] == '/' || p->name[len - 1] == '/')
651 | len--;
652 |
653 | // Sort by name
654 | if (entry->is_folder == p->is_folder) {
655 | int diff = strncasecmp(entry->name, p->name, len);
656 | if (diff < 0 || (diff == 0 && entry->name_length < p->name_length)) {
657 | break;
658 | }
659 | }
660 | }
661 |
662 | previous = p;
663 | p = p->next;
664 | }
665 |
666 | if (previous == NULL) { // Order: entry (new head) -> p (old head)
667 | entry->next = p;
668 | p->previous = entry;
669 | list->head = entry;
670 | } else if (previous->next == NULL) { // Order: p (old tail) -> entry (new tail)
671 | FileListEntry *tail = list->tail;
672 | tail->next = entry;
673 | entry->previous = tail;
674 | list->tail = entry;
675 | } else { // Order: previous -> entry -> p
676 | previous->next = entry;
677 | entry->previous = previous;
678 | entry->next = p;
679 | p->previous = entry;
680 | }
681 | } else {
682 | FileListEntry *tail = list->tail;
683 | tail->next = entry;
684 | entry->previous = tail;
685 | list->tail = entry;
686 | }
687 | }
688 |
689 | list->length++;
690 | }
691 |
692 | int fileListRemoveEntry(FileList *list, FileListEntry *entry) {
693 | if (entry) {
694 | if (entry->previous) {
695 | entry->previous->next = entry->next;
696 | } else {
697 | list->head = entry->next;
698 | }
699 |
700 | if (entry->next) {
701 | entry->next->previous = entry->previous;
702 | } else {
703 | list->tail = entry->previous;
704 | }
705 |
706 | list->length--;
707 | free(entry);
708 |
709 | return 1;
710 | }
711 |
712 | return 0;
713 | }
714 |
715 | int fileListRemoveEntryByName(FileList *list, char *name) {
716 | FileListEntry *entry = list->head;
717 | FileListEntry *previous = NULL;
718 |
719 | int name_length = strlen(name);
720 |
721 | while (entry) {
722 | if (entry->name_length == name_length && strcasecmp(entry->name, name) == 0) {
723 | if (previous) {
724 | previous->next = entry->next;
725 | } else {
726 | list->head = entry->next;
727 | }
728 |
729 | if (list->tail == entry) {
730 | list->tail = previous;
731 | }
732 |
733 | list->length--;
734 |
735 | free(entry);
736 |
737 | return 1;
738 | }
739 |
740 | previous = entry;
741 | entry = entry->next;
742 | }
743 |
744 | return 0;
745 | }
746 |
747 | void fileListEmpty(FileList *list) {
748 | FileListEntry *entry = list->head;
749 |
750 | while (entry) {
751 | FileListEntry *next = entry->next;
752 | free(entry);
753 | entry = next;
754 | }
755 |
756 | list->head = NULL;
757 | list->tail = NULL;
758 | list->length = 0;
759 | list->files = 0;
760 | list->folders = 0;
761 | }
762 |
763 | int fileListGetMountPointEntries(FileList *list) {
764 | int i;
765 | for (i = 0; i < N_MOUNT_POINTS; i++) {
766 | if (mount_points[i]) {
767 | SceIoStat stat;
768 | memset(&stat, 0, sizeof(SceIoStat));
769 | if (sceIoGetstat(mount_points[i], &stat) >= 0) {
770 | FileListEntry *entry = malloc(sizeof(FileListEntry));
771 | strcpy(entry->name, mount_points[i]);
772 | entry->name_length = strlen(entry->name);
773 | entry->is_folder = 1;
774 | entry->type = FILE_TYPE_UNKNOWN;
775 |
776 | memcpy(&entry->time, (SceDateTime *)&stat.st_ctime, sizeof(SceDateTime));
777 |
778 | fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER);
779 |
780 | list->folders++;
781 | }
782 | }
783 | }
784 |
785 | return 0;
786 | }
787 |
788 | int fileListGetDirectoryEntries(FileList *list, char *path) {
789 | SceUID dfd = sceIoDopen(path);
790 | if (dfd < 0)
791 | return dfd;
792 |
793 | FileListEntry *entry = malloc(sizeof(FileListEntry));
794 | strcpy(entry->name, DIR_UP);
795 | entry->name_length = strlen(entry->name);
796 | entry->is_folder = 1;
797 | entry->type = FILE_TYPE_UNKNOWN;
798 | fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER);
799 |
800 | int res = 0;
801 |
802 | do {
803 | SceIoDirent dir;
804 | memset(&dir, 0, sizeof(SceIoDirent));
805 |
806 | res = sceIoDread(dfd, &dir);
807 | if (res > 0) {
808 | if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
809 | continue;
810 |
811 | FileListEntry *entry = malloc(sizeof(FileListEntry));
812 |
813 | strcpy(entry->name, dir.d_name);
814 |
815 | entry->is_folder = SCE_S_ISDIR(dir.d_stat.st_mode);
816 | if (entry->is_folder) {
817 | addEndSlash(entry->name);
818 | entry->type = FILE_TYPE_UNKNOWN;
819 | list->folders++;
820 | } else {
821 | entry->type = getFileType(entry->name);
822 | list->files++;
823 | }
824 |
825 | entry->name_length = strlen(entry->name);
826 | entry->size = dir.d_stat.st_size;
827 |
828 | memcpy(&entry->time, (SceDateTime *)&dir.d_stat.st_mtime, sizeof(SceDateTime));
829 |
830 | fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER);
831 | }
832 | } while (res > 0);
833 |
834 | sceIoDclose(dfd);
835 |
836 | return 0;
837 | }
838 |
839 | int fileListGetEntries(FileList *list, char *path) {
840 | if (strcasecmp(path, HOME_PATH) == 0) {
841 | return fileListGetMountPointEntries(list);
842 | }
843 |
844 | return fileListGetDirectoryEntries(list, path);
845 | }
846 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------