Commit Graph

429 Commits

Author SHA1 Message Date
Gliniak
cdb88d0b36 [Kernel] Remove IsQueued check for DPC 2026-05-13 20:02:36 +02:00
Gliniak
74f34818e7 [Lint] Added InsertBraces to linter to unify codebase to one standard 2026-05-08 18:54:50 +02:00
Gliniak
80f2b535e9 [Kernel] Added KeSaveFloatingPointState and KeRestoreFloatingPointState from nukernel 2026-05-05 10:45:31 +02:00
Herman S.
658bd5db70 [Xboxkrnl] Return error code from KeSetAffinityThread on null thread
If the guest-supplied thread pointer doesn't resolve to an XThread,
we previously returned STATUS_SUCCESS without setting the affinity
or writing previous_affinity_ptr, leaving callers believing the call
succeeded. Real NT kernel would crash on a bad pointer, but that's not
easy for us to replicate so return STATUS_INVALID_HANDLE instead and
log the pointer value so the condition is visible rather than silent.
2026-04-13 13:07:53 +09:00
Herman S.
d42411ec2a [Kernel] Fix NtReleaseSemaphore returning wrong status code 2026-04-13 12:59:36 +09:00
Herman S.
c17a3b19fb [Kernel] Implement per-process TLS allocation
Previous global TLS bitmap was shared across all processes. Now
per-process TLS bitmaps stored X_KPROCESS structures which should
better match Xbox360 architecture.
2026-04-13 12:42:42 +09:00
Herman S.
65b74819aa [Threading] Implement priority boost on wake
When a thread wakes from a kernel wait, the Xenon scheduler boosts its
effective priority by the increment passed to the signaling call
(KeSetEvent, KeReleaseSemaphore, KeReleaseMutant). The boost is clamped
to the per-thread max_dynamic_priority cap, respects the guest
boost_disabled flag, and is drained on the next quantum expiry.
Guest KTHREAD priority fields are now initialized from parent process
defaults, and the previously unknown fields involved have been renamed
to match their identified purpose.
2026-04-11 17:05:05 +09:00
Herman S.
b3d8a21b72 [Threading] Add thread priority mapping with timer-driven quantum decay
And default ignore_thread_priorities to false.

Map Xenon's 0-31 priority range across all 5 host priority levels
instead of collapsing 0-17 into kNormal.

Use timer-driven quantum decay (~20ms period) matching Xenon's
60-quantum / 3-per-tick cycle to prevent starvation by gradually lowering
effective priority for non-real-time threads (< 18), piggybacking on the
existing 1ms timestamp timer.
2026-04-10 08:21:42 +09:00
Herman S.
61c8eb0707 [Threading] Improve same-CPU spinlock contention
Spinlock acquire now checks if the lock holder shares the same guest
CPU and yields more aggressively (Sleep(0)) when contending on the
same Xenon HW thread, which should better approximate real kernel's
implicit serialization.

Child threads without an explicit affinity mask now inherit the
parent's guest CPU assignment instead of round-robining, so the
spinlock check correctly identifies parent-child co-location.
2026-04-09 21:14:39 +09:00
Adrian
e23376afcc [Kernel] Fixed NtSignalAndWaitForSingleObjectEx prototype 2026-04-07 20:05:12 +02:00
Adrian
d3d0478403 [Kernel] Fixed ObCreateSymbolicLink returning error if symbolic link is already registered
Fixed Crackdown greyed out Play Now - CO-OP option.
2026-03-29 21:15:20 +02:00
Adrian
d680f5a499 [Kernel] Fixed XTimer reporting resume support
Fixed Quake 4 performance issues
2026-03-28 20:46:25 +01:00
Herman S.
cb12f7fa1e [Build] Generalize POSIX platform guards
Most non-Windows code paths use standard POSIX APIs (sockets, signals,
dlopen, threading) that work on any POSIX platform. Change Linux-specific
guards to !WIN32 or #else where the code is portable. Linux-specific
APIs (SIGRTMIN, Vulkan/X11, fontconfig/GTK) remain Linux-guarded.
2026-03-26 23:10:47 +09:00
Herman S.
597a0c2d1e [Xboxkrnl] Use towupper in RtlUpcaseUnicodeChar for portability
std::ctype<char16_t> is a non-standard extension that's not available
on all platforms. Neither this nor the original technically match the
Windows kernel's fixed Unicode table approach and can produce different
results based on system locale.
2026-03-26 23:10:47 +09:00
Gliniak
5f62db9289 [Kernel] Added kHighFrequency for RtlInitializeCriticalSectionAndSpinCount 2026-03-11 19:54:19 +01:00
Herman S.
f45a254774 [Linux/Threading] Self-suspend with condition variable instead of spin 2026-03-11 00:02:26 +09:00
Herman S.
4f1394bbaa [Kernel/Threading] Fix some kernel threading issues
- broken atomic exchange on linux
- spinlock release memory buffer
- race in thread suspension
- removed misleading volatile qualifiers
2026-03-10 23:53:03 +09:00
Herman S.
3585b6e592 [Kernel] Replace BCrypt RSA with portable bignum implementation
Removes the Windows-only BCrypt dependency from XeCryptBnQwNeRsaPubCrypt
and replaces it with a portable modular exponentiation implementation
using 64-bit arithmetic, enabling RSA signature verification on all
platforms. Adds Catch2 tests validating the implementation with a
2048-bit RSA key.
2026-03-10 16:20:38 +09:00
Herman S.
b0a387c6ea [XboxKrnl] Don't crash the host on guest trap 2026-03-09 14:15:14 +09:00
Herman S.
a00fd0eb12 [Kernel] Remove some log spam 2026-03-09 14:15:14 +09:00
Herman S.
5ac07f686d [Xboxkrnl] Remove devkit memory access assert and replace with warning 2026-03-09 14:15:14 +09:00
Herman S.
92b07391df [Linux/Threading] change self-suspend to wait to be resumed 2026-03-09 13:43:56 +09:00
Herman S.
32b8c341ee [Kernel] ReleaseSemaphore for Posix to match Windows semantics 2026-03-09 13:43:56 +09:00
Herman S.
bc3585d0ef Keep threads from trying to suspend themselves on Linux
Avoids certain sporadic lockups (usually on startup)
2026-03-09 13:43:56 +09:00
Herman S.
02fccd9113 [Kernel/XMP] Add title-specific file I/O hooks for XMP volume sync
Some games persist BGM volume through their own save files but never
call XMPSetVolume. Add a TitlePatch system that intercepts NtReadFile/
NtWriteFile to apply game-specific logic as well as logic to identify
the memory location that the volume data is read into and monitor that
memory location for changes, updating XMP player volume if it changes
during gameplay.

Includes patches for known games with this issue:
Dead or Alive Xtreme 2 (544307D2), PGR4 (4D5307F9) and PGR3 (4D5307D1)
2026-03-09 08:59:15 +09:00
AllanCat
e8263d3672 [XboxKrnl/Audio] Corrected XMASetLoopData's pointer type.
Fixed an issue where bgm was not looping for games that uses looping feature.
2026-03-07 11:02:23 +09:00
The-Little-Wolf
dd585ca0c8 [XboxKrnl/Crypt] - Implement XeCrypt & XeKeys Functions (#566)
- Implement XeKeysGetConsoleID, XeKeysGetKeyProperties, XeCryptDesEcb, and XeCryptDesKey.
- Stub XeCryptBnQwBeSigVerify, XeCryptRotSumSha, XeKeysGetKey, and XeKeysConsolePrivateKeySign.
2026-02-23 17:33:19 +09:00
Gliniak
8f5da619f9 [Kernel] Replaced Yield in XAudioGetVoiceCategoryVolumeChangeMask with NanoSleep
- Removed Yield in XamUserGetSigninState
2026-02-08 23:01:44 +01:00
The-Little-Wolf
a8fe4666ad [XEX] - log outputs
- Finish XEX_HEADER_XBOX360_LOGO, XEX_HEADER_FILE_FORMAT_INFO, XEX_HEADER_DELTA_PATCH_DESCRIPTOR, XEX_HEADER_SYSTEM_FLAGS_32, XEX_HEADER_ENABLED_FOR_CALLCAP, and XEX_HEADER_GAME_RATINGS
- Add missing xex2_header_keys
- Add flag name outputs
- Removed magic number
- Added X_FILE_CHARACTERISTICS to X_FILE_FS_DEVICE_INFORMATION
2026-01-30 18:45:04 +01:00
The-Little-Wolf
38ccc71afa [XboxKrnl/Threading] - implement KeInitializeTimerEx
- Taken from Crispy's Nukernel build
2026-01-29 23:05:23 +01:00
Gliniak
2ba82072fc [Kernel] Added stub for: NtCancelIoFile 2026-01-29 20:41:01 +01:00
Anton Dorozhkin
e588a772d4 [XBDM] Implement DmQueryTitleMemoryStatistics 2025-12-03 10:05:56 +01:00
Anton Dorozhkin
dfa70b3677 [Kernel] Change _vsnprintf overflow behavior. 2025-12-01 23:06:09 +01:00
Adrian
481ab595ce [Kernel] ObReferenceObjectByHandle Cleanup 2025-11-23 21:45:39 +01:00
Adrian
38ad9bf342 [Kernel] Fixed NtYieldExecution
Fixed Ninja Gaiden 3 stuck exiting challenge trials
2025-10-17 22:40:52 +02:00
Gliniak
777c394e25 [Kernel] Added VdQueryRealVideoMode 2025-10-17 09:24:06 +02:00
Adrian
a717c0cd9f [Kernel] Implemented RtlDowncaseUnicodeChar 2025-07-27 18:05:58 +02:00
The-Little-Wolf
39621ddec8 [KERNEL] - Replacing Unk
- Changes here are from Chrispy's Nukernel
2025-07-26 22:27:21 +02:00
Gliniak
4182852a4b [Base] Split of xbox.h file
- Splitted into: kernel.h and xam.h
- Removed UpdateSpaData from KernelState into ContentManager
2025-07-26 21:25:32 +02:00
The-Little-Wolf
c83522060e [XBOXKRNL/XCONFIG] - Properly set PC values
- Adding PC Related flags
- set correct size of XCONFIG_USER_PC_HINT
2025-07-23 21:46:49 +02:00
The-Little-Wolf
6314388c51 [XAM] - Replacing Unk
- Replacing unk parameters
- Naming unk xmp calls
- Added missing xmp structs
- Added missing messenger structs
- Added missing XamProfileCreate related structs
2025-07-19 20:37:23 +02:00
The-Little-Wolf
0f804c3690 [SMC] - add structs and enum for poweron and standby messages
- add structs for poweron and standby messages
- add enum for poweron and standby messages
- add enum for HalReturnToFirmware and log
2025-07-07 15:40:48 +02:00
Gliniak
b864149575 [Misc] Cleanup in Kernel 2025-05-31 12:00:47 +02:00
Gliniak
50492a951e [Misc] Moved pe_image to base from 3pp and cut unnecessary parts 2025-05-31 10:05:00 +02:00
Gliniak
96c2fb13f7 [Kernel] NtReadFile: Add APC call only for successful executions 2025-05-30 20:08:26 +02:00
Gliniak
97a45315e3 [XConfig] Added enum for all config settings 2025-05-20 22:41:27 +02:00
Gliniak
a79c00f67a [XConfig] Changed raw category values into enum 2025-05-20 22:13:53 +02:00
Gliniak
d211130c6c [Kernel] Fixed incorrect behaviour of IsSystemTitle util
- Added missing symlinks
2025-05-17 22:28:22 +02:00
Gliniak
fe739208b6 [VFS] Rewrote STFS to use memory mapping
- Replaced old-style buffer, buffer_length with std::span
- Added STFS and SVOD specific Entry and File classes
- Other smaller improvements
2025-05-14 21:38:02 +02:00
Gliniak
e85c2392ba [Kernel] Implemented: KeSetPriorityThread 2025-05-12 21:10:35 +02:00