valinet / WinCenterTitle

WinCenterTitle is a simple tool that allows you to center align the text in Windows 10 titlebars, the same way it was in Windows 8, 8.1, or even 3.1.
GNU General Public License v2.0
153 stars 16 forks source link

1.2.0.0 is incompatible with 1809 #14

Open SupahMario opened 3 years ago

SupahMario commented 3 years ago

Attempting to run 1.2.0.0 in the 1809 version of Windows results in the title text not budging, however symbols are still downloaded. Folder permissions are correct. Trying to run this in a 20H2 VM works fine. 1.1.0.0 also works fine. Kinda not surprised about this, so it's up to you if you want to add in compatibility. Would give more info if there was a log feature.

valinet commented 3 years ago

Yeah, 1.1.0.0 is pretty universal, but is not 100% correct, as the title is centered between icon and caption buttons, not relative to the entire width. 1.2.0.0 is the correct way, but is dependent on function and struct (classes) offsets from dwm which probably are different (or maybe even some program logic changed). Logs are not meaningful, it either works, either does not and mostly likely crashes or bugs out dwm. One has to look on the disassembly of uDWM.dll from 1809, compare it to the one in 2004/20h2/21h1 which is the same and see what differs there compared to here. Indeed, I was using 20xx when developing, so I have tested only on that. 1809 I presume is the LTSC, that’s why you are still on that, right? I don’t have much time to work on this anymore, if I ever find a time window, maybe I will add support, but I can’t promise anything. Thanks.

SupahMario commented 3 years ago

Yes, 1809 is one of the LTSC releases. I appreciate your consideration.

valinet commented 3 years ago

So, I looked a bit on uDWM from 1809. It is almost the same if not actually the same as the rest, everything is there except the CMatrixTransformProxy::Update function.

That function, in newer versions, is almost like a stub, a function that just calls another function with more or less the same parameters it got, but it is very useful since it adds assembly, it add calls, which means possibilities of hooking.

On 1809, that function does not exist. 0 is loaded into some registry (0 which means start drawing the text from the left edge of the rectangle), and then some instructions are performed which are required. Setting the registry to 0 takes 3 octets, which is not enough for a jump. That's how I see it now. The next call is what we actually would have to hook, but it is a dynamic dispatch call so I don't know statically where it goes, I could run it and see, only thing is debugging DWM is pretty impossible, on the same machine I mean, since if you enter it in a breakpoint, nothing updates on the screen.

So all in all it is a very interesting challenge, harder than what's in the new versions, that's for sure. Funny thing is, it probably looks the same in both versions in the high level language, it just compiled rather differently due to optimization flags or who knows what.

As I said, it is a nice challenge, it should be given as homework in faculty. It's fun and teaches you a lot, that's how I learned as well. Maybe if I ever have time and the mood to have some fun with it, I will actually attempt something even more hands on with it.