mirror of
https://github.com/reactos/reactos.git
synced 2024-07-10 14:45:06 +00:00
[NTOSKRNL]
- Fix completely broken code to detect invalid MSR access in KiTrap0DHandler - Fix MSVC warnings svn path=/trunk/; revision=52548
This commit is contained in:
parent
9659a39678
commit
b92c0d9f52
|
@ -42,7 +42,7 @@ UCHAR KiTrapIoTable[] =
|
||||||
0xEE, /* OUT */
|
0xEE, /* OUT */
|
||||||
0xEF, /* OUT */
|
0xEF, /* OUT */
|
||||||
0x6E, /* OUTS */
|
0x6E, /* OUTS */
|
||||||
0x6F, /* OUTS */
|
0x6F, /* OUTS */
|
||||||
};
|
};
|
||||||
|
|
||||||
PFAST_SYSTEM_CALL_EXIT KiFastCallExitHandler;
|
PFAST_SYSTEM_CALL_EXIT KiFastCallExitHandler;
|
||||||
|
@ -143,7 +143,7 @@ KiServiceExit(IN PKTRAP_FRAME TrapFrame,
|
||||||
KiCommonExit(TrapFrame, 0);
|
KiCommonExit(TrapFrame, 0);
|
||||||
|
|
||||||
/* Restore previous mode */
|
/* Restore previous mode */
|
||||||
KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode;
|
KeGetCurrentThread()->PreviousMode = (CCHAR)TrapFrame->PreviousPreviousMode;
|
||||||
|
|
||||||
/* Check for user mode exit */
|
/* Check for user mode exit */
|
||||||
if (TrapFrame->SegCs & MODE_MASK)
|
if (TrapFrame->SegCs & MODE_MASK)
|
||||||
|
@ -174,7 +174,7 @@ KiServiceExit2(IN PKTRAP_FRAME TrapFrame)
|
||||||
KiCommonExit(TrapFrame, 0);
|
KiCommonExit(TrapFrame, 0);
|
||||||
|
|
||||||
/* Restore previous mode */
|
/* Restore previous mode */
|
||||||
KeGetCurrentThread()->PreviousMode = TrapFrame->PreviousPreviousMode;
|
KeGetCurrentThread()->PreviousMode = (CCHAR)TrapFrame->PreviousPreviousMode;
|
||||||
|
|
||||||
/* Check if this was a V8086 trap */
|
/* Check if this was a V8086 trap */
|
||||||
if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame);
|
if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturnNoSegments(TrapFrame);
|
||||||
|
@ -213,7 +213,7 @@ KiDebugHandler(IN PKTRAP_FRAME TrapFrame,
|
||||||
Parameter1,
|
Parameter1,
|
||||||
Parameter2,
|
Parameter2,
|
||||||
Parameter3,
|
Parameter3,
|
||||||
TrapFrame);
|
TrapFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLSPEC_NORETURN
|
DECLSPEC_NORETURN
|
||||||
|
@ -463,7 +463,7 @@ KiTrap02(VOID)
|
||||||
//
|
//
|
||||||
// Note that in reality, we are already on the NMI tss -- we just need to
|
// Note that in reality, we are already on the NMI tss -- we just need to
|
||||||
// update the PCR to reflect this
|
// update the PCR to reflect this
|
||||||
//
|
//
|
||||||
PCR->TSS = NmiTss;
|
PCR->TSS = NmiTss;
|
||||||
__writeeflags(__readeflags() &~ EFLAGS_NESTED_TASK);
|
__writeeflags(__readeflags() &~ EFLAGS_NESTED_TASK);
|
||||||
TssGdt->HighWord.Bits.Dpl = 0;
|
TssGdt->HighWord.Bits.Dpl = 0;
|
||||||
|
@ -527,7 +527,7 @@ KiTrap02(VOID)
|
||||||
// Although the CPU disabled NMIs, we just did a BIOS Call, which could've
|
// Although the CPU disabled NMIs, we just did a BIOS Call, which could've
|
||||||
// totally changed things.
|
// totally changed things.
|
||||||
//
|
//
|
||||||
// We have to make sure we're still in our original NMI -- a nested NMI
|
// We have to make sure we're still in our original NMI -- a nested NMI
|
||||||
// will point back to the NMI TSS, and in that case we're hosed.
|
// will point back to the NMI TSS, and in that case we're hosed.
|
||||||
//
|
//
|
||||||
if (PCR->TSS->Backlink != KGDT_NMI_TSS)
|
if (PCR->TSS->Backlink != KGDT_NMI_TSS)
|
||||||
|
@ -652,7 +652,7 @@ KiTrap06Handler(IN PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
/* Should only happen in VDM mode */
|
/* Should only happen in VDM mode */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
while (TRUE);
|
while (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bring IRQL back */
|
/* Bring IRQL back */
|
||||||
|
@ -910,7 +910,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
/* Should only happen in VDM mode */
|
/* Should only happen in VDM mode */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
while (TRUE);
|
while (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bring IRQL back */
|
/* Bring IRQL back */
|
||||||
|
@ -933,7 +933,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
/* Enable interrupts and check error code */
|
/* Enable interrupts and check error code */
|
||||||
_enable();
|
_enable();
|
||||||
if (!TrapFrame->ErrCode)
|
if (!TrapFrame->ErrCode)
|
||||||
{
|
{
|
||||||
/* FIXME: Use SEH */
|
/* FIXME: Use SEH */
|
||||||
Instructions = (PUCHAR)TrapFrame->Eip;
|
Instructions = (PUCHAR)TrapFrame->Eip;
|
||||||
|
|
||||||
|
@ -1047,7 +1047,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
TrapFrame);
|
TrapFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a fault during checking of the user instruction.
|
* Check for a fault during checking of the user instruction.
|
||||||
*
|
*
|
||||||
* Note that the SEH handler will catch invalid EIP, but we could be dealing
|
* Note that the SEH handler will catch invalid EIP, but we could be dealing
|
||||||
|
@ -1059,7 +1059,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
/* Not implemented */
|
/* Not implemented */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
while (TRUE);
|
while (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1100,7 +1100,7 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
if (Instructions[0] == 0xCF)
|
if (Instructions[0] == 0xCF)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Some evil shit is going on here -- this is not the SS:ESP you're
|
* Some evil shit is going on here -- this is not the SS:ESP you're
|
||||||
* looking for! Instead, this is actually CS:EIP you're looking at!
|
* looking for! Instead, this is actually CS:EIP you're looking at!
|
||||||
* Why? Because part of the trap frame actually corresponds to the IRET
|
* Why? Because part of the trap frame actually corresponds to the IRET
|
||||||
* stack during the trap exit!
|
* stack during the trap exit!
|
||||||
|
@ -1121,8 +1121,8 @@ KiTrap0DHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
|
|
||||||
/* So since we're not dealing with the above case, check for RDMSR/WRMSR */
|
/* So since we're not dealing with the above case, check for RDMSR/WRMSR */
|
||||||
if ((Instructions[0] == 0xF) && // 2-byte opcode
|
if ((Instructions[0] == 0xF) && // 2-byte opcode
|
||||||
(((Instructions[1] >> 8) == 0x30) || // RDMSR
|
((Instructions[1] == 0x32) || // RDMSR
|
||||||
((Instructions[2] >> 8) == 0x32))) // WRMSR
|
(Instructions[1] == 0x30))) // WRMSR
|
||||||
{
|
{
|
||||||
/* Unknown CPU MSR, so raise an access violation */
|
/* Unknown CPU MSR, so raise an access violation */
|
||||||
KiDispatchException0Args(STATUS_ACCESS_VIOLATION,
|
KiDispatchException0Args(STATUS_ACCESS_VIOLATION,
|
||||||
|
@ -1211,7 +1211,7 @@ KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
/* Not yet implemented */
|
/* Not yet implemented */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
while (TRUE);
|
while (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for syscall fault */
|
/* Check for syscall fault */
|
||||||
|
@ -1496,7 +1496,7 @@ KiSystemCall(IN PKTRAP_FRAME TrapFrame,
|
||||||
/* Save previous mode */
|
/* Save previous mode */
|
||||||
TrapFrame->PreviousPreviousMode = Thread->PreviousMode;
|
TrapFrame->PreviousPreviousMode = Thread->PreviousMode;
|
||||||
|
|
||||||
/* Save the SEH chain and terminate it for now */
|
/* Save the SEH chain and terminate it for now */
|
||||||
TrapFrame->ExceptionList = KeGetPcr()->NtTib.ExceptionList;
|
TrapFrame->ExceptionList = KeGetPcr()->NtTib.ExceptionList;
|
||||||
KeGetPcr()->NtTib.ExceptionList = EXCEPTION_CHAIN_END;
|
KeGetPcr()->NtTib.ExceptionList = EXCEPTION_CHAIN_END;
|
||||||
|
|
||||||
|
@ -1533,7 +1533,7 @@ KiSystemCall(IN PKTRAP_FRAME TrapFrame,
|
||||||
goto ExitCall;
|
goto ExitCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert us to a GUI thread -- must wrap in ASM to get new EBP */
|
/* Convert us to a GUI thread -- must wrap in ASM to get new EBP */
|
||||||
Result = KiConvertToGuiThread();
|
Result = KiConvertToGuiThread();
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
|
@ -1541,7 +1541,7 @@ KiSystemCall(IN PKTRAP_FRAME TrapFrame,
|
||||||
//SetLastWin32Error(RtlNtStatusToDosError(Result));
|
//SetLastWin32Error(RtlNtStatusToDosError(Result));
|
||||||
goto ExitCall;
|
goto ExitCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reload trap frame and descriptor table pointer from new stack */
|
/* Reload trap frame and descriptor table pointer from new stack */
|
||||||
TrapFrame = *(volatile PVOID*)&Thread->TrapFrame;
|
TrapFrame = *(volatile PVOID*)&Thread->TrapFrame;
|
||||||
DescriptorTable = (PVOID)(*(volatile ULONG_PTR*)&Thread->ServiceTable + Offset);
|
DescriptorTable = (PVOID)(*(volatile ULONG_PTR*)&Thread->ServiceTable + Offset);
|
||||||
|
|
|
@ -452,7 +452,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType,
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PPOOL_HEADER Entry, NextEntry, FragmentEntry;
|
PPOOL_HEADER Entry, NextEntry, FragmentEntry;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
ULONG BlockSize, i;
|
USHORT BlockSize, i;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Some sanity checks
|
// Some sanity checks
|
||||||
|
@ -495,7 +495,8 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType,
|
||||||
// request would've been treated as a POOL_MAX_ALLOC earlier and resulted in
|
// request would've been treated as a POOL_MAX_ALLOC earlier and resulted in
|
||||||
// the direct allocation of pages.
|
// the direct allocation of pages.
|
||||||
//
|
//
|
||||||
i = (NumberOfBytes + sizeof(POOL_HEADER) + (POOL_BLOCK_SIZE - 1)) / POOL_BLOCK_SIZE;
|
i = (USHORT)((NumberOfBytes + sizeof(POOL_HEADER) + (POOL_BLOCK_SIZE - 1))
|
||||||
|
/ POOL_BLOCK_SIZE);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loop in the free lists looking for a block if this size. Start with the
|
// Loop in the free lists looking for a block if this size. Start with the
|
||||||
|
@ -748,7 +749,7 @@ ExFreePoolWithTag(IN PVOID P,
|
||||||
IN ULONG TagToFree)
|
IN ULONG TagToFree)
|
||||||
{
|
{
|
||||||
PPOOL_HEADER Entry, NextEntry;
|
PPOOL_HEADER Entry, NextEntry;
|
||||||
ULONG BlockSize;
|
USHORT BlockSize;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
POOL_TYPE PoolType;
|
POOL_TYPE PoolType;
|
||||||
PPOOL_DESCRIPTOR PoolDesc;
|
PPOOL_DESCRIPTOR PoolDesc;
|
||||||
|
|
Loading…
Reference in a new issue