ysc3839 / win32-darkmode

Example application shows how to use undocumented dark mode API introduced in Windows 10 1809.
MIT License
437 stars 48 forks source link

Small stability improvement #5

Closed DVSProductions closed 4 years ago

DVSProductions commented 4 years ago

If comctl32.dll has not been loaded for some reason, FixDarkScrollBar will crash the application. The changes in IatHook.h ensure that a null moduleBase is not accepted and FixDarkScrollBar returns without crashes. (This may not be immediately relevant to the demo application, but the issue may arise in derivatives)

The second fix is for reinterpret_cast<HANDLE>(dark). If the application is built for 64 bit systems HANDLE converts to a void * with a width of 64 Bit. But BOOL remains an int. Reinterpreting the smaller type to a larger one can potentially cause fatal crashes because the new 32 bits are random data. To fix this I have added a preprocessor check, but this may be solved a bit more elegantly.

ysc3839 commented 4 years ago

Thanks for pointing out bus and I used another way to fix. https://github.com/ysc3839/win32-darkmode/commit/1fe9d131b7d1973ffbf1f98675fd6b402b238434 https://github.com/ysc3839/win32-darkmode/commit/bb241c369fee7b56440420179654bb487f7259cd