A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <tuple> |
| 7 | |
| 8 | namespace Common { |
| 9 | |
| 10 | template <class Func> |
| 11 | struct FuncTraits {}; |
| 12 | |
| 13 | template <class ReturnType_, class... Args> |
| 14 | struct FuncTraits<ReturnType_ (*)(Args...)> { |
| 15 | using ReturnType = ReturnType_; |
| 16 | |
| 17 | static constexpr size_t NUM_ARGS = sizeof...(Args); |
| 18 | |
| 19 | template <size_t I> |
| 20 | using ArgType = std::tuple_element_t<I, std::tuple<Args...>>; |
| 21 | }; |
| 22 | |
| 23 | template <typename Func> |
| 24 | struct LambdaTraits : LambdaTraits<decltype(&std::remove_reference_t<Func>::operator())> {}; |
| 25 | |
| 26 | template <typename ReturnType, typename LambdaType, typename... Args> |
| 27 | struct LambdaTraits<ReturnType (LambdaType::*)(Args...) const> { |
| 28 | template <size_t I> |
| 29 | using ArgType = std::tuple_element_t<I, std::tuple<Args...>>; |
| 30 | |
| 31 | static constexpr size_t NUM_ARGS{sizeof...(Args)}; |
| 32 | }; |
| 33 | |
| 34 | } // namespace Common |
| 35 |