Skip to content

Commit 2f1d4fc

Browse files
committed
peview: Add missing file from commit a8a5b3d
1 parent 903ef74 commit 2f1d4fc

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

tools/peview/attributes.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Process Hacker -
3+
* PE viewer
4+
*
5+
* Copyright (C) 2018 dmex
6+
*
7+
* This file is part of Process Hacker.
8+
*
9+
* Process Hacker is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* Process Hacker is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#include <peview.h>
24+
25+
typedef struct _PV_EA_CALLBACK
26+
{
27+
HWND ListViewHandle;
28+
ULONG Count;
29+
} PV_EA_CALLBACK, *PPV_EA_CALLBACK;
30+
31+
BOOLEAN NTAPI PvpEnumFileAttributesCallback(
32+
_In_ PFILE_FULL_EA_INFORMATION Information,
33+
_In_opt_ PVOID Context
34+
)
35+
{
36+
PPV_EA_CALLBACK context = Context;
37+
PPH_STRING attributeName;
38+
INT lvItemIndex;
39+
WCHAR number[PH_INT32_STR_LEN_1];
40+
41+
PhPrintUInt32(number, ++context->Count);
42+
lvItemIndex = PhAddListViewItem(context->ListViewHandle, MAXINT, number, NULL);
43+
44+
attributeName = PhZeroExtendToUtf16(Information->EaName);
45+
PhSetListViewSubItem(
46+
context->ListViewHandle,
47+
lvItemIndex,
48+
1,
49+
attributeName->Buffer
50+
);
51+
PhDereferenceObject(attributeName);
52+
53+
PhSetListViewSubItem(
54+
context->ListViewHandle,
55+
lvItemIndex,
56+
2,
57+
PhaFormatSize(Information->EaValueLength, ULONG_MAX)->Buffer
58+
);
59+
60+
return TRUE;
61+
}
62+
63+
INT_PTR CALLBACK PvpPeExtendedAttributesDlgProc(
64+
_In_ HWND hwndDlg,
65+
_In_ UINT uMsg,
66+
_In_ WPARAM wParam,
67+
_In_ LPARAM lParam
68+
)
69+
{
70+
LPPROPSHEETPAGE propSheetPage;
71+
PPV_PROPPAGECONTEXT propPageContext;
72+
73+
if (!PvPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext))
74+
return FALSE;
75+
76+
switch (uMsg)
77+
{
78+
case WM_INITDIALOG:
79+
{
80+
HANDLE fileHandle;
81+
HWND lvHandle;
82+
83+
lvHandle = GetDlgItem(hwndDlg, IDC_LIST);
84+
PhSetListViewStyle(lvHandle, TRUE, TRUE);
85+
PhSetControlTheme(lvHandle, L"explorer");
86+
PhAddListViewColumn(lvHandle, 0, 0, 0, LVCFMT_LEFT, 40, L"#");
87+
PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 150, L"Name");
88+
PhAddListViewColumn(lvHandle, 2, 2, 2, LVCFMT_LEFT, 200, L"Value");
89+
PhSetExtendedListView(lvHandle);
90+
PhLoadListViewColumnsFromSetting(L"ImageAttributesListViewColumns", lvHandle);
91+
92+
if (NT_SUCCESS(PhCreateFileWin32(
93+
&fileHandle,
94+
PhGetString(PvFileName),
95+
FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA | SYNCHRONIZE,
96+
FILE_ATTRIBUTE_NORMAL,
97+
FILE_SHARE_READ,
98+
FILE_OPEN,
99+
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
100+
)))
101+
{
102+
PV_EA_CALLBACK context;
103+
104+
context.ListViewHandle = lvHandle;
105+
context.Count = 0;
106+
107+
PhEnumFileExtendedAttributes(fileHandle, PvpEnumFileAttributesCallback, &context);
108+
109+
NtClose(fileHandle);
110+
}
111+
112+
EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
113+
}
114+
break;
115+
case WM_DESTROY:
116+
{
117+
PhSaveListViewColumnsToSetting(L"ImageAttributesListViewColumns", GetDlgItem(hwndDlg, IDC_LIST));
118+
}
119+
break;
120+
case WM_SHOWWINDOW:
121+
{
122+
if (!propPageContext->LayoutInitialized)
123+
{
124+
PPH_LAYOUT_ITEM dialogItem;
125+
126+
dialogItem = PvAddPropPageLayoutItem(hwndDlg, hwndDlg, PH_PROP_PAGE_TAB_CONTROL_PARENT, PH_ANCHOR_ALL);
127+
PvAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_LIST), dialogItem, PH_ANCHOR_ALL);
128+
129+
PvDoPropPageLayout(hwndDlg);
130+
131+
propPageContext->LayoutInitialized = TRUE;
132+
}
133+
}
134+
break;
135+
case WM_NOTIFY:
136+
{
137+
PvHandleListViewNotifyForCopy(lParam, GetDlgItem(hwndDlg, IDC_LIST));
138+
}
139+
break;
140+
}
141+
142+
return FALSE;
143+
}

0 commit comments

Comments
 (0)