Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
common/shadpkg_types.h
ShadPKG / common / shadpkg_types.h
1// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3 
4#pragma once
5 
6#include <array>
7#include <cstdint>
8 
9using s8 = std::int8_t;
10using s16 = std::int16_t;
11using s32 = std::int32_t;
12using s64 = std::int64_t;
13 
14using u8 = std::uint8_t;
15using u16 = std::uint16_t;
16using u32 = std::uint32_t;
17using u64 = std::uint64_t;
18 
19using f32 = float;
20using f64 = double;
21 
22using u128 = std::array<std::uint64_t, 2>;
23static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide");
24 
25using VAddr = uintptr_t;
26using PAddr = uintptr_t;
27 
28#define PS4_SYSV_ABI __attribute__((sysv_abi))
29 
30// UDLs for memory size values
31constexpr unsigned long long operator""_KB(unsigned long long x) {
32 return 1024ULL * x;
33}
34constexpr unsigned long long operator""_MB(unsigned long long x) {
35 return 1024_KB * x;
36}
37constexpr unsigned long long operator""_GB(unsigned long long x) {
38 return 1024_MB * x;
39}
40