Author: tkreuzer
Date: Sat May 16 11:30:28 2015
New Revision: 67770
URL:
http://svn.reactos.org/svn/reactos?rev=67770&view=rev
Log:
[NDK]
- Add coprocessor constants
[NTOSKRNL]
- Handle process in NtFlushInstructionCache and validate parameters
- Use _MoveToCoprocessor instead of GCC inline assembly for ARM
Modified:
trunk/reactos/drivers/crypto/ksecdd/ksecdd.h
trunk/reactos/drivers/crypto/ksecdd/random.c
trunk/reactos/include/asm/ksarm.template.h
trunk/reactos/include/ndk/arm/ketypes.h
trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/drivers/crypto/ksecdd/ksecdd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/crypto/ksecdd/ksec…
==============================================================================
--- trunk/reactos/drivers/crypto/ksecdd/ksecdd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/crypto/ksecdd/ksecdd.h [iso-8859-1] Sat May 16 11:30:28 2015
@@ -9,6 +9,7 @@
#define _NO_KSECDD_IMPORT_
#include <ntifs.h>
#include <ndk/exfuncs.h>
+#include <ndk/ketypes.h>
#include <pseh/pseh2.h>
#include <ntstrsafe.h>
Modified: trunk/reactos/drivers/crypto/ksecdd/random.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/crypto/ksecdd/rand…
==============================================================================
--- trunk/reactos/drivers/crypto/ksecdd/random.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/crypto/ksecdd/random.c [iso-8859-1] Sat May 16 11:30:28 2015
@@ -77,8 +77,6 @@
}
#endif
#elif defined(_M_ARM)
-/* FIXME: this should go into a public header (from ksarm.h) */
-#define CP15_PMCCNTR 15, 0, 9, 13, 0
/* Read the Cycle Counter Register */
MachineSpecificCounters->Ccr = _MoveFromCoprocessor(CP15_PMCCNTR);
#else
Modified: trunk/reactos/include/asm/ksarm.template.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/asm/ksarm.template…
==============================================================================
--- trunk/reactos/include/asm/ksarm.template.h [iso-8859-1] (original)
+++ trunk/reactos/include/asm/ksarm.template.h [iso-8859-1] Sat May 16 11:30:28 2015
@@ -561,144 +561,5 @@
-#define CP15_MIDR 15, 0, 0, 0, 0
-#define CP15_CTR 15, 0, 0, 0, 1
-#define CP15_TCMTR 15, 0, 0, 0, 2
-#define CP15_TLBTR 15, 0, 0, 0, 3
-#define CP15_MPIDR 15, 0, 0, 0, 5
-#define CP15_PFR0 15, 0, 0, 1, 0
-#define CP15_PFR1 15, 0, 0, 1, 1
-#define CP15_DFR0 15, 0, 0, 1, 2
-#define CP15_AFR0 15, 0, 0, 1, 3
-#define CP15_MMFR0 15, 0, 0, 1, 4
-#define CP15_MMFR1 15, 0, 0, 1, 5
-#define CP15_MMFR2 15, 0, 0, 1, 6
-#define CP15_MMFR3 15, 0, 0, 1, 7
-#define CP15_ISAR0 15, 0, 0, 2, 0
-#define CP15_ISAR1 15, 0, 0, 2, 1
-#define CP15_ISAR2 15, 0, 0, 2, 2
-#define CP15_ISAR3 15, 0, 0, 2, 3
-#define CP15_ISAR4 15, 0, 0, 2, 4
-#define CP15_ISAR5 15, 0, 0, 2, 5
-#define CP15_ISAR6 15, 0, 0, 2, 6
-#define CP15_ISAR7 15, 0, 0, 2, 7
-#define CP15_SCTLR 15, 0, 1, 0, 0
-#define CP15_ACTLR 15, 0, 1, 0, 1
-#define CP15_CPACR 15, 0, 1, 0, 2
-#define CP15_SCR 15, 0, 1, 1, 0
-#define CP15_SDER 15, 0, 1, 1, 1
-#define CP15_NSACR 15, 0, 1, 1, 2
-#define CP15_TTBR0 15, 0, 2, 0, 0
-#define CP15_TTBR1 15, 0, 2, 0, 1
-#define CP15_TTBCR 15, 0, 2, 0, 2
-#define CP15_DACR 15, 0, 3, 0, 0
-#define CP15_DFSR 15, 0, 5, 0, 0
-#define CP15_IFSR 15, 0, 5, 0, 1
-#define CP15_DFAR 15, 0, 6, 0, 0
-#define CP15_IFAR 15, 0, 6, 0, 2
-#define CP15_ICIALLUIS 15, 0, 7, 1, 0
-#define CP15_BPIALLIS 15, 0, 7, 1, 6
-#define CP15_ICIALLU 15, 0, 7, 5, 0
-#define CP15_ICIMVAU 15, 0, 7, 5, 1
-#define CP15_BPIALL 15, 0, 7, 5, 6
-#define CP15_BPIMVA 15, 0, 7, 5, 7
-#define CP15_DCIMVAC 15, 0, 7, 6, 1
-#define CP15_DCISW 15, 0, 7, 6, 2
-#define CP15_DCCMVAC 15, 0, 7, 10, 1
-#define CP15_DCCSW 15, 0, 7, 10, 2
-#define CP15_DCCMVAU 15, 0, 7, 11, 1
-#define CP15_DCCIMVAC 15, 0, 7, 14, 1
-#define CP15_DCCISW 15, 0, 7, 14, 2
-#define CP15_PAR 15, 0, 7, 4, 0
-#define CP15_ATS1CPR 15, 0, 7, 8, 0
-#define CP15_ATS1CPW 15, 0, 7, 8, 1
-#define CP15_ATS1CUR 15, 0, 7, 8, 2
-#define CP15_ATS1CUW 15, 0, 7, 8, 3
-#define CP15_ISB 15, 0, 7, 5, 4
-#define CP15_DSB 15, 0, 7, 10, 4
-#define CP15_DMB 15, 0, 7, 10, 5
-#define CP15_TLBIALLIS 15, 0, 8, 3, 0
-#define CP15_TLBIMVAIS 15, 0, 8, 3, 1
-#define CP15_TLBIASIDIS 15, 0, 8, 3, 2
-#define CP15_TLBIMVAAIS 15, 0, 8, 3, 3
-#define CP15_ITLBIALL 15, 0, 8, 5, 0
-#define CP15_ITLBIMVA 15, 0, 8, 5, 1
-#define CP15_ITLBIASID 15, 0, 8, 5, 2
-#define CP15_DTLBIALL 15, 0, 8, 6, 0
-#define CP15_DTLBIMVA 15, 0, 8, 6, 1
-#define CP15_DTLBIASID 15, 0, 8, 6, 2
-#define CP15_TLBIALL 15, 0, 8, 7, 0
-#define CP15_TLBIMVA 15, 0, 8, 7, 1
-#define CP15_TLBIASID 15, 0, 8, 7, 2
-#define CP15_TLBIMVAA 15, 0, 8, 7, 3
-#define CP15_PMCR 15, 0, 9, 12, 0
-#define CP15_PMCNTENSET 15, 0, 9, 12, 1
-#define CP15_PMCNTENCLR 15, 0, 9, 12, 2
-#define CP15_PMOVSR 15, 0, 9, 12, 3
-#define CP15_PSWINC 15, 0, 9, 12, 4
-#define CP15_PMSELR 15, 0, 9, 12, 5
-#define CP15_PMCCNTR 15, 0, 9, 13, 0
-#define CP15_PMXEVTYPER 15, 0, 9, 13, 1
-#define CP15_PMXEVCNTR 15, 0, 9, 13, 2
-#define CP15_PMUSERENR 15, 0, 9, 14, 0
-#define CP15_PMINTENSET 15, 0, 9, 14, 1
-#define CP15_PMINTENCLR 15, 0, 9, 14, 2
-#define CP15_PRRR 15, 0, 10, 2, 0
-#define CP15_NMRR 15, 0, 10, 2, 1
-#define CP15_VBAR 15, 0, 12, 0, 0
-#define CP15_MVBAR 15, 0, 12, 0, 1
-#define CP15_ISR 15, 0, 12, 1, 0
-#define CP15_CONTEXTIDR 15, 0, 13, 0, 1
-#define CP15_TPIDRURW 15, 0, 13, 0, 2
-#define CP15_TPIDRURO 15, 0, 13, 0, 3
-#define CP15_TPIDRPRW 15, 0, 13, 0, 4
-#define CP15_CCSIDR 15, 1, 0, 0, 0
-#define CP15_CLIDR 15, 1, 0, 0, 1
-#define CP15_AIDR 15, 1, 0, 0, 7
-#define CP15_CSSELR 15, 2, 0, 0, 0
-#define CP14_DBGDIDR 14, 0, 0, 0, 0
-#define CP14_DBGWFAR 14, 0, 0, 6, 0
-#define CP14_DBGVCR 14, 0, 0, 7, 0
-#define CP14_DBGECR 14, 0, 0, 9, 0
-#define CP14_DBGDSCCR 14, 0, 0, 10, 0
-#define CP14_DBGDSMCR 14, 0, 0, 11, 0
-#define CP14_DBGDTRRX 14, 0, 0, 0, 2
-#define CP14_DBGPCSR 14, 0, 0, 1, 2
-#define CP14_DBGITR 14, 0, 0, 1, 2
-#define CP14_DBGDSCR 14, 0, 0, 2, 2
-#define CP14_DBGDTRTX 14, 0, 0, 3, 2
-#define CP14_DBGDRCR 14, 0, 0, 4, 2
-#define CP14_DBGCIDSR 14, 0, 0, 9, 2
-#define CP14_DBGBVR0 14, 0, 0, 0, 4
-#define CP14_DBGBVR1 14, 0, 0, 1, 4
-#define CP14_DBGBVR2 14, 0, 0, 2, 4
-#define CP14_DBGBVR3 14, 0, 0, 3, 4
-#define CP14_DBGBVR4 14, 0, 0, 4, 4
-#define CP14_DBGBVR5 14, 0, 0, 5, 4
-#define CP14_DBGBVR6 14, 0, 0, 6, 4
-#define CP14_DBGBVR7 14, 0, 0, 7, 4
-#define CP14_DBGBCR0 14, 0, 0, 0, 5
-#define CP14_DBGBCR1 14, 0, 0, 1, 5
-#define CP14_DBGBCR2 14, 0, 0, 2, 5
-#define CP14_DBGBCR3 14, 0, 0, 3, 5
-#define CP14_DBGBCR4 14, 0, 0, 4, 5
-#define CP14_DBGBCR5 14, 0, 0, 5, 5
-#define CP14_DBGBCR6 14, 0, 0, 6, 5
-#define CP14_DBGBCR7 14, 0, 0, 7, 5
-#define CP14_DBGWVR0 14, 0, 0, 0, 6
-#define CP14_DBGWVR1 14, 0, 0, 1, 6
-#define CP14_DBGWVR2 14, 0, 0, 2, 6
-#define CP14_DBGWVR3 14, 0, 0, 3, 6
-#define CP14_DBGWCR0 14, 0, 0, 0, 7
-#define CP14_DBGWCR1 14, 0, 0, 1, 7
-#define CP14_DBGWCR2 14, 0, 0, 2, 7
-#define CP14_DBGWCR3 14, 0, 0, 3, 7
-#define CPVFP_FPSID 10, 7, 0, 0, 0
-#define CPVFP_FPSCR 10, 7, 1, 0, 0
-#define CPVFP_MVFR1 10, 7, 6, 0, 0
-#define CPVFP_MVFR0 10, 7, 7, 0, 0
-#define CPVFP_FPEXC 10, 7, 8, 0, 0
-#define CP15_TTBRx_PD_MASK 0xffffc000
-
-
-
+
+
Modified: trunk/reactos/include/ndk/arm/ketypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/arm/ketypes.h?…
==============================================================================
--- trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] Sat May 16 11:30:28 2015
@@ -30,6 +30,149 @@
#define SYNCH_LEVEL DISPATCH_LEVEL
+
+//
+// Co-Processor register definitions
+//
+#define CP15_MIDR 15, 0, 0, 0, 0
+#define CP15_CTR 15, 0, 0, 0, 1
+#define CP15_TCMTR 15, 0, 0, 0, 2
+#define CP15_TLBTR 15, 0, 0, 0, 3
+#define CP15_MPIDR 15, 0, 0, 0, 5
+#define CP15_PFR0 15, 0, 0, 1, 0
+#define CP15_PFR1 15, 0, 0, 1, 1
+#define CP15_DFR0 15, 0, 0, 1, 2
+#define CP15_AFR0 15, 0, 0, 1, 3
+#define CP15_MMFR0 15, 0, 0, 1, 4
+#define CP15_MMFR1 15, 0, 0, 1, 5
+#define CP15_MMFR2 15, 0, 0, 1, 6
+#define CP15_MMFR3 15, 0, 0, 1, 7
+#define CP15_ISAR0 15, 0, 0, 2, 0
+#define CP15_ISAR1 15, 0, 0, 2, 1
+#define CP15_ISAR2 15, 0, 0, 2, 2
+#define CP15_ISAR3 15, 0, 0, 2, 3
+#define CP15_ISAR4 15, 0, 0, 2, 4
+#define CP15_ISAR5 15, 0, 0, 2, 5
+#define CP15_ISAR6 15, 0, 0, 2, 6
+#define CP15_ISAR7 15, 0, 0, 2, 7
+#define CP15_SCTLR 15, 0, 1, 0, 0
+#define CP15_ACTLR 15, 0, 1, 0, 1
+#define CP15_CPACR 15, 0, 1, 0, 2
+#define CP15_SCR 15, 0, 1, 1, 0
+#define CP15_SDER 15, 0, 1, 1, 1
+#define CP15_NSACR 15, 0, 1, 1, 2
+#define CP15_TTBR0 15, 0, 2, 0, 0
+#define CP15_TTBR1 15, 0, 2, 0, 1
+#define CP15_TTBCR 15, 0, 2, 0, 2
+#define CP15_DACR 15, 0, 3, 0, 0
+#define CP15_DFSR 15, 0, 5, 0, 0
+#define CP15_IFSR 15, 0, 5, 0, 1
+#define CP15_DFAR 15, 0, 6, 0, 0
+#define CP15_IFAR 15, 0, 6, 0, 2
+#define CP15_ICIALLUIS 15, 0, 7, 1, 0
+#define CP15_BPIALLIS 15, 0, 7, 1, 6
+#define CP15_ICIALLU 15, 0, 7, 5, 0
+#define CP15_ICIMVAU 15, 0, 7, 5, 1
+#define CP15_BPIALL 15, 0, 7, 5, 6
+#define CP15_BPIMVA 15, 0, 7, 5, 7
+#define CP15_DCIMVAC 15, 0, 7, 6, 1
+#define CP15_DCISW 15, 0, 7, 6, 2
+#define CP15_DCCMVAC 15, 0, 7, 10, 1
+#define CP15_DCCSW 15, 0, 7, 10, 2
+#define CP15_DCCMVAU 15, 0, 7, 11, 1
+#define CP15_DCCIMVAC 15, 0, 7, 14, 1
+#define CP15_DCCISW 15, 0, 7, 14, 2
+#define CP15_PAR 15, 0, 7, 4, 0
+#define CP15_ATS1CPR 15, 0, 7, 8, 0
+#define CP15_ATS1CPW 15, 0, 7, 8, 1
+#define CP15_ATS1CUR 15, 0, 7, 8, 2
+#define CP15_ATS1CUW 15, 0, 7, 8, 3
+#define CP15_ISB 15, 0, 7, 5, 4
+#define CP15_DSB 15, 0, 7, 10, 4
+#define CP15_DMB 15, 0, 7, 10, 5
+#define CP15_TLBIALLIS 15, 0, 8, 3, 0
+#define CP15_TLBIMVAIS 15, 0, 8, 3, 1
+#define CP15_TLBIASIDIS 15, 0, 8, 3, 2
+#define CP15_TLBIMVAAIS 15, 0, 8, 3, 3
+#define CP15_ITLBIALL 15, 0, 8, 5, 0
+#define CP15_ITLBIMVA 15, 0, 8, 5, 1
+#define CP15_ITLBIASID 15, 0, 8, 5, 2
+#define CP15_DTLBIALL 15, 0, 8, 6, 0
+#define CP15_DTLBIMVA 15, 0, 8, 6, 1
+#define CP15_DTLBIASID 15, 0, 8, 6, 2
+#define CP15_TLBIALL 15, 0, 8, 7, 0
+#define CP15_TLBIMVA 15, 0, 8, 7, 1
+#define CP15_TLBIASID 15, 0, 8, 7, 2
+#define CP15_TLBIMVAA 15, 0, 8, 7, 3
+#define CP15_PMCR 15, 0, 9, 12, 0
+#define CP15_PMCNTENSET 15, 0, 9, 12, 1
+#define CP15_PMCNTENCLR 15, 0, 9, 12, 2
+#define CP15_PMOVSR 15, 0, 9, 12, 3
+#define CP15_PSWINC 15, 0, 9, 12, 4
+#define CP15_PMSELR 15, 0, 9, 12, 5
+#define CP15_PMCCNTR 15, 0, 9, 13, 0
+#define CP15_PMXEVTYPER 15, 0, 9, 13, 1
+#define CP15_PMXEVCNTR 15, 0, 9, 13, 2
+#define CP15_PMUSERENR 15, 0, 9, 14, 0
+#define CP15_PMINTENSET 15, 0, 9, 14, 1
+#define CP15_PMINTENCLR 15, 0, 9, 14, 2
+#define CP15_PRRR 15, 0, 10, 2, 0
+#define CP15_NMRR 15, 0, 10, 2, 1
+#define CP15_VBAR 15, 0, 12, 0, 0
+#define CP15_MVBAR 15, 0, 12, 0, 1
+#define CP15_ISR 15, 0, 12, 1, 0
+#define CP15_CONTEXTIDR 15, 0, 13, 0, 1
+#define CP15_TPIDRURW 15, 0, 13, 0, 2
+#define CP15_TPIDRURO 15, 0, 13, 0, 3
+#define CP15_TPIDRPRW 15, 0, 13, 0, 4
+#define CP15_CCSIDR 15, 1, 0, 0, 0
+#define CP15_CLIDR 15, 1, 0, 0, 1
+#define CP15_AIDR 15, 1, 0, 0, 7
+#define CP15_CSSELR 15, 2, 0, 0, 0
+#define CP14_DBGDIDR 14, 0, 0, 0, 0
+#define CP14_DBGWFAR 14, 0, 0, 6, 0
+#define CP14_DBGVCR 14, 0, 0, 7, 0
+#define CP14_DBGECR 14, 0, 0, 9, 0
+#define CP14_DBGDSCCR 14, 0, 0, 10, 0
+#define CP14_DBGDSMCR 14, 0, 0, 11, 0
+#define CP14_DBGDTRRX 14, 0, 0, 0, 2
+#define CP14_DBGPCSR 14, 0, 0, 1, 2
+#define CP14_DBGITR 14, 0, 0, 1, 2
+#define CP14_DBGDSCR 14, 0, 0, 2, 2
+#define CP14_DBGDTRTX 14, 0, 0, 3, 2
+#define CP14_DBGDRCR 14, 0, 0, 4, 2
+#define CP14_DBGCIDSR 14, 0, 0, 9, 2
+#define CP14_DBGBVR0 14, 0, 0, 0, 4
+#define CP14_DBGBVR1 14, 0, 0, 1, 4
+#define CP14_DBGBVR2 14, 0, 0, 2, 4
+#define CP14_DBGBVR3 14, 0, 0, 3, 4
+#define CP14_DBGBVR4 14, 0, 0, 4, 4
+#define CP14_DBGBVR5 14, 0, 0, 5, 4
+#define CP14_DBGBVR6 14, 0, 0, 6, 4
+#define CP14_DBGBVR7 14, 0, 0, 7, 4
+#define CP14_DBGBCR0 14, 0, 0, 0, 5
+#define CP14_DBGBCR1 14, 0, 0, 1, 5
+#define CP14_DBGBCR2 14, 0, 0, 2, 5
+#define CP14_DBGBCR3 14, 0, 0, 3, 5
+#define CP14_DBGBCR4 14, 0, 0, 4, 5
+#define CP14_DBGBCR5 14, 0, 0, 5, 5
+#define CP14_DBGBCR6 14, 0, 0, 6, 5
+#define CP14_DBGBCR7 14, 0, 0, 7, 5
+#define CP14_DBGWVR0 14, 0, 0, 0, 6
+#define CP14_DBGWVR1 14, 0, 0, 1, 6
+#define CP14_DBGWVR2 14, 0, 0, 2, 6
+#define CP14_DBGWVR3 14, 0, 0, 3, 6
+#define CP14_DBGWCR0 14, 0, 0, 0, 7
+#define CP14_DBGWCR1 14, 0, 0, 1, 7
+#define CP14_DBGWCR2 14, 0, 0, 2, 7
+#define CP14_DBGWCR3 14, 0, 0, 3, 7
+#define CPVFP_FPSID 10, 7, 0, 0, 0
+#define CPVFP_FPSCR 10, 7, 1, 0, 0
+#define CPVFP_MVFR1 10, 7, 6, 0, 0
+#define CPVFP_MVFR0 10, 7, 7, 0, 0
+#define CPVFP_FPEXC 10, 7, 8, 0, 0
+#define CP15_TTBRx_PD_MASK 0xffffc000
+
//
// CPSR Values
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] Sat May 16 11:30:28 2015
@@ -2341,24 +2341,78 @@
NTSTATUS
NTAPI
-NtFlushInstructionCache(IN HANDLE ProcessHandle,
- IN PVOID BaseAddress,
- IN ULONG NumberOfBytesToFlush)
-{
+NtFlushInstructionCache(
+ _In_ HANDLE ProcessHandle,
+ _In_opt_ PVOID BaseAddress,
+ _In_ ULONG FlushSize)
+{
+ KAPC_STATE ApcState;
+ PKPROCESS Process;
+ NTSTATUS Status;
PAGED_CODE();
+ /* Is a base address given? */
+ if (BaseAddress != NULL)
+ {
+ /* If the requested size is 0, there is nothing to do */
+ if (FlushSize == 0)
+ {
+ return STATUS_SUCCESS;
+ }
+
+ /* Is this a user mode call? */
+ if (KeGetPreviousMode() != KernelMode)
+ {
+ /* Make sure the base address is in user space */
+ if (BaseAddress > MmHighestUserAddress)
+ {
+ DPRINT1("Invalid BaseAddress 0x%p\n", BaseAddress);
+ return STATUS_ACCESS_VIOLATION;
+ }
+ }
+ }
+
+ /* Is another process requested? */
+ if (ProcessHandle != NtCurrentProcess())
+ {
+ /* Reference the process */
+ Status = ObReferenceObjectByHandle(ProcessHandle,
+ PROCESS_VM_WRITE,
+ PsProcessType,
+ KeGetPreviousMode(),
+ (PVOID*)&Process,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to reference the process %p\n", ProcessHandle);
+ return Status;
+ }
+
+ /* Attach to the process */
+ KeStackAttachProcess(Process, &ApcState);
+ }
+
+ /* FIXME: don't flush everything if a range is requested */
#if defined(_M_IX86) || defined(_M_AMD64)
__wbinvd();
#elif defined(_M_PPC)
__asm__ __volatile__("tlbsync");
#elif defined(_M_MIPS)
DPRINT1("NtFlushInstructionCache() is not implemented\n");
- for (;;);
+ DbgBreakPoint();
#elif defined(_M_ARM)
- //__asm__ __volatile__("mov r1, #0; mcr p15, 0, r1, c7, c5, 0");
+ _MoveToCoprocessor(0, CP15_ICIALLU);
#else
#error Unknown architecture
#endif
+
+ /* Check if we attached */
+ if (ProcessHandle != NtCurrentProcess())
+ {
+ /* Detach from the process */
+ KeUnstackDetachProcess(&ApcState);
+ }
+
return STATUS_SUCCESS;
}