A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | #pragma once |
| 2 | |
| 3 | #include "../decompiler/DecompilerContext.h" |
| 4 | #include "common/backup_manager.h" |
| 5 | #include <memory> |
| 6 | #include <string> |
| 7 | #include <vector> |
| 8 | |
| 9 | namespace ShadPKG { |
| 10 | |
| 11 | // ╔═══════════════════════════════════════════════════════════════════════════╗ |
| 12 | // ║ PKG PROCESSING PIPELINE ║ |
| 13 | // ║ ║ |
| 14 | // ║ Automated pipeline that: ║ |
| 15 | // ║ 1. Loads PKG file ║ |
| 16 | // ║ 2. Decompiles to C++ ║ |
| 17 | // ║ 3. Applies automatic corrections (loop fixes, etc.) ║ |
| 18 | // ║ 4. Exports corrected source files ║ |
| 19 | // ║ 5. Backs up results to ps4MEL/backups/ ║ |
| 20 | // ║ ║ |
| 21 | // ║ Usage: ║ |
| 22 | // ║ PKGProcessor processor(ps4melPath); ║ |
| 23 | // ║ processor.processPKG("path/to/file.pkg"); ║ |
| 24 | // ║ auto results = processor.getResults(); ║ |
| 25 | // ╚═══════════════════════════════════════════════════════════════════════════╝ |
| 26 | |
| 27 | class PKGProcessor { |
| 28 | public: |
| 29 | struct ProcessingResult { |
| 30 | bool success = false; |
| 31 | std::string pkgPath; |
| 32 | std::string outputDirectory; |
| 33 | std::vector<std::string> generatedFiles; |
| 34 | std::vector<std::string> appliedCorrections; |
| 35 | std::string backupVersion; |
| 36 | std::string errorMessage; |
| 37 | }; |
| 38 | |
| 39 | PKGProcessor(const std::string &ps4melPath); |
| 40 | |
| 41 | // Process a single PKG file through the complete pipeline |
| 42 | ProcessingResult processPKG(const std::string &pkgPath); |
| 43 | |
| 44 | // Process multiple PKG files |
| 45 | std::vector<ProcessingResult> processPKGBatch(const std::vector<std::string> &pkgPaths); |
| 46 | |
| 47 | // Get processing result |
| 48 | const ProcessingResult &getLastResult() const { return lastResult_; } |
| 49 | |
| 50 | // List all processed PKGs |
| 51 | std::vector<std::string> getProcessedPKGs() const; |
| 52 | |
| 53 | // Enable/disable auto-backup |
| 54 | void setAutoBackup(bool enabled) { autoBackup_ = enabled; } |
| 55 | |
| 56 | // Set output directory |
| 57 | void setOutputDirectory(const std::string &path) { outputDir_ = path; } |
| 58 | |
| 59 | private: |
| 60 | std::string ps4melPath_; |
| 61 | std::string outputDir_; |
| 62 | PKGBackupManager backupManager_; |
| 63 | ProcessingResult lastResult_; |
| 64 | bool autoBackup_ = true; |
| 65 | |
| 66 | // Load PKG file and initialize decompiler context |
| 67 | bool loadPKG(const std::string &pkgPath); |
| 68 | |
| 69 | // Run decompilation analysis |
| 70 | bool decompile(); |
| 71 | |
| 72 | // Generate corrected C++ code |
| 73 | bool generateCode(); |
| 74 | |
| 75 | // Export project files |
| 76 | bool exportFiles(); |
| 77 | |
| 78 | // Track and report corrections |
| 79 | std::vector<std::string> getAppliedCorrections() const; |
| 80 | }; |
| 81 | |
| 82 | } // namespace ShadPKG |
| 83 |