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
- 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
- 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
- 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
- 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
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
"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
- 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
- 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
- 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
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
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
- Add missing prototypes to NDK
- Implement RtlInterlockedCompareExchange64 and RtlGetCurrentProcessorNumber
- Rename RtlpCurrentPeb to RtlGetCurrentPeb and export it from NTDLL
svn path=/trunk/; revision=36166
- comment out RtlCapturestackLimits
- use KeGetCurrentPrcb instead if KetGetPcr()->Prcb
- fix use of KPCR->Prcb
- use %p instead of %08x for ULONG_PTR
- update stubs
- add more files to build
- add FrLdrDbgPrint prototype to ntoskrnl.h
svn path=/branches/ros-amd64-bringup/; revision=34971
- Fix incorrect definition of ARM_CONTROL_REGISTER, which was stopping us from correctly enabling High Vectors.
- The RtlCaptureStackLimits and RtlWakeChainFrame routines in libsupp.c cannot possibly be portable across all architectures -- separated ARM versions in an arm directory.
- Setup the panic stack for abort/undefined exceptions, and the interrupt stack for FIQs.
- Implement support for exceptions! We can now display the address which caused a data abort, and begin handling exceptions.
- Implement all the HAL Spinlock/IRQL functions except KfRaise/LowerIrql which actually do the work.
- We're booting all the way to setting up the user_shared_data memory area.
svn path=/trunk/; revision=32653
We now define _disable and _enable for ARM.
We shouldn't define KeRaiseIrqlToSynchLevel for each architecture, since the prototype is portable itself.
It was a mistake to guard against x86 only system calls -- the system calls should be the same on all archs, just return STATUS_NOT_IMPLEMENTED if they don't make sense. Undo the guards.
We now define KeGetPcr() as portable -- it's PCR itself that is a per-arch define.
We now support ARM in RtlWalkFrameChain.
We now support ARM in PspCreateThread.
We now define KeArchHaltProcessor for ARM by using Wait-For-Interrupt Mode.
We now define KeArmInitThreadWithContext for ARM.
KiRestore/SaveProcessorControlState are portable prototypes, we now define them as such.
Bochs KD code should use the portable WRITE/READ_PORT_UCHAR defines, we now do so.
We now support ARM in SharedUserData->ImageNumberLow/High during ExpInitializeExecutive.
NtQuerySytemInformation for SystemProcessorInformation has now been fixed to use the portable KeProcesssorXxx variables instead of reading from the non-portable PRCB values.
We now support NtFlushInstructionCache for ARM by flushing the I-Cache.
svn path=/trunk/; revision=32197
- Remove ARC tree dump since this code has now been proven to work.
- Sync PointerFree with WINE, removing the unhandled data type=warning.
svn path=/trunk/; revision=31172
are indeed still stubs or WIP code.
Some people have been interested in helping out from some time and I'm sorry
I haven't been able to do this merge finally for a while.
svn path=/trunk/; revision=29407
- KeRosDumpStackFrames is fixed so that if the EIP can't be found in a module list, it's still displayed (just without the module name). Previously the EIP would not be shown, resulting in code running on the heap/stack/somewhere else not being shown as part of the trace.
svn path=/trunk/; revision=29332
- Fix bugs in RtlUnwind and RtlExceptionDispatch which assumed the DPC stack size was 4KB instead of 12KB.
- Fix multiple bugs in RtlpGetStackLimits and seure it against bugchecks. Properly detect DPC or invalid stacks.
- PsConvertToGuiThread should acquire a guarded region, not a critical section, to stop all APCs.
- Fix bug in bugzilla reporting which was making things crash.
- Unlock address space before raising to HIGH_LEVEL in KeBugCheck.
- Display blue screen at APC_LEVEL, to avoid the assertion in procobj.c when trying to attach to csrss. This should fix the recursive bugchecking when the GUI is up, and also take down the GUI properly. The fix is a hack.
- Fix bogus implementation of IoGetStackLimits and make it work properly.
- Make MmCreateKernelStack return the base of the stack, not the limit, and fix all callers appropriately.
- Remove svn:needs-lock properties of various files, whose contents either changes too often or whose contents is definately clean.
Bugreports and information - by Alex.
svn path=/trunk/; revision=29244
- We now print out error messages at each SESSIONX_INITIALIZATION_FAILURE directly on the screen.
- Build CmNtCSDVersion to include SP1 and our SVN Revision number.
- Build CmNtSpBuildNumber with the actual SP1 build number.
- Detect Headless Terminal usage.
- Build and create the CmVersionString.
- Display a startup banner similar to Windows based on the CmVersionString, also indicating the SVN revision.
- Fix some bugs in the timezone code.
- Display a second startup banner like Windows's, displaying memory and CPU counts.
- Add calls to initialize RANGE_LISTs, the Prefetecher, XIP Support and Phase 2 Executive Initialization.
- Parse the command line to detect /SAFEBOOT: switch and which type of safe mode boot this is.
- Display an optional third startup banner showing which safemode boot type this is.
- Detect /BOOTLOG switch and display a fourth startup banner if it's enabled, but don't initialize boot logging yet.
- Don't allow driver loading to push the progress bar beyond 75%.
- Write safe-boot type to registry, detect AlternateShell mode and validate that one is configured.
- Write MININT key to registry if booting in WinPE (LiveCD) mode.
- Don't leak smss environment and parameters anymore.
- Cleanup and reformat some code, use VER_ constants instead of magic numbers.
svn path=/trunk/; revision=26659
- Remove manual overrides of NTDDI_VERSION all over the thread and set it once globally, since ExHandle* was the only non-updated package. The entire kernel now builds with Windows 2003 SP1 as a target.
- Remove this entry from kernel fun.
svn path=/trunk/; revision=25586
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
- Delete rtl/nls.c and all the associated deprecated code.
- Do MmInit1 and SharedUserData stuff *after* initializing the initial thread, to avoid an ASSERT during bootup.
svn path=/trunk/; revision=24408