A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | /* |
| 2 | * ╔═══════════════════════════════════════════════════════════════════════════╗ |
| 3 | * ║ PS4 GRAPHICS STUBS - HEADER ║ |
| 4 | * ╠═══════════════════════════════════════════════════════════════════════════╣ |
| 5 | * ║ Emulates sceVideoOut* and sceGnm* graphics functions. ║ |
| 6 | * ║ These are stubs - no actual rendering occurs. ║ |
| 7 | * ╚═══════════════════════════════════════════════════════════════════════════╝ |
| 8 | */ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | #include <cstdint> |
| 13 | |
| 14 | /* |
| 15 | * ┌─────────────────────────────────────────────────────────────────┐ |
| 16 | * │ VIDEO OUTPUT CONSTANTS │ |
| 17 | * └─────────────────────────────────────────────────────────────────┘ |
| 18 | */ |
| 19 | |
| 20 | #define SCE_VIDEO_OUT_BUS_TYPE_MAIN 0 |
| 21 | #define SCE_VIDEO_OUT_BUS_TYPE_SUB 1 |
| 22 | |
| 23 | // Pixel formats |
| 24 | #define SCE_VIDEO_OUT_PIXEL_FORMAT_A8R8G8B8_SRGB 0x80000000 |
| 25 | #define SCE_VIDEO_OUT_PIXEL_FORMAT_A8B8G8R8_SRGB 0x80002200 |
| 26 | #define SCE_VIDEO_OUT_PIXEL_FORMAT_A2R10G10B10 0x80002100 |
| 27 | |
| 28 | // Flip modes |
| 29 | #define SCE_VIDEO_OUT_FLIP_MODE_VSYNC 1 |
| 30 | #define SCE_VIDEO_OUT_FLIP_MODE_HSYNC 2 |
| 31 | |
| 32 | // Resolution |
| 33 | #define SCE_VIDEO_OUT_RESOLUTION_1920x1080 1 |
| 34 | #define SCE_VIDEO_OUT_RESOLUTION_3840x2160 2 |
| 35 | |
| 36 | /* |
| 37 | * ┌─────────────────────────────────────────────────────────────────┐ |
| 38 | * │ GNM DRIVER CONSTANTS │ |
| 39 | * └─────────────────────────────────────────────────────────────────┘ |
| 40 | */ |
| 41 | |
| 42 | // Submit flags |
| 43 | #define SCE_GNM_SUBMIT_DEFAULT 0 |
| 44 | #define SCE_GNM_SUBMIT_FLIP 1 |
| 45 | |
| 46 | /* |
| 47 | * ┌─────────────────────────────────────────────────────────────────┐ |
| 48 | * │ STRUCTURES │ |
| 49 | * └─────────────────────────────────────────────────────────────────┘ |
| 50 | */ |
| 51 | |
| 52 | struct SceVideoOutBufferAttribute { |
| 53 | int32_t pixelFormat; |
| 54 | int32_t tilingMode; |
| 55 | int32_t aspectRatio; |
| 56 | uint32_t width; |
| 57 | uint32_t height; |
| 58 | uint32_t pitchInPixel; |
| 59 | }; |
| 60 | |
| 61 | struct SceVideoOutFlipStatus { |
| 62 | uint64_t count; |
| 63 | uint64_t processTime; |
| 64 | uint64_t tsc; |
| 65 | int64_t flipArg; |
| 66 | uint64_t submitTsc; |
| 67 | uint64_t gcQueueNum; |
| 68 | uint64_t flipPendingNum; |
| 69 | uint64_t currentBuffer; |
| 70 | }; |
| 71 | |
| 72 | struct SceVideoOutResolutionStatus { |
| 73 | uint32_t width; |
| 74 | uint32_t height; |
| 75 | uint32_t paneWidth; |
| 76 | uint32_t paneHeight; |
| 77 | uint64_t refreshRate; |
| 78 | float aspectRatio; |
| 79 | uint8_t padding[8]; |
| 80 | }; |
| 81 | |
| 82 | /* |
| 83 | * ┌─────────────────────────────────────────────────────────────────┐ |
| 84 | * │ VIDEO OUTPUT FUNCTIONS │ |
| 85 | * └─────────────────────────────────────────────────────────────────┘ |
| 86 | */ |
| 87 | |
| 88 | extern "C" { |
| 89 | |
| 90 | // ═══════════════════════════════════════════════════════════════════ |
| 91 | // VIDEO OUT |
| 92 | // ═══════════════════════════════════════════════════════════════════ |
| 93 | int32_t sceVideoOutOpen(int32_t userId, int32_t busType, int32_t index, |
| 94 | const void *param); |
| 95 | int32_t sceVideoOutClose(int32_t handle); |
| 96 | int32_t sceVideoOutSetFlipRate(int32_t handle, int32_t rate); |
| 97 | int32_t sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex, |
| 98 | void *const *addresses, int32_t bufferNum, |
| 99 | const SceVideoOutBufferAttribute *attr); |
| 100 | int32_t sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex, |
| 101 | int32_t flipMode, int64_t flipArg); |
| 102 | int32_t sceVideoOutGetFlipStatus(int32_t handle, SceVideoOutFlipStatus *status); |
| 103 | int32_t sceVideoOutGetResolutionStatus(int32_t handle, |
| 104 | SceVideoOutResolutionStatus *status); |
| 105 | void sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute *attr, |
| 106 | int32_t pixelFormat, int32_t tilingMode, |
| 107 | int32_t aspectRatio, uint32_t width, |
| 108 | uint32_t height, uint32_t pitchInPixel); |
| 109 | int32_t sceVideoOutWaitVblank(int32_t handle); |
| 110 | |
| 111 | // ═══════════════════════════════════════════════════════════════════ |
| 112 | // GNM DRIVER (GPU COMMAND SUBMISSION) |
| 113 | // ═══════════════════════════════════════════════════════════════════ |
| 114 | int32_t sceGnmSubmitCommandBuffers(uint32_t count, void *const *dcbGpuAddrs, |
| 115 | const uint32_t *dcbSizesInBytes, |
| 116 | void *const *ccbGpuAddrs, |
| 117 | const uint32_t *ccbSizesInBytes); |
| 118 | int32_t sceGnmSubmitAndFlipCommandBuffers( |
| 119 | uint32_t count, void *const *dcbGpuAddrs, const uint32_t *dcbSizesInBytes, |
| 120 | void *const *ccbGpuAddrs, const uint32_t *ccbSizesInBytes, |
| 121 | int32_t videoHandle, int32_t bufferIndex, int32_t flipMode, |
| 122 | int64_t flipArg); |
| 123 | void sceGnmFlushGarlic(); |
| 124 | uint32_t sceGnmGetGpuCoreClockFrequency(); |
| 125 | int32_t sceGnmIsUserPaEnabled(); |
| 126 | void *sceGnmGetTheTessellationFactorRingBufferBaseAddress(); |
| 127 | |
| 128 | // ═══════════════════════════════════════════════════════════════════ |
| 129 | // PAD (CONTROLLER INPUT) |
| 130 | // ═══════════════════════════════════════════════════════════════════ |
| 131 | int32_t scePadOpen(int32_t userId, int32_t type, int32_t index, |
| 132 | const void *param); |
| 133 | int32_t scePadClose(int32_t handle); |
| 134 | int32_t scePadRead(int32_t handle, void *data, int32_t num); |
| 135 | int32_t scePadReadState(int32_t handle, void *data); |
| 136 | int32_t scePadSetVibration(int32_t handle, const void *param); |
| 137 | int32_t scePadResetLightBar(int32_t handle); |
| 138 | int32_t scePadSetLightBar(int32_t handle, const void *param); |
| 139 | |
| 140 | // ═══════════════════════════════════════════════════════════════════ |
| 141 | // AUDIO OUTPUT |
| 142 | // ═══════════════════════════════════════════════════════════════════ |
| 143 | int32_t sceAudioOutOpen(int32_t userId, int32_t type, int32_t index, |
| 144 | uint32_t len, uint32_t freq, uint32_t param); |
| 145 | int32_t sceAudioOutClose(int32_t handle); |
| 146 | int32_t sceAudioOutOutput(int32_t handle, const void *ptr); |
| 147 | int32_t sceAudioOutSetVolume(int32_t handle, int32_t flag, int32_t *vol); |
| 148 | |
| 149 | } // extern "C" |
| 150 |