[NTGDI] Fix PatBlt with negative values (#6038) When I am implementing the IME soft keyboard (#6021 and #6036), I noticed an issue with PatBlt function. - Fix the rectangle coordinates when the value was negative in NtGdiPatBlt function. - Fix NC_DrawFrame function. - Fix UserDrawWindowFrame function. CORE-19334
[WIN32K][NTOS] Fix parameter to MmMapViewOfSection The code was passing 0 instead of SECTION_INHERIT::ViewUnmap (2). 0 isn't even a proper constant to be used here. It worked, because MmMapViewOfSection only compares against ViewShare (1) and treats everything else as ViewUnmap.
[GDI32] CreateDIBSection: Remove erroneous assignation (#5502) bmBits is only used and assigned on output. It points (holds the address) to the array of DIB bit values. The "Bits" parameter is however a pointer to a variable that will receive the address of that array. So it makes no sense to initially assign bmBits to the value of the Bits parameter...
[NTOSKRNL][NTGDI] Formatting addendum, no functional change I intend to port back the combined work of Thomas Faber and Serge Gautherie in context of CORE 14271. Both developers fixed wrong retval evaluations for SeSinglePrivilegeCheck() and RtlCreateUnicodeString(). Both functions do return a BOOLEAN, and therefore using NTSTATUS() on them is wrong. Those bugs have been fixed at multiple places. That is long gone. But Serge fixed his locations a bit more elegantly, without the need for additional variables. Therefore this addendum adapts a few of Thomas locations to the improved Serge-ified style. Yes: I intentionally used a space instead of a minus after the mentioned CORE 14271, as I don't want that pure stylistic addendum to be linked with the initial ticket anymore. That would be overkill.
[NTGDI][GDI32] Icon fixes for Office 2000, VB6, and Hoyle Cards (#5227) Many thanks for Simone Lombardo for pointing to the code needing attention and providing a working proof-of-concept solution. CORE-12377 CORE-18084 CORE-13889
[WIN32SS][ENG][NTDDRAW] Manage DirectDraw instances when switching display mode (#4519) CORE-17932 [ENG] Implement DirectDraw management in switch display mode functions (e.g. resolution change, color depth, display frequency etc.): - Switch DirectDraw instances between the two PDEVs (the current one and the new one allocated by ourselves) by calling dxg!DxDdDynamicModeChange function. - Suspend them before and resume after the display mode switch, by calling dxg!DxDdsuspendDirectDraw and dxg!DxDdResumeDirectDraw appropriately. We currently don't have these functions implemented, but MS DXG has, so it allows to properly manage DirectDraw PDEVs using this driver, similarly to Windows. My analysis confirms that these functions are always called in XP/2k3 on display mode switch, even when there is no any DirectX app running at the moment. Analyzing their prototypes show that my guesses are correct. - Initialize hDev and dhpdev members for EDD_DIRECTDRAW_GLOBAL for newly created surfaces, switch them during mode change and re-initialize after it also. They are commonly used by DirectDraw stack. In addition, enable DirectDraw for old and new PDEVs, by calling dxg!DxDdEnableDirectDraw function. [NTDDRAW] Additionally, fix usage of DirectDraw lock count in the PDEVOBJ structure. - Enable cDirectDrawDisableLocks member for storing its value, instead of DxDd_nCount, which is marked as ROS-specific. - Use it in win32k!DxEngGet/SetHdevData for getting/setting DirectDraw count appropriately. My analysis also shows that in Windows, the PDEVOBJ::cDirectDrawDisableLocks method calls DxEngGetHdevData with type 8, which corresponds to our DxDd_nCount. So there are no doubts that this member is used there. - Rename DxEngGetHdevData_dd_count alias of type 8 to DxEngGetHdevData_dd_locks, to match more accurately an actual member name. Update the enumeration and fix all code parts appropriately. All these changes allow to properly change display mode during executing DirectDraw applications, when they try to switch in full-screen mode. At least a bugcheck that happened before my changes, does no longer appear. There are still some games that don't run correctly, as if there is no 3D acceleration (which actually exists). This requires further investigations.
[NTGDI][NTUSER] Load DirectX graphics driver at system startup (#4551) CORE-18221 Load the DirectX graphics kernel driver (dxg.sys) by win32k at WINSRV initialization time, in NtUserInitialize(). Keep it always loaded in memory, as on Windows, instead of loading it only by DirectX dlls. This fixes the problem of acessing this driver: we need only to call DxDdEnableDirectDraw() and do other stuff when DirectDraw/Direct3D is required by anything. In other cases, it is called from win32k PDEV functions when changing display mode (as in Windows). Since it's used by other things too, it needs to be always loaded. Otherwise, if it's not loaded, its APIs are not accessible when needed, and execution fails. For example, it fixes display mode change problem in VMWare, when a new mode fails to be applied. Indeed, when it manages DirectDraw stuff, it calls DXG routines, and therefore fails if dxg.sys isn't loaded in memory at this moment. - Implement InitializeGreCSRSS() initialization routine, that initializes supplemental NTGDI/GRE data once CSRSS and WINSRV are loaded: * Call DxDdStartupDxGraphics() inside it, which loads dxg.sys. * Additionally, move fonts and language ID initialization there, from win32k!DriverEntry. Confirmed by analysis on Windows. - Call InitializeGreCSRSS() in NtUserInitialize() main initialization routine (called by WINSRV initialization). Moved to NTGDI from previously NTUSER place: Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
[WIN32SS:ENG] Do not free LDEV if unloading a driver failed Currently, LDEVOBJ_bUnloadImage always returns FALSE due to missing functionality in ntoskrnl. LDEVOBJ_vFreeLDEV contains an assert that driver is correctly unloaded before freeing it. Prevent this assert by calling LDEVOBJ_vFreeLDEV only if LDEVOBJ_bUnloadImage succeed. This can be easily triggered if DrvEnableDriver function (called in LDEVOBJ_bEnableDriver) fails.