New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIN32SS][LPK] Add BiDi support to menus and window captions #738
Conversation
Compiles and runs, until a menu is loaded...
Issue linger with last letter being corrupted
Now everything is being drawn properly
win32ss/gdi/ntgdi/freetype.c
Outdated
/* Draw via lpk */ | ||
if (!(fuOptions & (ETO_IGNORELANGUAGE | ETO_GLYPH_INDEX))) | ||
{ | ||
if(DrawUsingLPK(hDC, XStart, YStart, fuOptions, lprc, String, Count, &bLPKResult)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space between 'if' and '('.
win32ss/gdi/ntgdi/freetype.c
Outdated
|
||
Argument = IntCbAllocateMemory(ArgumentLength); | ||
|
||
if(!Argument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space between 'if' and '('.
win32ss/gdi/ntgdi/freetype.c
Outdated
/* copy rect */ | ||
if (lprc) | ||
{ | ||
Argument->rect.left = lprc->left; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Argument->rect = *(LPRECT)lprc;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
win32ss/gdi/ntgdi/freetype.c
Outdated
|
||
if (!NT_SUCCESS(Status)) | ||
{ | ||
*bResult = FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space.
win32ss/gdi/ntgdi/freetype.c
Outdated
{ | ||
_SEH2_TRY | ||
{ | ||
ProbeForRead(ResultPointer, sizeof(HMODULE), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From where did HMODULE come?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is based on what is in co_IntClientLoadLibrary
, which also a callback that uses string parameters. but will check if can be changed to BOOL
win32ss/gdi/ntgdi/freetype.c
Outdated
_SEH2_TRY | ||
{ | ||
ProbeForRead(ResultPointer, sizeof(HMODULE), 1); | ||
*bResult = *(BOOL*)ResultPointer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LPBOOL.
win32ss/user/user32/misc/dllmain.c
Outdated
|
||
Argument = (PLPK_CALLBACK_ARGUMENTS)Arguments; | ||
|
||
Argument->lpString = (PWCHAR)((ULONG_PTR)Argument->lpString + (ULONG_PTR)Argument); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysterious type casting.
what do you wanna do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See co_IntClientLoadLibrary
and User32CallClientLoadLibraryFromKernel
win32ss/user/user32/misc/dllmain.c
Outdated
Argument->count, | ||
NULL); | ||
|
||
return ZwCallbackReturn(&bResult, sizeof(HMODULE), STATUS_SUCCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HMODULE ditto.
[WIN32SS] Changed some castings to make more sense, simplified the rect copy. [GDI32] Added code in case of lpk.dll loading failed.[LPK] Fixed the propsheet bug in lpk.dll
Keep freetype.c clear from non font related code, moved function to rtl\text, now only will activated upon window captions and menus.
"Grey +" ? What's that? |
A 7-zip menu thing... |
Ah ok, so that's what they write instead of "Ctrl-+" etc... |
Fixes crash while installing Notepad++
win32ss/user/rtl/text.c
Outdated
|
||
return bResult; | ||
|
||
fallback: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the indentation.
win32ss/user/rtl/text.c
Outdated
return bResult; | ||
|
||
fallback: | ||
return GreExtTextOutW(hdc, x, y, flags, lprc, lpString, count, NULL, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce the indentation to 4 spaces.
|
||
Argument->lpString = (LPWSTR)((ULONG_PTR)Argument->lpString + (ULONG_PTR)Argument); | ||
|
||
bResult = ExtTextOutW(Argument->hdc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future this certainly will have to be generalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "generalization"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err forget what I've just said. I indeed see in the user32 symbols that there is indeed a special callback for ExtTextOutW (ClientExtTextOutW).
https://www.reactos.org/wiki/Techwiki:Win32k/apfnDispatch
win32ss/user/rtl/text.c
Outdated
} | ||
else | ||
{ | ||
Argument->bRect = FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're leaving rect
uninitialized here, which leaks kernel memory contents to user mode.
win32ss/user/rtl/text.c
Outdated
RtlStringCchCopyNW(Argument->lpString, count + 1, lpString, count); | ||
|
||
pStringBuffer -= (ULONG_PTR)Argument; | ||
Argument->lpString = (LPWSTR)(pStringBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little cumbersome. Why not set lpString
to the correct value in the first place, and use pStringBuffer
or some other value as the copy destination, e.g.
Argument->lpString = (LPWSTR)pStringBuffer;
pStringBuffer += (ULONG_PTR)Argument;
RtlStringCchCopyNW(pStringBuffer, ...);
Adding an extra callback is the way to go but morr changes are needed in the kernel mode part because doing a callback can have unpreidctable results. The thread coukd die in user mode and never return to free resources or the window pwnd could be destroyed while in user mode and we could end up with a stale pwnd pointrr this way. |
Hmm I don't see any such issues looking at the code. Are you able to point to specific instances? |
Zero rect struct member if not to be used. Simplify pointer arithmetic (Thanks for the suggestion!)
win32ss/user/rtl/text.c
Outdated
PVOID ResultPointer; | ||
ULONG ResultLength; | ||
ULONG ArgumentLength; | ||
ULONG_PTR pStringBuffer = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not need to be zero-initialized.
win32ss/user/rtl/text.c
Outdated
mimicks code from co_IntClientLoadLibrary */ | ||
Argument->lpString = (LPWSTR)pStringBuffer; | ||
pStringBuffer += (ULONG_PTR)Argument; | ||
RtlStringCchCopyNW((LPWSTR)pStringBuffer, count + 1, lpString, count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably check the return from this.
Added documentation to explain the use of the callback function. Address comments.
Any opinions on should I include the changes that are mentioned in: |
Hi! I think that the changes mentioned in the forum should be done in a separate PR. |
Purpose
Added callback function that redirects calls to GreExtTextOutW that didn't went through lpk BiDi processing, calls that are from the kernel.
Completely solves JIRA issue CORE-6910