Skip to content

Commit

Permalink
fix ksi port name
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Dec 5, 2024
1 parent 7c6055e commit 03c247e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion KSystemInformer/parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct _KPH_PARAMETER

KPH_PROTECTED_DATA_SECTION_RO_PUSH();
static const UNICODE_STRING KphpDefaultAltitude = RTL_CONSTANT_STRING(L"385210.5");
static const UNICODE_STRING KphpDefaultPortName = RTL_CONSTANT_STRING(L"\\KSystemInformer");
static const UNICODE_STRING KphpDefaultPortName = RTL_CONSTANT_STRING(L"\\SystemInformer");
KPH_PROTECTED_DATA_SECTION_RO_POP();
KPH_PROTECTED_DATA_SECTION_PUSH();
PUNICODE_STRING KphAltitude = NULL;
Expand Down
51 changes: 48 additions & 3 deletions plugins/WindowExplorer/wndprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,14 @@ HBITMAP (WINAPI* CreateBitmapFromDxSurface_I)(
_In_opt_ HANDLE phDxSurface
);

#define DWMWA_EXTENDED_FRAME_BOUNDS 9
static HRESULT(WINAPI* DwmGetWindowAttribute_I)(
_In_ HWND hwnd,
_In_ DWORD dwAttribute,
_Out_ PVOID pvAttribute,
_In_ DWORD cbAttribute
);

HBITMAP WepGetWindowSharedSurface(
_In_ HWND WindowHandle,
_In_ HDC WindowHdc
Expand All @@ -2331,6 +2339,8 @@ HBITMAP WepGetWindowSharedSurface(
DwmGetDxSharedSurface_I = PhGetModuleProcAddress(L"user32.dll", "DwmGetDxSharedSurface");
if (!CreateBitmapFromDxSurface_I)
CreateBitmapFromDxSurface_I = PhGetModuleProcAddress(L"gdi32.dll", "CreateBitmapFromDxSurface");
if (!DwmGetWindowAttribute_I)
DwmGetWindowAttribute_I = PhGetModuleProcAddress(L"dwmapi.dll", "DwmGetWindowAttribute");

if (!DwmGetDxSharedSurface_I)
return NULL;
Expand Down Expand Up @@ -2395,14 +2405,25 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 100, L"Value");
PhSetExtendedListView(lvHandle);

<<<<<<< Updated upstream
PhInitializeWindowTheme(hwndDlg, !!PhGetIntegerSetting(L"EnableThemeSupport"));
=======
LPRECT rect = PhAllocateZero(sizeof(RECT));
PhSetWindowContext(hwndDlg, (LONG)'WePv', rect);

PhInitializeWindowTheme(hwndDlg);
>>>>>>> Stashed changes

PhSetTimer(hwndDlg, PH_WINDOW_TIMER_DEFAULT, 1000, NULL);
}
break;
case WM_DESTROY:
{
PhKillTimer(hwndDlg, PH_WINDOW_TIMER_DEFAULT);

PRECT oldWindowRect = PhGetWindowContext(hwndDlg, (LONG)'WePv');
PhFree(oldWindowRect);
PhRemoveWindowContext(hwndDlg, (LONG)'WePv');
}
break;
case WM_SHOWWINDOW:
Expand All @@ -2420,6 +2441,12 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
}
break;
case WM_ERASEBKGND:
{
HDC hdc = (HDC)wParam;
RECT clientRect;
GetClientRect(hwndDlg, &clientRect);
FillRect(hdc, &clientRect, GetStockBrush(BLACK_BRUSH));
}
return TRUE;
case WM_PAINT:
{
Expand All @@ -2437,14 +2464,26 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
bufferDc = CreateCompatibleDC(hdc);

SetBkMode(hdc, TRANSPARENT);
FillRect(hdc, &clientRect, GetStockBrush(BLACK_BRUSH));

if (bitmap = WepGetWindowSharedSurface(context->WindowHandle, hdc))
{
HBITMAP oldbitmap;
INT width;
INT height;

if (DwmGetWindowAttribute_I)
{
RECT extendedRect;
if (SUCCEEDED(DwmGetWindowAttribute_I(context->WindowHandle, DWMWA_EXTENDED_FRAME_BOUNDS, &extendedRect, sizeof(extendedRect))))
{
OffsetRect(&extendedRect, -extendedRect.left, -extendedRect.top);
INT borderSize = ((extendedRect.right - extendedRect.left) - (windowClientRect.right - windowClientRect.left)) / 2;
INT headerSize = ((extendedRect.bottom - extendedRect.top) - (windowClientRect.bottom - windowClientRect.top)) - borderSize;

windowClientRect.left += (INT)ceil(headerSize / 7.0), windowClientRect.top += headerSize;
}
}

oldbitmap = SelectBitmap(bufferDc, bitmap);

if (clientRect.right > windowClientRect.right)
Expand All @@ -2463,7 +2502,8 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
width,
height,
bufferDc,
0, 0,
windowClientRect.left,
windowClientRect.top,
windowClientRect.right,
windowClientRect.bottom,
SRCCOPY
Expand All @@ -2476,6 +2516,7 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
{
PH_STRINGREF errorText = PH_STRINGREF_INIT(L"No preview available for this window.");

FillRect(hdc, &clientRect, GetStockBrush(BLACK_BRUSH));
SetTextColor(hdc, RGB(0x0, 0x0, 0xFF));
//SelectFont(hdc, PhApplicationFont);
DrawText(
Expand All @@ -2494,7 +2535,11 @@ INT_PTR CALLBACK WepWindowPreviewDlgProc(
return TRUE;
case WM_TIMER:
{
InvalidateRect(hwndDlg, NULL, TRUE);
RECT windowRect;
GetWindowRect(context->WindowHandle, &windowRect);
PRECT oldWindowRect = PhGetWindowContext(hwndDlg, (LONG)'WePv');
InvalidateRect(hwndDlg, NULL, !EqualRect(&windowRect, oldWindowRect));
*oldWindowRect = windowRect;
}
break;
}
Expand Down

0 comments on commit 03c247e

Please sign in to comment.