Skip to content

Handle validation of uxtheme.dll undocumented exported functions in ARM64 builds #1048

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

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

hmartinez82
Copy link
Contributor

@hmartinez82 hmartinez82 commented Feb 14, 2024

This is required for #1045 to continue.

For reference, here are the disassemblies:
AllowDarkModeForWindow():

00007FFB16C32450 D503237F             pacibsp  
00007FFB16C32454 A9BE53F3             stp         x19,x20,[sp,#-0x20]!  
00007FFB16C32458 F9000BF5             str         x21,[sp,#0x10]  
00007FFB16C3245C A9BF7BFD             stp         fp,lr,[sp,#-0x10]!  
00007FFB16C32460 910003FD             mov         fp,sp  
00007FFB16C32464 53001C33             uxtb        w19,w1  
00007FFB16C32468 D29523C1             mov         x1,#0xA91E  
00007FFB16C3246C AA0003F5             mov         x21,x0  
00007FFB16C32470 9400F226             bl          #GetPropW (07FFB16C6ED08h)
...

AllowDarkModeForWindowWithTelemetryId():

00007FFB16C33210 D503237F             pacibsp  
00007FFB16C33214 A9BE53F3             stp         x19,x20,[sp,#-0x20]!  
00007FFB16C33218 F9000BF5             str         x21,[sp,#0x10]  
00007FFB16C3321C A9BF7BFD             stp         fp,lr,[sp,#-0x10]!  
00007FFB16C33220 910003FD             mov         fp,sp  
00007FFB16C33224 53001C34             uxtb        w20,w1  
00007FFB16C33228 D29523C1             mov         x1,#0xA91E  
00007FFB16C3322C AA0003F5             mov         x21,x0  
00007FFB16C33230 9400EEB6             bl          #GetPropW (07FFB16C6ED08h)
...

SetPreferredAppMode():

00007FFB16C33E10 D503237F             pacibsp  
00007FFB16C33E14 F81F0FF3             str         x19,[sp,#-0x10]!  
00007FFB16C33E18 A9BF7BFD             stp         fp,lr,[sp,#-0x10]!  
00007FFB16C33E1C 910003FD             mov         fp,sp  
00007FFB16C33E20 D00007E8             adrp        x8,wil::details::g_enabledStateManager+40h (07FFB16D31000h)  
00007FFB16C33E24 B94BD913             ldr         w19,[x8,#0xBD8]  
00007FFB16C33E28 2A0003E1             mov         w1,w0  
00007FFB16C33E2C 912F6100             add         x0,x8,#0xBD8  
00007FFB16C33E30 97FF7910             bl          _InterlockedExchange (07FFB16C12270h)  
00007FFB16C33E34 2A1303E0             mov         w0,w19  
00007FFB16C33E38 A8C17BFD             ldp         fp,lr,[sp],#0x10  
00007FFB16C33E3C F84107F3             ldr         x19,[sp],#0x10  
00007FFB16C33E40 D50323FF             autibsp  
00007FFB16C33E44 D65F03C0             ret  
00007FFB16C33E48 B0000090             adrp        xip0,GetBufferedPaintBitsEx+7320h (07FFB16C44000h)
...

@hmartinez82 hmartinez82 changed the title Handle validation of undocumented uxtheme.dll exported functions in ARM64 builds Handle validation of uxtheme.dll exported undocumented functions in ARM64 builds Feb 14, 2024
@hmartinez82 hmartinez82 changed the title Handle validation of uxtheme.dll exported undocumented functions in ARM64 builds Handle validation of uxtheme.dll undocumented exported functions in ARM64 builds Feb 14, 2024
@SyntevoAlex
Copy link
Member

The code makes sense to me.
But I'm judging blindly without testing, let's wait until it can be smoke tested.

@hmartinez82 hmartinez82 reopened this Feb 14, 2024
@hmartinez82
Copy link
Contributor Author

How do you want to smoke test? :) these changes don't build standalone. They need @chirontt changes to be built. I thought the idea was for this to be merged so he can merge his

@SyntevoAlex
Copy link
Member

He will merge return FALSE, then your branch is rebased on top and tesred.

@chirontt
Copy link
Contributor

@hmartinez82 I've temporarily merged these changes of os_custom.c file to my PR and attempted to 'build' it, but the MSVC compiler complains about reinterpret_cast:

[INFO]      [exec] Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33135 for ARM64
[INFO]      [exec] Copyright (C) Microsoft Corporation.  All rights reserved.
[INFO]      [exec]
[INFO]      [exec]      cl -O1 /WX /W4 -DNDEBUG -DUNICODE -D_UNICODE /c   -DJNI64  -DSWT_VERSION=4964 -DSWT_REVISION=7 -DUSE_ASSEMBLER  /I"\apps\jdk-17.0.10+7_arm64\include" /I"\apps\jdk-17.0.10+7_arm64\include\win32" /I. os_custom.c
[INFO]      [exec] os_custom.c
[INFO]      [exec] os_custom.c(83): error C2065: 'reinterpret_cast': undeclared identifier

@hmartinez82
Copy link
Contributor Author

omg, it's C code, not C++ . I'll fix it in a moment 😅

@hmartinez82
Copy link
Contributor Author

@chirontt I've updated this PR with the new changes. They are the same, just using C casting instead of C++ ones.

@chirontt
Copy link
Contributor

Yes, it now compiles properly and the SWT binaries are generated for Arm64:

image

@SyntevoAlex how do we smoke test it, i.e. maybe not about the os_custom.c file itself, but about the generated *.dll modules? Do we have some C/Java tests for them already in the repo?

@SyntevoAlex
Copy link
Member

SyntevoAlex commented Feb 15, 2024

Snippet Bug562043_DarkTableNoHover.java should have dark scrollbars (expand some Tree item for scrollbar to appear).

But also set display.setData("org.eclipse.swt.internal.win32.useShellTitleColoring", true); and check that Shell's titlebar is dark.

@hmartinez82
Copy link
Contributor Author

@SyntevoAlex I can't test this. It will have to be @chirontt. I'll close this since he's incorporating it in his pull request.

I can't test this because I don't knwk to build anything that uses maven, :( I don't know how

@chirontt
Copy link
Contributor

@hmartinez82 you should wait for someone (@SyntevoAlex ?) to approve this PR and merge it to master, to claim credit for your excellent work. I don't plan to incorporate it into my PR. My plan is to remove this file from my PR.

@hmartinez82
Copy link
Contributor Author

hmartinez82 commented Feb 15, 2024 via email

@chirontt
Copy link
Contributor

Snippet Bug562043_DarkTableNoHover.java should have dark scrollbars (expand some Tree item for scrollbar to appear).

But also set display.setData("org.eclipse.swt.internal.win32.useShellTitleColoring", true); and check that Shell's titlebar is dark.

Yes, it works on my Arm64 box. I've built the org.eclipse.swt.win32.win32.aarch64-3.125.0-SNAPSHOT.jar which embeds the swt*.dll for Arm64, then run the Bug562043_DarkTableNoHover.java and it shows the dark scrollbars nicely, but with the lighted window title bar:

light-title

Then, as you suggested, I add the following statement to the Java code:

		display.setData("org.eclipse.swt.internal.win32.useShellTitleColoring", true);

and I get a window with dark title bar:

dark-title

and out of curiosity, I comment out this existing statement:

		display.setData("org.eclipse.swt.internal.win32.useDarkModeExplorerTheme", true);

then I get a window with both lighted title bar and scrollbars:

light-scrollbars

@chirontt
Copy link
Contributor

Further more, I've merged this PR to my Arm64 fork of this repo and built the complete Eclipse SDK, via the aggregator, and here's how it looks in Arm64:

Eclipse SDK

For comparison, in previous build I used the return FALSE; statements in the os_custom.c for Arm64, and here's how it used to look:

Eclipse SDK light

I think my testing is enough to confirm the working of this PR for Arm64.

@SyntevoAlex
Copy link
Member

SyntevoAlex commented Feb 17, 2024

Thanks for the detailed testing!

Yes, it can be merged, then.

Please squash commits into one nice commit.

Previous build failed for some weird reason, when you squash and push it will rebuild, hopefully well this time.

@iloveeclipse
Copy link
Member

Yes, it can be merged, then.

Please note, we are between M3 and RC1 time frame. Any merge requires extra review & PM approval.
https://www.eclipse.org/lists/platform-releng-dev/msg39974.html

@SyntevoAlex
Copy link
Member

SyntevoAlex commented Feb 17, 2024

Yes, I was checking mails right now... It says the feature freeze is on Feb 21 only?

Either way, I suggest to merge this PR, because it's under #elif defined(_M_ARM64) and therefore code changes may only affect arm64 build, which is not currently present.

@iloveeclipse please clarify what to do.

Copy link
Contributor

github-actions bot commented Feb 17, 2024

Test Results

   299 files  ±0     299 suites  ±0   5m 58s ⏱️ +22s
 4 100 tests ±0   4 092 ✅ ±0   8 💤 ±0  0 ❌ ±0 
12 212 runs  ±0  12 137 ✅ ±0  75 💤 ±0  0 ❌ ±0 

Results for commit 8a19fbe. ± Comparison against base commit 36c3b19.

♻️ This comment has been updated with latest results.

@hmartinez82
Copy link
Contributor Author

Rebased / squashed as requested

@iloveeclipse
Copy link
Member

please clarify what to do.

Please add your "approving" review on this PR.
Looking on code, I agree it shouldn't harm so OK to merge for RC1.

@SyntevoAlex SyntevoAlex self-assigned this Feb 17, 2024
@SyntevoAlex SyntevoAlex self-requested a review February 17, 2024 11:18
Copy link
Member

@SyntevoAlex SyntevoAlex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@SyntevoAlex
Copy link
Member

The branch built successfully.
I added my approval.

@SyntevoAlex
Copy link
Member

Everything looks good to me, I suggest to merge.

@SyntevoAlex
Copy link
Member

@iloveeclipse so, should I merge? Or approval from PM is still needed? Who is PM?
Also, oculd you please clarify if freeze is already in effect or only since Feb 21?

@merks
Copy link
Contributor

merks commented Feb 17, 2024

If everyone agrees it's very safe good to go, then it also has my +1 as a PMC member.

@SyntevoAlex SyntevoAlex merged commit f26f536 into eclipse-platform:master Feb 17, 2024
@SyntevoAlex
Copy link
Member

OK, merged.
@hmartinez82 thanks for your contribution!
It was a pleasure to see someone who's not scared of disasm :)

@hmartinez82 hmartinez82 deleted the oscommon_aarch64 branch February 17, 2024 18:34
@hmartinez82
Copy link
Contributor Author

@SyntevoAlex If you want to give me a gift. I wouldn't mind a local build of SmartGit for Windows on ARM64. You can even give it to me without the Java Runtime. I'll use Microsoft's Java 17 build for ARM64 :)

@tmssngr
Copy link
Contributor

tmssngr commented Mar 13, 2024

@hmartinez82 At the moment Windows/ARM has low priority for us. Please vote for https://smartgit.userecho.com/communities/1/topics/1416-windows-arm-support

@chirontt
Copy link
Contributor

@hmartinez82 Bad news: with recent Windows update to my Arm64 box, like this build:

image

these validation code no longer works, i.e. I get lighted scrollbars rather than dark ones. I guess Microsoft has updated/changed the uxtheme.dll file, so we may need your magical disassembly touch again :)

@hmartinez82
Copy link
Contributor Author

hmartinez82 commented Apr 13, 2024

Ok. I have the same version. I'll see what I can do.

@chirontt the function that changed is SetPreferredAppMode(). The other are still being validated. I'll create a PR soon.

@hmartinez82
Copy link
Contributor Author

hmartinez82 commented Apr 13, 2024

@chirontt I'll create the PR but you'll have to test it. I don't even know if the ordianal 135 is still SetPreferredAppMode(), but here is the disassembly:

00007FFA2A1D3E10 D503237F             pacibsp  
00007FFA2A1D3E14 F81F0FF3             str         x19,[sp,#-0x10]!  
00007FFA2A1D3E18 A9BF7BFD             stp         fp,lr,[sp,#-0x10]!  
00007FFA2A1D3E1C 910003FD             mov         fp,sp  
00007FFA2A1D3E20 B00007E8             adrp        x8,wil::details::g_enabledStateManager+40h (07FFA2A2D0000h)  
00007FFA2A1D3E24 B94BB913             ldr         w19,[x8,#0xBB8]  
00007FFA2A1D3E28 2A0003E1             mov         w1,w0  
00007FFA2A1D3E2C 912EE100             add         x0,x8,#0xBB8  
00007FFA2A1D3E30 97FF7910             bl          _InterlockedExchange (07FFA2A1B2270h)  
00007FFA2A1D3E34 2A1303E0             mov         w0,w19  
00007FFA2A1D3E38 A8C17BFD             ldp         fp,lr,[sp],#0x10  
00007FFA2A1D3E3C F84107F3             ldr         x19,[sp],#0x10  
00007FFA2A1D3E40 D50323FF             autibsp  
00007FFA2A1D3E44 D65F03C0             ret

@hmartinez82
Copy link
Contributor Author

@chirontt @SyntevoAlex #1172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants