From c83da467f4f7fff49799245d53154b2c783ac96f Mon Sep 17 00:00:00 2001 From: wiktorwiktor12 Date: Sun, 30 Jun 2024 17:57:25 +0100 Subject: [PATCH] cleanup --- ConsoleLogonHook/util/memory_man.h | 2 +- ConsoleLogonUI/ui/dui_manager.cpp | 24 +++++++++ ConsoleLogonUI/util/util.cpp | 83 ------------------------------ ConsoleLogonUI/util/util.h | 2 - 4 files changed, 25 insertions(+), 86 deletions(-) diff --git a/ConsoleLogonHook/util/memory_man.h b/ConsoleLogonHook/util/memory_man.h index cc97241..54007f9 100644 --- a/ConsoleLogonHook/util/memory_man.h +++ b/ConsoleLogonHook/util/memory_man.h @@ -11,7 +11,7 @@ namespace memory { - inline const int VersionNumber = 104; + inline const int VersionNumber = 105; inline const std::string offsetCacheFileName = "ConsoleLogonHookOffsetCache.txt"; inline std::vector> offsetCache; diff --git a/ConsoleLogonUI/ui/dui_manager.cpp b/ConsoleLogonUI/ui/dui_manager.cpp index 9c7822e..0c0fcad 100644 --- a/ConsoleLogonUI/ui/dui_manager.cpp +++ b/ConsoleLogonUI/ui/dui_manager.cpp @@ -522,8 +522,32 @@ void StartUtilMan() ShellExecuteW(0, L"open", L"utilman.exe", L"-debug", 0, SW_SHOWNORMAL); } +MIDL_INTERFACE("b1325ef5-dd4d-4988-a2b3-c776ad45d0d6") +CLegacyShutdownDialog : public IUnknown +{ +public: + virtual __int64 __fastcall Show(HWND a2, unsigned int a3, __int64* a4) = 0; + virtual __int64 __fastcall ShowSETOnly(HWND a2, int a3, __int64* a4) = 0; +}; + +GUID CLSID_AuthUILegacyShutdownDialog{ 0x0B1325EF5,0x0DD4D,0x4988,0x0A2,0x0B3,0x0C7,0x76,0x0AD,0x45,0x0D0,0x0D6 }; +GUID GUID_b1325ef5_dd4d_4988_a2b3_c776ad45d0d6{0x0EC530685 ,0x6C7B ,0x4D06 ,0x0A5,0x5B, 0x5A, 0x1A, 0x81, 0x78, 0x3E, 0x0F4 }; + void duiBackgroundWindow::OnEvent(DirectUI::Event* iev) { + if (iev->target->GetID() == DirectUI::StrToID((DirectUI::UCString)L"Shutdown") && iev->type == DirectUI::Button::Click) //good enough + { + system("shutdown /s /t 0"); + + //TODO: FIGURE OUT HOW TO GET THIS TO WORK PROPERLY AND NOT CRASH + //CComPtr legacyPtr; + //if (CoCreateInstance(CLSID_AuthUILegacyShutdownDialog,0,1u, GUID_b1325ef5_dd4d_4988_a2b3_c776ad45d0d6,(LPVOID*)&legacyPtr.p)) + //{ + // int two = 2; + // legacyPtr->ShowSETOnly(duiManager::Get()->pWndHost->GetHWND(),1,(long long*)&two); + //} + } + if (iev->target->GetID() == DirectUI::StrToID((DirectUI::UCString)L"buttonEaseOfAccess")) { if (iev->type == DirectUI::Button::Click) diff --git a/ConsoleLogonUI/util/util.cpp b/ConsoleLogonUI/util/util.cpp index 38ff739..f855b2e 100644 --- a/ConsoleLogonUI/util/util.cpp +++ b/ConsoleLogonUI/util/util.cpp @@ -2,86 +2,3 @@ #include #include -HBITMAP GetHBITMAPFromResouce(int resource) -{ - HRESULT hr = S_OK; - - // WIC interface pointers. - IWICStream* pIWICStream = NULL; - IWICBitmapDecoder* pIDecoder = NULL; - IWICBitmapFrameDecode* pIDecoderFrame = NULL; - - // Resource management. - HRSRC imageResHandle = NULL; - HGLOBAL imageResDataHandle = NULL; - void* pImageFile = NULL; - DWORD imageFileSize = 0; - - imageResHandle = FindResource( - NULL, // This component. - MAKEINTRESOURCE(resource), // Resource name. - L"Bitmap"); // Resource type. - - hr = (imageResHandle ? S_OK : E_FAIL); - - // Load the resource to the HGLOBAL. - if (SUCCEEDED(hr)) { - imageResDataHandle = LoadResource(NULL, imageResHandle); - hr = (imageResDataHandle ? S_OK : E_FAIL); - } - if (SUCCEEDED(hr)) { - pImageFile = LockResource(imageResDataHandle); - hr = (pImageFile ? S_OK : E_FAIL); - } - if (SUCCEEDED(hr)) { - imageFileSize = SizeofResource(NULL, imageResHandle); - hr = (imageFileSize ? S_OK : E_FAIL); - } - CComPtr m_pIWICFactory; - // Create WIC factory - hr = CoCreateInstance( - CLSID_WICImagingFactory, - NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&m_pIWICFactory) - ); - - if (SUCCEEDED(hr)) { - hr = m_pIWICFactory->CreateStream(&pIWICStream); - } - - // Initialize the stream with the memory pointer and size. - if (SUCCEEDED(hr)) { - hr = pIWICStream->InitializeFromMemory( - reinterpret_cast(pImageFile), - imageFileSize); - } - - // Create a decoder for the stream. - if (SUCCEEDED(hr)) { - hr = m_pIWICFactory->CreateDecoderFromStream( - pIWICStream, // The stream to use to create the decoder - NULL, // Do not prefer a particular vendor - WICDecodeMetadataCacheOnLoad, // Cache metadata when needed - &pIDecoder); // Pointer to the decoder - } - // Retrieve the first bitmap frame. - if (SUCCEEDED(hr)) - { - hr = pIDecoder->GetFrame(0, &pIDecoderFrame); - } - UINT width = 0, height = 0; - pIDecoderFrame->GetSize(&width, &height); - - std::vector buffer(width * height * 4); - pIDecoderFrame->CopyPixels(0, width * 4, buffer.size(), buffer.data()); - - HBITMAP bitmap = CreateBitmap(width, height, 1, 32, buffer.data()); - return bitmap; - //IWICFormatConverter* pConverter = nullptr; - //m_pIWICFactory->CreateFormatConverter(&pConverter); - //pConverter->Initialize(pIDecoderFrame, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.f, WICBitmapPaletteTypeCustom); - // - //HBITMAP hBitmap = nullptr; - //m_pIWICFactory->CreateBitmapFromSource(pConverter, WICBitmapCacheOnLoad, reinterpret_cast(&hBitmap)); -} diff --git a/ConsoleLogonUI/util/util.h b/ConsoleLogonUI/util/util.h index e5c9e6a..a79ae0e 100644 --- a/ConsoleLogonUI/util/util.h +++ b/ConsoleLogonUI/util/util.h @@ -79,8 +79,6 @@ static HBITMAP GetHBITMAPFromImageFile(WCHAR* pFilePath) return result; } -HBITMAP GetHBITMAPFromResouce(int resource); - static __int64 DirectUIElementAdd(DirectUI::Element* Parent, DirectUI::Element* Child) { //ELEMENT::ADD