Commit graph

34 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 4ec191c413 [CONSOLE.DLL-CONSRV]
Fix cursor size.

svn path=/branches/ros-csrss/; revision=58459
2013-03-10 02:23:46 +00:00
Hermès Bélusca-Maïto 7268b8776a [CONSRV]
Fix the initialization of screen buffers (concerning the cursor size).

[KERNEL32]
Fix almost all of the console winetests. Only 26 tests remain to be fixed, concerning principally WriteConsoleInputA/W and GetNumberOfConsoleInputEvents.

svn path=/branches/ros-csrss/; revision=58448
2013-03-09 01:39:49 +00:00
Hermès Bélusca-Maïto 818ee21a07 [CONSRV]
- Start to sort out things that depends only of the internals of a console, and things which are only related to "terminal emulators". Do it especially for (what I will call starting from now) the "GUI terminal emulator".
- Temporarily deactivate starting "TUI terminals".
- Temporarily break report that the terminal window is held by the current running console application in it (see r58107). This will be fixed later on.

svn path=/branches/ros-csrss/; revision=58447
2013-03-08 23:37:11 +00:00
Hermès Bélusca-Maïto beff3acbf2 [CONSOLE.DLL]
Use a new unique sample text for fonts and colors overview.

[CONSRV]
Remove few DPRINTs.

svn path=/branches/ros-csrss/; revision=58419
2013-03-03 17:39:44 +00:00
Hermès Bélusca-Maïto 28842d99ad [CONSOLE.DLL-KERNEL32-CONSRV]
Fix the console properties dialog, when launching and transmitting console properties. Before, the properties dialog was directly launched by the console server (consrv), running with CSRSS (System) privileges, what constituted a security hole. Now, I create a remote thread in the running process owning the console for launching the properties dialog (thus it has only user privileges, and not System ones anymore). For that purpose, I basically took the technique described in the following paper (Cesar Cerrudo, "Story of a dumb patch", http://www.argeniss.com/research/MSBugPaper.pdf or http://www.scn.rain.com/~neighorn/PDF/MSBugPaper.pdf), where basically the console server shares the console properties via a shared memory section with the console properties dialog dll. The address of the thread which launches the dialog in the context of the console app is given to the console server the same way as we do for the control handler (called e.g. when you press Ctrl-C, etc...)
Of course this is quite hackish, because you have the GUI interface split between the console server and the console properties dialog dll. Something far more elegant would be to put all the GUI thingie into a dedicated dll or exe, running with the same privileges as the console program itself (a kind of console -- or terminal -- emulator).

[CONSOLE.DLL]
Fix retriving / setting colors.c and other things.

[CONSRV.DLL]
- Fix retrieving / setting console properties from the registry (via the HKCU\Console\* keys), via the shell shortcuts (not totally done at the moment, because somebody has to implement properly that thing : http://msdn.microsoft.com/en-us/library/windows/desktop/bb773359(v=vs.85).aspx (NT_CONSOLE_PROPS structure stored as a shortcut data block) (at application launching time), and via the console properties dialog.
- Few DPRINTs removed.

svn path=/branches/ros-csrss/; revision=58415
2013-03-03 15:35:12 +00:00
Hermès Bélusca-Maïto f4d53fbd91 [KERNEL32-CONSRV]
- Introduce a CONSOLE_PROPS structure to hold console properties such as its title or startup attributes it should have. Initialized at console application launch time. I have to see how could it be possible to merge this structure with some parts of the GUI_CONSOLE_DATA structure and of the ConsoleInfo structure from console.dll (in /dll/cpl).
- Use a helper function to initialize the CONSOLE_PROPS structure in kernel32, at console app start or when calling AllocConsole.
- In BasepInitConsole, do initialization of CONSOLE_PROPS and related only if we are about to launch a console app.

[CONSRV]
- Adapt CONSOLE_CONNECTION_INFO and CONSOLE_ALLOCCONSOLE structures to take into account CONSOLE_PROPS.
- Fix the way we are setting console titles.
- Add experimental support for loading console properties and title and icon from shell links, thanks to the helper LoadShellLinkInfo. However I'm using there Shell COM facility to extract link properties (I could do it "the RAW way", however I would then know the format of link files, that I don't know and that I don't want to mix up with the console code). Therefore I must add dependencies to uuid and ole32 libraries. Note that icons are used in GUI consoles only (use the PrivateExtractIconExW function to retrieve both handles to the big and small icons at the same time).

Part 1/2

[CONSRV]
- Remove an unuseful xxxInitScreenBuffer function in the virtual functions console table.
- In GUI_CONSOLE_DATA structure and related functions, temporarily explicitely mark which members may be used for both GUI and TUI consoles (for a future simplification).
- Add temporary debug prints when we are setting console icon, to see the flow of calls (will be removed just before merging back to trunk).
- Add temporary debug prints in ConSrvInitConsoleScreenBuffer and ConioDeleteScreenBuffer, to figure out how SBs are initialized.

svn path=/branches/ros-csrss/; revision=58305
2013-02-10 12:36:57 +00:00
Hermès Bélusca-Maïto 03d1c009f0 [CONSRV]
- Add a macro which specifies how much space chars a TAB is.
- Implement BELL ANSI character handling (basic) and add temporary DPRINTs to see who is called (by the way, Beep() functions seems not to work correctly).

svn path=/branches/ros-csrss/; revision=58253
2013-01-30 22:59:47 +00:00
Hermès Bélusca-Maïto 7846f054ff [KERNEL32]
Clean-up IntReadConsoleOutputCode a little bit.

[CONSRV]
Fix a buffer overflow in SrvReadConsoleOutputString, which was translated sometimes into heap corruption and assert, triggered when freeing a remote captured buffer in csrsrv, when executing kernel32_winetest console, just during a call to ReadConsoleOutputCharacterA.
Nevertheless I still keep the culprit code (commented-out now) because it might be useful in the future.

svn path=/branches/ros-csrss/; revision=58229
2013-01-26 19:07:59 +00:00
Hermès Bélusca-Maïto 50a9e6a485 [CONSRV]
Rename functions to their new scheme: ConSrv* instead of Win32Csr* or Conio* (with some exceptions for the latter case).
No code changes.

svn path=/branches/ros-csrss/; revision=58213
2013-01-24 22:41:33 +00:00
Hermès Bélusca-Maïto fe7b0f74d3 [CONSRV]
- Start to implement waiting threads notifications. They can be notified by:
  * the required action (screen displaying lock/unlock, presence of new characters in the input buffer),
  * the fact that the application terminates,
  * we close a (input) handle.
  TODO: When we notify them by calling CsrNotifyWait, they are not dereferenced automatically, but they can be
  by calling a dedicated CSR function. We need to know where it is the best to dereference them.
- Correct a bug introduced in revision r58191, which broke console input mode changes (in SrvSetConsoleMode and SrvGetConsoleMode).

svn path=/branches/ros-csrss/; revision=58211
2013-01-24 20:48:42 +00:00
Hermès Bélusca-Maïto 85da7a06cd [CONSRV]
- Start to uniformize some helpers' names :
  ConioLockConsole --> ConioGetConsole and ConioUnlockConsole --> ConioReleaseConsole
  ConioLockInputBuffer --> ConioGetInputBuffer and ConioUnlockInputBuffer --> ConioReleaseInputBuffer
  ConioLockScreenBuffer --> ConioGetScreenBuffer and ConioUnlockScreenBuffer --> ConioReleaseScreenBuffer
  but the overall naming must be revamped.
- Add them a boolean parameter to determine whether or not we should lock the console. It is useful to not lock an already locked console when input / output waiting threads are called,
  because these are called from functions which lock the console.
- In the GUI console window message loop, after retrieving a pointer to the corresponding console, lock it before calling funtions in the message dispatcher (and unlock the console at the end).
- Use PostMessage instead of SendMessage for "sending" GUI messages to console windows, to avoid possible deadlocks (because of console locking).

- Add temporary /// LOCK /// comments to easily localize where I deactivated extra console (un)locking code (this remains to be analyzed further).

svn path=/branches/ros-csrss/; revision=58205
2013-01-22 23:28:51 +00:00
Hermès Bélusca-Maïto f2e3e7ac9d [CONSRV]
- Isolate the members of the CONSOLE structure which are used as input buffer data, in a new structure called ... CONSOLE_INPUT_BUFFER !
- Rename some helper functions to better match what they are doing.

svn path=/branches/ros-csrss/; revision=58191
2013-01-18 22:31:16 +00:00
Hermès Bélusca-Maïto 9967600abf [CONSRV]
- Finish to do the replacements HeapAlloc --> RtlAllocateHeap and Co.
- Finish to UNICODify consrv (it happens that it has been almost done already).
- Modify the way we start BlueScreen driver (in TUI mode): instead of using the SCM which, at that moment, is starting (and is not ready to answer to start/stop services requests), use the NT apis to start the driver (in the same way the SCM performs driver starting).
- Add a note on HAVE_WMEMSET.

svn path=/branches/ros-csrss/; revision=58169
2013-01-13 19:50:52 +00:00
Hermès Bélusca-Maïto bc73176945 [CONSRV]
HeapAlloc --> RtlAllocateHeap
HeapFree --> RtlFreeHeap
GetProcessHeap --> RtlGetProcessHeap

svn path=/branches/ros-csrss/; revision=58168
2013-01-13 19:18:54 +00:00
Hermès Bélusca-Maïto fc78a963d0 [CONSRV]
Renaming CSRSS_... structures into CONSOLE_...

svn path=/branches/ros-csrss/; revision=58120
2013-01-05 23:37:04 +00:00
Hermès Bélusca-Maïto 86fa2ba4e0 [KERNEL32-CONSRV]
Rename some structures (CSRSS_... ---> CONSOLE_...) and clarify what the ConsoleHandle members are for (--> OutputHandle or InputHandle).
No code changes otherwise.

svn path=/branches/ros-csrss/; revision=58119
2013-01-05 23:10:12 +00:00
Hermès Bélusca-Maïto 31776e274a [CONSRV]
Revert unwanted changes brought accidentally in r58104.

svn path=/branches/ros-csrss/; revision=58105
2013-01-03 17:47:34 +00:00
Hermès Bélusca-Maïto e4d97e422f [KERNEL32]
Silent more debug prints and remove an unused DPRINT1 I've introduced in r57666.

svn path=/branches/ros-csrss/; revision=58104
2013-01-03 17:42:27 +00:00
Hermès Bélusca-Maïto dd5a9c5231 [CONSRV]
- Fix console apps initialization.
- Add some debug output (NOTE TO MYSELF: remove them when all things work).
- Rewrite ConsoleNewProcess.
- Reorganize SrvAllocConsole and create ConsoleConnect based on SrvAllocConsole.
- Create ConsoleDisconnect which undoes what ConsoleConnect and ConsoleNewProcess did.
- Rework a little bit CsrInitConsole.

Now the console app. initialization algorithm is the following:

1- A process is created, its type (GUI or CUI) is determined (kernel32 and basesrv).
2- ConsoleNewProcess is called (consrv) and makes this new process inherit the console handles table from its parent
   (NOTE: this is done for all CUI processes, because at this point, we still don't know whether we must inherit
   the handles from the parent or not).
3- (back in kernel32) In BasepInitConsole, we determine whether or not we must create a new console window or use
   the parent's one or not using one at all. We (as a client) connect to the console server (consrv) (via CsrClientConnectToServer)
   which in turn (via CSRSS mechanism) calls ConsoleConnect. For GUI processes we do nothing. For CUI processes, we initialize
   a new console based on properties set in BasepInitConsole.
4- When a process dies, ConsoleDisconnect is called and whether it is a GUI or CUI process, we revert the actions done previously.

Part 2/2

TODO: - Debug the CSR waits.
      - Work on the console properties property-sheet.
      - See what can be done on http://jira.reactos.org/browse/CORE-122

svn path=/branches/ros-csrss/; revision=58098
2013-01-02 00:32:20 +00:00
Hermès Bélusca-Maïto ca2cc847d2 [CONSRV]
- Delete all the remnants of Win32CsrValidateBuffer calls, which were replaced by standard CsrValidateMessageBuffer calls, and therefore delete the unused server.c file.
- Adapt WriteConsole API to use CSR waits. This replaces the old event-based waiting.

TODO: Dereference all the waits in Console->WriteWaitQueue.

svn path=/branches/ros-csrss/; revision=57819
2012-12-08 16:13:16 +00:00
Hermès Bélusca-Maïto 90229a39a0 [KERNEL32/CONSRV]
- Merge IntWriteConsoleOutputCharacter and WriteConsoleOutputAttribute functions into IntWriteConsoleOutputCode helper functions, which is used inside WriteConsoleOutputAttribute and WriteConsoleOutputCharacterW/A.
- In server-side, merge CsrWriteConsoleOutputChar and CsrWriteConsoleOutputAttrib into the server API SrvWriteConsoleOutputString.
- The structures CSRSS_WRITE_CONSOLE_OUTPUT_CHAR and CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB are merged into CSRSS_WRITE_CONSOLE_OUTPUT_CODE.

[CONSRV]
- Add a CsrValidateMessageBuffer usage.

svn path=/branches/ros-csrss/; revision=57740
2012-11-19 23:26:36 +00:00
Hermès Bélusca-Maïto ef1e1fc82b [KERNEL32/CONSRV]
- Modify the helper function IntWriteConsole to make it use of capture buffers for passing things to write.
- Now, the loop disappears.
- I moved the pause-event wait (introduced in revision r47359) inside consrv, and (concerning the server-api-part SrvWriteConsole), especially in the ConioWriteConsole function, to be sure that all functions calling ConioWriteConsole become sensible to pause event. This REALLY NEEDS testing (and of course the code needs cleaning of the introduced comments, when I'm sure it works).

svn path=/branches/ros-csrss/; revision=57738
2012-11-19 21:48:22 +00:00
Hermès Bélusca-Maïto e71f1dd200 [KERNEL32/CONSRV]
- Merge IntFillConsoleOutputCharacter and FillConsoleOutputAttribute functions into IntFillConsoleOutputCode helper and make it used by FillConsoleOutputAttribute/CharacterW/A.
- In server-side, CsrFillOutputChar and CsrFillOutputAttrib are merged into SrvFillConsoleOutput.
- Merge CSRSS_FILL_OUTPUT and CSRSS_FILL_OUTPUT_ATTRIB structures into CSRSS_FILL_OUTPUT.

svn path=/branches/ros-csrss/; revision=57734
2012-11-18 17:06:48 +00:00
Hermès Bélusca-Maïto e505499a2c [CONSRV]
CsrSetTextAttrib --> SrvSetConsoleTextAttribute and activate it in the list of APIs indices.

svn path=/branches/ros-csrss/; revision=57732
2012-11-18 14:30:25 +00:00
Hermès Bélusca-Maïto f079b2b2b6 [CONSRV]
- Use the ConsoleGetPerProcessData macro (--> CONSOLE_PROCESS_DATA structure).
- Do not forget to leave a critical section if we fail.

svn path=/branches/ros-csrss/; revision=57731
2012-11-18 14:21:21 +00:00
Hermès Bélusca-Maïto a4ef6acb0a [CONSRV]
Use the ConsoleGetPerProcessData macro (--> CONSOLE_PROCESS_DATA structure).

svn path=/branches/ros-csrss/; revision=57730
2012-11-18 14:17:47 +00:00
Hermès Bélusca-Maïto 4b04f7d488 [KERNEL32]
Use new structures and api indices namings.

[CONSRV]
Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer.

svn path=/branches/ros-csrss/; revision=57729
2012-11-18 13:54:32 +00:00
Hermès Bélusca-Maïto de31fffea8 [KERNEL32/CONSRV]
- Use new structures and api indices namings (as usual).

[CONSRV]
- Merge CSRSS_SET_TITLE and CSRSS_GET_TITLE into CSRSS_CONSOLE_TITLE.
- Merge CSRSS_GET_CONSOLE_(OUTPUT_)CP and CSRSS_SET_CONSOLE_(OUTPUT_)CP into CSRSS_CONSOLE_CP.
- NtDuplicateObject(GetCurrentProcess(), ... ---> NtDuplicateObject(NtCurrentProcess(), ...
- Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer.
- Use CONSOLE_PROCESS_DATA structure.

TODO: Remove a DPRINT1 checkpoint in SrvAllocConsole after future tests are OK.

svn path=/branches/ros-csrss/; revision=57727
2012-11-18 13:10:03 +00:00
Hermès Bélusca-Maïto 1568822b7c [KERNEL32]
- Use new structures and api indices namings.

[CONSRV]
- CSRSS_SET_CURSOR ==> CSRSS_SET_CURSOR_POSITION for SrvSetConsoleCursorPosition.
- Merge CSRSS_GET_CURSOR_INFO and CSRSS_SET_CURSOR_INFO into CSRSS_CURSOR_INFO.

svn path=/branches/ros-csrss/; revision=57725
2012-11-17 23:29:53 +00:00
Hermès Bélusca-Maïto 2006c3bf86 [KERNEL32/CONSRV]
- Move the waiting loop of IntReadConsole into SrvReadConsole instead.
- Merge IntPeekConsoleInput and IntReadConsoleInput helpers into a single IntGetConsoleInput helper function
  and make PeekConsoleInputW/A and ReadConsoleInputW/A use it.
  Indeed, the "only" difference between these two functions, is that the first one keeps the data read inside
  the console input buffer, but on the contrary the second removes the data and does not return until at least
  one input record has been read.
  In server-side, CsrReadInputEvent and CsrPeekConsoleInput are merged into SrvGetConsoleInput. Merge the corresponding
  structures.
- Use shorter variable names in IntReadConsoleOutput and use CONSOLE_PROCESS_DATA structure in SrvReadConsoleOutput.
- Merge IntReadConsoleOutputCharacter and ReadConsoleOutputAttribute functions into a single IntReadConsoleOutputCode
  helper function, and make ReadConsoleOutputAttribute and ReadConsoleOutputCharacterW/A use it.
  In server-side, CsrReadConsoleOutputChar and CsrReadConsoleOutputAttrib are merged into SrvReadConsoleOutputString.
  (Remark: the SrvReadConsoleOutputString name comes from http://j00ru.vexillium.org/csrss_list/api_list.html and I
  checked that it was indeed the server function that was called by both ReadConsoleOutputAttribute and ReadConsoleOutputCharacter).
  The idea behind merging these two functions is, that an attribute or a character are instances of the same entity, namely
  a "code" (what would be called an (ANSI) escape sequence). Therefore I encode them inside the same CSRSS_READ_CONSOLE_OUTPUT_CODE
  structure and I use it with the previous functions.

[CONSRV]
- Make use of the CONSOLE_PROCESS_DATA structure (introduced in r57685).
- Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer.
- Reorganize conmsg.h a little bit.

svn path=/branches/ros-csrss/; revision=57721
2012-11-17 21:39:41 +00:00
Hermès Bélusca-Maïto ecb660bb7d [CONSRV]
Code reorganization only, no code changes.

svn path=/branches/ros-csrss/; revision=57717
2012-11-17 15:41:31 +00:00
Hermès Bélusca-Maïto b507bd0612 [CSR/BASESRV/CONSRV/WINSRV]
- Fix code headers. No code changes.
- Rename csrcl.h to csr.h for readability purposes.
- exitros.c --> shutdown.c

svn path=/branches/ros-csrss/; revision=57618
2012-10-25 20:40:41 +00:00
Hermès Bélusca-Maïto 1827b99497 [CONSRV]
- Add consrv to compilation. It compiles now \o/
- Convert the used console-csrss structures to the new ones.

[CSR]
- Continue to move some structures, and temporary activate a symbol.

[WIN32CSR]
- Clean a header.

svn path=/branches/ros-csrss/; revision=57602
2012-10-23 22:31:36 +00:00
Hermès Bélusca-Maïto 608c1e0428 [CONSRV/WIN32CSR]
- Move all the console subsystem from win32csr to a new server dll called consrv.dll (instead of putting it directly to winsrv.dll). It's because I want to rework on this later on.
Many things must be done in order to achieve the moving (renaming functions, etc...). Tables & symbol names come from http://j00ru.vexillium.org/csrss_list/api_list.html as usual,
but here I took the Win 2k3 ones and I added few Win 7 functions which already existed in our codebase. The other table names are guessed based on what originally existed in csrsrv
and so on. Many stubs are also missing.
Cultural remark: consrv.dll originally existed in Beta releases of Windows NT 3.1 (e.g. the October 1991 one), but was soon merged with winsrv.dll and thus, in subsequent versions of
Windows, the console subsystem is also found in winsrv.dll. See http://www.logotypes.se/NT310CSRSS.txt and http://j00ru.vexillium.org/?p=349#comment-1883. One has to wait until
Windows 7 to see it moving again to conhost.exe.

[CSRSRV]
- Add an explanation comment on what the ValidTable member in the CSR_SERVER_DLL structure is for.

svn path=/branches/ros-csrss/; revision=57597
2012-10-22 23:55:51 +00:00
Renamed from win32ss/user/win32csr/conoutput.c (Browse further)