diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index b83e0c7..aabff09 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ pkg2zip.exe *.obj *.pdb *.zip +.direnv +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..42c04dd --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1739446958, + "narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2ff53fe64443980e139eaa286017f53f88336dd0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1257c57 --- /dev/null +++ b/flake.nix @@ -0,0 +1,75 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" ]; + forEachSupportedSystem = + f: + nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + devShells = forEachSupportedSystem ( + { pkgs }: + { + default = + pkgs.mkShell.override + { + stdenv = pkgs.gccStdenv; + } + { + packages = with pkgs; [ + python3 + gcc + clang-tools + gdb + typos + pkg-config + ]; + + }; + } + ); + + packages = forEachSupportedSystem ( + { pkgs }: + { + default = pkgs.stdenv.mkDerivation { + pname = "pkg2zip"; + version = "0.1"; + + src = ./.; + + # nativeBuildInputs = [ pkgs.makeWrapper ]; # If you need wrappers + buildInputs = [ ]; # Add dependencies like pkgs.openssl if needed + + buildPhase = '' + printenv + make + ''; + + installPhase = '' + mkdir -p $out/bin + cp ./pkg2zip $out/bin/ + ''; + + meta = { + description = "Decrypts PlayStation Vita pkg file and packages to zip archive"; + license = pkgs.lib.licenses.unlicense; + platforms = pkgs.lib.platforms.linux; + }; + }; + } + ); + }; +} diff --git a/pkg2zip.c b/pkg2zip.c index fe852ae..7cf1976 100644 --- a/pkg2zip.c +++ b/pkg2zip.c @@ -256,7 +256,7 @@ static void find_psp_sfo(const aes128_key* key, const aes128_key* ps3_key, const static void find_pbp_sfo(const aes128_key* key, const aes128_key* ps3_key, const uint8_t* iv, sys_file pkg, uint64_t pkg_size, uint64_t enc_offset, uint64_t items_offset, uint32_t item_count, char* discid) { - memset(discid, 0x00, 0x10); + memset(discid, 0x00, 0x0A); for (uint32_t item_index = 0; item_index < item_count; item_index++) { uint8_t item[32];