Merge pull request #1355 from LukeUsher/better-locking-for-fs

Prevent side-effects of the lock/unlock action for FS
This commit is contained in:
Luke Usher 2018-07-27 22:15:34 +01:00 committed by GitHub
commit e313367b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 22 deletions

View File

@ -130,35 +130,32 @@ xboxkrnl::KPCR* KeGetPcr();
uint32_t fs_lock = 0;
__declspec(naked) void LockFSInternal()
{
__asm {
mov eax, 1
xchg eax, [fs_lock]
test eax, eax
jnz LockFSInternal
ret
}
}
__declspec(naked) void LockFS()
{
__asm {
push eax
call LockFSInternal
pop eax
ret
__asm {
pushfd
pushad
spinlock :
mov eax, 1
xchg eax, fs_lock
test eax, eax
jnz spinlock
popad
popfd
ret
}
}
__declspec(naked) void UnlockFS()
{
__asm {
push eax
xor eax, eax
xchg eax, [fs_lock]
pop eax
ret
__asm {
pushfd
pushad
xor eax, eax
xchg eax, fs_lock
popad
popfd
ret
}
}