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:
commit
e313367b2b
|
@ -130,35 +130,32 @@ xboxkrnl::KPCR* KeGetPcr();
|
||||||
|
|
||||||
uint32_t fs_lock = 0;
|
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()
|
__declspec(naked) void LockFS()
|
||||||
{
|
{
|
||||||
__asm {
|
__asm {
|
||||||
push eax
|
pushfd
|
||||||
call LockFSInternal
|
pushad
|
||||||
pop eax
|
spinlock :
|
||||||
ret
|
mov eax, 1
|
||||||
|
xchg eax, fs_lock
|
||||||
|
test eax, eax
|
||||||
|
jnz spinlock
|
||||||
|
popad
|
||||||
|
popfd
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void UnlockFS()
|
__declspec(naked) void UnlockFS()
|
||||||
{
|
{
|
||||||
__asm {
|
__asm {
|
||||||
push eax
|
pushfd
|
||||||
xor eax, eax
|
pushad
|
||||||
xchg eax, [fs_lock]
|
xor eax, eax
|
||||||
pop eax
|
xchg eax, fs_lock
|
||||||
ret
|
popad
|
||||||
|
popfd
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue