Commit graph

244 commits

Author SHA1 Message Date
Timo Kreuzer 402bc38ba7 [NTGDI] Rewrite NtGdiPolyDraw
It is now a wrapper around GdiPolyDraw, which implements the main body of the function, while the Nt function only probes and captures the user mode data into safe kernel mode buffers.
Previously some people thought it was a great idea to just wrap the entire implementation in SEH, so when something throws an exception somewhere for whatever reason, we can just catch it here... and LEAK ALL RESOURCES IN THE PROCESS!
TODO: Rewrite all of this. It's broken everywhere.
2024-09-12 15:52:30 +03:00
Timo Kreuzer 9414fb6b59 [NTGDI] Prevent NULL pointer dereference in CLIPPING_UpdateGCRegion
This can happen, when the paged pool is full. This will probably cause drawing issues, but at least we don't crash (in this place).
2024-09-08 03:20:52 +03:00
Doug Lyons a1bff5b94e
[NTGDI:FREETYPE] Account for spaces in x-dimension of IntExtTextOutW function (#7274)
@I_Kill_Bugs fix

CORE-11787, CORE-17721 and CORE-19721

For function IntExtTextOutW with space character, the x-dimension should be taken into account.
Fixes HexEdit 1.2.1 right side of display window not being cleared.

Account for x-dimension if TA_UPDATECP flag set and 'String' is not NULL.

Clarify 'etx' is ASCII End of Text
2024-09-01 13:18:23 -05:00
George Bișoc 560428e250
[WIN32K] Add debug switch for the Win32 power manager 2024-07-13 11:30:07 +02:00
Oleg Dubinskiy 04f04efc96
[NTGDI] FontLink: avoid invalid font name buffer freeing (#7131)
Don't free the linked font name if it's already NULL. Since it is allocated only once (when loading the font name from Registry), it should be freed only once too. All subsequent freeing attempts will result in invalid pool freeing.
This fixes the 0xC2 BAD_POOL_CALLER bugcheck when trying to resize window (and draw more text) from soundcloud.com in K-Meleon 76.5.4 Goanna engine and when switching between channels (during redrawing the text) in DiscordMessenger v1.06 Beta.
Addendum to 0f9e889736.
CORE-19681
2024-07-11 14:27:26 +02:00
Katayama Hirofumi MZ 61cdd02d1c
[NTGDI] Fix MaskBlt error code and check pattern usage (#7083)
Follow-up to #7074. Fix MaskBlt behaviour.
JIRA issue: CORE-13133
- Fix MaskBlt error code.
- Fix MaskBlt pattern usage check.
2024-07-06 13:28:26 +09:00
Katayama Hirofumi MZ a207a3c931
[NTGDI][FREETYPE] Fix FontLink freeze (#7063)
#7009 introduced unexpected freezing on gdi* bot tests.
JIRA issue: CORE-19667
Fix the locking-related assertions by adding/removing
lock/unlock.
2024-07-01 22:34:59 +09:00
Katayama Hirofumi MZ 0f9e889736
[NTGDI][FREETYPE][SETUP][INF] Support FontLink (#7009)
If East Asian people were unable
to see the Latin characters, it
becomes a barrier to mutual
understanding.
FontLink will break that barrier.
JIRA issue: CORE-9616
JIRA issue: CORE-15480
- Modify font substitutes.
- Unify the lock variables.
- Add FONTLINK and
  FONTLINK_CHAIN structures.
- Add FontLink_Create and
  FontLink_Destroy functions.
- Add FontLink_Chain_Init,
  FontLink_Chain_Free,
  FontLink_Chain_LoadReg,
  FontLink_Chain_Populate, and
  FontLink_Chain_FindGlyph
  functions.
- Implement FontLink.
- Add font file DroidSansFallback.ttf
  for LiveCD.
2024-06-30 22:15:34 +09:00
Doug Lyons 6190a97df4
[NTGDI][FREETYPE] Multiple indirect Font Substitutes fix for Factusol (#7020)
Fixes double use of Font Substitutes "Helv" -> "MS Sans Serif" -> "Tahoma".
2024-06-15 17:08:59 -05:00
Katayama Hirofumi MZ 890b9c0b93
[NTGDI][FREETYPE] Simplify get_glyph_index_flagged (#6977)
Simplify code.
JIRA issue: CORE-9616
- Reduce one parameter of get_glyph_index_flagged function.
2024-06-03 09:28:52 +09:00
Katayama Hirofumi MZ a541a468ba
[NTGDI][FREETYPE] Unload font engine on system shut-down (#6955)
Check system integrity by explicitly
releasing the font engine.
JIRA issue: CORE-9616
- Use RTL_STATIC_LIST_HEAD against
  g_FontListHead and
  g_FontCacheListHead variables and
  omit initialization of them.
- Implement FreeFontSupport function.
- Call FreeFontSupport in win32k!
  DriverUnload function.
- Fix some usages of
  CONTAINING_RECORD macro.
2024-05-29 09:41:39 +09:00
Oleg Dubinskiy 96acfcb3dc
[NTGDI] AlphaBlend/TransparentBlt: check whether the source DC is an INFO DC too (#6885)
Improve checks in AlphaBlend and TransparentBlt functions: check whether DCSrc is of DCTYPE_INFO also, to fail in that case properly too.
Spotted by PVS-Studio analysis.
Reference: https://pvs-studio.com/en/blog/posts/cpp/1122/.
2024-05-14 19:08:37 +02:00
Katayama Hirofumi MZ 5a287473fd
[NTGDI][FREETYPE] Initial support of Surrogate Pairs and emojis (#6851)
Support emoji characters and minor characters.
JIRA issue: CORE-19030
NOTE: Not every emoji is supported yet (No ZWJ support). Surrogate pairs only.
NOTE: This feature only works if the appropriate font is selected.
- Add IS_HIGH_SURROGATE and
  IS_LOW_SURROGATE macros.
- Add Utf32FromSurrogatePair helper function
  to convert a surrogate pair to a UTF-32 code
  point.
- Convert the surrogate pairs in the text in
  TextIntGetTextExtentPoint, IntGetTextDisposition,
  and IntExtTextOutW functions.
2024-05-07 15:24:34 +09:00
Katayama Hirofumi MZ d076146f4e
[NTGDI][FREETYPE] Check 'No transformation' for performance (#6850)
Slight performance improvement.
JIRA issue: CORE-15554
- Add bNoTransform variable.
- Check whether mat is identity matrix.
- If so, then don't do FT_Vector_Transform.
2024-05-07 11:14:16 +09:00
Katayama Hirofumi MZ 521eb0c7c0
[NTGDI][FREETYPE] Increase STACK_TEXT_BUFFER_SIZE (#6847)
Slight performance improvement. STACK_TEXT_BUFFER_SIZE = 100 was too small
for long text. This PR can reduce unnecessary buffer allocations in NtGdiExtTextOutW
function.
JIRA issue: CORE-15554
- Change STACK_TEXT_BUFFER_SIZE to 512.
2024-05-06 20:39:26 +09:00
Katayama Hirofumi MZ 0056313e15
[NTGDI][FREETYPE] Simplify code around bold/italic glyph caches (#6846)
Simplify and reduce font code.
JIRA issue: CORE-15554
- Don't treat bold/italic glyphs specially in font cache.
- Delete useless IntGetBitmapGlyphNoCache function.
2024-05-06 19:17:09 +09:00
Katayama Hirofumi MZ 3768f0893d
[WIN32SS] Fix const-ness of registry helper functions (#6525)
Improve code quality.
JIRA issue: CORE-19360
- Fix const-ness of the arguments
  of win32k registry helper functions.
- Compact UserIsIMMEnabled function.
2024-02-23 21:26:12 +09:00
Serge Gautherie bf7e7c2383
[WIN32SS:GDI] eng/error.c: Minor code tweaks (#6128)
- Remove a useless debug.h include.
- Use the initialized pTeb pointer.
- Remove a useless else.
- Add a SAL2 annotation.
2023-12-17 22:13:45 +01:00
Katayama Hirofumi MZ 0bfa0cd0d2
[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
2023-11-26 11:46:42 +09:00
Serge Gautherie 24757e30e9
[NTDDRAW][NTGDI][VGADDI] Add missing \n to DPRINT() calls (#5952)
Add missing \n to DPRINT() calls and demote some DPRINT1().
2023-11-15 21:07:27 +01:00
Katayama Hirofumi MZ 2a16fc5e19
[NTGDI] GetPixel's return top byte is zero if valid (#5677)
According to the results of CImage testcase,
the top byte of the GetPixel() return value is
zero if the return is a valid color.
Do bitwise-AND operation if the color value is valid.
CORE-19008
2023-09-12 05:56:36 +09:00
Andriy Shevchenko 2ea03b5b22
[REACTOS] Fix typos in comments (#5591)
Fixing typos in code comments enhances code readability and comprehension for developers and collaborators.
2023-08-22 16:20:29 +03:00
Joachim Henze 53b30e3f3b [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.
2023-08-01 22:32:25 +02:00
Doug Lyons 12e1919e5e
[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
2023-07-02 13:24:15 +02:00
Oleg Dubinskiy 114bc2b96e
[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>
2023-06-11 13:44:56 +02:00
Julio Carchi a999c43746
[NTGDI] Check if face->charmap is not zero before accessing its encoding (#4390)
This allows DevExpress Ribbon Notepad sample to start.

Also add a fat DPRINT1 suggested by Timo Kreuzer,
because there is a lot wrong in the code.

CORE-18091 CORE-18558
2023-01-18 21:24:40 +03:00
Serge Gautherie 8efde69a25
[WIN32K:NTGDI] PATH_PathToRegion(): Update documentation (#4941)
Addendum to 215e0d9 (r64177).
2022-12-22 01:27:51 +01:00
Timo Kreuzer a206b55838 [WIN32K] Fix memory leak on failure in REGION_SetPolyPolygonRgn 2022-12-13 07:18:24 +01:00
Timo Kreuzer 4f0f5f6ff8 [WIN32K] Fix a bug in PATH_PathToRegion 2022-12-13 07:18:24 +01:00
Timo Kreuzer 84b09285c8 [WIN32K] Fix missing NULL check in NtGdiPathToRegion 2022-12-13 07:18:24 +01:00
Timo Kreuzer 60af8194bb [WIN32K] Fix uninitialized variable in IntExtTextOutW 2022-12-13 07:18:24 +01:00
Katayama Hirofumi MZ 11ee1fa88e [NTGDI][FREETYPE] Follow-up of #4920 (e316d61); Rename functions
Follow the naming policy.

- ftGdiGetRealGlyph --> IntGetRealGlyph
- ftGdiGlyphCacheGet --> IntFindGlyphCache
- ftGdiGlyphSet --> IntGetBitmapGlyphNoCache
- ftGdiGlyphCacheSet --> IntGetBitmapGlyphWithCache
- FtMatrixFromMx --> IntMatrixFromMx

CORE-11848
2022-12-04 22:11:46 +09:00
Katayama Hirofumi MZ e316d61215
[NTGDI][FREETYPE] lfEscapement for TextOut (#4920)
Rotation and shearing transformation of font/text is now available. Retrial of PR #1207.
- Rename ftGdiGetTextWidth as IntGetTextDisposition and add a Y parameter.
- Apply lfEscapement values (by multiplying matrices).
- Add IntEngFillPolygon and IntEngFillBox helper functions.
CORE-11848
2022-12-03 13:03:28 +09:00
Timo Kreuzer 9fc56bfc9d [WIN32K] Fix missing NULL check in IntCreateDIBitmap 2022-12-01 20:17:40 +02:00
Katayama Hirofumi MZ 138eb58b95
[NTGDI][FREETYPE] lfWidth for GetTextMetrics and GetCharWidth (#4919)
- Add lfWidth member into FONTGDI structure.
- Delete IntWidthMatrix function.
- Fix IntRequestFontSize behavior for processing lfWidth value.
- Apply lfWidth in GetTextMetrics and GetCharWidth.
- Ignore the XFORM values in GetTextMetrics and GetCharWidth.
CORE-11848
2022-12-01 08:54:39 +09:00
Katayama Hirofumi MZ 4d0d22aee2
[NTGDI][FREETYPE] Add special structure for hashing (#4916)
Add FONT_CACHE_HASHED structure and use it.
CORE-11848
2022-11-29 19:41:09 +09:00
Katayama Hirofumi MZ b85f0056a8
[NTGDI][FREETYPE] lfWidth for GetTextExtentPoint32 (#4912)
- Apply LOGFONT.lfWidth in TextIntGetTextExtentPoint function.
- Delete XFORM transformation in TextIntGetTextExtentPoint (to be simply ignored).
CORE-11848
2022-11-28 07:34:58 +09:00
Katayama Hirofumi MZ 015cd2596c [NTGDI][FREETYPE] Follow-up of #4901 (57702ed)
- Drop APIENTRYs for static functions.
- Use FIELD_OFFSET instead of offsetof.
- Delete unnecessary ASSERTs.
- Add annotations.
CORE-11848
2022-11-27 12:42:25 +09:00
Katayama Hirofumi MZ 57702ed401
[NTGDI][FREETYPE] Font cache: Use hash (#4901)
- Modify FONT_CACHE_ENTRY structure to use hash.
- Use hash in ftGdiGlyphCacheGet and ftGdiGlyphCacheSet functions.
- Reduce function call overheads by using FONT_CACHE_ENTRY, in getting glyph.
CORE-11848
2022-11-27 11:26:44 +09:00
Katayama Hirofumi MZ 3f3714bad4
[NTGDI][FREETYPE] Font cache: Use FT_Matrix instead of MATRIX (#4900)
- Use FT_Matrix instead of MATRIX in FONT_CACHE_ENTRY structure.
- Use FtMatrixFromMx and FT_Set_Transform instead of FtSetCoordinateTransform.
CORE-11848
2022-11-25 11:23:29 +09:00
Katayama Hirofumi MZ 375b02f337 [NTGDI][FREETYPE] Simplify IntRequestFontSize and FONTGDI
FONTGDI.lfWidth and FONTGDI.EmHeight are not used.
Simplify code without setting these members.
CORE-11848
2022-11-24 14:18:20 +09:00
Katayama Hirofumi MZ 476f94c0fe [NTGDI][FREETYPE] Formatting code; Follow up #4865 (a620c6f)
CORE-11848
2022-11-24 12:28:10 +09:00
Katayama Hirofumi MZ a620c6f82e
[NTGDI][FREETYPE] Simplify font rendering (#4865)
- Add ftGdiGetRealGlyph and ftGdiGetTextWidth helper functions.
- Optimize font rendering.
CORE-11848
2022-11-24 11:51:04 +09:00
Katayama Hirofumi MZ a2c6af0da4
[BOOTDATA][NTUSER] Add UserIsIMMEnabled and use it (#4882)
This PR enables SRVINFO_IMM32 also for non-CJK. You can disable this flag by setting zero to the LoadIMM registry value if you're non-CJK.
CORE-11700
2022-11-15 17:10:06 +09:00
Katayama Hirofumi MZ 0bc6bd6480
[NTGDI][NTUSER][INCLUDE] Add 'See also:' comments for structures (#4872)
Add 'See also' URLs to some undocumented structures.
2022-11-12 20:27:50 +09:00
Katayama Hirofumi MZ 9f36a9d4a7
[NTGDI][FREETYPE] Optimize MatchFontNames (#4861)
Optimize MatchFontNames helper function for speed.
CORE-15554
2022-11-08 16:35:01 +09:00
Katayama Hirofumi MZ 467768f766
[NTGDI][FREETYPE] Reduce font size request (#4862)
- Delete some IntRequestFontSize function calls.
- Enable cache on font size requests.
- Add two members into FONTGDI structure, for font size cache.
CORE-15554
2022-11-08 16:31:10 +09:00
Thamatip Chitpong dd75ae8eca
[WIN32SS] Use GDI_HANDLE_* macros for readability (#4797) 2022-10-26 02:17:01 +02:00
Timo Kreuzer 090ccb3d8e [WIN32K] Add missing NULL checks
Also fix an old copy-pasta.
2022-08-04 16:15:24 +02:00
Oleg Dubinskiy 31139c253f
[WIN32SS][NTDDRAW][NTGDI] Implement some DxEng* callbacks (#3638)
Implement the following DxEng* functions:
- DxEngAltLockSurface
- DxEngDeleteSurface
- DxEngReferenceHdev
- DxEngSelectBitmap
- DxEngSetBitmapOwner
- DxEngUnreferenceHdev

Update their prototypes and call the appropriate win32k functions
inside them, since they are already implemented. Also get rid of
now unused IntGdi(Un)ReferencePdev, whose were called only by dxeng,
and whose are not used anymore. In Windows, DxEng(Un)ReferenceHdev calls
PDEVOBJ_vReferencePDEV and PDEVOBJ_vDeferencePDEV directly (those
correspond to our PDEVOBJ_vReference and PDEVOBJ_vRelease accordingly).

Required by MS DirectDraw stack (ddraw.dll & dxg.sys). CORE-17561
2022-06-01 00:58:35 +03:00