peview: Add file stream information, Fix listview indexes

This commit is contained in:
dmex
2018-10-25 11:13:41 +11:00
parent 19d22d8254
commit 8e208a813a
11 changed files with 101 additions and 62 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ VOID PvpProcessElfExports(
if (!export->ExportSymbol)
continue;
PhPrintUInt64(number, ++count);
PhPrintUInt32(number, ++count);
lvItemIndex = PhAddListViewItem(ListViewHandle, MAXINT, number, NULL);
PhPrintPointer(pointer, (PVOID)export->Address);
+9 -1
View File
@@ -119,7 +119,15 @@ VOID PvExlfProperties(
NULL
);
PvAddPropPage(propContext, newPage);
// Streams page
newPage = PvCreatePropPageContext(
MAKEINTRESOURCE(IDD_PESTREAMS),
PvpPeStreamsDlgProc,
NULL
);
PvAddPropPage(propContext, newPage);
PhModalPropertySheet(&propContext->PropSheetHeader);
PhDereferenceObject(propContext);
+7
View File
@@ -343,6 +343,13 @@ INT_PTR CALLBACK PvpPeExtendedAttributesDlgProc(
_In_ LPARAM lParam
);
INT_PTR CALLBACK PvpPeStreamsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
// ELF
PWSTR PvpGetSymbolTypeName(
+10
View File
@@ -198,6 +198,16 @@ VOID PvPeProperties(
PvAddPropPage(propContext, newPage);
}
// Streams page
{
newPage = PvCreatePropPageContext(
MAKEINTRESOURCE(IDD_PESTREAMS),
PvpPeStreamsDlgProc,
NULL
);
PvAddPropPage(propContext, newPage);
}
// Symbols page
if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_DEBUG, &entry)) && entry->VirtualAddress)
{
+16
View File
@@ -148,6 +148,14 @@ BEGIN
TOPMARGIN, 3
BOTTOMMARGIN, 277
END
IDD_PESTREAMS, DIALOG
BEGIN
LEFTMARGIN, 3
RIGHTMARGIN, 297
TOPMARGIN, 3
BOTTOMMARGIN, 277
END
END
#endif // APSTUDIO_INVOKED
@@ -294,6 +302,14 @@ BEGIN
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,3,3,294,274
END
IDD_PESTREAMS DIALOGEX 0, 0, 300, 280
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Streams"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,3,3,294,274
END
/////////////////////////////////////////////////////////////////////////////
//
+2 -1
View File
@@ -222,7 +222,7 @@
<ClCompile Include="cfgprp.c" />
<ClCompile Include="clrprp.c" />
<ClCompile Include="colmgr.c" />
<ClCompile Include="eaprp.c" />
<ClCompile Include="attributes.c" />
<ClCompile Include="exlfexports.c" />
<ClCompile Include="exlfimports.c" />
<ClCompile Include="exlfprp.c" />
@@ -240,6 +240,7 @@
<ClCompile Include="resprp.c" />
<ClCompile Include="searchbox.c" />
<ClCompile Include="settings.c" />
<ClCompile Include="streams.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="colmgr.h" />
+5 -2
View File
@@ -81,10 +81,13 @@
<ClCompile Include="exlfexports.c">
<Filter>Source Files\Pages\Linux</Filter>
</ClCompile>
<ClCompile Include="eaprp.c">
<ClCompile Include="propstore.c">
<Filter>Source Files\Pages</Filter>
</ClCompile>
<ClCompile Include="propstore.c">
<ClCompile Include="streams.c">
<Filter>Source Files\Pages</Filter>
</ClCompile>
<ClCompile Include="attributes.c">
<Filter>Source Files\Pages</Filter>
</ClCompile>
</ItemGroup>
+1 -1
View File
@@ -51,7 +51,7 @@ VOID PvpPeEnumerateFilePropStore(
PWSTR propKeyName;
WCHAR number[PH_INT32_STR_LEN_1];
PhPrintUInt32(number, i);
PhPrintUInt32(number, i + 1);
lvItemIndex = PhAddListViewItem(ListViewHandle, MAXINT, number, NULL);
if (SUCCEEDED(PSGetNameFromPropertyKey(&propkey, &propKeyName)))
+1
View File
@@ -18,6 +18,7 @@
#define IDB_SEARCH_ACTIVE_BMP 112
#define IDD_PEATTR 112
#define IDB_SEARCH_INACTIVE_BMP 113
#define IDD_PESTREAMS 113
#define IDC_SYMBOLTREE 119
#define IDC_TARGETMACHINE 1003
#define IDC_CHECKSUM 1004
+1
View File
@@ -46,6 +46,7 @@ VOID PhAddDefaultSettings(
PhpAddStringSetting(L"ImageResourcesListViewColumns", L"");
PhpAddStringSetting(L"ImageAttributesListViewColumns", L"");
PhpAddStringSetting(L"ImagePropertiesListViewColumns", L"");
PhpAddStringSetting(L"ImageStreamsListViewColumns", L"");
PhpAddStringSetting(L"LibListViewColumns", L"");
PhpAddStringSetting(L"PdbTreeListColumns", L"");
+48 -56
View File
@@ -22,47 +22,57 @@
#include <peview.h>
typedef struct _PV_EA_CALLBACK
{
HWND ListViewHandle;
ULONG Count;
} PV_EA_CALLBACK, *PPV_EA_CALLBACK;
BOOLEAN NTAPI PvpEnumFileAttributesCallback(
_In_ PFILE_FULL_EA_INFORMATION Information,
_In_opt_ PVOID Context
VOID PvpPeEnumerateFileStreams(
_In_ HWND ListViewHandle
)
{
PPV_EA_CALLBACK context = Context;
PPH_STRING attributeName;
INT lvItemIndex;
WCHAR number[PH_INT32_STR_LEN_1];
HANDLE fileHandle;
PhPrintUInt32(number, context->Count);
lvItemIndex = PhAddListViewItem(context->ListViewHandle, MAXINT, number, NULL);
if (NT_SUCCESS(PhCreateFileWin32(
&fileHandle,
PhGetString(PvFileName),
FILE_READ_ATTRIBUTES | FILE_READ_DATA | SYNCHRONIZE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
)))
{
ULONG count = 0;
PVOID buffer;
PFILE_STREAM_INFORMATION i;
attributeName = PhZeroExtendToUtf16(Information->EaName);
PhSetListViewSubItem(
context->ListViewHandle,
lvItemIndex,
1,
attributeName->Buffer
);
PhDereferenceObject(attributeName);
if (NT_SUCCESS(PhEnumFileStreams(fileHandle, &buffer)))
{
for (i = PH_FIRST_STREAM(buffer); i; i = PH_NEXT_STREAM(i))
{
INT lvItemIndex;
PPH_STRING attributeName;
WCHAR number[PH_INT32_STR_LEN_1];
PhSetListViewSubItem(
context->ListViewHandle,
lvItemIndex,
2,
PhaFormatSize(Information->EaValueLength, ULONG_MAX)->Buffer
);
PhPrintUInt32(number, ++count);
lvItemIndex = PhAddListViewItem(ListViewHandle, MAXINT, number, NULL);
context->Count++;
attributeName = PhCreateStringEx(i->StreamName, i->StreamNameLength);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 1, attributeName->Buffer);
PhDereferenceObject(attributeName);
return TRUE;
PhSetListViewSubItem(
ListViewHandle,
lvItemIndex,
2,
PhaFormatSize(i->StreamSize.QuadPart, ULONG_MAX)->Buffer
);
}
PhFree(buffer);
}
NtClose(fileHandle);
}
}
INT_PTR CALLBACK PvpPeExtendedAttributesDlgProc(
INT_PTR CALLBACK PvpPeStreamsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
@@ -79,7 +89,6 @@ INT_PTR CALLBACK PvpPeExtendedAttributesDlgProc(
{
case WM_INITDIALOG:
{
HANDLE fileHandle;
HWND lvHandle;
lvHandle = GetDlgItem(hwndDlg, IDC_LIST);
@@ -87,36 +96,19 @@ INT_PTR CALLBACK PvpPeExtendedAttributesDlgProc(
PhSetControlTheme(lvHandle, L"explorer");
PhAddListViewColumn(lvHandle, 0, 0, 0, LVCFMT_LEFT, 40, L"#");
PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 150, L"Name");
PhAddListViewColumn(lvHandle, 2, 2, 2, LVCFMT_LEFT, 200, L"Value");
PhAddListViewColumn(lvHandle, 2, 2, 2, LVCFMT_LEFT, 150, L"Size");
PhSetExtendedListView(lvHandle);
PhLoadListViewColumnsFromSetting(L"ImageAttributesListViewColumns", lvHandle);
if (NT_SUCCESS(PhCreateFileWin32(
&fileHandle,
PhGetString(PvFileName),
FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA | SYNCHRONIZE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
)))
{
PV_EA_CALLBACK context;
context.ListViewHandle = lvHandle;
context.Count = 0;
PhEnumFileExtendedAttributes(fileHandle, PvpEnumFileAttributesCallback, &context);
NtClose(lvHandle);
}
PhLoadListViewColumnsFromSetting(L"ImageStreamsListViewColumns", lvHandle);
PvpPeEnumerateFileStreams(lvHandle);
//ExtendedListView_SortItems(lvHandle);
EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
}
break;
case WM_DESTROY:
{
PhSaveListViewColumnsToSetting(L"ImageAttributesListViewColumns", GetDlgItem(hwndDlg, IDC_LIST));
PhSaveListViewColumnsToSetting(L"ImageStreamsListViewColumns", GetDlgItem(hwndDlg, IDC_LIST));
}
break;
case WM_SHOWWINDOW: