Commit graph

367 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 26b7393e00 [NTDLL][HAL][INFLIB][RTL][NTOS] VOIDify function paramater lists when they indeed don't take any arguments.
svn path=/trunk/; revision=68971
2015-09-03 23:57:39 +00:00
Stefan Ginsberg e4007ae73a - Implement super-simple KeSweepICache that always flushes the entire instruction cache. Use it in KD64 after modifying memory to make sure CPU gets the correct code to execute, and in NtFlushInstructionCache. May improve breakpoints somewhat.
- Move NtFlushInstructionCache from sysinfo.c to virtual.c where it fits better. Likewise, move it from kefuncs to mmfuncs in NDK, and fix function arguments (ULONG -> SIZE_T).
- Re-enable TRAP_DEBUG, adding back critical checks in the trap code. Checks can be improved but it is better than potentially silently messing up system state.
- Move remaining RtlPrefetchMemoryNonTemporal code into kernel. Stubbed for non-x86.
- By Hermes suggestion, override ASSERT to NT_ASSERT only for MSVC builds as that is where the main benefit is.

svn path=/trunk/; revision=68907
2015-09-01 23:45:48 +00:00
Stefan Ginsberg eebbf23330 - Move misplaced RtlPrefetchMemoryNonTemporal from rtl into kernel where it belongs (it only exists as an export for use by drivers to safely try to use prefetchnta even if it may not be available). Use existing global KePrefetchNTAGranularity that is set to the correct value via cpuid instead of hardcoded "Ke386CacheAlignment".
svn path=/trunk/; revision=68903
2015-09-01 19:51:52 +00:00
Timo Kreuzer adc234ba9c [NTOSKRNL]
Fix ARM build

svn path=/trunk/; revision=67735
2015-05-14 22:31:58 +00:00
Thomas Faber 9a56808986 [NTOSKRNL]
- More pool tagging!

svn path=/trunk/; revision=66948
2015-03-29 06:04:19 +00:00
Thomas Faber 33e318ed91 [RTL]
- Implement RtlTryEnterHeapLock and use it to fix RtlpDphEnterCriticalSection

svn path=/trunk/; revision=64970
2014-10-24 19:05:54 +00:00
Thomas Faber 1da67b8fcd [RTL]
- Apply Wine commit 5b0fcb06 (ntdll: Avoid crashing on an empty resource directory.) by Alexandre Julliard

svn path=/trunk/; revision=63630
2014-06-22 18:44:21 +00:00
Timo Kreuzer 6f0131873e [NTOSKRNL]
Implement RtlpCloseHandleCallback, closing the handle table, and use it as callback for ExSweepHandleTable in RtlpDestroyAtomHandleTable. Without a callback ExSweepHandleTable simply crashes, so obviously we never clean up any atom tables, possibly because the window station is never closed.

svn path=/trunk/; revision=61039
2013-11-18 15:21:53 +00:00
Kamil Hornicek 4e23142740 [NTOSKRNL][KERNEL32]
Fix a few more cases of missing _SEH2_YIELD.

svn path=/trunk/; revision=60061
2013-09-12 10:06:34 +00:00
Amine Khaldi a1bafaeaaf [NTOSKRNL]
* Fix several print specifiers.
* Add some missing variables to debug prints.

svn path=/trunk/; revision=59923
2013-08-31 16:02:13 +00:00
Alex Ionescu 4ca622a65d [RTL]: Correctly read PEB or Kernel Variables for Heap Tuning.
[NTOSKRNL]: MmCreatePeb should correctly fill out the Heap PEB parameters.
[NTOSKRNL]: MmInitSystem and mminit.c should correctly initialize and hold the Heap Tuning Parameters.
[NTOSKRNL]: CmControlVector should read the registry Heap Tuning Parameters into the real Mm variables, instaed of "Dummy".
This removes heap hacks and makes Windows NTDLL happy.

svn path=/trunk/; revision=59857
2013-08-28 18:57:29 +00:00
Alex Ionescu 1f8570be62 [NTOSKRNL]: RtlGetVersion in the kernel does not fail, does not return a CSD version, and should not be returning negative build numbers. Fix it so that it works as it should (and anyone that relied on correct build numbers will no longer fail).
svn path=/trunk/; revision=59717
2013-08-13 03:14:22 +00:00
Timo Kreuzer 69bc32e0f6 [RTL/NTOSKRNL]
- Seperate some usermode only heap functions into their own file and implement dummys in the kernel rtl so that they don't get included in the kernel
- Convert usage of RTL_CRITICAL_SECTION in heappage.c to use of HEAP_LOCK
- Implement A kernel dummy for RtlCallVectoredExceptionHandlers, so we don't put vectored exception handler code into ntoskrnl
- Now we don't have critical section code in the kernel anymore, which wasn't working anyway.

svn path=/trunk/; revision=58173
2013-01-14 09:35:50 +00:00
Hermès Bélusca-Maïto 8ba1ca638e [KERNEL32/NTDLL]
- Move the ReactOS-specific workaround described in http://jira.reactos.org/browse/CORE-6611 and http://jira.reactos.org/browse/CORE-4620
  from kernel32 to ntdll for using it by RtlGetVersion, in order to :
  * still having it available in user-mode only,
  * and having VerifyVersionInfo (and its Rtl counter-part) working properly.

[RTL/NTOSKRNL]
- Code formatting.
- Use a defined-constant instead of a hard-coded value.

svn path=/trunk/; revision=57662
2012-11-01 12:52:34 +00:00
Thomas Faber 69232d954d [NTOSKRNL][NTDLL][RTL][KERNEL32]
- Code simplification and clarification for version-reporting functionality. Patch by Hermès Bélusca (1/X)
CORE-6611

svn path=/trunk/; revision=57354
2012-09-20 19:53:14 +00:00
Timo Kreuzer ad26240c79 [RTL]
Implement RtlpSafeCopyMemory, which uses SEH to copy the memory (not in freeldr)
Make RtlLargeIntegerToChar use RtlpSafeCopyMemory to copy the string to the target buffer.
CORE-3767 #resolve

svn path=/trunk/; revision=57295
2012-09-14 09:56:23 +00:00
Roel Messiant 2e6e9dd622 [NTOSKRNL]
- Keep APC delivery disabled while holding a Heap Lock, not just while acquiring/releasing it (Dedicated to Timo and Ged).
- Store the Heap Lock in non-paged pool, the only place where executive resources belong (Dedicated to patient people).
[RTL]
- Restructure/simplify/correct Heap and Heap Segment initialization (partially to cope with the changed Heap Lock interface).
- Restrict the location of Heap Segment headers to the base address of the Heap Segment (which frees up a whopping 60 bytes per Heap!).
- Cater for acquiring the Heap Lock exclusively or shared (the latter is only available in kernel-mode); only exclusive locking is used for now.
- Use a plain critical section to guard the Process Heap list, no reason to disguise it as a Heap Lock (saves us a handful more bytes).


svn path=/trunk/; revision=53761
2011-09-19 16:52:37 +00:00
Roel Messiant 1a7296bb39 [NTOSKRNL]
Disable normal APC delivery while acquiring/releasing a heap lock. Also, BOOLEAN != NTSTATUS.


svn path=/trunk/; revision=53729
2011-09-17 20:26:31 +00:00
Timo Kreuzer 1d70b8136a [ASM]
Merge asm related changes from cmake branch.

svn path=/trunk/; revision=49826
2010-11-27 22:12:15 +00:00
Aleksey Bragin faa70e3d70 [HEAP]
- Move on to using a real HEAP_LOCK structure for a heap lock.
- Implement kernel-mode counterparts of this lock too. Right now these don't introduce much of a difference, but they are going to be properly used by the new heap manager code.

svn path=/trunk/; revision=48994
2010-10-05 12:42:55 +00:00
Timo Kreuzer 19540dcad5 [NTOSKRNL]
- Add KiGetLinkedTrapFrame for amd64
- Add MiAddressToPti
- Fix MmCreateProcessAddressSpace, MmInitializeHandBuiltProcess prototype (ULONG -> ULONG_PTR)
- #if out some C_ASSERTs for other architectures than x86
- #define InitializeSListHead to RtlInitializeSListHead on amd64
- Don't implement MiSyncARM3WithROS on amd64
- Implement RtlPcToFileHeader, RtlpGetStackLimits

svn path=/trunk/; revision=48219
2010-07-23 23:30:00 +00:00
Timo Kreuzer 677bd3c418 [NTOSKRNL]
- #if out RtlpCaptureStackLimits on amd64 as well

svn path=/trunk/; revision=48087
2010-07-16 17:53:00 +00:00
Timo Kreuzer 8dc269c258 [NTOSKRNL]
- Fix RtlWalkFrameChain to do usermode back traces for threads that are not system threads. Also use _SEH2_YIELD when leaving the SEH block.

svn path=/trunk/; revision=47066
2010-04-30 22:47:44 +00:00
Timo Kreuzer fb69e522da Merge from amd64-branch:
44501 (tkreuzer)
[NDK]
- Add CLIENT_ID32/64
- Create explicit 32/64 bit versions of PEB, GDI_TEB_BATCH and TEB, using macros.
- Fix some member names.


44503 (tkreuzer)
[CMD]
Fix a teb member name

44504 (tkreuzer)
[NTSOKRNL]
Fix a teb member name

44506 (tkreuzer)
[NDK]
fix a typo in the TEB definition

44511 (tkreuzer)
[NDK]
- Add Wx86ThreadState
- Add WinXP version of ACTIVATION_CONTEXT_STACK
- rtltypes doesn't depend on pstypes, but the opposite way around now

44512 (tkreuzer)
[NDK]
Fix some dependencies

44521 (tkreuzer)
[NTDKK]
- Don't use PEB::FastPeb(Un)LockRoutine, these members are deprecated since Windows 2003, use RtlEnter/LeaveCriticalSection instead.

44523 (tkreuzer)
[NTDLL]
Fix usage of PEB::KernelCallbacktable. It's a PVOID.

44524 (tkreuzer)
NDK]
- Add missing TEB member for Vista

44525 (tkreuzer)
[NDK]
Fix a TEB array size.

44526 (tkreuzer)
[USER32]
More fix of TEB::KernelCallbackTable usage

svn path=/trunk/; revision=46434
2010-03-25 12:22:59 +00:00
Timo Kreuzer 32014b63b8 [NTOSKRNL]
"Fix things": Add architecture specific macros KeGetTrapFrame, KeGetExceptionFrame and KeGetContextSwitches. Should fix kernel build on arm. Patch by Alex, modified by me.

svn path=/trunk/; revision=44640
2009-12-17 20:58:58 +00:00
Timo Kreuzer c5a2bbe739 [NDK]
- Add CLIENT_ID32/64
- Create explicit 32/64 bit versions of PEB, GDI_TEB_BATCH and TEB, using macros. Thanks to Alex for feedback and suggestions.
- Fix some member names.
- Note to self: fix rostests, too!

svn path=/branches/ros-amd64-bringup/; revision=44501
2009-12-10 00:35:12 +00:00
Timo Kreuzer 843b9ee1eb Merge trunk HEAD (r44067)
svn path=/branches/ros-amd64-bringup/; revision=44069
2009-11-10 02:40:48 +00:00
Timo Kreuzer 4896a4fbb2 use RtlPcToFileHeader instead of RtlpLookupModuleBase
svn path=/branches/ros-amd64-bringup/; revision=43980
2009-11-05 20:57:53 +00:00
Stefan Ginsberg f84d5a02f4 - Fix support for /CRASHDEBUG and /NODEBUG; we didn't respect those settings properly and would initialize KD at boot even if they were set.
- Re-enable the breakpoint in vDbgPrintExWithPrefixInternal() as this works properly now. Without this breakpoint some break-in requests got lost if the break-in occurred when handling a debug print (happened a lot at boot).
- Implement Command String support for DbgCommandString() -- we now handle every debug service call.
- Implement NtSetDebugFilterState() and NtQueryDebugFilterState() for KD, meaning we now support debug filters properly.
- Implement KdRefreshDebuggerNotPresent(), KdChangeOption() and KdPowerTransition(). Stub KdSystemDebugControl() to return error status instead of hanging the system.
- Stub the rest of the KD API to print a warning and return a failure packet instead of hanging.
- Set and respect KdpContextSent when getting and setting the thread context -- WinDbg doesn't seem to rely on this, but better safe than sorry.
- Support MP when getting and setting the thread context too -- if the context is operation is for another processor than the current, just get it through the KiProcessorBlock array.
- Initialize the MajorVersion in the KD version block more properly -- the high byte is the major identifier (0 for NT). Add the required DBGKD_MAJOR_TYPES enumeration to wdbgexts.h.
- Simplify setting and clearing the InDbgPrint flag in the TEB to minimize the impact on kernel execution; use 2 dedicated routines instead of a generic one.
- KdpSymbol doesn't return anything, so don't return an ignore status from KdpReportLoadSymbolsStateChange.
- Expose the KdpDefaultRetries and Kd_WIN2000_Mask variables to the registry and add them to KDBG too (unused there).
- No reason to implement KdpSysGetVersion per architecture; move it back to the generic code.
- Add some ARM offsets to the debugger data block that (N/A on other architectures).
- Fix the default size of the DbgPrint log buffer for free builds to save some space. It should be 4 KB for a free build and 32 KB for a checked build.
- Move KeDisableInterrupts to cpu.c as it fits here more than in the IRQ support code in irqobj.c.
- Use KeDisableInterrupts in KeFreezeExecution instead of checking the x86 EFLAG directly.

svn path=/trunk/; revision=43912
2009-11-02 17:45:51 +00:00
Timo Kreuzer cc5c0a0816 Merge trunk head (r43756)
svn path=/branches/ros-amd64-bringup/; revision=43759
2009-10-25 22:13:11 +00:00
Stefan Ginsberg 10bbe664b7 - Replace RtlpGetExceptionAddress by the _ReturnAddress intrinsic and add it to ARM intrin.h as it was missing.
- Simplify RtlpCheckForActiveDebugger: Remove the BOOLEAN parameter as we would always pass it FALSE. Always return FALSE false from kernel mode for simplicity.
- Fix a critical flaw in our exception support: RtlRaiseException and RtlRaiseStatus were implemented in C on x86. This lead to unpredictable register corruption because the compiler could not know that it had to preserve non-volatile registers before calling RtlCaptureContext as the saved context is later used to restore the caller in case the exception is handled and execution is continued. This made the functions unsafe to return from as any non-volatile register could be corrupted. Implement them in assembly for x86 to safely capture the context using only EBP and ESP. The C versions of those routines are still used and shared for the other architectures we support -- needs to be determined if this is safe and correct for those architectures.
- The ntdll exception Wine exposed this issue, and all tests now pass. The remaining failures on the build server are caused by missing or incomplete debug register support in KVM/QEMU. Run the test in another VM or on real hardware and all the tests will pass.
- Implement Debug Prompt (DbgPrompt) support for KD and KDBG. The KDBG implementation reads the prompt from keyboard or serial depending on the mode so that sysreg and rosdbg can support it too.
- Properly implement RtlAssert using DbgPrompt to prompt for the action to take instead of always doing a breakpoint. The new implementation is disabled until sysreg can support this. Also move RtlAssert to its own file as it has nothing to do with the error routines (nor does it belong in exception.c).
- Note that DbgPrompt was already used in PspCatchCriticalBreak, and this would have resulted in a silent hang as BREAKPOINT_PROMPT wasn't handled at all by KDBG.
- Implement KiRaiseAssertion (10 lines of code with the trap macros) and thus support NT_ASSERT. Add partial support for it to KDBG to print out a warning and the address of the failure, but don't do anything else. Also add NT_ASSERT to the DDK headers so that we can use it, but don't use it yet as the ARM method of performing this has not been decided nor implemented.
- KiTrap3 doesn't set STATUS_SUCCESS but BREAKPOINT_BREAK. They have the same numerical value but very different meaning -- BREAKPOINT_BREAK means that the exception is a software breakpoint and not a debug service call. Fix some comments to document that this is what is checked for.
- Fix inverted and broken logic in KdpReport. It would never pass second chance exceptions to the debugger, didn't respect the stop-on-exception flag properly and would always fail to handle some special exceptions in both first and second chance instead of just failing to handle it in first chance. Clean up, reformat and document what is going on.
- The DebugPrint and DebugPrompt support routines only perform a 2D interrupt on x86; use more portable comments.
- Add Alex to the programmer section of x86's kdsup.c -- he wrote KdpGetStateChange, KdpSetContextState and the code that was previously in KdpRead/WriteControlSpace.
- Add my name to the parts of KD where I have made significant work on getting KD/WinDbg support up and running.
- KD debugging is now quite functional and stable. Some bugs and stubs remain to be flushed out, but overall KD is now much better and easier to use than KDBG.

svn path=/trunk/; revision=43705
2009-10-23 22:51:39 +00:00
Timo Kreuzer cb662b3fc9 Sync to trunk HEAD (r43416)
svn path=/branches/ros-amd64-bringup/; revision=43422
2009-10-12 22:00:47 +00:00
Stefan Ginsberg 3c5b2d9a61 Mega KD64 revival patch:
KD64
- Fix some 64-bit issues and some x86 specificness.
- Sub out some KdpTrap cases more properly.
- Implement support for .crash and .reboot. Does not seem to work currently because of weird issues.
- Implement KdpDprintf to send strings directly to the debugger from inside of KD64. Use it in KdEnterDebugger instead of DbgPrint so we won't try to enter the debugger recursively.
- Implement KdUpdateDataBlock to set the KeUserCallbackDispatcher pointer in the debugger block after its address is retrieved from ntdll.
- Don't assume breakpoints are 1 byte long in portable code -- use KD_BREAKPOINT_SIZE and define it per architecture.
- KdpStub: KdEnableDebugger returns NTSTATUS, not TRUE/FALSE.

Other
- wdbgexts.h: Properly define CURRENT_KD_SECONDARY_VERSION for AMD64.
- Make PsNtosImageBase pointer-sized as it should be.
- Change the definition of KDSTATUS so it is guaranteed to be 32-bit.
- Fix a critical bug in KiRestoreProcessorControlState: it didn't clear the busy flag in the TSS before reloading the task register, resulting in a GPF if we tried to reload the same register.
- Add macros for getting and setting special purpose registers (the Program Counter and the "return register") in portable code instead of using #ifdef every time. Do likewise for setting IMAGE_FILE_MACHINE_XXX, using a new IMAGE_FILE_MACHINE_ARCHITECTURE macro.
- Don't refer to the Program Counter as "Eip" in portable code.
- Define DBG_STATUS_CONTROL_C for assembly code and use it in KeUpdateSystemTime.

svn path=/trunk/; revision=43283
2009-10-04 16:53:15 +00:00
Timo Kreuzer f9c2afd00a Sync with trunk r43000
svn path=/branches/ros-amd64-bringup/; revision=43079
2009-09-19 13:58:16 +00:00
Stefan Ginsberg beba1269e6 - Get rid of TAG() from the kernel
- mmtypes.h: Goodbye TAG(), you won't be missed

svn path=/trunk/; revision=42920
2009-08-24 18:19:53 +00:00
Aleksey Bragin 9e804e5230 - Rewrite RtlpCreateAtomHandle to readable code and fix a problem spotted in bug 4788.
svn path=/trunk/; revision=42635
2009-08-12 11:42:34 +00:00
Timo Kreuzer 4135e99ab6 Merge trunk head (r41474)
svn path=/branches/ros-amd64-bringup/; revision=41488
2009-06-20 13:45:51 +00:00
Stefan Ginsberg 88e9b2a513 - In Win32 DBG is defined to 0 for a non-debug build and to 1 for a debug build. In ReactOS we do this slightly different: DBG is correctly defined to 1 for debug, but not defined at all on non-debug/release build. Because gcc is awesome we can then check for debug compilation with both #ifdef DBG and #if DBG (error free! yay gcc!), and so we have mixed usage all over the tree.
- Fix this by defining DBG on non-debug build too and deprecate all usage of #ifdef DBG.

svn path=/trunk/; revision=41436
2009-06-17 12:44:05 +00:00
Timo Kreuzer 26b6703525 sync trunk head (r37928)
svn path=/branches/ros-amd64-bringup/; revision=37931
2008-12-08 08:30:30 +00:00
Dmitry Gorbachev 32580ec32a Silence GCC warnings.
svn path=/trunk/; revision=37919
2008-12-07 21:52:22 +00:00
Timo Kreuzer d00a945f03 sync to trunk head (37853) (except rbuild changes)
This breaks everything. Sorry, but it has to be done.
Will fix ASAP.

svn path=/branches/ros-amd64-bringup/; revision=37867
2008-12-05 15:30:17 +00:00
Stefan Ginsberg 165bfe865b - STDCALL -> NTAPI
svn path=/trunk/; revision=37745
2008-11-29 20:47:48 +00:00
Aleksey Bragin e9b31b7fdf - Fix weird code in RtlGetVersion (inspired by Coverity ID 1355 and Daniel's patch in bug 3906).
See issue #3906 for more details.

svn path=/trunk/; revision=37638
2008-11-25 16:31:07 +00:00
KJK::Hyperion c086cc2302 Everything
Migrate ntoskrnl to PSEH 2.0. The code should speak for itself

modified   ntoskrnl/ex/atom.c
   _SEH_LEAVE was used improperly in NtQueryInformationAtom. As a free bonus, the upgrade to PSEH 2.0 (and to _SEH2_LEAVE) fixes the potential bug

modified   ntoskrnl/fsrtl/fastio.c
   Corrected exception filter logic

modified   ntoskrnl/include/internal/ex.h
   Goodbye _SEH_ExSystemExceptionFilter, you won't be missed

modified   ntoskrnl/include/internal/ntoskrnl.h
   Don't FORCEINLINE functions that use SEH, it's bad form and the compiler doesn't like

modified   ntoskrnl/ke/i386/usercall.c
   Dispatch the correct EXCEPTION_RECORD in case of exception inside KiInitializeUserApc

modified   ntoskrnl/ke/powerpc/exp.c
   Removed bogus, unused SEH code

modified   ntoskrnl/ntoskrnl-generic.rbuild
   Sources using PSEH 2.0 must be compiled with -fno-unit-at-a-time due to a GCC bug. See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17982 and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38054
   Apparently, -fno-unit-at-a-time makes GCC crash when using precompiled headers. Disable precompiled headers for ntoskrnl

svn path=/trunk/; revision=37615
2008-11-24 13:40:26 +00:00
Timo Kreuzer 9726adc85e "[00:08] Stefan100: 5) Alex_Ionescu will have your head"
Well, no risk, no fun... ;-)
Implement RtlpGetStackLimits

svn path=/branches/ros-amd64-bringup/; revision=37426
2008-11-18 00:31:22 +00:00
Timo Kreuzer f3668beb0c Implement RtlLookupFunctionTable, RtlLookupFunctionEntry and a usermode/kernelmode version of RtlpLookupModuleBase helper function.
svn path=/branches/ros-amd64-bringup/; revision=37308
2008-11-12 15:24:40 +00:00
Timo Kreuzer 3552ed757c sync to trunk revision 36500
svn path=/branches/ros-amd64-bringup/; revision=36846
2008-10-20 15:46:20 +00:00
Stefan Ginsberg 420195308d - Uncomment NTDLL exports which we implement, and add stubs for numerous routines
- Add missing prototypes to NDK
- Implement RtlInterlockedCompareExchange64 and RtlGetCurrentProcessorNumber
- Rename RtlpCurrentPeb to RtlGetCurrentPeb and export it from NTDLL

svn path=/trunk/; revision=36166
2008-09-12 15:09:17 +00:00
Timo Kreuzer 53181b207f sync to trunk head (35945)
svn path=/branches/ros-amd64-bringup/; revision=35954
2008-09-05 00:03:53 +00:00
Hervé Poussineau d2ba8bac96 Replace some ExFreePool by ExFreePoolWithTag
svn path=/trunk/; revision=35834
2008-08-31 15:29:21 +00:00