Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorwiktor12 committed Jun 30, 2024
1 parent 77fdb41 commit c83da46
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 86 deletions.
2 changes: 1 addition & 1 deletion ConsoleLogonHook/util/memory_man.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<std::string, uintptr_t>> offsetCache;
Expand Down
24 changes: 24 additions & 0 deletions ConsoleLogonUI/ui/dui_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CLegacyShutdownDialog> 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)
Expand Down
83 changes: 0 additions & 83 deletions ConsoleLogonUI/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,3 @@
#include <wincodec.h>
#include <wincodecsdk.h>

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<IWICImagingFactory> 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<BYTE*>(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<BYTE> 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<IWICBitmap**>(&hBitmap));
}
2 changes: 0 additions & 2 deletions ConsoleLogonUI/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c83da46

Please sign in to comment.