Skip to content

Commit

Permalink
high dpi support
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorwiktor12 committed Jun 29, 2024
1 parent a78f8fe commit 87ea519
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 107 deletions.
2 changes: 1 addition & 1 deletion ConsoleLogonHook/ui/ui_securitycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void uiSecurityControl::InitHooks(uintptr_t baseaddress)
void** SecurityOptionControlVtable = (void**)REL(memory::FindPatternCached<uintptr_t>("SecurityOptionControlVtable", { "48 8D 05 ?? ?? ?? ?? 48 83 63 48 00 48 83 63 50 00 48 83 63 58 00 48 83 63 68 00 83 63 70 00 48 89 43 08","48 8D 05 ?? ?? ?? ?? 48 89 43 08 48 8D 05 ?? ?? ?? ?? 48 89 43 30 48 89 6B 48"}), 3);

SecurityOptionControl_Destructor = (decltype(SecurityOptionControl_Destructor))(SecurityOptionControlVtable[7]);
SecurityOptionsView__RuntimeClassInitialize = memory::FindPatternCached<decltype(SecurityOptionsView__RuntimeClassInitialize)>("SecurityOptionsView__RuntimeClassInitialize", { "55 56 57 41 56 41 57 48 8B EC 48 83 EC 30" },true);
SecurityOptionsView__RuntimeClassInitialize = memory::FindPatternCached<decltype(SecurityOptionsView__RuntimeClassInitialize)>("SecurityOptionsView__RuntimeClassInitialize", { "55 56 57 41 56 41 57 48 8B EC 48 83 EC 30 49 8B D8","55 56 57 41 56 41 57 48 8B EC 48 83 EC 30" },true);
//CredUIManager__ShowCredentialView = memory::FindPatternCached<decltype(CredUIManager__ShowCredentialView)>("CredUIManager__ShowCredentialView", "48 89 5C 24 08 55 56 57 41 54 41 55 41 56 41 57 48 8B EC");
SecurityOptionsView__Destructor = memory::FindPatternCached<decltype(SecurityOptionsView__Destructor)>("SecurityOptionsView__Destructor", { "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 8B F2 48 8B D9 48 8B 79 78 48 83 61 78 00","48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 48 8B 79 78 8B F2 48 83 61 78 00 48 8B D9"});

Expand Down
9 changes: 8 additions & 1 deletion ConsoleLogonHook/ui/ui_userselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ __int64 SelectableUserOrCredentialControl__RuntimeClassInitialize_Hook(void* _th

std::wstring sid = L"";
auto hr = GetSIDStringFromUsername(wrapper.GetText().c_str(), &sid);
auto path = GetProfilePicturePathFromSID(sid.c_str());

//Use higher res image for dpis higher than 96
bool bHighRes = false;
int DPI = GetDpiForSystem();
if (DPI > 96)
bHighRes = true;

auto path = GetProfilePicturePathFromSID(sid.c_str(), bHighRes);

external::SelectableUserOrCredentialControl_Create(wrapper.actualInstance, path);

Expand Down
5 changes: 3 additions & 2 deletions ConsoleLogonUI/ConsoleLogonUI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>comctl32.lib;gdiplus.lib;dwmapi.lib</AdditionalDependencies>
<AdditionalDependencies>comctl32.lib;gdiplus.lib;dwmapi.lib;gdi32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -145,7 +145,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>comctl32.lib;gdiplus.lib;dwmapi.lib</AdditionalDependencies>
<AdditionalDependencies>comctl32.lib;gdiplus.lib;dwmapi.lib;gdi32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand All @@ -156,6 +156,7 @@
<ClCompile Include="ui\dui_selectedcredentialview.cpp" />
<ClCompile Include="ui\dui_statusview.cpp" />
<ClCompile Include="ui\dui_userselect.cpp" />
<ClCompile Include="util\util.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="dui\dui_includes.h" />
Expand Down
3 changes: 3 additions & 0 deletions ConsoleLogonUI/ConsoleLogonUI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<ClCompile Include="ui\dui_manager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="util\util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="spdlog\cfg\argv.h">
Expand Down
Binary file added ConsoleLogonUI/resources/Bitmap1120.bmp
Binary file not shown.
Binary file added ConsoleLogonUI/resources/Bitmap2120.bmp
Binary file not shown.
2 changes: 2 additions & 0 deletions ConsoleLogonUI/resources/ConsoleLogonUI.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ IDUIF_SELECTEDCREDENTIALVIEW UIFILE "selectedcredentialview.xml"
IDUIF_STATUSVIEW UIFILE "statusview.xml"
IDUIF_USERSELECT UIFILE "userselect.xml"
IDB_BRAND BITMAP "Bitmap120.bmp"
IDB_BRAND2 BITMAP "Bitmap1120.bmp"
IDB_BRAND3 BITMAP "Bitmap2120.bmp"
IDB_SPINNER1 BITMAP "Bitmap5000.bmp"
IDB_SPINNER2 BITMAP "Bitmap5001.bmp"
IDB_SPINNER3 BITMAP "Bitmap5002.bmp"
Expand Down
109 changes: 49 additions & 60 deletions ConsoleLogonUI/resources/Main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<if class="status">
<element background="argb(0,0,0,0)" foreground="argb(255,255,255,255)" shadowintensity="75" fontsize="18pt" fontstyle="Shadow" padding="rect(24rp,0,0,100rp)"/>
</if>
<if class="branding">
<element background="resbmp(107,7,-1,0,0,1,1)"/>
</if>


<if id="atom(Background)">
<element background="resbmp(113,4,-1,0,0,0,0)"/>
Expand All @@ -28,73 +26,71 @@
</if>
</if>

<if class="ShutDownFrame">
<element margin="rect(6rp, 0rp, 6rp, 0rp)"/>
</if>



<if class="ShutdownButton">
<button width="38rp" height="28rp" borderthickness="rect(4rp,1rp,4rp,1rp)" background="resbmp(12296,7,-1,0,0,0,0,library(au7hui.dll))"
margin="rect(0,0,0,0)" accdesc="resstr(12128)" bordercolor="gray" borderstyle="raised"/>

<if selected="true">
<button content="resbmp(12216,2,-1,0,0,0,0,library(au7hui.dll))" accdesc="resstr(12133)" bordercolor="windowtext" borderstyle="solid"/>
<if id="atom(buttonEaseOfAccess)">
<button width="38rp" height="28rp" padding="rect(0,0,0,0)" contentalign="MiddleCenter" content="resbmp(12213,2,-1,0,0,0,1,library(au7hui.dll))" accname="resstr(12122)" accdesc="resstr(12122)" borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12263,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="gray" borderstyle="raised"/>
<if keyfocused="true">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12259,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused="true">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12260,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if keyfocused="true" mousefocused="true" pressed="false">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12261,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if pressed="true">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12262,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
</if>
</if>

<if id="atom(ToggleTabletKeyboard)">
<button width="45rp" height="28rp" padding="rect(0,0,0,0)" content="resbmp(12214,2,-1,0,0,0,1,library(au7hui.dll))" accname="resstr(12142)" accdesc="resstr(12142)" borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12263,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="gray" borderstyle="raised"/>
<if keyfocused="true">
<button background="resbmp(12293,7,-1,0,0,0,0,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12259,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>

<if mousefocused="true">
<button background="resbmp(12294,7,-1,0,0,0,0,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12260,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused = "true" keyfocused = "true" pressed = "false">
<button background="resbmp(12292,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
<if keyfocused="true" mousefocused="true" pressed="false">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12261,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if pressed="true">
<button background="resbmp(12295,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12262,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
</if>
</if>


<if class="PowerOptionsButton">
<button width="20rp" height="28rp" background="resbmp(12302,7,-1,0,0,1,1,library(au7hui.dll))"
borderthickness = "rect(4rp, 3rp, 4rp, 3rp)" margin="rect(0,0,0,0)" bordercolor="gray" borderstyle="raised"/>
<if id="atom(ShutdownFrame)">
<element margin="rect(6rp, 0rp, 6rp, 0rp)"/>
</if>
<if id="atom(Shutdown)">
<button width="38rp" height="28rp" borderthickness="rect(4rp, 1rp, 4rp, 1rp)" background="resbmp(12296,7,-1,0,0,1,1,library(au7hui.dll))" contentalign="middlecenter" content="resbmp(12215,2,-1,0,0,1,1,library(au7hui.dll))" margin="rect(0,0,0,0)" accdesc="resstr(12128)" bordercolor="gray" borderstyle="raised"/>
<if selected="true">
<button content="resbmp(12216,2,-1,0,0,1,1,library(au7hui.dll))" accdesc="resstr(12133)" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if keyfocused="true">
<button background="resbmp(12299,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="gray" borderstyle="solid"/>
<button background="resbmp(12293,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused="true">
<button background="resbmp(12300,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
<button background="resbmp(12294,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused = "true" keyfocused = "true" pressed = "false">
<button background="resbmp(12298,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
<if mousefocused="true" keyfocused="true" pressed="false">
<button background="resbmp(12292,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if pressed="true">
<button background="resbmp(12301,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
<button background="resbmp(12295,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
</if>
</if>

<if class="EaseOfAccessButton">
<button width="38rp" height="28rp" padding="rect(0,0,0,0)"
accname="resstr(12122)" accdesc="resstr(12122)" borderthickness = "rect(4rp, 2rp, 4rp, 2rp)"
background = "resbmp(12263,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="gray" borderstyle="raised"/>

<if keyfocused = "true">
<button borderthickness = "rect(4rp, 2rp, 4rp, 2rp)" background = "resbmp(12259,7,-1,0,0,1,1,library(au7hui.dll))"
bordercolor="windowtext" borderstyle="solid"/>
<if id="atom(ShutdownOptions)">
<button width="20rp" height="28rp" contentalign="middlecenter" content="resbmp(12217,2,-1,0,0,1,1,library(au7hui.dll))" background="resbmp(12302,7,-1,0,0,1,1,library(au7hui.dll))" borderthickness="rect(4rp, 3rp, 4rp, 3rp)" margin="rect(0,0,0,0)" bordercolor="gray" borderstyle="raised"/>
<if keyfocused="true">
<button background="resbmp(12299,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused="true">
<button borderthickness = "rect(4rp, 2rp, 4rp, 2rp)" background = "resbmp(12260,7,-1,0,0,1,1,library(au7hui.dll))"
bordercolor="windowtext" borderstyle="solid"/>
<button background="resbmp(12300,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if mousefocused = "true" keyfocused = "true" pressed = "false">
<button borderthickness = "rect(4rp, 2rp, 4rp, 2rp)" background="resbmp(12261,7,-1,0,0,1,1,library(au7hui.dll))"
bordercolor="windowtext" borderstyle="solid"/>
<if mousefocused="true" keyfocused="true" pressed="false">
<button background="resbmp(12298,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="solid"/>
</if>
<if pressed="true">
<button borderthickness="rect(4rp, 2rp, 4rp, 2rp)" background = "resbmp(12262,7,-1,0,0,1,1,library(au7hui.dll))"
bordercolor="windowtext" borderstyle="sunken"/>
<button background="resbmp(12301,7,-1,0,0,1,1,library(au7hui.dll))" bordercolor="windowtext" borderstyle="sunken"/>
</if>
</if>

Expand All @@ -113,24 +109,17 @@
<element id="atom(Options)" layoutpos="bottom" visible="true" enabled="true" layout="filllayout()" background="argb(0,116,184,252)" height="96rp">

<element id="atom(OptionsButton)" layout="borderlayout()" padding="rect(34rp, 34rp, 34rp, 34rp)">
<button class="EaseOfAccessButton" layout="flowlayout(0,2,2,0)" layoutpos="left" id="atom(buttonEaseOfAccess)">
<element background="resbmp(12213,7,-1,0,0,1,1,library(au7hui.dll))" height="24rp" width="24rp"/>
</button>

<button id="atom(buttonEaseOfAccess)" tooltip="true" layoutpos="left"/>
<button id="atom(ToggleTabletKeyboard)" tooltip="true" layoutpos="none"/>
<element layout="flowlayout(0,1,2,2)" layoutpos="right">
<element class="ShutDownFrame" layout="flowlayout()">
<button class="ShutdownButton" layout="flowlayout(0,2,2,0)" width="38rp" height="28rp" id="atom(buttonShutdown)">
<element background="resbmp(12215,7,-1,0,0,1,1,library(au7hui.dll))" height="24rp" width="24rp"/>
</button>
<button class="PowerOptionsButton" accname="resstr(12131)" layout="flowlayout(0,2,2,0)" accdesc="resstr(12131)" tooltip="true" shortcut="115" id="atom(buttonPowerOptions)">
<element background="resbmp(12217,7,-1,0,0,1,1,library(au7hui.dll))" height="6rp" width="9rp"/>
</button>

<element id="atom(ShutDownFrame)" layout="flowlayout()">
<button id="atom(ShutDown)" accname="resstr(12128)" tooltip="true"/>
<button id="atom(ShutDownOptions)" accname="resstr(12131)" accdesc="resstr(12131)" tooltip="true" shortcut="115"/>
</element>
</element>
</element>
<element layout="flowlayout(0,2,2,2)">
<element id="atom(BrandingImage)" class="branding" width="350rp" height="50rp"/>
<element id="atom(BrandingImage)" class="branding" />
</element>
</element>
<element layoutpos="auto" visible="true" enabled="true" layout="filllayout()" background="argb(0,116,184,252)" height="1504rp">
Expand Down
4 changes: 3 additions & 1 deletion ConsoleLogonUI/resources/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#define IDUIF_SELECTEDCREDENTIALVIEW 104
#define IDUIF_STATUSVIEW 105
#define IDUIF_USERSELECT 106
#define IDB_BRAND 107
#define IDB_BRAND 122
#define IDB_BRAND2 1122
#define IDB_BRAND3 2122
#define IDB_SPINNER1 108
#define IDB_SPINNER2 109
#define IDB_SPINNER3 110
Expand Down
2 changes: 1 addition & 1 deletion ConsoleLogonUI/resources/statusview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

</element>
<element id="atom(Status)" visible="true" Enabled="true" layout="flowlayout(0,0,2,2)" minsize="size(0rp,36rp)">
<AnimationStrip id="atom(WaitAnimation)" content="resbmp(110)" visible="true" play="true" framewidth="20" frameduration="33" frameindex="0" width="20rp" height="20rp" margin="rect(0rp,0rp,5rp,0rp)"/>
<AnimationStrip id="atom(WaitAnimation)" content="resbmp(110)" visible="true" play="true" framewidth="20rp" frameduration="33" frameindex="0" width="20rp" height="20rp" margin="rect(0rp,0rp,5rp,0rp)"/>
<element content="STATUS VIEW" id="atom(StatusText)"/>
</element>
</element>
Expand Down
47 changes: 43 additions & 4 deletions ConsoleLogonUI/ui/dui_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,61 @@ void duiManager::LoadBackground()
}*/
}

void duiManager::LoadHighResImageForDPI()
{
int DPI = GetDpiForSystem();
if (DPI <= 96) // no change
return;


}

void duiManager::LoadBranding()
{
if (!this->pUIElement) return;

auto brandingElement = this->pUIElement->FindDescendent(ATOMID(L"BrandingImage"));
if (!brandingElement) return;

HBITMAP bitmap = external::BrandingLoadImage(L"Basebrd", 122, 0, 0, 0, 0);
if (!bitmap) return;
const int brandingSizes[3][2] = {{122,350}, {1122,438} ,{2122,525}};

int residToUse = 122;
int lastdist = 9999999;
int DPI = GetDpiForSystem();
int scalecompare = MulDiv(350, DPI, 96);/* 350 * (DPI / 96);*/
for (int i = 0; i < 3; ++i)
{
auto pair = brandingSizes[i];
int resid = pair[0];
int reso = pair[1];

int dist = abs(reso - scalecompare);
if (dist < lastdist)
{
lastdist = dist;
residToUse = resid;
}
}
//MessageBoxW(0,std::format(L"resid{} dist{} DPI {} scalecompare{}",residToUse,lastdist,DPI,scalecompare).c_str(),0,0);
HBITMAP bitmap = external::BrandingLoadImage(L"Basebrd", residToUse, 0, 0, 0, 0);
if (!bitmap)
{
bitmap = LoadBitmapW(duiManager::Get()->hInstance, MAKEINTRESOURCEW(residToUse));
}

auto graphic = DirectUI::Value::CreateGraphic(bitmap, (unsigned char)2, (unsigned int)0xFFFFFFFF, (bool)0, 0, 0);
if (!graphic)
{
bitmap = LoadBitmapW(duiManager::Get()->hInstance, MAKEINTRESOURCEW(residToUse));
graphic = DirectUI::Value::CreateGraphic(bitmap, (unsigned char)2, (unsigned int)0xFFFFFFFF, (bool)0, 0, 0);
}
if (!graphic) return;
//MessageBoxW(0,L"",0,0);


if (!brandingElement->SetMinSize(0, 0)) return;
//if (!brandingElement->SetMinSize(0, 0)) return;

brandingElement->SetValue(DirectUI::Element::BackgroundProp, 1, graphic);
brandingElement->SetValue(DirectUI::Element::ContentProp, 1, graphic);
graphic->Release();
}

Expand Down
1 change: 1 addition & 0 deletions ConsoleLogonUI/ui/dui_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ class duiManager

void LoadBranding();
void LoadBackground();
void LoadHighResImageForDPI();
bool UseOEMBackground();
};
Loading

0 comments on commit 87ea519

Please sign in to comment.