Seregon/ShadPKG

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

C++/47.3 KB/No license
common/ntapi.cpp
ShadPKG / common / ntapi.cpp
1// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3 
4#ifdef _WIN32
5 
6#include "ntapi.h"
7 
8NtClose_t NtClose = nullptr;
9NtSetInformationFile_t NtSetInformationFile = nullptr;
10NtCreateThread_t NtCreateThread = nullptr;
11NtTerminateThread_t NtTerminateThread = nullptr;
12NtQueueApcThreadEx_t NtQueueApcThreadEx = nullptr;
13 
14namespace Common::NtApi {
15 
16void Initialize() {
17 HMODULE nt_handle = GetModuleHandleA("ntdll.dll");
18 
19 // http://stackoverflow.com/a/31411628/4725495
20 NtClose = (NtClose_t)GetProcAddress(nt_handle, "NtClose");
21 NtSetInformationFile =
22 (NtSetInformationFile_t)GetProcAddress(nt_handle, "NtSetInformationFile");
23 NtCreateThread = (NtCreateThread_t)GetProcAddress(nt_handle, "NtCreateThread");
24 NtTerminateThread = (NtTerminateThread_t)GetProcAddress(nt_handle, "NtTerminateThread");
25 NtQueueApcThreadEx = (NtQueueApcThreadEx_t)GetProcAddress(nt_handle, "NtQueueApcThreadEx");
26}
27 
28} // namespace Common::NtApi
29 
30#endif
31