Commit graph

78545 commits

Author SHA1 Message Date
Timo Kreuzer 68cb54dc58 [SHELL32] Fix usage of return value 2020-09-27 19:58:21 +02:00
Hermès Bélusca-Maïto f0fccb752f
[CMD] Fix batch/CALL arguments initialization.
- Move initialization of bc->raw_params also in BatchParams().

- The bc->raw_params, i.e. the unparsed batch/CALL parameters obtained
  with %*, has any leading and trailing whitespace trimmed
  (since Windows 2000+).
2020-09-27 19:06:10 +02:00
Hermès Bélusca-Maïto 37bda06eed
[CMD] CALL: Fix the implementation of the CALL command, make it more compatible with Windows' CMD.
- Fail if no parameter is provided.

- The "CALL :label args..." syntax is available only when command extensions
  are enabled. Fail if this syntax is used outside of a batch context.

- Reparse the CALL command parameter with the command parser, in order
  to accurately parse and interpret it as a possible command (including
  escape carets, etc...) and not duplicate the logic.
  ** CURRENT Windows' CMD-compatibility LIMITATION ** (may be lifted in
  a "ROS-specific" running mode of CMD): only allow standard commands to
  be specified as parameter of the CALL command.

  This reparsing behaviour can be observed in Windows' CMD, by dumping
  the interpreted commands after enabling the cmd!fDumpParse flag from
  a debugger (using public symbols).

- When reparsing, we should tell the parser to NOT ignore lines that
  start with a colon, because in this situation these are to be
  considered as valid "commands" (for parsing "CALL :label").

  * For Windows' CMD-compatibility, the remaining escape carets need to
    be doubled again so that, after the new parser step, they are escaped
    back to their original form. But then we also need to do it the "buggy"
    way à la Windows, where carets in quotes are doubled either! However
    when being re-parsed, since they are in quotes they remain doubled!!
    (see "Phase 6" in https://stackoverflow.com/a/4095133/13530036 ).

  * A MSCMD_CALL_QUIRKS define allows to disable this buggy behaviour,
    and instead tell the parser to not not interpret the escape carets.

- When initializing a new batch context when the "CALL :label" syntax is
  used, ensure that we reuse the same batch file position pointer as its
  parent, so as to have correct call label ordering behaviour.

  That is,

  :label
  ECHO hi
  CALL :label
  :label
  ECHO bye

  should display:

  hi
  bye
  bye

  i.e., the CALL calls the second label instead of the first one (and
  thus entering into an infinite loop).

  Finally, the "CALL :label" syntax strips the first ':' away, so, as a
  side-effect, the command "CALL :EOF" fails (otherwise it would perform
  a "GOTO :EOF" and succeeds), while "CALL ::EOF" succeeds.

Fixes some cmd_winetests.
2020-09-27 19:05:23 +02:00
Hermès Bélusca-Maïto 4f4af5d271
[CMD_ROSTEST] Add tests for CALL label parsing, and for CALL and GOTO behaviour.
Tests adapted from https://stackoverflow.com/q/31987023/13530036
and from https://stackoverflow.com/a/38938416/13530036 .

- Test when CALL with a label containing /? actually calls GOTO's help,
  and test when CALL's help is displayed instead.

- Test when CALL with a label containing /?, but specified by variables,
  do NOT trigger GOTO's or CALL's help.

- Test the effect of the presence of escape carets in CALL label string.

- Test that CALL indeed supports double delayed expansion. Adapted from
  https://stackoverflow.com/a/31990563/13530036 .
2020-09-27 19:04:51 +02:00
Katayama Hirofumi MZ fe41acdc11 [SHLWAPI] Follow-up of #3230 (f496a5f)
CORE-9281
2020-09-27 15:47:10 +09:00
Katayama Hirofumi MZ f496a5fc4f
[SHLWAPI] 1/3-implement SHAutoComplete (#3230)
Retrial of #3214. Try to implment shlwapi!SHAutoComplete function. Unfinished. CORE-9281
2020-09-27 15:27:18 +09:00
Hermès Bélusca-Maïto d029a626e9
[CMD] Make the command-line parser more compatible with Windows' CMD one.
All these modifications have been verified with Windows' CMD, either
by using written cmd_rostests and the existing cmd_winetests, or
manually by enabling the flags cmd!fDumpTokens and cmd!fDumpParse
(available in the public symbols) and analyzing how the tokens are
being parsed, as well as the generated command tree.

See also the following links for more details (but remember that these
observations have to be double-checked in Windows' CMD!):

* Parser rules: https://stackoverflow.com/a/4095133/13530036
* Discussion: https://www.dostips.com/forum/viewtopic.php?f=3&t=8355
* Numbers parsing: https://www.dostips.com/forum/viewtopic.php?t=3758
* Label names vs. GOTO and CALL: https://www.dostips.com/forum/viewtopic.php?f=3&t=3803
  and: https://www.dostips.com/forum/viewtopic.php?f=3&t=3803&p=55405#p55405

- Fix REM command parsing. A C_COMMAND-like structure should still
  be built, so that it can show up during batch command echo. However
  some specific handling needs to be done, so use instead a new C_REM
  command type.
  Escape carets are parsed differently than usual: they are explicitly
  kept in the command line and don't participate in line continuations.
  Also, the Windows' CMD behaviour is to discards everything before the
  last line continuation.

- Prefix operator '@' (the "silent" operator) is parsed as a separate
  command. Thus, the command @@foo@bar is parsed as: '@', '@', 'foo@bar'.

- Improve the checks for numbered redirection.
  For this purpose, we check whether this is a number, that is in first
  position in the current parsing buffer or is preceded by a whitespace-
  like separator, including standard command operators (excepting '@' !)
  and double-quotes.

- Empty command blocks, i.e. "( )", standing by themselves, or present
  in IF or FOR commands, are considered invalid. (The closing parenthesis
  is considered "unexpected".)

- Ignore single closing parenthesis when being outside of command blocks,
  thus interpreting it as a command, and ignore explicitly everything
  following on the same line, including line continuations.
  This very specific situation can happen e.g. while running in batch mode,
  when jumping to a label present inside a command block.
  See the code for a thorough explanation.

- Detect whether a parenthesized block is not terminated at the end
  of a command stream (getting a NUL character instead of a newline),
  and if so, bail out early instead of entering into an infinite loop.

- Perform a similar check for the parenthesized list in FOR commands.

- Initialize the static 'InsideBlock' value to a known value.

- The '&' operator (multi-commmand) is allowed to have an empty RHS.
  When such situation occurs, turn the CurrentTokenType to TOK_END
  so as to avoid a parse error later on.

- The main body of a IF statement, or its 'else' clause, as well as
  the main body of a FOR statement, must not be empty, otherwise this
  is considered a syntax error. If so, call ParseError() that sets
  the 'bParseError' flag, and forcing all batch execution to stop.
2020-09-27 02:27:15 +02:00
Adam Słaboń 50ff453434
[TRANSLATION] Polish translation update (#3233) 2020-09-26 21:42:36 +03:00
Hermès Bélusca-Maïto 7988a2ac54
[CMD_ROSTEST] Add more tests for the command echoer and new tests for the parser. 2020-09-26 17:51:07 +02:00
Kyle Katarn b217d8bd14 [ROSTEST] Fix copy paste bug in RtlBitmap.c 2020-09-26 17:12:36 +02:00
Katayama Hirofumi MZ c8e1460ac5
[COMDLG32] Support shortcut keys on Open/Save Dialog (#3238)
Enable key accelerators on File Open/Save Dialog. CORE-14332
2020-09-26 21:26:06 +09:00
Katayama Hirofumi MZ 1062a297bf [DRIVERS][SCSIPORT] Fix build fdc47e7 2020-09-26 11:20:11 +09:00
Katayama Hirofumi MZ f341e60fbe [USER32] Mute 'Imm Api Table Init 2' spam
CORE-11700
2020-09-26 11:13:43 +09:00
Victor Perevertkin fdc47e7ea7
[SCSIPORT][FORMATTING] Fix formatting and PCH generation 2020-09-26 03:47:52 +03:00
Mark Jansen 3da04a9b68
[RAPPS] Remove string casts after the conutils fix 2020-09-25 22:03:28 +02:00
Timo Kreuzer d8b5c00c33 [KERNEL32_VISTA] Move vista.c from kernel32 to kernel32_vista
- Remove duplicated functions
- Use AreFileApisANSI() instead of global variable bIsFileApiAnsi in shared kernel32_shared
2020-09-25 09:45:54 +02:00
Timo Kreuzer fcd83242d4 [KERNEL32] Move some functions into a static library to be shared between kernel32 and kernel32_vista 2020-09-25 09:45:54 +02:00
Timo Kreuzer 4e72da0858 [KERNEL32_VISTA] Move under kernel32 2020-09-25 09:45:54 +02:00
Timo Kreuzer ab43f86980 [KSECDD] Fix RtlEncryptMemory and improve test 2020-09-25 09:39:51 +02:00
Katayama Hirofumi MZ ed02f41af5 [SHELL32] Call SHAutoComplete on 'Run' dialog
CORE-9281
2020-09-25 15:59:30 +09:00
Katayama Hirofumi MZ 0a8fb87d84 [COMCTL32] IP Address controls follow-up of #3212 (3f30b1e)
The rightest field didn't work Left arrow key.

CORE-3479
2020-09-25 15:32:58 +09:00
Kyle Katarn b9754fa5d6
[SETUP][MMSYS][SHELL32] Adding missing French translation (and update existing ones) (#3232)
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2020-09-25 01:39:31 +02:00
Victor Perevertkin bb94e711ef
[NTOSKRNL_VISTA] Add stubs for functions needed in KMDF 2020-09-25 01:28:55 +03:00
Victor Perevertkin d01518da7c
[XDK] Add definitions required for newer storage class drivers (cdrom)
That introduced some warnings in the current code which were corrected as well

CORE-17129
2020-09-24 22:30:52 +03:00
Victor Perevertkin be276dde28
[XDK][NTOSKRNL_VISTA] Put NTKRNLVISTAAPI to XDK headers
for vista+ APIs implemented in ntoskrnl_vista.
Now if you statically link ntoskrnl_vista into a driver,
NTKERNELAPI will automatically be removed from an API definition
2020-09-24 21:51:57 +03:00
Victor Perevertkin 7af229f5b5
[PSDK] Fix order and formatting of IOCTL definitions in ntddcdrm.h 2020-09-24 17:44:18 +03:00
Victor Perevertkin 99489553fc
[PSDK] Add definitions required for newer storage class drivers (cdrom)
CORE-17129
2020-09-24 17:31:15 +03:00
Victor Perevertkin d7d716a64c
[DDK] Add definitions required for newer storage class drivers (cdrom)
CORE-17129
2020-09-24 05:47:48 +03:00
Victor Perevertkin f7c58468f1
[XDK] Move UNREACHABLE macro definition to ntbasedef.h 2020-09-24 05:35:43 +03:00
Victor Perevertkin 87a5311116
[SDK] Fix __forceinline definition for C++ 2020-09-24 05:33:35 +03:00
Katayama Hirofumi MZ 33fe4333f4
[USER32] Load IMM table (#3215)
Implement the IMM function table in module user32.dll. CORE-11700
File immtable.h is located at win32ss/user/user32/include, that is a list of the DEFINE_IMM_ENTRY macro calls.
2020-09-23 21:42:54 +09:00
Katayama Hirofumi MZ 3f30b1eda7
[COMCTL32] Improve IP Address Controls (Tab and caret) (#3212)
Improve IP address controls.
- Set focus to EDIT control to show caret.
- Process WM_GETDLGCODE messages on EDIT control to catch Tab key.
- Process Tab key and Shift+Tab key in processing WM_KEYDOWN.
CORE-3479
2020-09-23 08:32:40 +09:00
Hermès Bélusca-Maïto 17e094cd34
[CMD] SET: Diverse fixes for the arithmetic-expression parser (/A option).
- Detect whether a division by zero is done, and fail if so.

- Detect whether an invalid number is provided:
  * If _tcstol() fails with errno == ERANGE, we've got an overflow or
    underflow.
  * If the next character where _tcstol() is not a whitespace but is a
    character compatible with the first character of an identifier, the
    number is invalid.

- Add + to the list of existing unary operators (!,~,-), and parse them
  where many of these are present. Indeed, expressions like: +3, -+-+3,
  !!-+3 (or with other unary ops, etc.) are valid.

- Operators constituted of more than one characters, can contain
  whitespace separating their constituting characters.
  Thus, "a + = 3" is equivalent to "a += 3" (and the same for -=, *=,
  /=, %=, &=, |= and ^=), and "a < < 3" is equivalent to "a << 3" (and
  the same for >>, <<= and >>=).

- After evaluating everything, if unparsed data remains, fail and bail out.

- Return Windows' CMD-compatible errorlevels.

See https://ss64.com/nt/set.html for more details.

Fixes some cmd_winetests.
2020-09-23 00:22:48 +02:00
Hermès Bélusca-Maïto f5cf67f455
[CMD_ROSTEST] Add tests for SET /A errorlevels. 2020-09-23 00:22:48 +02:00
Hermès Bélusca-Maïto 87a5403318
[CMD] Add a MSCMD_BATCH_ECHO define for enabling Windows' CMD.EXE way of preserving/restoring the echo flag across batch calls.
Observation shows that this is done only when the top-level batch file
is being run (and then terminates); the echo flag is not restored to its
previous state when a child batch file terminates and gives main back to
its parent batch.
2020-09-23 00:22:47 +02:00
Hermès Bélusca-Maïto 141378cfc8
[CMD] ASSOC: Simplify the code and make it more robust; fix returned ERRORLEVEL values.
- Make sure that non-administrator users can list associations, and
  display appropriate error messages when e.g. they don't have sufficient
  privileges to perform an operation.

- Make the helper functions all return Win32 values, used as the
  ERRORVALUE, except when a specific extension association fails to be
  displayed, in which case the ERRORVALUE is normalized to 1.

- Since the 'param' is a modifiable string (that can be modified by the
  command, independently of the way it's called), just use it to isolate
  the extension by zeroing out the equls-sign separator.
2020-09-23 00:22:47 +02:00
Hermès Bélusca-Maïto 63316df520
[CMD] Change ERRORLEVEL behaviour for commands ASSOC, PATH, PROMPT and SET.
Commands APPEND/DPATH and FTYPE are also concerned by this; however
we do not implement them in our CMD.EXE yet.

These commands set the ERRORLEVEL differently, whether or not they are
run manually from the command-line/from a .BAT file, or from a .CMD file:

- From command-line/.BAT file, these commands set the ERRORLEVEL only if
  an error occurs. So, if two commands are run consecutively and the first
  one fails, the ERRORLEVEL will remain set even if the second command
  succeeds.

- However, when being run from a .CMD file, these command will always
  set the ERRORLEVEL. In the example case described above, the second
  command that succeeds will reset the ERRORLEVEL to 0.

This behaviour is determined from the top-level batch/script file being
run. This means that, if a .BAT file is first started, then starts a
.CMD file, the commands will still behave the .BAT way; on the opposite,
if a .CMD file is first started, then starts a .BAT file, these commands
will still behave the .CMD way.

To implement this we introduce one global BATCH_TYPE enum variable that
is initialized to the corresponding batch/script file type when the
top-level script is loaded. It is reset to "none" when that script
terminates.

See https://ss64.com/nt/errorlevel.html for more details,
section "Old style .bat Batch files vs .cmd Batch scripts",
and https://groups.google.com/forum/#!msg/microsoft.public.win2000.cmdprompt.admin/XHeUq8oe2wk/LIEViGNmkK0J
(comment by Mark Zbikowski).
2020-09-23 00:22:46 +02:00
Hermès Bélusca-Maïto 0b400bbb98
[CMD_ROSTEST] Add tests for particular ERRORLEVEL behaviour in some commands. 2020-09-23 00:22:45 +02:00
Hermès Bélusca-Maïto a5d7a2cd61
[CMD] Code style and formatting fixes for assoc.c and path.c 2020-09-23 00:22:45 +02:00
Hermès Bélusca-Maïto 69258973e0
[CMD_ROSTEST] Add tests for the FOR /F "tokens=" command. See commit 0695ecbf. 2020-09-22 23:08:13 +02:00
Doug Lyons 90be2f4e1b
[IPHLPAPI] Fix for hasArp which crashes some iphlpapi tests. (#3216)
CORE-16513
2020-09-22 15:50:41 +02:00
Michael Stamper e45bacda07
[PORTCLS] Fix audio stutter with official AC97 driver (#3225)
Replace call to AllocatedBufferSize(), with BufferSize().

Indeed (quoting https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/portcls/nf-portcls-idmachannel-buffersize ):

> The BufferSize() method returns the buffer size that was set by the previous call to IDmaChannel::SetBufferSize(). If SetBufferSize() has not been called since the IDmaChannel::AllocateBuffer() call, BufferSize returns the allocated buffer size. The DMA-channel object does not actually use this value internally. This value is maintained by the object to **allow its various clients to communicate the intended size of the buffer**.

And this is exactly what we want to do.
2020-09-22 15:49:34 +02:00
Hermès Bélusca-Maïto 0695ecbfd6
[CMD] FOR: Additional Windows' CMD compatibility "fixes" for FOR /F token parsing command.
This compatibility behaviour implements the buggy behaviour of FOR /F
token parsing that can be observed in Windows' CMD, and that is tested
by the cmd_winetests.
It can be disabled at compile time via the MSCMD_FOR_QUIRKS define.

It fixes additional cmd_winetests, in concert with commit cb2a9c31.

Explanation of the implemented buggy behaviour
==============================================

In principle, the "tokens=x,y,m-n[*]" option describes a list of token
numbers (must be between 1 and 31) that will be assigned into variables.
Theoretically this option does not cumulate: only the latest 'tokens='
specification should be taken into account.

However things are not that simple in practice. First, not all of the
"tokens=" option state is reset when more than one specification is
provided. Second, when specifying a token range, e.g. "1-5", Windows'
CMD just ignores without error ranges that are not specified in
increasing order. Thus for example, a range "5-1" is ignored without
error. Then, token numbers strictly greater than 31 are just ignored,
and if they appear in a range, the whole range is ignored.

Another bug is the following one: suppose that the 'tokens'
specification reads:
  "tokens=1-5,1-30" , or: "tokens=1-5,3" ,
i.e. more than one range, that overlap partially. Then the actual total
number of variables will not be of the larger range size, but will be
the sum, instead.
Thus, in the first example, a total of 5 + 30 == 35 variables (> 31) is
allocated, while in the second example, a total of 5 + 1 == 6 variables
is allocated, even if they won't all store data !!
In the first example, only the first 30 FOR variables will be used, and
the 5 others will contain an empty string. In the second example, only
the first 5 FOR variables will be used, and the other one will be empty.

We also see that due to that, the "Variables" buffer of fixed size
cannot always be used (since it can contain at most 32 variables).

Last but not least, when more than one "tokens=" specification is
provided, for example:
  "tokens=1-31 tokens=1-20"
a total number of 31 FOR variables (because 31 is the max of 31 and 20)
is allocated, **but** only 20 are actually used, and the 11 others
return an empty string.

And in the specification: "tokens=1-31,* tokens=1-20", a total of
31 + 1 + 20 = 52 variables is initialized, but only the first 20 will
be used, and no "remaining-line" token (the '*' one) is used.
2020-09-21 03:31:01 +02:00
Hermès Bélusca-Maïto e904471023
[CMD] IF: Fix x64 warning C4267. 2020-09-21 03:31:01 +02:00
Timo Kreuzer cb22d5f697 [NTOS:PS] On x64 don't fail in NtSetInformationProcess with ProcessUserModeIOPL information class, instead just don't do anything.
For NT6+ appcompat setting return STATUS_NOT_IMPLEMENTED
2020-09-20 23:08:17 +02:00
Timo Kreuzer 26484eea9f [NTOS:MM] Fix MiSubsectionPteToSubsection 2020-09-20 23:08:17 +02:00
Timo Kreuzer 896d090ee6 [NTOS:MM] Call MiSessionAddProcess() from MmCreateProcess() like on x86 2020-09-20 23:08:17 +02:00
Timo Kreuzer bebcda0b0b [NTOS:MM] In the x64 version of MmCreateProcessAddressSpace() zero out all page table PFNs 2020-09-20 23:08:17 +02:00
Timo Kreuzer 04f0c7d0d7 [NTOS:KE] Zero out ExceptionFrame member in Syscall handler 2020-09-20 23:08:17 +02:00
Timo Kreuzer 366e8a840c [NTOS:KE] Disable interrupts before lowering IRQL in KiDpcInterruptHandler to avoid stacking up DPC interrupts 2020-09-20 23:08:17 +02:00