diff options
| author | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 20:32:34 +0530 |
|---|---|---|
| committer | SHAURYASANYAL3 <shauryasanya.21jun@gmail.com> | 2026-11-22 23:14:50 +0530 |
| commit | 48cf34f3a82db657d9725b5fe44f75fd97ed5d63 (patch) | |
| tree | 956a473082080215db8478dbaa38ea1376421f31 /runtime/test/xgameruntime_test.cpp | |
| parent | 49475796c226c8511b9470bf97a4daf57b8af323 (diff) | |
xgameruntime: implement XPackageGetMountPathSize and validate XPackageMountHandle per GDK spec
Diffstat (limited to 'runtime/test/xgameruntime_test.cpp')
| -rw-r--r-- | runtime/test/xgameruntime_test.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/runtime/test/xgameruntime_test.cpp b/runtime/test/xgameruntime_test.cpp index 8f5057662..779f77599 100644 --- a/runtime/test/xgameruntime_test.cpp +++ b/runtime/test/xgameruntime_test.cpp | |||
| @@ -72,14 +72,20 @@ struct XSystemAnalyticsInfo { | |||
| 72 | }; | 72 | }; |
| 73 | static_assert(sizeof(XSystemAnalyticsInfo) == 144, "XSystemAnalyticsInfo must be 144 bytes per GDK spec"); | 73 | static_assert(sizeof(XSystemAnalyticsInfo) == 144, "XSystemAnalyticsInfo must be 144 bytes per GDK spec"); |
| 74 | 74 | ||
| 75 | struct XPackageMountHandle { | ||
| 76 | uint64_t handle; | ||
| 77 | }; | ||
| 78 | |||
| 75 | using AnalyticsInfoFn = XSystemAnalyticsInfo(__stdcall*)(); | 79 | using AnalyticsInfoFn = XSystemAnalyticsInfo(__stdcall*)(); |
| 76 | using PackageIdentifierFn = HRESULT(__stdcall*)(size_t, char*); | 80 | using PackageIdentifierFn = HRESULT(__stdcall*)(size_t, char*); |
| 77 | using PackageMountPathFn = HRESULT(__stdcall*)(void*, size_t, char*); | 81 | using PackageMountPathSizeFn = HRESULT(__stdcall*)(XPackageMountHandle, size_t*); |
| 82 | using PackageMountPathFn = HRESULT(__stdcall*)(XPackageMountHandle, size_t, char*); | ||
| 78 | using PackagedProcessFn = bool(__stdcall*)(); | 83 | using PackagedProcessFn = bool(__stdcall*)(); |
| 79 | 84 | ||
| 80 | const char* const kNames[] = { | 85 | const char* const kNames[] = { |
| 81 | "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId", | 86 | "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId", |
| 82 | "XSystemGetAnalyticsInfo", "XPackageGetCurrentProcessPackageIdentifier", "XPackageGetMountPath", | 87 | "XSystemGetAnalyticsInfo", "XPackageGetCurrentProcessPackageIdentifier", "XPackageGetMountPathSize", |
| 88 | "XPackageGetMountPath", | ||
| 83 | "XPackageIsPackagedProcess", | 89 | "XPackageIsPackagedProcess", |
| 84 | "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle", | 90 | "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle", |
| 85 | "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback", | 91 | "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback", |
| @@ -367,16 +373,32 @@ int main() { | |||
| 367 | "XPackageGetCurrentProcessPackageIdentifier respects LEONIDA_PACKAGE_ID override"); | 373 | "XPackageGetCurrentProcessPackageIdentifier respects LEONIDA_PACKAGE_ID override"); |
| 368 | SetEnvironmentVariableA("LEONIDA_PACKAGE_ID", nullptr); | 374 | SetEnvironmentVariableA("LEONIDA_PACKAGE_ID", nullptr); |
| 369 | 375 | ||
| 376 | auto mount_path_size = get<PackageMountPathSizeFn>("XPackageGetMountPathSize"); | ||
| 370 | auto mount_path = get<PackageMountPathFn>("XPackageGetMountPath"); | 377 | auto mount_path = get<PackageMountPathFn>("XPackageGetMountPath"); |
| 371 | check(mount_path(nullptr, 0, nullptr) == E_INVALIDARG, "XPackageGetMountPath rejects null buffer and size 0"); | 378 | |
| 379 | const XPackageMountHandle kInvalidMount{0}; | ||
| 380 | const XPackageMountHandle kValidMount{1}; | ||
| 381 | |||
| 382 | size_t req_size = 0; | ||
| 383 | check(mount_path_size(kInvalidMount, &req_size) == E_INVALIDARG, | ||
| 384 | "XPackageGetMountPathSize rejects invalid mount handle 0"); | ||
| 385 | check(mount_path_size(kValidMount, nullptr) == E_INVALIDARG, | ||
| 386 | "XPackageGetMountPathSize rejects null size pointer"); | ||
| 387 | |||
| 388 | check(mount_path(kInvalidMount, 0, nullptr) == E_INVALIDARG, | ||
| 389 | "XPackageGetMountPath rejects invalid mount handle 0"); | ||
| 372 | char mnt_path[MAX_PATH] = {}; | 390 | char mnt_path[MAX_PATH] = {}; |
| 373 | check(mount_path(nullptr, 0, mnt_path) == E_INVALIDARG, "XPackageGetMountPath rejects size 0 with buffer"); | 391 | check(mount_path(kValidMount, 0, mnt_path) == E_INVALIDARG, |
| 374 | check(mount_path(nullptr, 10, nullptr) == E_INVALIDARG, "XPackageGetMountPath rejects null pointer with size"); | 392 | "XPackageGetMountPath rejects size 0 with buffer"); |
| 393 | check(mount_path(kValidMount, 10, nullptr) == E_INVALIDARG, | ||
| 394 | "XPackageGetMountPath rejects null pointer with size"); | ||
| 375 | 395 | ||
| 376 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", "C:\\LeonidaGameDir"); | 396 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", "C:\\LeonidaGameDir"); |
| 377 | check(mount_path(nullptr, 5, mnt_path) == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), | 397 | check(mount_path_size(kValidMount, &req_size) == S_OK && req_size == std::strlen("C:\\LeonidaGameDir") + 1, |
| 398 | "XPackageGetMountPathSize returns required buffer size including null terminator"); | ||
| 399 | check(mount_path(kValidMount, 5, mnt_path) == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), | ||
| 378 | "XPackageGetMountPath rejects insufficient buffer"); | 400 | "XPackageGetMountPath rejects insufficient buffer"); |
| 379 | check(mount_path(nullptr, sizeof(mnt_path), mnt_path) == S_OK && | 401 | check(mount_path(kValidMount, sizeof(mnt_path), mnt_path) == S_OK && |
| 380 | std::strcmp(mnt_path, "C:\\LeonidaGameDir") == 0, | 402 | std::strcmp(mnt_path, "C:\\LeonidaGameDir") == 0, |
| 381 | "XPackageGetMountPath returns configured game directory"); | 403 | "XPackageGetMountPath returns configured game directory"); |
| 382 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr); | 404 | SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr); |