[Misc] Replaced const with constexpr where possible

This commit is contained in:
Xphalnos
2025-03-20 21:16:32 +01:00
committed by Radosław Gliński
parent d20620eb5e
commit 5f918ef28d
64 changed files with 191 additions and 190 deletions

View File

@@ -778,8 +778,9 @@ DECLARE_XBOXKRNL_EXPORT1(XeCryptHmacSha, kNone, kImplemented);
// TODO: Array of keys we need
// Retail key 0x19
static const uint8_t key19[] = {0xE1, 0xBC, 0x15, 0x9C, 0x73, 0xB1, 0xEA, 0xE9,
0xAB, 0x31, 0x70, 0xF3, 0xAD, 0x47, 0xEB, 0xF3};
static constexpr uint8_t key19[] = {0xE1, 0xBC, 0x15, 0x9C, 0x73, 0xB1,
0xEA, 0xE9, 0xAB, 0x31, 0x70, 0xF3,
0xAD, 0x47, 0xEB, 0xF3};
dword_result_t XeKeysHmacSha_entry(dword_t key_num, lpvoid_t inp_1,
dword_t inp_1_size, lpvoid_t inp_2,

View File

@@ -30,7 +30,7 @@ struct error_lookup_table {
};
// TODO(gibbed): replace these with named error codes
const uint32_t error_table_0x00000103[] = {
constexpr uint32_t error_table_0x00000103[] = {
0x000003E5, // 0x00000103
0, //
0x000000EA, // 0x00000105
@@ -44,7 +44,7 @@ const uint32_t error_table_0x00000103[] = {
0x00000516, // 0x0000010D
};
const uint32_t error_table_0x40000002[] = {
constexpr uint32_t error_table_0x40000002[] = {
0x00000057, // 0x40000002
0, //
0, //
@@ -59,15 +59,15 @@ const uint32_t error_table_0x40000002[] = {
0x00000518, // 0x4000000D
};
const uint32_t error_table_0x40020056[] = {
constexpr uint32_t error_table_0x40020056[] = {
0x00000720, // 0x40020056
};
const uint32_t error_table_0x400200AF[] = {
constexpr uint32_t error_table_0x400200AF[] = {
0x00000779, // 0x400200AF
};
const uint32_t error_table_0x80000001[] = {
constexpr uint32_t error_table_0x80000001[] = {
0x80000001, // 0x80000001
0x000003E6, // 0x80000002
0x80000003, // 0x80000003
@@ -107,12 +107,12 @@ const uint32_t error_table_0x80000001[] = {
0x00000962, // 0x80000025
};
const uint32_t error_table_0x80000288[] = {
constexpr uint32_t error_table_0x80000288[] = {
0x0000048D, // 0x80000288
0x0000048E, // 0x80000289
};
const uint32_t error_table_0x80090300[] = {
constexpr uint32_t error_table_0x80090300[] = {
0x000005AA, // 0x80090300
0x00000006, // 0x80090301
0x00000001, // 0x80090302
@@ -165,7 +165,7 @@ const uint32_t error_table_0x80090300[] = {
0x00000001, // 0x80090331
};
const uint32_t error_table_0xC0000001[] = {
constexpr uint32_t error_table_0xC0000001[] = {
0x0000001F, // 0xC0000001
0x00000001, // 0xC0000002
0x00000057, // 0xC0000003
@@ -579,7 +579,7 @@ const uint32_t error_table_0xC0000001[] = {
0x00000712, // 0xC000019B
};
const uint32_t error_table_0xC0000202[] = {
constexpr uint32_t error_table_0xC0000202[] = {
0x00000572, // 0xC0000202
0x0000003B, // 0xC0000203
0x00000717, // 0xC0000204
@@ -815,7 +815,7 @@ const uint32_t error_table_0xC0000202[] = {
0x00000052, // 0xC00002EA
};
const uint32_t error_table_0xC0020001[] = {
constexpr uint32_t error_table_0xC0020001[] = {
0x000006A4, // 0xC0020001
0x000006A5, // 0xC0020002
0x00000006, // 0xC0020003
@@ -917,7 +917,7 @@ const uint32_t error_table_0xC0020001[] = {
0x0000077B, // 0xC0020063
};
const uint32_t error_table_0xC0030001[] = {
constexpr uint32_t error_table_0xC0030001[] = {
0x000006EC, // 0xC0030001
0x000006ED, // 0xC0030002
0x000006EE, // 0xC0030003
@@ -932,7 +932,7 @@ const uint32_t error_table_0xC0030001[] = {
0x000006F7, // 0xC003000C
};
const uint32_t error_table_0xC0030059[] = {
constexpr uint32_t error_table_0xC0030059[] = {
0x00000723, // 0xC0030059
0x00000724, // 0xC003005A
0x00000725, // 0xC003005B
@@ -944,12 +944,12 @@ const uint32_t error_table_0xC0030059[] = {
0x0000077E, // 0xC0030061
};
const uint32_t error_table_0xC0050003[] = {
constexpr uint32_t error_table_0xC0050003[] = {
0x0000045D, // 0xC0050003
0x00000456, // 0xC0050004
};
const uint32_t error_table_0xC0980001[] = {
constexpr uint32_t error_table_0xC0980001[] = {
0x00000037, // 0xC0980001
0x00000037, // 0xC0980002
0, //
@@ -961,7 +961,7 @@ const uint32_t error_table_0xC0980001[] = {
};
#define MAKE_ENTRY(x) {x, xe::countof(error_table_##x), error_table_##x}
const error_lookup_table error_tables[] = {
constexpr error_lookup_table error_tables[] = {
MAKE_ENTRY(0x00000103), MAKE_ENTRY(0x40000002), MAKE_ENTRY(0x40020056),
MAKE_ENTRY(0x400200AF), MAKE_ENTRY(0x80000001), MAKE_ENTRY(0x80000288),
MAKE_ENTRY(0x80090300), MAKE_ENTRY(0xC0000001), MAKE_ENTRY(0xC0000202),

View File

@@ -29,14 +29,14 @@ namespace xboxkrnl {
struct CreateOptions {
// https://processhacker.sourceforge.io/doc/ntioapi_8h.html
static const uint32_t FILE_DIRECTORY_FILE = 0x00000001;
static constexpr uint32_t FILE_DIRECTORY_FILE = 0x00000001;
// Optimization - files access will be sequential, not random.
static const uint32_t FILE_SEQUENTIAL_ONLY = 0x00000004;
static const uint32_t FILE_SYNCHRONOUS_IO_ALERT = 0x00000010;
static const uint32_t FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020;
static const uint32_t FILE_NON_DIRECTORY_FILE = 0x00000040;
static constexpr uint32_t FILE_SEQUENTIAL_ONLY = 0x00000004;
static constexpr uint32_t FILE_SYNCHRONOUS_IO_ALERT = 0x00000010;
static constexpr uint32_t FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020;
static constexpr uint32_t FILE_NON_DIRECTORY_FILE = 0x00000040;
// Optimization - file access will be random, not sequential.
static const uint32_t FILE_RANDOM_ACCESS = 0x00000800;
static constexpr uint32_t FILE_RANDOM_ACCESS = 0x00000800;
};
dword_result_t NtCreateFile_entry(lpdword_t handle_out, dword_t desired_access,
@@ -625,7 +625,7 @@ dword_result_t NtDeviceIoControlFile_entry(
// Called by XMountUtilityDrive cache-mounting code
// (checks if the returned values look valid, values below seem to pass the
// checks)
const uint32_t cache_size = 0xFF000;
constexpr uint32_t cache_size = 0xFF000;
if (io_control_code == X_IOCTL_DISK_GET_DRIVE_GEOMETRY) {
if (output_buffer_len < 0x8) {

View File

@@ -703,7 +703,7 @@ DECLARE_XBOXKRNL_EXPORT1(ExAllocatePoolWithTag, kMemory, kImplemented);
dword_result_t ExAllocatePool_entry(dword_t size,
const ppc_context_t& context) {
const uint32_t none = 0x656E6F4E; // 'None'
constexpr uint32_t none = 0x656E6F4E; // 'None'
return xeAllocatePoolTypeWithTag(context, size, none, 0);
}
DECLARE_XBOXKRNL_EXPORT1(ExAllocatePool, kMemory, kImplemented);