Commit graph

1979 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 31322f5df9
[CONUTILS:PAGER][MORE] Implement text line caching + fix some bugs.
- Implement caching of individual (newline-separated) text lines; this
  behaviour can be enabled with a flag (enabled by MORE):
  CON_PAGER_CACHE_INCOMPLETE_LINE.
  This feature is necessary when reading a text file, whose text lines
  may span across two or more successive temporary read buffers, and is
  required for correctly determining whether the lines being read are
  blank and may be squeezed.

- When squeezing blank lines, the blank-line check must be done for each
  line segment corresponding to the screen line (and following) that
  need to be displayed. This matches the behaviour of MS MORE.COM.

- Fix the IsBlankLine() check to not consider FORM-FEEDs as being blank
  characters: This is necessary for correctly handling FORM-FEED
  expansion. Also note that MS MORE.COM only checks for spaces and TABs,
  so we are slightly overdoing these checks (considering other types of
  whitespace).

- Get rid of ConCallPagerLine() and the intermediate CON_PAGER_DONT_OUTPUT
  state flag that were used repeatedly for each and every small line
  chunks. Instead, call directly the user-specified 'PagerLine' callback
  when we are about to start treating the next line segment to be
  displayed (see comment above).

- Fix the exit return condition of ConPagerWorker(): it should return
  TRUE whenever we displayed all the required lines, and FALSE otherwise.
  Otherwise, the previous (buggy) condition on the data being read from
  the text file, may lead to the prompt not showing when a screenful of
  text has been displayed, if it happened that the current text buffer
  becomes empty at the same time (even if, overall, the text file hasn't
  been fully displayed).

- In MorePagerLine(), when we encounter for the first time a blank line
  that will be squeezed with other successive ones, display a single
  blank line. But for that, just display one space and a newline: this
  single space is especially needed in order to force line wrapping when
  the ENABLE_VIRTUAL_TERMINAL_PROCESSING or DISABLE_NEWLINE_AUTO_RETURN
  console modes are enabled. Otherwise the cursor remains at the
  previous line (without wrapping), and just outputting one newline will
  not make it move past 2 lines as one would naively expect.
2021-06-28 21:26:32 +02:00
Hermès Bélusca-Maïto aff90f530c
[CONUTILS:PAGER] Extract the character-specific handling out of the character-loop.
This also allows to factor out the ConCallPagerLine() call for outputting the pending text.
2021-06-28 21:26:32 +02:00
Hermès Bélusca-Maïto ff445ca184
[CONUTILS:PAGER][MORE] Fix the default paging region.
- The column extent should cover the whole width of the console screenbuffer.
  On the contrary, the line extent covers only the number of lines that
  cover the current displayed console window.

- Since the console can be resized while the pager is prompting, we need
  to actually recalculate in the prompt routine the default number of
  lines for a screen.

- Reset s_nNextLineNo when paging a new file.
2021-06-28 21:26:31 +02:00
Hermès Bélusca-Maïto f74a3f6e29
[CONUTILS:PAGER][MORE] Code style/formatting.
- Shorten the names of the flags: CON_PAGER_FLAG_*** --> CON_PAGER_***.
- Reorder few members in the CON_PAGER pager structure where they make sense.
- ScreenColumns, ScreenRows --> PageColumns, PageRows: keeping the open
  possibility for having a pager controlling a region of different size
  than the screen.
- Add doxygen documentation for ConWritePaging().
2021-06-28 21:26:30 +02:00
Victor Perevertkin 1c7f3476a0
[CMAKE] Use BUILD_MP CMake option correctly 2021-06-28 17:54:09 +03:00
Jérôme Gardou ada609bdbc [PSDK] Alias _Check_return_ annotation to warn_unused_result attribute 2021-06-28 10:20:57 +02:00
Jérôme Gardou e10892e4f4 [CRT] Put __MINGW_EXTENSION (whatever that means) in front of function declarations
Needed for next commit
2021-06-28 10:20:57 +02:00
Jérôme Gardou d1f5c31820 [SDK] Add GCC overrides for SAL annotations
GCC has some functions, variables & type attributes which can be used as aliases
for some of the SAL annotations. Although it's not as rich & precise, it's still useful
since we actually enable -Werror on GCC builds whereas we don't use such an option
on MSVC builds.

For now, _Must_inspect_result_ is aliased to warn_result_unused attribute.
2021-06-28 10:20:57 +02:00
Jérôme Gardou a28a34f108 [NDK][XDK] Remove _Must_inspect_result_ from RtlTimeFieldsToTime & RtlTimeToSecondsSince1970
WDK doesn't have it and it causes more mess than anything.
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 28c5f7538a [DDK] Do not put _Must_inspect_result_ on function returning void & without _Out_ parameters 2021-06-28 10:20:57 +02:00
Jérôme Gardou e55eeb2d9c [WDF] Synchronize function attributes between declaration & definition
Addendum to 1f377076d7
2021-06-28 10:20:57 +02:00
Jérôme Gardou 46394ab80d [RTL] In RtlReleasePrivilege, raise exception if restoring old privileges fails
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou fb9ebe17bf [RTL] When taking system volume ownership, assert that we succeeded to restore privileges
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 9c5b39e25a [RTL] Check and cascade down RtlGUIDFromString value
CORE-17637
2021-06-28 10:20:57 +02:00
Timo Kreuzer 8a68820429 [SDK] Add missing sal annotations in driverspecs.h and kernelspec.h
CORE-6706
2021-06-28 08:48:59 +02:00
Hermès Bélusca-Maïto 8ec3580123 [SHELL32] Add the handy WHICH_DEFAULT value to the list of flags in shlwapi_undoc.h.
- Add as well the undocumented 0x40 dwFlags value from shlwapi!PathFileExistsDefExtW()
  to the list.

- Fix a bug (also present in Win2k3) in PathResolveW() where, specifying
  the PRF_DONTFINDLNK flag, would also erroneously exclude checking for
  the .cmd extension as well (which was obviously NOT the original
  intention, from the name of the flag and the documentation as well:
  https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-pathresolve
  ).

Addendum to 3a822e4f.
2021-06-28 02:19:30 +02:00
Katayama Hirofumi MZ 3a822e4f74
[SHELL32] Implement PathResolveW function (#3762)
- Implement PathResolveW function.
- Implement PathQualifyA/W functions using newly-defined PathQualifyExW function.
CORE-12665
2021-06-28 07:53:26 +09:00
Joachim Henze 81f8bcea8c [DSOUND][WAVE] Workaround crash when recording sound in Scratch 1.4 CORE-13202
It regressed by SVN r44721 == git 356d4bab16092de335705e02b0e87698ec35c393
when #define USE_MMIXER_LIB was removed.

Thanks to the patches author Doug Lyons.

VBox https://reactos.org/testman/compare.php?ids=77914,77919 LGTM
 KVM https://reactos.org/testman/compare.php?ids=77913,77918 LGTM
2021-06-27 23:04:36 +02:00
Hervé Poussineau 979b7d4d8e [TCPIP] Fix bugcheck when using fragmented datagrams
Memory was allocated from paged pool, and freed at DISPATCH_LEVEL,
leading to the following bugcheck:

*** Fatal System Error: 0x000000c2
                       (0x00000009,0x00000002,0x00000001,0xB7C8A268)

Entered debugger on embedded INT3 at 0x0008:0x8058324B.
kdb:> bt
Eip:
<ntoskrnl.exe:18324c (sdk/lib/rtl/i386/debug_asm.S:56 (RtlpBreakWithStatusInstruction))>
<ntoskrnl.exe:89b21 (ntoskrnl/ke/bug.c:1066 (KeBugCheckWithTf))>
<ntoskrnl.exe:8a08b (ntoskrnl/ke/bug.c:1413 (KeBugCheckEx))>
<ntoskrnl.exe:abb1d (ntoskrnl/mm/ARM3/expool.c:431 (ExFreePoolWithTag))>
<tcpip.sys:13e42 (sdk/lib/drivers/ip/network/receive.c:114 (FreeIPDR))>
<tcpip.sys:14e09 (sdk/include/ddk/wdm.h:11462 (IPDatagramReassemblyTimeout))>
<tcpip.sys:11604 (sdk/lib/drivers/ip/network/ip.c:135 (IPTimeoutDpcFn))>
<ntoskrnl.exe:8b7d0 (ntoskrnl/ke/dpc.c:282 (KiTimerExpiration))>
<ntoskrnl.exe:8c2c8 (ntoskrnl/ke/dpc.c:592 (KiRetireDpcList))>
<ntoskrnl.exe:1420b2 (ntoskrnl/ke/i386/thrdini.c:294 (KiIdleLoop))>
<ntoskrnl.exe:23a54a (ntoskrnl/ke/i386/kiinit.c:687 (KiSystemStartupBootStack))>
2021-06-27 17:45:53 +02:00
He Yang 42e111f26b
[ATL] Close m_hKey in CRegKey destructor and when attaching to a new key (#3764) 2021-06-24 23:50:01 +02:00
Jérôme Gardou 27fcfe66a2 [TCPIP][IP] Use an ERESOURCE as mutex for address files & connection end points
Spinlocks are not reentrant (and this is done a lot), using them forces us to have
an horrible hack in the kernel, which unschedules threads which are at DISPATCH_LEVEL
thus allowing another thread to take ownership of the spinlock while the unscheduled
thread should already hold it.

CORE-6473
2021-06-21 11:42:01 +02:00
Dmitry Borisov 8939abf113 [ISAPNP] Disable bus scan on unsupported platforms
This speeds up boot a bit and also decreases binary size.

- Introduce a new CMake define ISAPNP_ENABLE that defined only in x86 platform
  when ISA PnP is supported.
2021-06-20 19:24:32 +06:00
Mark Jansen 560fdd150a [SDK] Add script to check includes with modified struct packing 2021-06-19 16:30:21 +02:00
Timo Kreuzer f4d47faeb7 [NTOS:KE] Fix usage of KTHREAD::SwapBusy 2021-06-19 12:17:18 +02:00
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Serge Gautherie c2317d773e [CMAKE] host-tools: Define ROS_SAVED_* for MSVC_IDE only
Addendum to 18e95f5.
ROSBE-174
2021-06-11 02:08:12 +03:00
Timo Kreuzer 9229e73f03 [HIDPARSER] Don't include pshpack1.h before including other headers
NEVER DO THIS! It is guaranteed to be wrong. Instead always individually pack single structures that need packing.
This fixes USB mouse on 64 bit builds.
2021-06-10 08:52:22 +02:00
Katayama Hirofumi MZ b552901df5
[MORE][CONUTILS] Implement missing features of the MORE command (#3658)
Implement missing features of the MORE command. Special thanks to @HBelusca. CORE-4019
2021-06-09 23:30:30 +09:00
Jérôme Gardou c8fb3f7514 [NTOS:MM] Implement proper refcounting of page tables on amd64
CORE-17552
2021-06-09 11:27:18 +02:00
George Bișoc a330b56787
[NTOS:PS] Enable alignment probing for thread/process information classes
In addition to that, here are some stuff done in this commit whilst testing:

- ICIF_QUERY_SIZE_VARIABLE and friends were badly misused, they should be used only when an information class whose information length size is dyanmic and not fixed. By removing such flags from erroneous classes, this fixes the STATUS_INFO_LENGTH_MISMATCH testcases.

- Use CHAR instead of UCHAR for classes that do not need alignment probing, as every other class in the table do, for the sake of consistency.

- ProcessEnableAlignmentFaultFixup uses BOOLEAN as type size, not CHAR. This fixes a testcase failure on ROS.

- Check for information length size before proceeding further on querying the process' cookie information.

- ProcessHandleTracing wants an alignment of a ULONG, not CHAR.

- Move PROCESS_LDT_INFORMATION and PROCESS_LDT_SIZE outside of NTOS_MODE_USER macro case. This fixes a compilation issue when enabling the alignment probing. My mistake of having them inside NTOS_MODE_USER case, sorry.

- On functions like NtQueryInformationThread and the Process equivalent, complete probing is not done at the beginning of the function, complete probing including if the buffer is writable alongside with datatype misalignment check that is. Instead such check is done on each information class case basis. With that said, we have to explicitly tell DefaultQueryInfoBufferCheck if we want a complete probing or not initially.
2021-06-06 17:14:22 +02:00
Mark Jansen 64d3a54de9
[HOST-TOOLS] Block sending telemetry when spawning a new shell 2021-06-06 00:43:05 +02:00
Mark Jansen 5ea3814a22 [ATL] Implement CString 'operator !=' 2021-06-05 23:28:38 +02:00
Timo Kreuzer 3cf2bea0de [RTL] Fix RtlWalkFrameChain and wrap it in SEH 2021-06-05 13:52:42 +02:00
Timo Kreuzer e6af7d9dfe [RTL] Simplify RtlRaiseException 2021-06-05 13:52:42 +02:00
Timo Kreuzer 3ec1ca9b46 [RTL] Implement RtplUnwindInternal and wrap RtlUnwindEx and RtlDispatchException around it
Based on the description in this blog article: http://www.nynaeve.net/?p=106
2021-06-05 13:52:42 +02:00
Timo Kreuzer 1d58e84736 [RTL] Improve RtlVirtualUnwind
* Add support for version 2 unwind info
* Implement UnwindOpSlots() and use it (based on https://github.com/dotnet/coreclr/blob/master/src/unwinder/amd64/unwinder_amd64.cpp)
* Fix handling of UWOP_PUSH_MACHFRAME
2021-06-05 13:52:42 +02:00
Timo Kreuzer 5075f7d746 [RTL] Move exception handling code to except.c 2021-06-05 13:52:42 +02:00
Timo Kreuzer 65c3911ffc [RTL] Improve / fix the SList code
Don't push a register in the middle of a an asm function. Instead add a proper prolog and store rbx in a home param slot.
2021-06-05 13:52:42 +02:00
Timo Kreuzer 0520c75aaf [CRT] Implement __C_specific_handler 2021-06-05 13:52:42 +02:00
Timo Kreuzer f1ed97d6cc [NTOS:KE/x64] Implement KiSetTrapContext
KiSetTrapContext is an asm wrapper around RtlSetUnwindContext, which first stores an exception frame to assure that all non-volatile registers were put on the stack, then calls RtlSetUnwindContext to update their first saving positions on the stack and finally restore the exception frame to potentially load any updated registers, that haven't been saved elsewhere on the stack.
2021-06-02 18:25:36 +02:00
Timo Kreuzer e801b7dda2 [RTL/x64] Implement RtlpCaptureNonVolatileContextPointers and RtlSetUnwindContext
RtlpCaptureNonVolatileContextPointers walks the stack and captures the addresses of all non-volatile registers on the stack, when they have been saved first. This is needed to be able to fix up the non-volatile on a system call, which doesn't capture non-volatiles, but relies on them to be restored by the callees.

Instead of only checking for the TargetFrame, also check for a mode change, i.e. RIP went from kernel to user, in which case the target frame was not reached yet, because it was too large, but processing can't continue here.

RtlSetUnwindContext uses RtlpCaptureNonVolatileContextPointers to set the non-volatile registers in the the stack. They will be picked up, when returning back or unwinding, e.g. to the system call handler.
2021-06-02 18:25:36 +02:00
Stanislav Motylkov 11687e9e43
[CRT][ARM] Fix uninitialized variables caught by RTC
CORE-17613
2021-06-02 13:18:40 +03:00
Timo Kreuzer 0c3812eb7e [RTL/x64] Implement RtlRestoreContext 2021-05-29 21:20:48 +02:00
Timo Kreuzer abb338b13d [RTL/x64] Improve RtlCaptureContext
Use movaps instead of movdqa, it does the same thing, but is one byte shorter.
Shuffle instructions around a bit to maximize parallel execution.
2021-05-29 21:20:48 +02:00
Timo Kreuzer 3831c0ca31 [RTL/x64] Improve RtlInitializeContext 2021-05-29 21:20:48 +02:00
Timo Kreuzer db0c59cbd4 [CRT] Use the asm version of sqrt on amd64 2021-05-28 11:52:42 +02:00
Timo Kreuzer 90a0e426ed [NTOS:KE] Add IRQL checks and fix KiInitiateUserApc 2021-05-28 11:52:42 +02:00
Timo Kreuzer 42e1fefcc6 [ASM] Clear interrupt flag in ExitTrap before returning 2021-05-28 11:52:42 +02:00
Hermès Bélusca-Maïto 7c3aabc088
[CONUTILS] Implement ConSetThreadUILanguage() as a wrapper for kernel32!SetThreadUILanguage().
CORE-17601

Dynamically load SetThreadUILanguage(), so as to support systems where this API is not present.

Hopefully implemented in a thread-safe manner.
2021-05-26 01:42:10 +02:00
Hermès Bélusca-Maïto 35f499e52f
[CONUTILS][CMD] Add and use a helper ConStdStreamsSetCacheCodePage() macro instead of repeatedly calling ConStreamSetCacheCodePage() on the standard streams. 2021-05-26 01:42:09 +02:00