Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Nov 22, 2024
1 parent 2cbaf58 commit 08eb25c
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Source/KNSoft.MakeLifeEasier/Crypt/Cert.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "../MakeLifeEasier.inl"

#pragma comment(lib, "Crypt32.lib")

W32ERROR
NTAPI
Crypt_EnumBlobCertificates(
Expand Down
7 changes: 4 additions & 3 deletions Source/KNSoft.MakeLifeEasier/Error/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ PCWSTR
Err_GetHrInfo(
_In_ HRESULT Hr)
{
ULONG Facility, Code;
ULONG Facility, Severity, Code;

Facility = HRESULT_FACILITY(Hr);
Severity = HRESULT_SEVERITY(Hr);
Code = HRESULT_CODE(Hr);

if (Facility == FACILITY_WIN32)
if (Facility == FACILITY_WIN32 && Severity == SEVERITY_ERROR)
{
return Err_GetWin32ErrorInfo(Code);
} else if ((ULONG)Hr & FACILITY_NT_BIT)
{
return Err_GetNtStatusInfo((NTSTATUS)((ULONG)Hr & ~FACILITY_NT_BIT));
}

return NULL;
return Err_GetWin32ErrorInfo((ULONG)Hr);
}

#pragma endregion
Expand Down
4 changes: 4 additions & 0 deletions Source/KNSoft.MakeLifeEasier/MakeLifeEasier.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include <KNSoft/NDK/NDK.h>

#include <WinTrust.h>
#include <Uxtheme.h>
#include <dwmapi.h>

#ifndef MLE_API
#define MLE_API DECLSPEC_IMPORT
#endif
Expand Down
4 changes: 4 additions & 0 deletions Source/KNSoft.MakeLifeEasier/MakeLifeEasier.inl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

#pragma comment(lib, "KNSoft.NDK.WinAPI.lib")

#pragma comment(lib, "Crypt32.lib")
#pragma comment(lib, "UxTheme.lib")
#pragma comment(lib, "Dwmapi.lib")

EXTERN_C_START

PCWSTR
Expand Down
2 changes: 0 additions & 2 deletions Source/KNSoft.MakeLifeEasier/PE/Resolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "../MakeLifeEasier.h"

#include <WinTrust.h>

EXTERN_C_START

typedef struct _PE_STRUCT
Expand Down
4 changes: 4 additions & 0 deletions Source/KNSoft.MakeLifeEasier/UI/Control.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ UI_CreateMenuItemsEx(
{
SetMenuItemBitmaps(Parent, Index, MF_BYPOSITION, Items[i].Icon, Items[i].Icon);
}
if (Items[i].Flags & MF_DEFAULT)
{
SetMenuDefaultItem(Parent, Index, MF_BYPOSITION);
}
Index++;
}

Expand Down
4 changes: 0 additions & 4 deletions Source/KNSoft.MakeLifeEasier/UI/GDI.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "../MakeLifeEasier.inl"

#include <Uxtheme.h>

#pragma comment(lib, "UxTheme.lib")

#pragma region Font

/* ENUMLOGFONTEXDVW->elfEnumLogfontEx.elfLogFont should be filled by the caller */
Expand Down
2 changes: 1 addition & 1 deletion Source/KNSoft.MakeLifeEasier/UI/GDI.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ UI_FillSolidRect(

FORCEINLINE
LOGICAL
UI_FrameRect(
UI_DrawFrameRect(
_In_ HDC DC,
_In_ PRECT Rect,
_In_ INT Width,
Expand Down
79 changes: 79 additions & 0 deletions Source/KNSoft.MakeLifeEasier/UI/Window.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,82 @@ UI_SetWindowThemeProperty(
}
return Ret;
}

static
_Function_class_(USER_THREAD_START_ROUTINE)
NTSTATUS
NTAPI
UI_FlashWindow_Thread(
_In_ PVOID ThreadParameter)
{
NTSTATUS Status;
HWND hWnd;
HDC hDC;
RECT rc;
UINT uTimes = 4 * 2;

hWnd = (HWND)ThreadParameter;
hDC = GetDCEx(hWnd, NULL, DCX_WINDOW);
if (hDC == NULL)
{
return STATUS_INVALID_HANDLE;
}
if (SUCCEEDED(UI_GetWindowRect(hWnd, &rc)))
//if (GetWindowRect(hWnd, &rc))
{
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.left = rc.top = 0;
do
{
UI_DrawFrameRect(hDC, &rc, -3, PATINVERT);
PS_DelayExec(100);
uTimes--;
} while (uTimes != 0);
Status = STATUS_SUCCESS;
} else
{
Status = NTSTATUS_FROM_WIN32(NtGetLastError());
}
ReleaseDC(hWnd, hDC);

return Status;
}

LOGICAL
NTAPI
UI_FlashWindow(
_In_ HWND Window)
{
return NT_SUCCESS(PS_CreateThread(NtCurrentProcess(),
FALSE,
UI_FlashWindow_Thread,
(PVOID)Window,
NULL,
NULL));
}

LOGICAL
NTAPI
UI_FlashWindowSync(
_In_ HWND Window,
_In_ ULONG Milliseconds)
{
NTSTATUS Status;
HANDLE ThreadHandle;

Status = PS_CreateThread(NtCurrentProcess(),
FALSE,
UI_FlashWindow_Thread,
(PVOID)Window,
&ThreadHandle,
NULL);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
Status = PS_WaitForObject(ThreadHandle, Milliseconds);
NtClose(ThreadHandle);

return NT_SUCCESS(Status);
}
30 changes: 30 additions & 0 deletions Source/KNSoft.MakeLifeEasier/UI/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,34 @@ UI_DisableWindowVisualStyle(

#pragma endregion

FORCEINLINE
HRESULT
UI_GetWindowRect(
_In_ HWND Window,
_Out_ PRECT Rect)
{
HRESULT hr;

hr = DwmGetWindowAttribute(Window, DWMWA_EXTENDED_FRAME_BOUNDS, Rect, sizeof(*Rect));
if (hr != S_OK)
{
hr = GetWindowRect(Window, Rect) ? S_FALSE : HRESULT_FROM_WIN32(NtGetLastError());
}

return hr;
}

MLE_API
LOGICAL
NTAPI
UI_FlashWindow(
_In_ HWND Window);

MLE_API
LOGICAL
NTAPI
UI_FlashWindowSync(
_In_ HWND Window,
_In_ ULONG Milliseconds);

EXTERN_C_END

0 comments on commit 08eb25c

Please sign in to comment.