Commit graph

2722 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 0e88f0485c
[PSDK][WIN32SS] Fix WINNT in ddraw.h; remove NT_BUILD_ENVIRONMENT usage
Keep compatibility with MS PSDK ddraw.h file by using WINNT instead of
_WINNT_ in the preprocessor conditional test.
Incidentally this allows also removing those #define NT_BUILD_ENVIRONMENT
in the win32ss modules.

See commit 5fcfaf2e1 (r42346).
2023-11-22 15:46:06 +01:00
Hermès Bélusca-Maïto 9578bae858
[PSDK] Minor cleanup and fixes in headers
- Remove nonsensical XFree86 stuff;
- Add missing #ifndef NORESOURCE around RT_* defines.
2023-11-21 22:23:55 +01:00
Serge Gautherie 5a0cd3743e
[WIDL] CMakeLists.txt: Remove an obsolete comment (#6016)
Addendum to 8184186 (r55855).
2023-11-20 16:07:46 +01:00
Justin Miller 516ccad340
[NTOS:KE][HALX86] Implement AP startup code (#5879)
Co-authored-by: Victor Perevertkin <victor.perevertkin@reactos.org>

Introduce the initial changes needed to get other processors up and into kernel mode. 
This only supports x86 as of now but is the first real step towards using other system processors.
2023-11-19 15:51:33 -08:00
George Bișoc f3141fb29e
[NTOS:CM] Implement support for alternate registry hives
Sometimes repairing a broken hive with a hive log does not always guarantee the hive
in question has fully recovered. In worst cases it could happen the LOG itself is even
corrupt too and that would certainly lead to a total unbootable system. This is most likely
if the victim hive is the SYSTEM hive.

This can be anyhow solved by the help of a mirror hive, or also called an "alternate hive".
Alternate hives serve the purpose as backup hives for primary hives of which there is still
a risk that is not worth taking. For now only the SYSTEM hive is granted the right to have
a backup alternate hive.

=== NOTE ===

Currently the SYSTEM hive can only base upon the alternate SYSTEM.ALT hive, which means the
corresponding LOG file never gets updated. When time comes the existing code must be adapted
to allow the possibility to use .ALT and .LOG hives simultaneously.
2023-11-19 20:44:29 +01:00
George Bișoc 279f8f8864
[CMLIB] Fix the bin during hive initialization from memory if it's corrupt
As we iterate over the chunk hive data pointer for hive bins that we are going
to enlist, we might encounter one or several bins that would get corrupted
during a premature abortion of a registry writing operation such as due to
a power outage of the system, hardware malfunction, etc.

Corruption at the level of hive bins is nasty because they contain actual cell
data of registry information such as keys, values etc. Assuming a bin is corrupt
in part we can fix it by recovering some of the bin properties that, theoretically,
could be fixed -- namely the signature, size and offset.

For size and offset we are more or less safe because a bin typically has a size
of a block, and the offset is the coordinate index of where a hive bin should lay at.
2023-11-19 20:44:29 +01:00
George Bișoc fa80176a62
[FREELDR][HACK] Temporarily disable registry recovery code for AMD64
The newly implemented code for registry recovery makes the FreeLdr binary to grow
in size, to the point that it would BSOD because the PE image is too big.

For now we have to temporarily disable any of the newly added code, until
either FreeLdr is split into a basic PE bootloader image itself and a
"FreeLdrlib" that is used by the PE image to access various bootloader APIs
or another proper solution is found.
2023-11-19 20:44:28 +01:00
George Bișoc 4db1b0fb62
[SDK][CMLIB] Purge volatile data of registry in a proper way with CmCheckRegistry
Thanks to CmCheckRegistry, the function can perform volatile data purging upon boot which this removes old hacky CmPrepareHive code. This also slightly refactors HvInitialize making it more proper.
2023-11-19 20:44:28 +01:00
George Bișoc cc63d8f4a2
[SDK][CMLIB] Implement log transaction writes & Resuscitation
=== DOCUMENTATION REMARKS ===

This implements (also enables some parts of code been decayed for years) the transacted writing of the registry. Transacted writing (or writing into registry in a transactional way) is an operation that ensures the successfulness can be achieved by monitoring two main points.
In CMLIB, such points are what we internally call them the primary and secondary sequences. A sequence is a numeric field that is incremented each time a writing operation (namely done with the FileWrite function and such) has successfully completed.

The primary sequence is incremented to suggest that the initial work of syncing the registry is in progress. During this phase, the base block header is written into the primary hive file and registry data is being written to said file in form of blocks. Afterwards the seconady sequence
is increment to report completion of the transactional writing of the registry. This operation occurs in HvpWriteHive function (invoked by HvSyncHive for syncing). If the transactional writing fails or if the lazy flushing of the registry fails, LOG files come into play.

Like HvpWriteHive, LOGs are updated by the HvpWriteLog which writes dirty data (base block header included) to the LOG themselves. These files serve for recovery and emergency purposes in case the primary machine hive has been damaged due to previous forced interruption of writing stuff into
the registry hive. With specific recovery algorithms, the data that's been gathered from a LOG will be applied to the primary hive, salvaging it. But if a LOG file is corrupt as well, then the system will perform resuscitation techniques by reconstructing the base block header to reasonable values,
reset the registry signature and whatnot.

This work is an inspiration from PR #3932 by mrmks04 (aka Max Korostil). I have continued his work by doing some more tweaks and whatnot. In addition to that, the whole transaction writing code is documented.

=== IMPORTANT NOTES ===

HvpWriteLog -- Currently this function lacks the ability to grow the log file size since we pretty much lack the necessary code that deals with hive shrinking and log shrinking/growing as well. This part is not super critical for us so this shall be left as a TODO for future.

HvLoadHive -- Currently there's a hack that prevents us from refactoring this function in a proper way. That is, we should not be reading the whole and prepare the hive storage using HvpInitializeMemoryHive which is strictly used for HINIT_MEMORY but rather we must read the hive file block by block
and deconstruct the read buffer from the file so that we can get the bins that we read from the file. With the hive bins we got the hive storage will be prepared based on such bins. If one of the bins is corrupt, self healing is applied in such scenario.

For this matter, if in any case the hive we'll be reading is corrupt we could potentially read corrupt data and lead the system into failure. So we have to perform header and data recovery as well before reading the whole hive.
2023-11-19 20:44:27 +01:00
George Bișoc f33da480af
[SDK][CMLIB] Implement CmCheckRegistry and validation private helpers
CmCheckRegistry is a function that provides the necessary validation checks for a registry hive. This function usually comes into action when logs have been replayed for example, or when a registry hive internals have changed such as when saving a key, loading a key, etc.

This commit implements the whole Check Registry infrastructure (cmcheck.c) in CMLIB library for ease of usage and wide accessibility across parts of the OS. In addition, two more functions for registry checks are also implemented -- HvValidateHive and HvValidateBin.

Instead of having the CmCheckRegistry implementation in the kernel, it's better to have it in the Configuration Manager library instead (aka CMLIB). The benefits of having it in the library are the following:

- CmCheckRegistry can be used in FreeLdr to fix the SYSTEM hive
- It can be used on-demand in the kernel
- It can be used for offline registry repair tools
- It makes the underlying CmCheckRegistry implementation code debug-able in user mode

CORE-9195
CORE-6762
2023-11-19 20:44:27 +01:00
George Bișoc 54c552392f
[SDK][CMLIB] Implement self-heal registry helpers
This implements cmheal.c file which provides the basic registry self-heal infrastructure needed by the public CmCheckRegistry function. The infrastructure provides a range of various self-heal helpers for the hive, such as subkey, class, values and node healing functions.
2023-11-19 20:44:27 +01:00
George Bișoc 586bea138e
[CMLIB] Add STATUS_INVALID_PARAMETER and STATUS_REGISTRY_IO_FAILED status codes
Add these NTSTATUS codes in the CMLIB library. STATUS_INVALID_PARAMETER will be used mostly for HvInitialize function, STATUS_REGISTRY_IO_FAILED for whatever routines that deal with reading or writing into a hive file.
2023-11-19 20:44:26 +01:00
George Bișoc 99fab7b905
[SDK][CMLIB] Declare some BootType and BootRecover identifiers & Miscellaneous Stuff
=== DOCUMENTATION REMARKS ===

HBOOT_TYPE_REGULAR and HBOOT_TYPE_SELF_HEAL are boot type values set up by the CMLIB library (for the BootType field respectively). HBOOT_TYPE_REGULAR indicates a normal system boot whereas HBOOT_TYPE_SELF_HEAL indicates the system boot is assisted within self healing mode.

Whether the former or the latter value is set it's governed by both the kernel and the bootloader. The bootloader and the kernel negotiate together to determine if any of the registry properties (the hive, the base block, the registry base, etc) are so severed from corruption or not. In extreme cases where
registry healing is possible, the specific base block of the damaged hive will have its flags marked with HBOOT_TYPE_SELF_HEAL. At this point the boot phase procedure is orchestrated since the boot phase no longer goes on the default path but it's assisted, as I have already said above.

HBOOT_NO_BOOT_RECOVER, HBOOT_BOOT_RECOVERED_BY_HIVE_LOG and HBOOT_BOOT_RECOVERED_BY_ALTERNATE_HIVE on the other hand are identifiers for the BootRecover field of the BASE_BLOCK header structure. These are used exclusively by FreeLdr to tell the kernel if the bootloader recovered the SYSTEM hive or not. In case where the bootloader did recover the SYSTEM hive,
the kernel will perform a flush request on the dirty data down to disk. The (almost) worse case FreeLdr could not repair the main hive by applying log data, it will load the alternate mirror version of the hive.

In addition to that, declare other miscellaneous CMLIB identifiers for log transaction writes purposes.
2023-11-19 20:44:23 +01:00
Serge Gautherie d27ec14822
[PSDK][SHELLBTRFS] Get rid of FILE_INFO_BY_HANDLE_CLASS.MaximumFileInfoByHandlesClass (#6003)
Follow-up to commit 455f330 (see PR #5802).
'MaximumFileInfoByHandlesClass' was our typo.
2023-11-19 19:42:18 +01:00
Timo Kreuzer e3f204e228 [CMAKE] Remove "/Gy" option from ML
Reason: VS solution builds pass the compiler options to the assembler. These are usually ignored and result in a warning only, but ML of the latest VS supports /Gy (function level linking), but that requires all functions to be declared with "PROC" and otherwise results in an error.
2023-11-19 09:19:33 +02:00
Timo Kreuzer 455f330775 [KERNEL32_VISTA] Sync GetFileInformationByHandleEx with wine head 2023-11-18 17:53:42 +02:00
Ratin Gao bd0a5498b0
[NTDLL:LDR] Little fixes about SAL annotation and behavior (#5793)
- Uniform function declarations in .c and .h with fixes and SAL2 improvements.
- Use LDR_[UN]LOCK_LOADER_LOCK_FLAG_XXX correctly.
- Fix incorrect UsedSize calculation in LdrQueryProcessModuleInformationEx (caught by ThFabba).
- Whatever the callback request stop the enumeration or not in LdrEnumerateLoadedModules, the following operations should be the same.
- Fix 2 incorrect DPRINT1 that printed incorrect parameter.
- Return error if RtlAllocateHeap failed in LdrpGetProcedureAddress, and add comments about NT6.2 new changes.
2023-11-15 20:59:32 +01:00
Hermès Bélusca-Maïto 161eb5d375
[CRT] dbgrpt.cpp: Fix buffer sizes in the *nprintf functions (#5678)
Sizes are in number of chars; use _countof() instead of hardcoding
them in the functions.
2023-11-14 12:24:00 +01:00
Hermès Bélusca-Maïto f49e213943
[CRT][MSVCRT] Implement _CrtDbgReport(W)V and redefine _CrtDbgReport(W) around those (#5678)
Also add the internal _VCrtDbgReportA and _VCrtDbgReportW functions listed in
https://learn.microsoft.com/en-us/cpp/c-runtime-library/internal-crt-globals-and-functions?view=msvc-170

CORE-11835, CORE-15517
2023-11-14 12:23:51 +01:00
Whindmar Saksit 7fb91d98f9
[SHELL32] Add support for more registry verb flags and CMF flags (#5785)
- Adds support for registry controlled menu separators and the documented
  values to turn off verbs.
- Adds support for CMF_OPTIMIZEFORINVOKE, CMF_NODEFAULT, CMF_DONOTPICKDEFAULT,
  CMF_EXPLORE and CMF_DISABLEDVERBS.

Bugs fixed:

- A verb with "Extended" set in the registry could cause the menu to invoke
  the incorrect command! This happened because skipping InsertMenuItemW
  caused InvokeCommand to use the wrong index with m_StaticEntries.
- Uses IS_INTRESOURCE instead of HIWORD to check if something is a string
  (only matters on 64-bit).
- TryToBrowse leaking a PIDL when calling ILCombine.

Notes:

- This PR introduces the RosGetProcessEffectiveVersion() helper function
  discussed in chat.
- Relaxed FAILED_UNEXPECTEDLY to FAILED in two places because IContextMenu
  cannot assume that it has a site that leads to IShellBrowser.
2023-11-13 16:21:13 +01:00
Whindmar Saksit c6ec8d924e
[ATL] Added CComPtr.CoCreateInstance helper methods (#5905) 2023-11-13 11:03:05 +01:00
Hermès Bélusca-Maïto ee11747527
[CRT] Fix "wcsat_s" typo... 2023-11-11 21:30:09 +01:00
Timo Kreuzer 6ca8eb5c1e [CMAKE] Update baseaddress cmake files 2023-11-10 19:20:24 +02:00
Timo Kreuzer 7377f14339 [GEN_BASEADDRESS] Add handling of 64 bit builds 2023-11-10 19:20:24 +02:00
Timo Kreuzer 9cc4d8994b [CMAKE] Use baseaddress64.cmake for all 64 bit builds
- Rename baseaddress_msvc_x64.cmake to baseaddress64.cmake
- Include it for all compilers and 64 bit architectures
2023-11-10 19:20:24 +02:00
Timo Kreuzer 2b7246fd3c [CMAKE] Add support for "IMAGEBASE default" and use it for test/sample dlls 2023-11-10 19:20:24 +02:00
Timo Kreuzer 58f1201eae [FUSION] Provide baseaddress for fusion_1_1 and fusion_2_0
These DLLs are also named fusion.dll. Give them the same baseaddress as fusion.dll
2023-11-10 19:20:24 +02:00
Timo Kreuzer 2245dd78f5 [ASMPP] Improve handling of rip relative addressing 2023-11-10 19:20:24 +02:00
Timo Kreuzer a34f1ed03c [CRT] Make ML based asm code GAS compatible
Our transpiler asmpp cannot handle rip relative addressing for "[symbol]".
2023-11-10 19:20:24 +02:00
Timo Kreuzer d4993c67cd [CRT] Fix parameter check for _memicmp on NT 6+
Fixes a crash in msvcrt_winetest:string
2023-11-10 19:19:22 +02:00
Timo Kreuzer 840dfdc3a1 [CRT] Add parameter check to _mbscmp
Fixes crash in msvcrt_winetest::string
2023-11-10 19:19:22 +02:00
Timo Kreuzer 86f98baaf8 [CRT][MSVCRT] Import _gcvt and _gcvt_s from wine and export _gcvt_s on Vista+
Fixes a crash in msvcrt_winetest string
2023-11-10 19:19:22 +02:00
Timo Kreuzer 51b5d846e9 [CRT] Define _NTSYSTEM_ in 2 files to force using import-stubs
This prevents the code from linking to __imp_*, which would pull in the symbol from the import library (e.g. kernel32), which creates problems with the GNU linker, which doesn't like to have the import and a static definition at the same time.
2023-11-10 19:00:41 +02:00
Andrei Miloiu d7b7d36721
[NETEVENT][MC] Update neteventmsg.mc (#5928) 2023-11-08 11:16:58 +00:00
Andrei Miloiu 46f67b1970
Update net_msg.mc (#5926) 2023-11-08 11:13:17 +00:00
Timo Kreuzer dfcf07b825 [NTOS:KE/x64] Remove GCC vs ML hack 2023-11-07 23:16:50 +02:00
Katayama Hirofumi MZ 0ae6a509b0
[SHLWAPI][SDK] Implement IContextMenu_Invoke (#5856)
- Modify shlwapi.spec.
- Add dll/win32/shlwapi/utils.cpp.
- Implement IContextMenu_Invoke function.
- Add it to <shlwapi_undoc.h>.
CORE-19278
2023-11-05 21:45:08 +09:00
Joachim Henze 7f80d5ee79 [CMLIB] Revert previous commit to avoid future merges of other devs
because George is having an open Draft PR since July 2022,
which might also touch this file on master in some years.
And it ofc is easier for me to revert my work now, then for him to
go through the great lengths of merging his work then.
2023-11-05 09:55:03 +01:00
Joachim Henze f6de3881ca
[CMLIB] UNIMPLEMENTED_ONCE less hand-knitted (#5889)
allows to get rid of static var PrintCount, at least visually in the code
2023-11-05 09:12:49 +01:00
Katayama Hirofumi MZ 4aa1bcb72b
[IMM32][SDK] Implement software keyboard, Part 1 (#5865)
- Add dll/win32/imm32/softkbd.c source file.
- Half-implement ImmCreateSoftKeyboard function.
- Move ImmShowSoftKeyboard, and ImmDestroySoftKeyboard functions.
- Modify ImmCreateSoftKeyboard prototype.
CORE-19268
2023-11-04 05:58:17 +09:00
Katayama Hirofumi MZ eb4d13c823
[IMM32][SDK] Implement CtfImm(Hide,Restore)ToolbarWnd (#5863)
- Add Imm32GetFn helper function.
- Implement CtfImmHideToolbarWnd and
  CtfImmRestoreToolbarWnd functions.
- Add them to <imm32_undoc.h>.
CORE-19268
2023-11-03 22:45:51 +09:00
Katayama Hirofumi MZ dabb3f4d61
[IMM32][SDK] Add CtfAImmIsIME, CtfImmSetAppCompatFlags etc. (#5862)
- Add CtfAImmIsIME, CtfImmIsCiceroStartedInThread and CtfImmSetAppCompatFlags functions.
- Implement CtfImmDispatchDefImeMessage function.
- Modify imm32.spec.
- Add the prototypes of ImmGetAppCompatFlags, CtfAImmIsIME, CtfImmIsCiceroStartedInThread,
  CtfImmSetAppCompatFlags, and CtfImmDispatchDefImeMessage into <imm32_undoc.h>.
CORE-19268
2023-11-02 08:16:12 +09:00
Katayama Hirofumi MZ b3194e320c
[IMM32][SDK] Add CtfAImmActivate/Deactivate functions (#5835)
- Add dll/win32/imm32/CtfImeTable.h for CTF
  IME functions.
- Implementing Imm32CheckAndApplyAppCompat,
  Imm32LoadCtfIme, and
  Imm32EnumCreateCtfICProc helper functions.
- Add CtfAImmActivate and CtfAImmDeactivate
  functions.
- s/CI_TFSDISABLED/CI_TSFDISABLED/
CORE-19268
2023-10-31 22:45:28 +09:00
Katayama Hirofumi MZ 8a049d0b68
[SHELL32][SDK] Implement CopyStreamUI (#5848)
- Modify shell32.spec.
- Add CopyStreamUI prototype to <undocshell.h>.
CORE-19278
2023-10-31 22:32:02 +09:00
Serge Gautherie 60b0afc3af
[BDASUP][KMIXER][MMIXER][STREAM] Replace meaningless YDEBUG (#5818)
bdasup: Addendum to 40c15ec (r46632).
kmixer: Addendum to 3e489bf (r42143).
mmixer: Addendum to c42d9f2 (r44872).
stream: Addendum to 4a0debf (r41662).
Serge plans a follow up that will remove all other remaining YDEBUG in the source tree.
The ones covered here he considered to be the most trivial ones.
2023-10-31 12:04:24 +00:00
Katayama Hirofumi MZ 128e7f5aea
[SHELL32][SDK] Implement SHStartNetConnectionDialogA (#5847)
and add SHStartNetConnectionDialog prototype to <shlobj.h>.
2023-10-28 22:29:05 +09:00
Katayama Hirofumi MZ a52c713755 [SHELL32][SDK] Follow-up of #5840 (ad5df2d)
Fix the parameters of Activate_RunDLL.
2023-10-28 21:31:11 +09:00
Katayama Hirofumi MZ ad5df2d199
[SHELL32][SDK] Implement Activate_RunDLL (#5840)
- Add Activate_RunDLL function implementation.
- Add Activate_RunDLL prototype to <undocshell.h>.
2023-10-28 14:56:27 +09:00
Katayama Hirofumi MZ 2ccdd87809
[SHELL32][SDK] Implement ShortSizeFormatW (#5829)
- Implement ShortSizeFormatW.
- Add ShortSizeFormatW prototype into <undocshell.h>.
- Modify shell32.spec.
2023-10-28 14:55:25 +09:00
Katayama Hirofumi MZ 81e936486e
[SHELL32] Implement ExtractIconResInfoA (#5846)
- Add ExtractIconResInfoA implementation.
- Add ExtractIconResInfo prototype to <undocshell.h>.
2023-10-28 11:38:29 +09:00