From fb011d205977f2311083610facc020aad444b345 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Mon, 6 May 2024 00:39:00 +0000 Subject: [PATCH] add api name support for tests/tests-exclude options --- README.md | 6 +++--- src/main.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 37d962d..f835200 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Here is a setup guide: https://github.com/XboxDev/nxdk/wiki/Getting-Started The following list of options can be used inside the config.txt file: - `seed` = `` -- `tests` = `[,...]` -- `tests-exclude` = `[,...]` +- `tests` = `[,...]` +- `tests-exclude` = `[,...]` - `disable-video` = ``[^1] [^1]: boolean value can be 1 or 0 @@ -28,7 +28,7 @@ The following list of options can be used inside the config.txt file: > ``` > seed=5 > -> tests=1,25,3,F +> tests=1,25,3,F,NtReadFile > ``` ## NAME FILE: diff --git a/src/main.cpp b/src/main.cpp index 55cd2a0..71a50c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,6 +90,26 @@ void load_name_file(const char* file_path) static std::bitset tests_to_run; static std::bitset tests_to_exclude; +constexpr size_t XBOXKRNL_API_NAME_STR_MIN_LENGTH = 6; // XcHMAC and RtlRip APIs are the shortest kernel names. +unsigned long convert_test_api_input(char* test_str) { + // Trim space(s) before attempting to compare strings. + while(test_str[0] == ' ') { + test_str++; + } + if (strlen(test_str) >= XBOXKRNL_API_NAME_STR_MIN_LENGTH) { + for (unsigned long i = 0; i < kernel_api_tests_size; i++) { + // If the API name is a match, then return the index value. + if (_stricmp(test_str, kernel_api_tests[i].name) == 0) { + return i; + } + } + // If no match is found, then return a max value to skip add to the list. + return ULONG_MAX; + } + // Otherwise, we assumed the input is a hexadecimal string. + return strtoul(test_str, NULL, 16); +} + int load_conf_file(const char *file_path) { print("Trying to open config file: %s", file_path); @@ -142,7 +162,7 @@ int load_conf_file(const char *file_path) char *current_test; char *tests = strtok(NULL, NEWLINE_DELIMITER); while ((current_test = strtok_r(tests, ",", &tests))) { - unsigned long value = strtoul(current_test, NULL, 16); + unsigned long value = convert_test_api_input(current_test); if (value < kernel_api_tests_size) { tests_to_run.set(value); } @@ -152,7 +172,7 @@ int load_conf_file(const char *file_path) char *current_test; char *tests = strtok(NULL, NEWLINE_DELIMITER); while ((current_test = strtok_r(tests, ",", &tests))) { - unsigned long value = strtoul(current_test, NULL, 16); + unsigned long value = convert_test_api_input(current_test); if (value < kernel_api_tests_size) { tests_to_exclude.set(value); }