Update to the latest SDK

This commit is contained in:
dmex
2024-12-01 16:35:49 +11:00
parent f8757ab345
commit 95bc2fe8c1
42 changed files with 1548 additions and 643 deletions
-3
View File
@@ -216,15 +216,12 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
if (PhIsNullOrEmptyString(entry->Name))
unknownType = PhFormatString(L"(unknown: %lu)", (ULONG)i);
countString = PhFormatUInt64(entry->Count, TRUE);
lvItemIndex = PhAddListViewItem(
context->ListViewHandle,
MAXINT,
PhIsNullOrEmptyString(entry->Name) ? PhGetString(entry->Name) : PhGetString(unknownType),
entry
);
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, 1, countString->Buffer);
countString = PhFormatUInt64(entry->Count, TRUE);
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, 1, countString->Buffer);
+1
View File
@@ -410,6 +410,7 @@ VOID PhMwpShowWindow(
ShowWindow(PhMainWndHandle, ShowCommand);
UpdateWindow(PhMainWndHandle);
SetForegroundWindow(PhMainWndHandle);
PhConsoleSetForeground(NtCurrentProcess(), TRUE);
}
if (PhGetIntegerSetting(L"MiniInfoWindowPinned"))
+5 -1
View File
@@ -279,7 +279,11 @@ VOID PhNfCreateIconThreadDelayed(
// Use a separate thread so we don't block the main GUI or
// the provider threads when explorer is not responding. (dmex)
PhCreateThreadEx(&PhpTrayIconThreadHandle, PhNfpTrayIconUpdateThread, NULL);
if (NT_SUCCESS(PhCreateThreadEx(&PhpTrayIconThreadHandle, PhNfpTrayIconUpdateThread, NULL)))
{
NtClose(PhpTrayIconThreadHandle);
PhpTrayIconThreadHandle = NULL;
}
}
PhEndInitOnce(&initOnce);
+1 -1
View File
@@ -6596,7 +6596,7 @@ PPH_STRING PhBufferToHexStringEx(
{
PPH_STRING string;
PCCH table;
ULONG i;
SIZE_T i;
if (UpperCase)
table = PhIntegerToCharUpper;
+2 -2
View File
@@ -259,7 +259,7 @@ PhDeleteWindowsRuntimeString(
);
PHLIBAPI
UINT32
ULONG
NTAPI
PhGetWindowsRuntimeStringLength(
_In_opt_ HSTRING String
@@ -270,7 +270,7 @@ PCWSTR
NTAPI
PhGetWindowsRuntimeStringBuffer(
_In_opt_ HSTRING String,
_Out_opt_ PUINT32 Length
_Out_opt_ PULONG Length
);
PHLIBAPI
+119 -53
View File
@@ -15,13 +15,47 @@
// "660B90C8-73A9-4B58-8CAE-355B7F55341B"
DEFINE_GUID(CLSID_StartMenuCacheAndAppResolver_I, 0x660B90C8, 0x73A9, 0x4B58, 0x8C, 0xAE, 0x35, 0x5B, 0x7F, 0x55, 0x34, 0x1B);
// "46A6EEFF-908E-4DC6-92A6-64BE9177B41C"
DEFINE_GUID(IID_IApplicationResolver61_I, 0x46A6EEFF, 0x908E, 0x4DC6, 0x92, 0xA6, 0x64, 0xBE, 0x91, 0x77, 0xB4, 0x1c);
DEFINE_GUID(IID_IApplicationResolver_I, 0x46A6EEFF, 0x908E, 0x4DC6, 0x92, 0xA6, 0x64, 0xBE, 0x91, 0x77, 0xB4, 0x1c);
// "DE25675A-72DE-44b4-9373-05170450C140"
DEFINE_GUID(IID_IApplicationResolver62_I, 0xDE25675A, 0x72DE, 0x44b4, 0x93, 0x73, 0x05, 0x17, 0x04, 0x50, 0xC1, 0x40);
DEFINE_GUID(IID_IApplicationResolver2_I, 0xDE25675A, 0x72DE, 0x44b4, 0x93, 0x73, 0x05, 0x17, 0x04, 0x50, 0xC1, 0x40);
// "33F71155-C2E9-4FFE-9786-A32D98577CFF"
DEFINE_GUID(IID_IStartMenuAppItems61_I, 0x33F71155, 0xC2E9, 0x4FFE, 0x97, 0x86, 0xA3, 0x2D, 0x98, 0x57, 0x7C, 0xFF);
DEFINE_GUID(IID_IStartMenuAppItems_I, 0x33F71155, 0xC2E9, 0x4FFE, 0x97, 0x86, 0xA3, 0x2D, 0x98, 0x57, 0x7C, 0xFF);
// "02C5CCF3-805F-4654-A7B7-340A74335365"
DEFINE_GUID(IID_IStartMenuAppItems62_I, 0x02C5CCF3, 0x805F, 0x4654, 0xA7, 0xB7, 0x34, 0x0A, 0x74, 0x33, 0x53, 0x65);
DEFINE_GUID(IID_IStartMenuAppItems2_I, 0x02C5CCF3, 0x805F, 0x4654, 0xA7, 0xB7, 0x34, 0x0A, 0x74, 0x33, 0x53, 0x65);
// ba5a92ae_bfd7_4916_854f_6b3a402b84a8
// 21cbc515_2dde_4d66_8292_ba34bd25094a
// 17541a17_f509_4cb6_8d08_651dc68d8227
// 67383c80_7543_4e04_9e97_c990f5e3878d
// 3af46105_16ce_776f_43a2_341172b6e95a
// 6b1d7151_7a17_4c66_abc4_c9b1bc6c0e8d
// ffd2cca4_adfb_46e9_9a02_49d019db2a68
// 8dda7cc4_ae71_4e2a_bc8d_7f16ec66f540
// "ba5a92ae-bfd7-4916-854f-6b3a402b84a8"
//DEFINE_GUID(IID_IStartMenuItemsCache, 0xba5a92ae, 0xbfd7, 0x4916, 0x85, 0x4f, 0x6b, 0x3a, 0x40, 0x2b, 0x84, 0xa8);
// "21cbc515-2dde-4d66-8292-ba34bd25094a"
DEFINE_GUID(IID_IDesktopTileActivator, 0x21cbc515, 0x2dde, 0x4d66, 0x82, 0x92, 0xba, 0x34, 0xbd, 0x25, 0x09, 0x4a);
// "17541a17-f509-4cb6-8d08-651dc68d8227"
DEFINE_GUID(IID_IAppResolverPinToStart, 0x17541a17, 0xf509, 0x4cb6, 0x8d, 0x08, 0x65, 0x1d, 0xc6, 0x8d, 0x82, 0x27);
// "67383c80-7543-4e04-9e97-c990f5e3878d"
DEFINE_GUID(IID_ILauncherAppList, 0x67383c80, 0x7543, 0x4e04, 0x9e, 0x97, 0xc9, 0x90, 0xf5, 0xe3, 0x87, 0x8d);
// "3af46105-16ce-776f-43a2-341172b6e95a"
DEFINE_GUID(IID_IStartMenuRankManager, 0x3af46105, 0x16ce, 0x776f, 0x43, 0xa2, 0x34, 0x11, 0x72, 0xb6, 0xe9, 0x5a);
// "6b1d7151-7a17-4c66-abc4-c9b1bc6c0e8d"
DEFINE_GUID(IID_IAppResolverCacheAccessor, 0x6b1d7151, 0x7a17, 0x4c66, 0xab, 0xc4, 0xc9, 0xb1, 0xbc, 0x6c, 0x0e, 0x8d);
// "ffd2cca4-adfb-46e9-9a02-49d019db2a68"
DEFINE_GUID(IID_IAppResolverPinToStartFF, 0xffd2cca4, 0xadfb, 0x46e9, 0x9a, 0x02, 0x49, 0xd0, 0x19, 0xdb, 0x2a, 0x68);
// "8dda7cc4-ae71-4e2a-bc8d-7f16ec66f540"
DEFINE_GUID(IID_IAppResolverPinToStartF, 0x8dda7cc4, 0xae71, 0x4e2a, 0xbc, 0x8d, 0x7f, 0x16, 0xec, 0x66, 0xf5, 0x40);
// "DE25675A-72DE-44b4-9373-05170450C140"
// IStartMenuItemsCache
// IDesktopTileActivator
// IAppResolverPinToStart
// ILauncherAppList
// IStartMenuRankManager
// IAppResolverCacheAccessor
// "DBCE7E40-7345-439D-B12C-114A11819A09"
DEFINE_GUID(CLSID_MrtResourceManager_I, 0xDBCE7E40, 0x7345, 0x439D, 0xB1, 0x2C, 0x11, 0x4A, 0x11, 0x81, 0x9A, 0x09);
@@ -174,16 +208,14 @@ DECLARE_INTERFACE_IID(IDesktopAppXActivator, IUnknown)
#define IDesktopAppXActivator_ActivateWithOptions(This, ApplicationUserModelId, Executable, Arguments, ActivationOptions, ParentProcessId, ProcessHandle) \
((This)->lpVtbl->ActivateWithOptions(This, ApplicationUserModelId, Executable, Arguments, ActivationOptions, ParentProcessId, ProcessHandle))
typedef enum _START_MENU_APP_ITEMS_FLAGS
{
SMAIF_DEFAULT = 0,
SMAIF_EXTENDED = 1,
SMAIF_USAGEINFO = 2
} START_MENU_APP_ITEMS_FLAGS;
// "ba5a92ae-bfd7-4916-854f-6b3a402b84a8"
DEFINE_GUID(IID_IStartMenuItemsCache, 0xba5a92ae, 0xbfd7, 0x4916, 0x85, 0x4f, 0x6b, 0x3a, 0x40, 0x2b, 0x84, 0xa8);
// Note: Interface checks GetModuleFileNameW is equal L"EXPLORER.EXE",
// else L"PPISHELL.EXE", L"TE.PROCESSHOST.EXE" from HKLM "AppResolverHostProcess"
#undef INTERFACE
#define INTERFACE IApplicationResolver61
DECLARE_INTERFACE_IID(IApplicationResolver61, IUnknown)
#define INTERFACE IStartMenuItemsCache
DECLARE_INTERFACE_IID(IStartMenuItemsCache, IUnknown)
{
BEGIN_INTERFACE
@@ -192,7 +224,40 @@ DECLARE_INTERFACE_IID(IApplicationResolver61, IUnknown)
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// IApplicationResolver61
// IStartMenuItemsCache
STDMETHOD(OnChangeNotify)(THIS, _In_ ULONG, _In_ LONG, _In_ PCIDLIST_ABSOLUTE, _In_ PCIDLIST_ABSOLUTE);
STDMETHOD(RegisterForNotifications)(THIS) PURE;
STDMETHOD(UnregisterForNotifications)(THIS) PURE;
STDMETHOD(PauseNotifications)(THIS) PURE;
STDMETHOD(ResumeNotifications)(THIS) PURE;
STDMETHOD(RegisterARNotify)(THIS, struct IAppResolverNotify*);
STDMETHOD(RefreshCache)(THIS, enum START_MENU_REFRESH_CACHE_FLAGS Flags);
STDMETHOD(ReleaseGlobalCacheObject)(THIS) PURE;
STDMETHOD(IsCacheMatchingLanguage)(THIS, PLONG);
STDMETHOD(EnableAppUsageData)(THIS) PURE;
END_INTERFACE
};
typedef enum _START_MENU_APP_ITEMS_FLAGS
{
SMAIF_DEFAULT = 0,
SMAIF_EXTENDED = 1,
SMAIF_USAGEINFO = 2
} START_MENU_APP_ITEMS_FLAGS;
#undef INTERFACE
#define INTERFACE IApplicationResolver
DECLARE_INTERFACE_IID(IApplicationResolver, IUnknown)
{
BEGIN_INTERFACE
// IUnknown
STDMETHOD(QueryInterface)(THIS, REFIID riid, PVOID *ppvObject) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// IApplicationResolver
STDMETHOD(GetAppIDForShortcut)(THIS,
_In_ IShellItem *psi,
_Outptr_ PWSTR *ppszAppID
@@ -274,9 +339,16 @@ DECLARE_INTERFACE_IID(IApplicationResolver61, IUnknown)
#define IApplicationResolver_GenerateShortcutFromItemProperties(This, psi2, ppsi) \
((This)->lpVtbl->GenerateShortcutFromItemProperties(This, psi2, ppsi))
typedef enum tagAPP_RESOLVER_ITEM_FILTER_FLAGS
{
ARIFF_NONE = 0,
ARIFF_REQUIRE_PREVENT_PINNING_NOT_SET = 1,
ARIFF_REQUIRE_PINNABLE = 2,
} APP_RESOLVER_ITEM_FILTER_FLAGS;
#undef INTERFACE
#define INTERFACE IApplicationResolver62
DECLARE_INTERFACE_IID(IApplicationResolver62, IUnknown)
#define INTERFACE IApplicationResolver2
DECLARE_INTERFACE_IID(IApplicationResolver2, IUnknown)
{
BEGIN_INTERFACE
@@ -285,7 +357,7 @@ DECLARE_INTERFACE_IID(IApplicationResolver62, IUnknown)
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// IApplicationResolver62
// IApplicationResolver2
STDMETHOD(GetAppIDForShortcut)(THIS,
_In_ IShellItem *psi,
_Outptr_ PWSTR *ppszAppID
@@ -345,10 +417,19 @@ DECLARE_INTERFACE_IID(IApplicationResolver62, IUnknown)
_In_ IShellItem2 *psi2,
_Out_opt_ IShellItem **ppsi
) PURE;
// STDMETHOD(GetLauncherAppIDForItem)(THIS)
// STDMETHOD(GetShortcutForAppID)(THIS)
// STDMETHOD(GetLauncherAppIDForItemEx)(THIS)
STDMETHOD(GetLauncherAppIDForItem)(THIS,
_In_ IShellItem *psi,
_Outptr_opt_ PWSTR *ppszAppID
) PURE;
STDMETHOD(GetShortcutForAppID)(THIS,
_In_ PCWSTR ppszAppID,
_Out_opt_ IShellItem **ppsi
) PURE;
STDMETHOD(GetLauncherAppIDForItemEx)(THIS,
_In_ IShellItem *psi,
_In_ APP_RESOLVER_ITEM_FILTER_FLAGS Flags,
_Outptr_opt_ PWSTR *ppszAppID
) PURE;
END_INTERFACE
};
@@ -385,8 +466,8 @@ DECLARE_INTERFACE_IID(IApplicationResolver62, IUnknown)
((This)->lpVtbl->GenerateShortcutFromItemProperties(This, psi2, ppsi))
#undef INTERFACE
#define INTERFACE IStartMenuAppItems61
DECLARE_INTERFACE_IID(IStartMenuAppItems61, IUnknown)
#define INTERFACE IStartMenuAppItems
DECLARE_INTERFACE_IID(IStartMenuAppItems, IUnknown)
{
BEGIN_INTERFACE
@@ -395,7 +476,7 @@ DECLARE_INTERFACE_IID(IStartMenuAppItems61, IUnknown)
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// IStartMenuAppItems61
// IStartMenuAppItems
STDMETHOD(EnumItems)(THIS,
_In_ START_MENU_APP_ITEMS_FLAGS Flags,
_In_ REFIID riid, // IID_IEnumObjects, IID_IObjectCollection
@@ -405,7 +486,7 @@ DECLARE_INTERFACE_IID(IStartMenuAppItems61, IUnknown)
_In_ START_MENU_APP_ITEMS_FLAGS Flags,
_In_ PCWSTR AppUserModelId,
_In_ REFIID riid,
_Outptr_ PVOID *ppvObject // ppvObject == IPropertyStore, IStartMenuAppItems61
_Outptr_ PVOID *ppvObject // ppvObject == IPropertyStore, IStartMenuAppItems
) PURE;
END_INTERFACE
@@ -423,8 +504,8 @@ DECLARE_INTERFACE_IID(IStartMenuAppItems61, IUnknown)
((This)->lpVtbl->GetItem(This, Flags, AppUserModelId, riid, ppvObject))
#undef INTERFACE
#define INTERFACE IStartMenuAppItems62
DECLARE_INTERFACE_IID(IStartMenuAppItems62, IUnknown)
#define INTERFACE IStartMenuAppItems2
DECLARE_INTERFACE_IID(IStartMenuAppItems2, IUnknown)
{
BEGIN_INTERFACE
@@ -433,7 +514,7 @@ DECLARE_INTERFACE_IID(IStartMenuAppItems62, IUnknown)
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// IStartMenuAppItems62
// IStartMenuAppItems2
STDMETHOD(EnumItems)(THIS,
_In_ START_MENU_APP_ITEMS_FLAGS Flags,
_In_ REFIID riid, // IID_IEnumObjects, IID_IObjectCollection
@@ -443,10 +524,18 @@ DECLARE_INTERFACE_IID(IStartMenuAppItems62, IUnknown)
_In_ START_MENU_APP_ITEMS_FLAGS Flags,
_In_ PCWSTR AppUserModelId,
_In_ REFIID riid,
_Outptr_ PVOID *ppvObject // ppvObject == IPropertyStore, IStartMenuAppItems61
_Outptr_ PVOID *ppvObject // ppvObject == IPropertyStore, IStartMenuAppItems
) PURE;
STDMETHOD(GetItemByAppPath)(THIS,
_In_ PCWSTR AppPath,
_In_ REFIID riid,
_Outptr_ PVOID *ppvObject
) PURE;
STDMETHOD(EnumCachedItems)(THIS,
_In_ PCIDLIST_ABSOLUTE pidl,
_In_ REFIID riid,
_Outptr_ PVOID *ppvObject
) PURE;
// STDMETHOD(GetItemByAppPath)(THIS)
// STDMETHOD(EnumCachedItems)(THIS)
END_INTERFACE
};
@@ -915,7 +1004,6 @@ typedef enum PackageGlobalizationProperty
// Package Properties
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -926,7 +1014,6 @@ GetCurrentPackageContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -938,7 +1025,6 @@ GetPackageContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -950,7 +1036,6 @@ GetPackageProperty(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -962,7 +1047,6 @@ GetPackagePropertyString(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -974,7 +1058,6 @@ GetPackageOSMaxVersionTested(
// Package Application Properties
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -985,7 +1068,6 @@ GetCurrentPackageApplicationContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -997,7 +1079,6 @@ GetPackageApplicationContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -1009,7 +1090,6 @@ GetPackageApplicationProperty(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -1023,7 +1103,6 @@ GetPackageApplicationPropertyString(
// Package Resource Properties
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -1034,7 +1113,6 @@ GetCurrentPackageResourcesContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -1046,7 +1124,6 @@ GetPackageResourcesContext(
);
// rev
_Success_(return == ERROR_SUCCESS)
WINBASEAPI
ULONG
WINAPI
@@ -1058,7 +1135,6 @@ GetCurrentPackageApplicationResourcesContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageApplicationResourcesContext(
@@ -1070,7 +1146,6 @@ GetPackageApplicationResourcesContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageResourcesProperty(
@@ -1084,7 +1159,6 @@ GetPackageResourcesProperty(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetCurrentPackageSecurityContext(
@@ -1094,7 +1168,6 @@ GetCurrentPackageSecurityContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageSecurityContext(
@@ -1105,7 +1178,6 @@ GetPackageSecurityContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageSecurityProperty(
@@ -1123,7 +1195,6 @@ GetPackageSecurityProperty(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetCurrentTargetPlatformContext(
@@ -1132,7 +1203,6 @@ GetCurrentTargetPlatformContext(
);
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetTargetPlatformContext(
@@ -1143,7 +1213,6 @@ GetTargetPlatformContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageTargetPlatformProperty(
@@ -1173,7 +1242,6 @@ GetCurrentPackageInfo3(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetCurrentPackageGlobalizationContext(
@@ -1184,7 +1252,6 @@ GetCurrentPackageGlobalizationContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageGlobalizationContext(
@@ -1196,7 +1263,6 @@ GetPackageGlobalizationContext(
// rev
WINBASEAPI
_Success_(return == ERROR_SUCCESS)
LONG
WINAPI
GetPackageGlobalizationProperty(
+2 -2
View File
@@ -70,10 +70,10 @@ PHLIBAPI
NTSTATUS
NTAPI
PhCreateFileStream(
_Out_ PPH_FILE_STREAM *FileStream,
_Out_ PPH_FILE_STREAM* FileStream,
_In_ PCWSTR FileName,
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG ShareMode,
_In_ ULONG ShareAccess,
_In_ ULONG CreateDisposition,
_In_ ULONG Flags
);
+249 -44
View File
@@ -14,6 +14,7 @@
#define _PH_PHGUI_H
#include <commctrl.h>
#include <guisupview.h>
EXTERN_C_START
@@ -67,21 +68,24 @@ PHLIBAPI
VOID
NTAPI
PhGuiSupportUpdateSystemMetrics(
_In_opt_ HWND WindowHandle
_In_opt_ HWND WindowHandle,
_In_opt_ LONG WindowDpi
);
PHLIBAPI
VOID
NTAPI
PhInitializeFont(
_In_ HWND WindowHandle
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
);
PHLIBAPI
VOID
NTAPI
PhInitializeMonospaceFont(
_In_ HWND WindowHandle
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
);
PHLIBAPI
@@ -384,7 +388,7 @@ FORCEINLINE WNDPROC PhGetWindowProcedure(
FORCEINLINE WNDPROC PhSetWindowProcedure(
_In_ HWND WindowHandle,
_In_ PVOID SubclassProcedure
_In_ WNDPROC SubclassProcedure
)
{
return (WNDPROC)SetWindowLongPtr(WindowHandle, GWLP_WNDPROC, (LONG_PTR)SubclassProcedure);
@@ -519,6 +523,34 @@ FORCEINLINE VOID PhSetListViewStyle(
);
}
PHLIBAPI
LONG
NTAPI
PhAddListViewColumnDpi(
_In_ HWND ListViewHandle,
_In_ LONG ListViewDpi,
_In_ LONG Index,
_In_ LONG DisplayIndex,
_In_ LONG SubItemIndex,
_In_ LONG Format,
_In_ LONG Width,
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
PhAddIListViewColumnDpi(
_In_ IListView* ListView,
_In_ LONG ListViewDpi,
_In_ LONG Index,
_In_ LONG DisplayIndex,
_In_ LONG SubItemIndex,
_In_ LONG Format,
_In_ LONG Width,
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
@@ -532,6 +564,19 @@ PhAddListViewColumn(
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
PhAddIListViewColumn(
_In_ IListView* ListView,
_In_ LONG Index,
_In_ LONG DisplayIndex,
_In_ LONG SubItemIndex,
_In_ LONG Format,
_In_ LONG Width,
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
@@ -542,6 +587,16 @@ PhAddListViewItem(
_In_opt_ PVOID Param
);
PHLIBAPI
LONG
NTAPI
PhAddIListViewItem(
_In_ IListView* ListView,
_In_ LONG Index,
_In_ PCWSTR Text,
_In_opt_ PVOID Param
);
PHLIBAPI
LONG
NTAPI
@@ -551,6 +606,15 @@ PhFindListViewItemByFlags(
_In_ ULONG Flags
);
PHLIBAPI
LONG
NTAPI
PhFindIListViewItemByFlags(
_In_ IListView* ListView,
_In_ LONG StartIndex,
_In_ ULONG Flags
);
PHLIBAPI
LONG
NTAPI
@@ -560,6 +624,15 @@ PhFindListViewItemByParam(
_In_opt_ PVOID Param
);
PHLIBAPI
LONG
NTAPI
PhFindIListViewItemByParam(
_In_ IListView* ListView,
_In_ LONG StartIndex,
_In_opt_ PVOID Param
);
_Success_(return)
PHLIBAPI
BOOLEAN
@@ -580,6 +653,16 @@ PhGetListViewItemParam(
_Outptr_ PVOID *Param
);
_Success_(return)
PHLIBAPI
BOOLEAN
NTAPI
PhGetIListViewItemParam(
_In_ IListView* ListView,
_In_ LONG Index,
_Outptr_ PVOID * Param
);
PHLIBAPI
BOOLEAN
NTAPI
@@ -616,6 +699,16 @@ PhSetListViewSubItem(
_In_ PCWSTR Text
);
PHLIBAPI
VOID
NTAPI
PhSetIListViewSubItem(
_In_ IListView* ListView,
_In_ LONG Index,
_In_ LONG SubItemIndex,
_In_ PCWSTR Text
);
PHLIBAPI
VOID
NTAPI
@@ -623,6 +716,14 @@ PhRedrawListViewItems(
_In_ HWND ListViewHandle
);
PHLIBAPI
VOID
NTAPI
PhRedrawIListViewItems(
_In_ IListView* ListView,
_In_ HWND ListViewHandle
);
PHLIBAPI
LONG
NTAPI
@@ -632,6 +733,15 @@ PhAddListViewGroup(
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
PhAddIListViewGroup(
_In_ IListView* ListView,
_In_ LONG GroupId,
_In_ PCWSTR Text
);
PHLIBAPI
LONG
NTAPI
@@ -643,6 +753,17 @@ PhAddListViewGroupItem(
_In_opt_ PVOID Param
);
PHLIBAPI
LONG
NTAPI
PhAddIListViewGroupItem(
_In_ IListView* ListView,
_In_ LONG GroupId,
_In_ LONG Index,
_In_ PCWSTR Text,
_In_opt_ PVOID Param
);
PHLIBAPI
LONG
NTAPI
@@ -745,6 +866,15 @@ PhSetStateAllListViewItems(
_In_ ULONG Mask
);
PHLIBAPI
VOID
NTAPI
PhSetStateAllIListViewItems(
_In_ IListView* ListView,
_In_ ULONG State,
_In_ ULONG Mask
);
PHLIBAPI
PVOID
NTAPI
@@ -752,6 +882,13 @@ PhGetSelectedListViewItemParam(
_In_ HWND WindowHandle
);
PHLIBAPI
PVOID
NTAPI
PhGetSelectedIListViewItemParam(
_In_ IListView* ListView
);
PHLIBAPI
VOID
NTAPI
@@ -762,7 +899,34 @@ PhGetSelectedListViewItemParams(
);
PHLIBAPI
PVOID
VOID
NTAPI
PhGetSelectedIListViewItemParams(
_In_ IListView* ListView,
_Out_ PVOID** Items,
_Out_ PULONG NumberOfItems
);
PHLIBAPI
BOOLEAN
NTAPI
PhGetIListViewClientRect(
_In_ IListView* ListView,
_Inout_ PRECT ClientRect
);
PHLIBAPI
BOOLEAN
NTAPI
PhGetIListViewItemRect(
_In_ IListView* ListView,
_In_ LONG StartIndex,
_In_ ULONG Flags,
_Inout_ PRECT ItemRect
);
PHLIBAPI
IListView*
NTAPI
PhGetListViewInterface(
_In_ HWND ListViewHandle
@@ -790,8 +954,8 @@ PhLoadIcon(
_In_opt_ PVOID ImageBaseAddress,
_In_ PCWSTR Name,
_In_ ULONG Flags,
_In_opt_ ULONG Width,
_In_opt_ ULONG Height,
_In_opt_ LONG Width,
_In_opt_ LONG Height,
_In_opt_ LONG SystemDpi
);
@@ -875,7 +1039,7 @@ PhCreateDialog(
PHLIBAPI
HWND
NTAPI
PhCreateWindowWx(
PhCreateWindowEx(
_In_ PCWSTR ClassName,
_In_opt_ PCWSTR WindowName,
_In_ ULONG Style,
@@ -1029,7 +1193,7 @@ PhGetWindowContextEx(
_In_ HWND WindowHandle
)
{
#if (PHNT_WINDOW_CLASS_CONTEXT)
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
return PhGetWindowContext(WindowHandle, MAXCHAR);
#else
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
@@ -1045,7 +1209,7 @@ PhSetWindowContextEx(
_In_ PVOID Context
)
{
#if (PHNT_WINDOW_CLASS_CONTEXT)
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
PhSetWindowContext(WindowHandle, MAXCHAR, Context);
#else
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
@@ -1060,7 +1224,7 @@ PhRemoveWindowContextEx(
_In_ HWND WindowHandle
)
{
#if (PHNT_WINDOW_CLASS_CONTEXT)
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
PhRemoveWindowContext(WindowHandle, MAXCHAR);
#else
//assert(GetClassLongPtr(WindowHandle, GCL_CBWNDEXTRA) == sizeof(PVOID));
@@ -1068,6 +1232,49 @@ PhRemoveWindowContextEx(
#endif
}
FORCEINLINE
PVOID
NTAPI
PhGetDialogContext(
_In_ HWND WindowHandle
)
{
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
return PhGetWindowContext(WindowHandle, MAXCHAR);
#else
return (PVOID)GetWindowLongPtr(WindowHandle, DWLP_USER);
#endif
}
FORCEINLINE
VOID
NTAPI
PhSetDialogContext(
_In_ HWND WindowHandle,
_In_ PVOID Context
)
{
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
PhSetWindowContext(WindowHandle, MAXCHAR, Context);
#else
SetWindowLongPtr(WindowHandle, DWLP_USER, (LONG_PTR)Context);
#endif
}
FORCEINLINE
VOID
NTAPI
PhRemoveDialogContext(
_In_ HWND WindowHandle
)
{
#if defined(PHNT_WINDOW_CLASS_CONTEXT)
PhRemoveWindowContext(WindowHandle, MAXCHAR);
#else
SetWindowLongPtr(WindowHandle, DWLP_USER, (LONG_PTR)NULL);
#endif
}
typedef BOOL (CALLBACK* PH_ENUM_CALLBACK)(
_In_ HWND WindowHandle,
_In_opt_ PVOID Context
@@ -1208,7 +1415,7 @@ FORCEINLINE VOID PhCopyControlRectangle(
RECT windowRect;
GetWindowRect(FromControlHandle, &windowRect);
MapWindowPoints(NULL, ParentWindowHandle, (POINT *)&windowRect, 2);
MapWindowRect(NULL, ParentWindowHandle, &windowRect);
MoveWindow(ToControlHandle, windowRect.left, windowRect.top,
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, FALSE);
}
@@ -1489,6 +1696,22 @@ PhWindowNotifyTopMostEvent(
_In_ BOOLEAN TopMost
);
PHLIBAPI
NTSTATUS
NTAPI
PhCreateEnvironmentBlock(
_Outptr_ PVOID* Environment,
_In_opt_ HANDLE TokenHandle,
_In_ BOOLEAN Inherit
);
PHLIBAPI
VOID
NTAPI
PhDestroyEnvironmentBlock(
_In_ _Post_invalid_ PVOID Environment
);
_Success_(return)
PHLIBAPI
BOOLEAN
@@ -1745,7 +1968,7 @@ PhImageListDrawEx(
_In_ LONG dy,
_In_ COLORREF BackColor,
_In_ COLORREF ForeColor,
_In_ UINT Style,
_In_ UINT32 Style,
_In_ ULONG State
);
@@ -1779,30 +2002,6 @@ PhSetProcessShutdownParameters(
_In_ ULONG Flags
);
PHLIBAPI
VOID
NTAPI
PhCustomDrawTreeCpuHeatMap(
_In_ HWND WindowHandle,
_In_ HDC Hdc,
_In_ RECT CellRect,
_In_ RECT TextRect,
_In_ ULONG ShowCpuBelow001,
_In_ FLOAT Value
);
PHLIBAPI
VOID
NTAPI
PhCustomDrawTreePrivateBytesHeatMap(
_In_ HWND WindowHandle,
_In_ HDC Hdc,
_In_ RECT CellRect,
_In_ RECT TextRect,
_In_ SIZE_T Value,
_In_ SIZE_T Total
);
#define PH_DRAW_TIMELINE_OVERFLOW 0x1
#define PH_DRAW_TIMELINE_DARKTHEME 0x2
@@ -2103,9 +2302,15 @@ extern COLORREF PhThemeWindowTextColor;
PHLIBAPI
VOID
NTAPI
PhInitializeWindowTheme(
_In_ HWND WindowHandle,
_In_ BOOLEAN EnableThemeSupport
PhUpdateWindowThemeSupport(
_In_ ULONG EnableThemeSupport
);
PHLIBAPI
VOID
NTAPI
PhSetWindowTheme(
_In_ HWND WindowHandle
);
PHLIBAPI
@@ -2347,7 +2552,7 @@ PhRectEmpty(
_In_ PRECT Rect
)
{
#if (PHNT_NATIVE_RECT)
#if defined(PHNT_NATIVE_RECT)
return !!IsRectEmpty(Rect);
#else
if (!Rect)
@@ -2369,7 +2574,7 @@ PhInflateRect(
_In_ LONG dy
)
{
#if (PHNT_NATIVE_RECT)
#if defined(PHNT_NATIVE_RECT)
InflateRect(Rect, dx, dy);
#else
Rect->left -= dx;
@@ -2388,7 +2593,7 @@ PhOffsetRect(
_In_ LONG dy
)
{
#if (PHNT_NATIVE_RECT)
#if defined(PHNT_NATIVE_RECT)
OffsetRect(Rect, dx, dy);
#else
Rect->left += dx;
@@ -2406,7 +2611,7 @@ PhPtInRect(
_In_ POINT Point
)
{
#if (PHNT_NATIVE_RECT)
#if defined(PHNT_NATIVE_RECT)
return !!PtInRect(Rect, Point);
#else
return Point.x >= Rect->left && Point.x < Rect->right &&
-11
View File
@@ -18,14 +18,6 @@
#pragma comment(lib, "comctl32.lib")
#endif
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#if !defined(_PHLIB_)
#define PHLIBAPI __declspec(dllimport)
#else
@@ -37,9 +29,6 @@
#include <phsup.h>
#include <ref.h>
#include <queuedlock.h>
#include <stdlib.h>
#include <phconfig.h>
#include <phbasesup.h>
#include <phdata.h>
+87 -10
View File
@@ -48,6 +48,7 @@ NTAPI
PhCreateUserThread(
_In_ HANDLE ProcessHandle,
_In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ ULONG CreateFlags,
_In_opt_ SIZE_T ZeroBits,
_In_opt_ SIZE_T StackSize,
@@ -94,6 +95,51 @@ PhQueueUserWorkItem(
// Misc. system
PHLIBAPI
ULONGLONG
NTAPI
PhReadTimeStampCounter(
VOID
);
PHLIBAPI
BOOLEAN
NTAPI
PhQueryPerformanceCounter(
_Out_ PLARGE_INTEGER PerformanceCounter
);
PHLIBAPI
BOOLEAN
NTAPI
PhQueryPerformanceFrequency(
_Out_ PLARGE_INTEGER PerformanceFrequency
);
FORCEINLINE
ULONGLONG
NTAPI
PhReadPerformanceCounter(
VOID
)
{
LARGE_INTEGER counter;
PhQueryPerformanceCounter(&counter);
return (ULONGLONG)counter.QuadPart;
}
FORCEINLINE
ULONGLONG
NTAPI
PhReadPerformanceFrequency(
VOID
)
{
LARGE_INTEGER counter;
PhQueryPerformanceCounter(&counter);
return (ULONGLONG)counter.QuadPart;
}
PHLIBAPI
VOID
NTAPI
@@ -214,6 +260,7 @@ PhFree(
PHLIBAPI
_May_raise_
_Post_writable_byte_size_(Size)
_Success_(return != NULL)
DECLSPEC_ALLOCATOR
DECLSPEC_NOALIAS
DECLSPEC_RESTRICT
@@ -228,6 +275,7 @@ PHLIBAPI
_Must_inspect_result_
_Ret_maybenull_
_Post_writable_byte_size_(Size)
_Success_(return != NULL)
DECLSPEC_ALLOCATOR
DECLSPEC_NOALIAS
DECLSPEC_RESTRICT
@@ -267,6 +315,28 @@ PhFreePage(
_In_ _Post_invalid_ PVOID Memory
);
PHLIBAPI
_Must_inspect_result_
_Ret_maybenull_
_Post_writable_byte_size_(Size)
_Success_(return != NULL)
DECLSPEC_ALLOCATOR
DECLSPEC_NOALIAS
DECLSPEC_RESTRICT
PVOID
NTAPI
PhAllocatePageAligned(
_In_ SIZE_T Size,
_In_ SIZE_T Alignment
);
PHLIBAPI
VOID
NTAPI
PhFreePageAligned(
_In_ _Post_invalid_ PVOID Memory
);
PHLIBAPI
NTSTATUS
NTAPI
@@ -343,7 +413,7 @@ PhInitializeSListHead(
_Out_ PSLIST_HEADER ListHead
)
{
#if (PHNT_NATIVE_SLIST)
#if defined(PHNT_NATIVE_SLIST)
RtlInitializeSListHead(ListHead);
#else
if (IS_ALIGNED(ListHead, MEMORY_ALLOCATION_ALIGNMENT))
@@ -361,7 +431,7 @@ PhQueryDepthSList(
_In_ PSLIST_HEADER ListHead
)
{
#if (PHNT_NATIVE_SLIST)
#if defined(PHNT_NATIVE_SLIST)
return RtlQueryDepthSList(ListHead);
#else
#ifdef _M_X64
@@ -407,7 +477,7 @@ typedef struct _PH_EVENT
HANDLE EventHandle;
} PH_EVENT, *PPH_EVENT;
C_ASSERT(sizeof(PH_EVENT) == sizeof(ULONG_PTR) + sizeof(HANDLE));
static_assert(sizeof(PH_EVENT) == sizeof(ULONG_PTR) + sizeof(HANDLE));
#define PH_EVENT_INIT { { PH_EVENT_REFCOUNT_INC }, NULL }
@@ -461,8 +531,8 @@ PhInitializeEvent(
_Out_ PPH_EVENT Event
)
{
Event->Value = PH_EVENT_REFCOUNT_INC;
Event->EventHandle = NULL;
WriteULongPtrRelease(&Event->Value, PH_EVENT_REFCOUNT_INC);
WritePointerRelease(&Event->EventHandle, UlongToPtr(0));
}
/**
@@ -1636,7 +1706,7 @@ PhGetStringRefZ(
if (String)
return String->Buffer;
else
return TEXT("");
return L"";
}
/**
@@ -1654,7 +1724,7 @@ PhGetStringOrEmpty(
if (String)
return String->Buffer;
else
return TEXT("");
return L"";
}
/**
@@ -3868,7 +3938,7 @@ BOOLEAN
NTAPI
PhHexStringToBufferEx(
_In_ PPH_STRINGREF String,
_In_ ULONG BufferLength,
_In_ SIZE_T BufferLength,
_Out_writes_bytes_(BufferLength) PVOID Buffer
);
@@ -3877,14 +3947,14 @@ PPH_STRING
NTAPI
PhBufferToHexString(
_In_reads_bytes_(Length) PUCHAR Buffer,
_In_ ULONG Length
_In_ SIZE_T Length
);
PPH_STRING
NTAPI
PhBufferToHexStringEx(
_In_reads_bytes_(Length) PUCHAR Buffer,
_In_ ULONG Length,
_In_ SIZE_T Length,
_In_ BOOLEAN UpperCase
);
@@ -3987,6 +4057,7 @@ PhFormatEntropy(
_In_opt_ USHORT VariancePrecision
);
DECLSPEC_NOALIAS
PHLIBAPI
VOID
NTAPI
@@ -3996,6 +4067,7 @@ PhFillMemoryUlong(
_In_ SIZE_T Count
);
DECLSPEC_NOALIAS
PHLIBAPI
VOID
NTAPI
@@ -4005,6 +4077,7 @@ PhDivideSinglesBySingle(
_In_ SIZE_T Count
);
DECLSPEC_NOALIAS
PHLIBAPI
FLOAT
NTAPI
@@ -4013,6 +4086,7 @@ PhMaxMemorySingles(
_In_ SIZE_T Count
);
DECLSPEC_NOALIAS
PHLIBAPI
FLOAT
NTAPI
@@ -4022,6 +4096,7 @@ PhAddPlusMaxMemorySingles(
_In_ SIZE_T Count
);
DECLSPEC_NOALIAS
PHLIBAPI
VOID
NTAPI
@@ -4031,6 +4106,7 @@ PhConvertCopyMemoryUlong(
_In_ SIZE_T Count
);
DECLSPEC_NOALIAS
PHLIBAPI
VOID
NTAPI
@@ -4042,6 +4118,7 @@ PhConvertCopyMemorySingles(
typedef struct _PH_CIRCULAR_BUFFER_ULONG* PPH_CIRCULAR_BUFFER_ULONG;
DECLSPEC_NOALIAS
PHLIBAPI
VOID
NTAPI
+2 -1
View File
@@ -55,7 +55,7 @@ extern PCWSTR WindowsVersionName;
#define WINDOWS_NEW ULONG_MAX
#ifdef DEBUG
#define dprintf(format, ...) DbgPrint(format, ##__VA_ARGS__)
#define dprintf(format, ...) DbgPrint(format __VA_OPT__(,) __VA_ARGS__)
#else
#define dprintf(format, ...)
#endif
@@ -91,6 +91,7 @@ typedef struct _PH_SYSTEM_BASIC_INFORMATION
{
USHORT PageSize;
USHORT NumberOfProcessors;
ULONG MaximumTimerResolution;
ULONG NumberOfPhysicalPages;
ULONG AllocationGranularity;
ULONG_PTR MaximumUserModeAddress;
+4 -4
View File
@@ -77,7 +77,7 @@ PhPopulationCount32(
#ifdef _WIN64
FORCEINLINE
ULONG
ULONG64
PhPopulationCount64(
_In_ ULONG64 Value
)
@@ -96,9 +96,9 @@ PhPopulationCount64(
count32x2_val = vpaddl_u16(count16x4_val);
count64x1_val = vpaddl_u32(count32x2_val);
vst1_u64(&count, count64x1_val);
return (ULONG)count;
return (ULONG64)count;
#else
return (ULONG)_mm_popcnt_u64(Value);
return (ULONG64)_mm_popcnt_u64(Value);
#endif
}
#endif
@@ -243,7 +243,7 @@ PhSetINT128by16(
FORCEINLINE
PH_INT128
PhSetINT128by32(
_In_ INT32 Value
_In_ LONG Value
)
{
#ifdef _ARM64_
+168 -19
View File
@@ -15,10 +15,17 @@
EXTERN_C_START
/** The PID of the interrupt process. */
#define INTERRUPTS_PROCESS_ID ((HANDLE)(LONG_PTR)-3)
/** The PID of the dpc process. */
#define DPCS_PROCESS_ID ((HANDLE)(LONG_PTR)-2)
/** The PID of the current process. */
#define CURRENT_PROCESS_ID ((HANDLE)(LONG_PTR)-1)
/** The PID of the idle process. */
#define SYSTEM_IDLE_PROCESS_ID ((HANDLE)0)
/** The PID of the system process. */
#define SYSTEM_PROCESS_ID ((HANDLE)4)
/** The name of the system idle process. */
#define SYSTEM_IDLE_PROCESS_NAME ((UNICODE_STRING)RTL_CONSTANT_STRING(L"System Idle Process"))
@@ -44,6 +51,8 @@ typedef NTSTATUS (NTAPI *PPH_OPEN_OBJECT)(
);
typedef NTSTATUS (NTAPI *PPH_CLOSE_OBJECT)(
_In_ HANDLE Handle,
_In_ BOOLEAN Release,
_In_opt_ PVOID Context
);
@@ -132,7 +141,7 @@ NTAPI
PhOpenThreadClientId(
_Out_ PHANDLE ThreadHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ CLIENT_ID ClientId
_In_ PCLIENT_ID ClientId
);
PHLIBAPI
@@ -1076,6 +1085,28 @@ PhCreateSecurityDescriptor(
return STATUS_SUCCESS;
}
FORCEINLINE
NTSTATUS
NTAPI
PhCreateAcl(
_Out_ PACL Acl,
_In_ ULONG Length,
_In_ UCHAR Revision
)
{
if (Length < sizeof(ACL))
return STATUS_BUFFER_TOO_SMALL;
if (Length > USHRT_MAX)
return STATUS_INVALID_PARAMETER;
if (Revision < MIN_ACL_REVISION || Revision > MAX_ACL_REVISION)
return STATUS_INVALID_PARAMETER;
memset(Acl, 0, sizeof(ACL));
Acl->AclRevision = Revision;
Acl->AclSize = (USHORT)(Length & ~0x0003);
return STATUS_SUCCESS;
}
FORCEINLINE
NTSTATUS
NTAPI
@@ -1231,7 +1262,7 @@ NTAPI
PhGetTokenIntegrityLevelEx(
_In_ HANDLE TokenHandle,
_Out_opt_ PPH_INTEGRITY_LEVEL IntegrityLevel,
_Out_opt_ PPH_STRINGREF IntegrityString
_Out_opt_ PPH_STRINGREF* IntegrityString
);
PHLIBAPI
@@ -1421,12 +1452,14 @@ PhGetProcessIdsUsingFile(
_Out_ PFILE_PROCESS_IDS_USING_FILE_INFORMATION *ProcessIdsUsingFile
);
typedef USN *PUSN;
PHLIBAPI
NTSTATUS
NTAPI
PhGetFileUsn(
_In_ HANDLE FileHandle,
_Out_ PLONGLONG Usn
_Out_ PUSN Usn
);
PHLIBAPI
@@ -1538,7 +1571,7 @@ PhUnloadDriver(
_In_opt_ PCWSTR Name
);
typedef NTSTATUS (NTAPI* PPH_ENUM_PROCESS_VIRTUAL_IMAGES_CALLBACK)(
typedef NTSTATUS (NTAPI* PPH_ENUM_PROCESS_MODULES_LIMITED_CALLBACK)(
_In_ HANDLE ProcessHandle,
_In_ PVOID VirtualAddress,
_In_ PVOID ImageBase,
@@ -1552,7 +1585,23 @@ NTSTATUS
NTAPI
PhEnumProcessModulesLimited(
_In_ HANDLE ProcessHandle,
_In_ PPH_ENUM_PROCESS_VIRTUAL_IMAGES_CALLBACK Callback,
_In_ PPH_ENUM_PROCESS_MODULES_LIMITED_CALLBACK Callback,
_In_opt_ PVOID Context
);
typedef NTSTATUS (NTAPI* PPH_ENUM_PROCESS_MODULES_RUNDOWN_CALLBACK)(
_In_ PVOID ImageBase,
_In_ SIZE_T ImageSize,
_In_ PPH_STRING FileName,
_In_opt_ PVOID Context
);
PHLIBAPI
NTSTATUS
NTAPI
PhEnumProcessModulesRundown(
_In_opt_ ULONG ProcessId,
_In_ PPH_ENUM_PROCESS_MODULES_RUNDOWN_CALLBACK Callback,
_In_opt_ PVOID Context
);
@@ -1668,7 +1717,7 @@ PhSetProcessEmptyPageWorkingSet(
PHLIBAPI
NTSTATUS
NTAPI
PhGetProcessPriority(
PhGetProcessPriorityClass(
_In_ HANDLE ProcessHandle,
_Out_ PUCHAR PriorityClass
);
@@ -1676,7 +1725,7 @@ PhGetProcessPriority(
PHLIBAPI
NTSTATUS
NTAPI
PhSetProcessPriority(
PhSetProcessPriorityClass(
_In_ HANDLE ProcessHandle,
_In_ UCHAR PriorityClass
);
@@ -1911,8 +1960,7 @@ PhEnumHandlesGeneric(
_In_ HANDLE ProcessId,
_In_ HANDLE ProcessHandle,
_In_ BOOLEAN EnableHandleSnapshot,
_Out_ PSYSTEM_HANDLE_INFORMATION_EX* Handles,
_Out_ PBOOLEAN FilterNeeded
_Out_ PSYSTEM_HANDLE_INFORMATION_EX* Handles
);
#define PH_FIRST_PAGEFILE(Pagefiles) ( \
@@ -2205,13 +2253,6 @@ PhUpdateDosDevicePrefixes(
VOID
);
PHLIBAPI
BOOLEAN
NTAPI
PhIsMupDevicePrefix(
_In_ PPH_STRINGREF FileName
);
PHLIBAPI
NTSTATUS
NTAPI
@@ -2378,6 +2419,26 @@ PhCreateKey(
_Out_opt_ PULONG Disposition
);
FORCEINLINE
NTSTATUS
NTAPI
PhCreateKeyZ(
_Out_ PHANDLE KeyHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ HANDLE RootDirectory,
_In_ PCWSTR ObjectName,
_In_ ULONG Attributes,
_In_ ULONG CreateOptions,
_Out_opt_ PULONG Disposition
)
{
PH_STRINGREF name;
PhInitializeStringRef(&name, ObjectName);
return PhCreateKey(KeyHandle, DesiredAccess, RootDirectory, &name, Attributes, CreateOptions, Disposition);
}
PHLIBAPI
NTSTATUS
NTAPI
@@ -2389,6 +2450,24 @@ PhOpenKey(
_In_ ULONG Attributes
);
FORCEINLINE
NTSTATUS
NTAPI
PhOpenKeyZ(
_Out_ PHANDLE KeyHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ HANDLE RootDirectory,
_In_ PCWSTR ObjectName,
_In_ ULONG Attributes
)
{
PH_STRINGREF name;
PhInitializeStringRef(&name, ObjectName);
return PhOpenKey(KeyHandle, DesiredAccess, RootDirectory, &name, Attributes);
}
PHLIBAPI
NTSTATUS
NTAPI
@@ -2854,8 +2933,8 @@ NTAPI
PhCreatePipeEx(
_Out_ PHANDLE PipeReadHandle,
_Out_ PHANDLE PipeWriteHandle,
_In_ BOOLEAN InheritHandles,
_In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
_In_opt_ PSECURITY_ATTRIBUTES PipeReadAttributes,
_In_opt_ PSECURITY_ATTRIBUTES PipeWriteAttributes
);
PHLIBAPI
@@ -2967,6 +3046,13 @@ PhEnumDirectoryNamedPipe(
_In_opt_ PVOID Context
);
PHLIBAPI
NTSTATUS
NTAPI
PhDefaultNpAcl(
_Out_ PACL* DefaultNpAc
);
PHLIBAPI
NTSTATUS
NTAPI
@@ -3348,6 +3434,13 @@ PhGetThreadIsFiber(
_Out_ PBOOLEAN ThreadIsFiber
);
PHLIBAPI
BOOLEAN
NTAPI
PhSwitchToThread(
VOID
);
PHLIBAPI
BOOLEAN
NTAPI
@@ -3797,7 +3890,7 @@ NTSTATUS
NTAPI
PhIsEcCode(
_In_ HANDLE ProcessHandle,
_In_ ULONG64 CodePointer,
_In_ PVOID CodePointer,
_Out_ PBOOLEAN IsEcCode
);
#endif
@@ -3830,6 +3923,59 @@ PhFilterSendMessage(
_Out_ PULONG BytesReturned
);
typedef struct _FILTER_MESSAGE_HEADER
{
//
// OUT
//
// Total buffer length in bytes, including the FILTER_REPLY_HEADER, of
// the expected reply. If no reply is expected, 0 is returned.
//
ULONG ReplyLength;
//
// OUT
//
// Unique Id for this message. This will be set when the kernel message
// satifies this FilterGetMessage or FilterInstanceGetMessage request.
// If replying to this message, this is the MessageId that should be used.
//
ULONGLONG MessageId;
//
// General filter-specific buffer data follows...
//
} FILTER_MESSAGE_HEADER, *PFILTER_MESSAGE_HEADER;
typedef struct _FILTER_REPLY_HEADER
{
//
// IN.
//
// Status of this reply. This status will be returned back to the filter
// driver who is waiting for a reply.
//
NTSTATUS Status;
//
// IN
//
// Unique Id for this message. This id was returned in the
// FILTER_MESSAGE_HEADER from the kernel message to which we are replying.
//
ULONGLONG MessageId;
//
// General filter-specific buffer data follows...
//
} FILTER_REPLY_HEADER, *PFILTER_REPLY_HEADER;
PHLIBAPI
NTSTATUS
NTAPI
@@ -3849,6 +3995,9 @@ PhFilterReplyMessage(
_In_ ULONG ReplyBufferSize
);
// Filter connect options: Windows 8 and above
#define FLT_PORT_FLAG_SYNC_HANDLE 0x00000001
PHLIBAPI
NTSTATUS
NTAPI
+6 -1
View File
@@ -1985,8 +1985,13 @@ PhGetProcessIsCetEnabled(
if (NT_SUCCESS(status))
{
#if !defined(NTDDI_WIN10_CO) || (NTDDI_VERSION < NTDDI_WIN10_CO)
*IsCetEnabled = _bittest((const PLONG)&policyInfo.ControlFlowGuardPolicy.Flags, 0);
*IsCetStrictModeEnabled = _bittest((const PLONG)&policyInfo.ControlFlowGuardPolicy.Flags, 4);
#else
*IsCetEnabled = !!policyInfo.UserShadowStackPolicy.EnableUserShadowStack;
*IsCetStrictModeEnabled = !!policyInfo.UserShadowStackPolicy.EnableUserShadowStackStrictMode;
#endif
}
return status;
@@ -1996,7 +2001,7 @@ FORCEINLINE
NTSTATUS
NTAPI
PhGetSystemHypervisorSharedPageInformation(
_Out_ PPVOID HypervisorSharedUserVa
_Out_ PSYSTEM_HYPERVISOR_USER_SHARED_DATA* HypervisorSharedUserVa
)
{
NTSTATUS status;
+21 -12
View File
@@ -20,8 +20,13 @@
#include <assert.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <inttypes.h>
#include <math.h>
#include <malloc.h>
#include <float.h>
@@ -82,9 +87,13 @@
#if defined(_M_IX86)
#define UInt32Add32To64(a, b) ((unsigned __int64)(((unsigned __int64)((unsigned int)(a))) + ((unsigned int)(b)))) // Avoids warning C26451 (dmex)
#define UInt32Sub32To64(a, b) ((unsigned __int64)(((unsigned __int64)((unsigned int)(a))) - ((unsigned int)(b))))
#define UInt32Div32To64(a, b) ((unsigned __int64)(((unsigned __int64)((unsigned int)(a))) / ((unsigned int)(b))))
#define UInt32Mul32To64(a, b) ((unsigned __int64)(((unsigned __int64)((unsigned int)(a))) / ((unsigned int)(b))))
#else
#define UInt32Add32To64(a, b) (((unsigned __int64)((unsigned int)(a))) + ((unsigned __int64)((unsigned int)(b)))) // from UInt32x32To64 (dmex)
#define UInt32Sub32To64(a, b) (((unsigned __int64)((unsigned int)(a))) - ((unsigned __int64)((unsigned int)(b))))
#define UInt32Div32To64(a, b) (((unsigned __int64)((unsigned int)(a))) / ((unsigned __int64)((unsigned int)(b))))
#define UInt32Mul32To64(a, b) (((unsigned __int64)((unsigned int)(a))) * ((unsigned __int64)((unsigned int)(b))))
#endif
// Time
@@ -300,9 +309,9 @@ FORCEINLINE LONG_PTR __InterlockedExchangeAddPointer(
)
{
#ifdef _WIN64
return (LONG_PTR)_InterlockedExchangeAdd64((PLONG64)Addend, (LONG64)Value);
return (LONG_PTR)_InterlockedExchangeAdd64((volatile LONG64*)Addend, (LONG64)Value);
#else
return (LONG_PTR)_InterlockedExchangeAdd((PLONG)Addend, (LONG)Value);
return (LONG_PTR)_InterlockedExchangeAdd((volatile LONG*)Addend, (LONG)Value);
#endif
}
@@ -313,9 +322,9 @@ FORCEINLINE LONG_PTR _InterlockedIncrementPointer(
)
{
#ifdef _WIN64
return (LONG_PTR)_InterlockedIncrement64((PLONG64)Addend);
return (LONG_PTR)_InterlockedIncrement64((volatile LONG64*)Addend);
#else
return (LONG_PTR)_InterlockedIncrement((PLONG)Addend);
return (LONG_PTR)_InterlockedIncrement((volatile LONG*)Addend);
#endif
}
@@ -324,9 +333,9 @@ FORCEINLINE LONG_PTR __InterlockedDecrementPointer(
)
{
#ifdef _WIN64
return (LONG_PTR)_InterlockedDecrement64((PLONG64)Addend);
return (LONG_PTR)_InterlockedDecrement64((volatile LONG64*)Addend);
#else
return (LONG_PTR)_InterlockedDecrement((PLONG)Addend);
return (LONG_PTR)_InterlockedDecrement((volatile LONG*)Addend);
#endif
}
@@ -338,9 +347,9 @@ FORCEINLINE BOOLEAN _InterlockedBitTestAndResetPointer(
)
{
#ifdef _WIN64
return _interlockedbittestandreset64((PLONG64)Base, (LONG64)Bit);
return _interlockedbittestandreset64((volatile LONG64*)Base, (LONG64)Bit);
#else
return _interlockedbittestandreset((PLONG)Base, (LONG)Bit);
return _interlockedbittestandreset((volatile LONG*)Base, (LONG)Bit);
#endif
}
@@ -350,9 +359,9 @@ FORCEINLINE BOOLEAN _InterlockedBitTestAndSetPointer(
)
{
#ifdef _WIN64
return _interlockedbittestandset64((PLONG64)Base, (LONG64)Bit);
return _interlockedbittestandset64((volatile LONG64*)Base, (LONG64)Bit);
#else
return _interlockedbittestandset((PLONG)Base, (LONG)Bit);
return _interlockedbittestandset((volatile LONG*)Base, (LONG)Bit);
#endif
}
@@ -550,7 +559,7 @@ FORCEINLINE LONG PhMultiplyDivideSigned(
)
{
if (Number >= 0)
return PhMultiplyDivide(Number, Numerator, Denominator);
return (LONG)PhMultiplyDivide(Number, Numerator, Denominator);
else
return -(LONG)PhMultiplyDivide(-Number, Numerator, Denominator);
}
+12 -23
View File
@@ -252,6 +252,13 @@ PhGetWin32FormatMessage(
_In_ ULONG Result
);
PHLIBAPI
PPH_STRING
NTAPI
PhGetNtFormatMessage(
_In_ NTSTATUS Status
);
PHLIBAPI
LONG
NTAPI
@@ -275,7 +282,7 @@ PhShowMessage2(
_In_opt_ PCWSTR Icon,
_In_opt_ PCWSTR Title,
_In_ PCWSTR Format,
_In_ ...
...
);
#define TD_OK_BUTTON 0x0001
@@ -325,9 +332,12 @@ PhTaskDialogNavigatePage(
_In_ PTASKDIALOGCONFIG Config
)
{
#ifdef DEBUG
assert(HandleToUlong(NtCurrentThreadId()) == GetWindowThreadProcessId(WindowHandle, NULL));
#endif
#define WM_TDM_NAVIGATE_PAGE (WM_USER + 101)
SendMessage(WindowHandle, (WM_USER + 101), 0, (LPARAM)(Config));
SendMessage(WindowHandle, WM_TDM_NAVIGATE_PAGE, 0, (LPARAM)(Config));
}
_Success_(return)
@@ -2026,27 +2036,6 @@ PhDelayExecutionEx(
_In_ PLARGE_INTEGER DelayInterval
);
PHLIBAPI
ULONGLONG
NTAPI
PhReadTimeStampCounter(
VOID
);
PHLIBAPI
BOOLEAN
NTAPI
PhQueryPerformanceCounter(
_Out_ PLARGE_INTEGER PerformanceCounter
);
PHLIBAPI
BOOLEAN
NTAPI
PhQueryPerformanceFrequency(
_Out_ PLARGE_INTEGER PerformanceFrequency
);
// Stopwatch
typedef struct _PH_STOPWATCH
+4 -4
View File
@@ -38,11 +38,11 @@ typedef VOID (NTAPI *PPH_TYPE_DELETE_PROCEDURE)(
_In_ ULONG Flags
);
struct _PH_OBJECT_TYPE;
typedef struct _PH_OBJECT_TYPE *PPH_OBJECT_TYPE;
typedef struct _PH_OBJECT_TYPE PH_OBJECT_TYPE;
typedef PH_OBJECT_TYPE* PPH_OBJECT_TYPE;
struct _PH_QUEUED_LOCK;
typedef struct _PH_QUEUED_LOCK PH_QUEUED_LOCK, *PPH_QUEUED_LOCK;
typedef struct _PH_QUEUED_LOCK PH_QUEUED_LOCK;
typedef PH_QUEUED_LOCK* PPH_QUEUED_LOCK;
#ifdef DEBUG
typedef VOID (NTAPI *PPH_CREATE_OBJECT_HOOK)(
+28 -3
View File
@@ -94,7 +94,16 @@ C_ASSERT(FIELD_OFFSET(PH_OBJECT_HEADER, Body) == 0x8);
*
* \return A pointer to the object header of the object.
*/
#define PhObjectToObjectHeader(Object) ((PPH_OBJECT_HEADER)CONTAINING_RECORD((Object), PH_OBJECT_HEADER, Body))
//#define PhObjectToObjectHeader(Object) ((PPH_OBJECT_HEADER)CONTAINING_RECORD((Object), PH_OBJECT_HEADER, Body))
FORCEINLINE
PPH_OBJECT_HEADER
NTAPI
PhObjectToObjectHeader(
_In_ PVOID Object
)
{
return CONTAINING_RECORD(Object, PH_OBJECT_HEADER, Body);
}
/**
* Gets a pointer to an object from an object header.
@@ -103,7 +112,15 @@ C_ASSERT(FIELD_OFFSET(PH_OBJECT_HEADER, Body) == 0x8);
*
* \return A pointer to an object.
*/
#define PhObjectHeaderToObject(ObjectHeader) ((PVOID)&((PPH_OBJECT_HEADER)(ObjectHeader))->Body)
//#define PhObjectHeaderToObject(ObjectHeader) ((PVOID)&((PPH_OBJECT_HEADER)(ObjectHeader))->Body)
FORCEINLINE
PVOID
PhObjectHeaderToObject(
_In_ PPH_OBJECT_HEADER ObjectHeader
)
{
return &ObjectHeader->Body;
}
/**
* Calculates the total size to allocate for an object.
@@ -112,7 +129,15 @@ C_ASSERT(FIELD_OFFSET(PH_OBJECT_HEADER, Body) == 0x8);
*
* \return The new size, including space for the object header.
*/
#define PhAddObjectHeaderSize(Size) ((Size) + UFIELD_OFFSET(PH_OBJECT_HEADER, Body))
//#define PhAddObjectHeaderSize(Size) ((Size) + UFIELD_OFFSET(PH_OBJECT_HEADER, Body))
FORCEINLINE
SIZE_T
PhAddObjectHeaderSize(
_In_ SIZE_T Size
)
{
return UFIELD_OFFSET(PH_OBJECT_HEADER, Body) + Size;
}
/** An object type specifies a kind of object and its delete procedure. */
typedef struct _PH_OBJECT_TYPE
+16 -16
View File
@@ -52,8 +52,8 @@ typedef enum _PH_SYMBOL_RESOLVE_LEVEL
typedef struct _PH_SYMBOL_INFORMATION
{
ULONG64 Address;
ULONG64 ModuleBase;
PVOID Address;
PVOID ModuleBase;
ULONG Index;
ULONG Size;
} PH_SYMBOL_INFORMATION, *PPH_SYMBOL_INFORMATION;
@@ -91,7 +91,7 @@ BOOLEAN
NTAPI
PhGetLineFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_ PPH_STRING *FileName,
_Out_opt_ PULONG Displacement,
_Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information
@@ -99,11 +99,11 @@ PhGetLineFromAddress(
_Success_(return != 0)
PHLIBAPI
ULONG64
PVOID
NTAPI
PhGetModuleFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_opt_ PPH_STRING *FileName
);
@@ -114,7 +114,7 @@ PPH_SYMBOL_MODULE
NTAPI
PhGetSymbolModuleFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address
_In_ PVOID Address
);
_Success_(return != NULL)
@@ -123,7 +123,7 @@ PPH_STRING
NTAPI
PhGetSymbolFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_opt_ PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel,
_Out_opt_ PPH_STRING *FileName,
_Out_opt_ PPH_STRING *SymbolName,
@@ -146,7 +146,7 @@ NTAPI
PhLoadModuleSymbolProvider(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_STRING FileName,
_In_ ULONG64 BaseAddress,
_In_ PVOID BaseAddress,
_In_ ULONG Size
);
@@ -156,7 +156,7 @@ NTAPI
PhLoadFileNameSymbolProvider(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_STRING FileName,
_In_ ULONG64 BaseAddress,
_In_ PVOID BaseAddress,
_In_ ULONG Size
);
@@ -374,7 +374,7 @@ NTAPI
PhEnumerateSymbols(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ HANDLE ProcessHandle,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_In_opt_ PCWSTR Mask,
_In_ PPH_ENUMERATE_SYMBOLS_CALLBACK EnumSymbolsCallback,
_In_opt_ PVOID UserContext
@@ -386,7 +386,7 @@ BOOLEAN
NTAPI
PhGetSymbolProviderDiaSource(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_Out_ PVOID* DiaSource
);
@@ -396,7 +396,7 @@ BOOLEAN
NTAPI
PhGetSymbolProviderDiaSession(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_Out_ PVOID* DiaSession
);
@@ -466,7 +466,7 @@ PhGetSymbolFromInlineContext(
_Out_opt_ PPH_STRING* FileName,
_Out_opt_ PPH_STRING* SymbolName,
_Out_opt_ PULONG64 Displacement,
_Out_opt_ PULONG64 BaseAddress
_Out_opt_ PPVOID BaseAddress
);
_Success_(return)
@@ -476,7 +476,7 @@ NTAPI
PhGetLineFromInlineContext(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_THREAD_STACK_FRAME StackFrame,
_In_opt_ ULONG64 BaseAddress,
_In_opt_ PVOID BaseAddress,
_Out_ PPH_STRING* FileName,
_Out_opt_ PULONG Displacement,
_Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information
@@ -506,7 +506,7 @@ PhGetLineFromInlineContext(
typedef struct _PH_DIA_SYMBOL_INFORMATION
{
ULONG64 FunctionLength;
ULONG FunctionLength;
PPH_STRING UndecoratedName;
PPH_STRING SymbolInformation;
PPH_STRING SymbolLangugage;
@@ -515,7 +515,7 @@ typedef struct _PH_DIA_SYMBOL_INFORMATION
_Success_(return)
BOOLEAN PhGetDiaSymbolInformation(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_ PPH_DIA_SYMBOL_INFORMATION SymbolInformation
);
+1 -2
View File
@@ -850,9 +850,8 @@ VOID PhInitializeCapabilitySidCache(
if (!RtlDeriveCapabilitySidsFromName_Import())
return;
if (capabilityListFileName = PhGetApplicationDirectory())
if (capabilityListFileName = PhGetApplicationDirectoryFileNameZ(L"Resources\\CapsList.txt", TRUE))
{
PhMoveReference(&capabilityListFileName, PhConcatStringRefZ(&capabilityListFileName->sr, L"capslist.txt"));
capabilityListString = PhFileReadAllText(&capabilityListFileName->sr, TRUE);
PhDereferenceObject(capabilityListFileName);
}
+11 -11
View File
@@ -337,7 +337,7 @@ PVOID PhGetDllHandle(
_In_ PCWSTR DllName
)
{
#if (PHNT_NATIVE_LDR)
#if defined(PHNT_NATIVE_LDR)
UNICODE_STRING dllName;
PVOID dllHandle;
@@ -361,7 +361,7 @@ PVOID PhGetModuleProcAddress(
_In_opt_ PCSTR ProcedureName
)
{
#if (PHNT_NATIVE_LDR)
#if defined(PHNT_NATIVE_LDR)
PVOID module;
module = PhGetDllHandle(ModuleName);
@@ -384,7 +384,7 @@ PVOID PhGetProcedureAddress(
_In_opt_ USHORT ProcedureNumber
)
{
#if (PHNT_NATIVE_LDR)
#if defined(PHNT_NATIVE_LDR)
NTSTATUS status;
ANSI_STRING procedureName;
PVOID procedureAddress;
@@ -1714,8 +1714,8 @@ VOID PhLoaderEntrySnapShowErrorMessage(
{
PhShowError2(
NULL,
PhApplicationName,
L"Unable to load plugin.\r\nName: %s\r\nOrdinal: %u\r\nModule: %hs",
L"Unable to load plugin.",
L"Name: %s\r\nOrdinal: %u\r\nModule: %hs",
PhGetStringOrEmpty(fileName),
IMAGE_ORDINAL(OriginalThunk->u1.Ordinal),
ImportName
@@ -1729,8 +1729,8 @@ VOID PhLoaderEntrySnapShowErrorMessage(
PhShowError2(
NULL,
L"Error.",
L"Unable to load plugin.\r\nName: %s\r\nFunction: %hs\r\nModule: %hs",
L"Unable to load plugin.",
L"Name: %s\r\nFunction: %hs\r\nModule: %hs",
PhGetStringOrEmpty(fileName),
importByName->Name,
ImportName
@@ -1780,7 +1780,7 @@ NTSTATUS PhLoaderEntrySnapImportThunk(
return STATUS_ORDINAL_NOT_FOUND;
}
#if (PH_NATIVE_LOADER_WORKQUEUE)
#if defined(PH_NATIVE_LOADER_WORKQUEUE)
typedef struct _PH_LOADER_IMPORT_THUNK_WORKQUEUE_CONTEXT
{
PVOID BaseAddress;
@@ -1851,7 +1851,7 @@ NTSTATUS PhLoaderEntrySnapImportDirectory(
return STATUS_DLL_NOT_FOUND;
}
#if (PH_NATIVE_LOADER_WORKQUEUE)
#if defined(PH_NATIVE_LOADER_WORKQUEUE)
PTP_POOL loaderThreadpool;
TP_CALLBACK_ENVIRON loaderThreadpoolEnvironment;
PTP_CLEANUP_GROUP loaderThreadpoolCleanupGroup;
@@ -2666,7 +2666,7 @@ NTSTATUS PhLoadPluginImage(
PIMAGE_NT_HEADERS imageNtHeaders;
PLDR_INIT_ROUTINE imageEntryRoutine;
#if (PH_NATIVE_PLUGIN_IMAGE_LOAD)
#if defined(PH_NATIVE_PLUGIN_IMAGE_LOAD)
UNICODE_STRING imageFileName;
ULONG imageType;
@@ -2739,7 +2739,7 @@ CleanupExit:
}
else
{
#if (PH_NATIVE_PLUGIN_IMAGE_LOAD)
#if defined(PH_NATIVE_PLUGIN_IMAGE_LOAD)
LdrUnloadDll(imageBaseAddress);
#else
PhLoaderEntryUnloadDll(imageBaseAddress);
+140 -96
View File
@@ -533,6 +533,7 @@ NTSTATUS PhTerminateProcessAlternative(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -2225,6 +2226,7 @@ NTSTATUS PhLoadDllProcess(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -2250,13 +2252,8 @@ CleanupExit:
if (powerRequestHandle)
PhDestroyExecutionRequiredRequest(powerRequestHandle);
fileNameAllocationSize = 0;
NtFreeVirtualMemory(
ProcessHandle,
&fileNameBaseAddress,
&fileNameAllocationSize,
MEM_RELEASE
);
if (fileNameBaseAddress)
PhFreeVirtualMemory(ProcessHandle, fileNameBaseAddress, MEM_RELEASE);
return status;
}
@@ -2348,6 +2345,7 @@ NTSTATUS PhUnloadDllProcess(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -2514,6 +2512,7 @@ NTSTATUS PhSetEnvironmentVariableRemote(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
THREAD_CREATE_FLAGS_CREATE_SUSPENDED,
0,
0,
@@ -2724,8 +2723,8 @@ NTSTATUS PhPostWindowQuitMessageRemote(
)
{
NTSTATUS status;
CLIENT_ID clientId;
PVOID postQuitMessage = NULL;
HANDLE threadId = NULL;
HANDLE threadHandle = NULL;
HANDLE powerRequestHandle = NULL;
PPH_PROCESS_RUNTIME_LIBRARY runtimeLibrary;
@@ -2759,18 +2758,15 @@ NTSTATUS PhPostWindowQuitMessageRemote(
goto CleanupExit;
}
threadId = UlongToHandle(GetWindowThreadProcessId(WindowHandle, NULL));
status = PhGetWindowClientId(WindowHandle, NULL);
if (!threadId)
{
status = STATUS_NOT_FOUND;
if (!NT_SUCCESS(status))
goto CleanupExit;
}
status = PhOpenThread(
status = PhOpenThreadClientId(
&threadHandle,
THREAD_SET_CONTEXT, // THREAD_ALERT
threadId
&clientId
);
if (!NT_SUCCESS(status))
@@ -4168,7 +4164,7 @@ typedef struct _PH_INTEGRITY_LEVEL_STRING_ENTRY
NTSTATUS PhGetTokenIntegrityLevelEx(
_In_ HANDLE TokenHandle,
_Out_opt_ PPH_INTEGRITY_LEVEL IntegrityLevel,
_Out_opt_ PPH_STRINGREF IntegrityString
_Out_opt_ PPH_STRINGREF* IntegrityString
)
{
static PH_STRINGREF integrityLevelDefaultString = PH_STRINGREF_INIT(L"Other");
@@ -4240,13 +4236,13 @@ NTSTATUS PhGetTokenIntegrityLevelEx(
if (!IntegrityString)
return STATUS_SUCCESS;
*IntegrityString = integrityLevelDefaultString;
*IntegrityString = &integrityLevelDefaultString;
for (ULONG i = 0; i < RTL_NUMBER_OF(integrityLevelStringTable); i++)
{
if (integrityLevelStringTable[i].IntegrityLevel.Level == integrityLevel.Level)
{
*IntegrityString = integrityLevelStringTable[i].String;
*IntegrityString = &integrityLevelStringTable[i].String;
break;
}
}
@@ -5099,7 +5095,7 @@ NTSTATUS PhGetProcessIdsUsingFile(
NTSTATUS PhGetFileUsn(
_In_ HANDLE FileHandle,
_Out_ PLONGLONG Usn
_Out_ PUSN Usn
)
{
NTSTATUS status;
@@ -5540,13 +5536,11 @@ typedef struct _OPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT
BOOLEAN NTAPI PhpOpenDriverByBaseAddressCallback(
_In_ PPH_STRINGREF Name,
_In_ PPH_STRINGREF TypeName,
_In_opt_ PVOID Context
_In_ POPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT Context
)
{
static PH_STRINGREF driverDirectoryName = PH_STRINGREF_INIT(L"\\Driver\\");
NTSTATUS status;
POPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT context = Context;
PPH_STRING driverName;
UNICODE_STRING driverNameUs;
OBJECT_ATTRIBUTES objectAttributes;
@@ -5585,10 +5579,10 @@ BOOLEAN NTAPI PhpOpenDriverByBaseAddressCallback(
if (NT_SUCCESS(status))
{
if (context && basicInfo.DriverStart == context->BaseAddress)
if (basicInfo.DriverStart == Context->BaseAddress)
{
context->Status = STATUS_SUCCESS;
context->DriverHandle = driverHandle;
Context->Status = STATUS_SUCCESS;
Context->DriverHandle = driverHandle;
return FALSE;
}
@@ -5615,19 +5609,16 @@ NTSTATUS PhOpenDriverByBaseAddress(
)
{
NTSTATUS status;
UNICODE_STRING driverDirectoryName;
UNICODE_STRING objectDirectoryName;
OBJECT_ATTRIBUTES objectAttributes;
HANDLE driverDirectoryHandle;
OPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT context;
RtlInitUnicodeString(
&driverDirectoryName,
L"\\Driver"
);
RtlInitUnicodeString(&objectDirectoryName, L"\\Driver");
InitializeObjectAttributes(
&objectAttributes,
&driverDirectoryName,
0,
&objectDirectoryName,
OBJ_EXCLUSIVE,
NULL,
NULL
);
@@ -5678,7 +5669,7 @@ NTSTATUS PhOpenDriver(
InitializeObjectAttributes(
&objectAttributes,
&objectName,
OBJ_CASE_INSENSITIVE,
OBJ_EXCLUSIVE | OBJ_CASE_INSENSITIVE,
RootDirectory,
NULL
);
@@ -5887,21 +5878,13 @@ NTSTATUS PhpUnloadDriver(
if (disposition == REG_CREATED_NEW_KEY)
{
static PH_STRINGREF imagePath = PH_STRINGREF_INIT(L"\\SystemRoot\\System32\\drivers\\ntfs.sys");
PH_STRINGREF valueName;
ULONG dword;
// Set up the required values.
dword = 1;
PhInitializeStringRef(&valueName, L"ErrorControl");
PhSetValueKey(serviceKeyHandle, &valueName, REG_DWORD, &dword, sizeof(ULONG));
PhInitializeStringRef(&valueName, L"Start");
PhSetValueKey(serviceKeyHandle, &valueName, REG_DWORD, &dword, sizeof(ULONG));
PhInitializeStringRef(&valueName, L"Type");
PhSetValueKey(serviceKeyHandle, &valueName, REG_DWORD, &dword, sizeof(ULONG));
// Use a bogus name.
PhInitializeStringRef(&valueName, L"ImagePath");
PhSetValueKey(serviceKeyHandle, &valueName, REG_SZ, imagePath.Buffer, (ULONG)imagePath.Length + sizeof(UNICODE_NULL));
PhSetValueKeyZ(serviceKeyHandle, L"ErrorControl", REG_DWORD, &(ULONG){ 0 }, sizeof(ULONG));
PhSetValueKeyZ(serviceKeyHandle, L"Start", REG_DWORD, &(ULONG){ 0 }, sizeof(ULONG));
PhSetValueKeyZ(serviceKeyHandle, L"Type", REG_DWORD, &(ULONG){ 0 }, sizeof(ULONG));
PhSetValueKeyZ(serviceKeyHandle, L"ImagePath", REG_SZ, imagePath.Buffer, (ULONG)imagePath.Length + sizeof(UNICODE_NULL));
}
status = NtUnloadDriver(&fullServiceKeyNameUs);
@@ -6112,7 +6095,7 @@ NTSTATUS PhSetProcessEmptyPageWorkingSet(
return status;
}
NTSTATUS PhGetProcessPriority(
NTSTATUS PhGetProcessPriorityClass(
_In_ HANDLE ProcessHandle,
_Out_ PUCHAR PriorityClass
)
@@ -6138,7 +6121,7 @@ NTSTATUS PhGetProcessPriority(
return status;
}
NTSTATUS PhSetProcessPriority(
NTSTATUS PhSetProcessPriorityClass(
_In_ HANDLE ProcessHandle,
_In_ UCHAR PriorityClass
)
@@ -6966,17 +6949,15 @@ NTSTATUS PhEnumHandlesEx2(
*
* \param ProcessId The ID of the process.
* \param ProcessHandle A handle to the process.
* \param EnableHandleSnapshot TRUE to return a snapshot of the process handles.
* \param Handles A variable which receives a pointer to a buffer containing
* information about the handles.
* \param FilterNeeded A variable which receives a boolean indicating
* whether the handle information needs to be filtered by process ID.
*/
NTSTATUS PhEnumHandlesGeneric(
_In_ HANDLE ProcessId,
_In_ HANDLE ProcessHandle,
_In_ BOOLEAN EnableHandleSnapshot,
_Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles,
_Out_ PBOOLEAN FilterNeeded
_Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles
)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
@@ -7002,19 +6983,20 @@ NTSTATUS PhEnumHandlesGeneric(
for (i = 0; i < handles->HandleCount; i++)
{
convertedHandles->Handles[i].Object = handles->Handles[i].Object;
convertedHandles->Handles[i].UniqueProcessId = (ULONG_PTR)ProcessId;
convertedHandles->Handles[i].HandleValue = (ULONG_PTR)handles->Handles[i].Handle;
convertedHandles->Handles[i].GrantedAccess = (ULONG)handles->Handles[i].GrantedAccess;
PKPH_PROCESS_HANDLE handle = &handles->Handles[i];
convertedHandles->Handles[i].Object = handle->Object;
convertedHandles->Handles[i].UniqueProcessId = ProcessId;
convertedHandles->Handles[i].HandleValue = handle->Handle;
convertedHandles->Handles[i].GrantedAccess = handle->GrantedAccess;
convertedHandles->Handles[i].CreatorBackTraceIndex = 0;
convertedHandles->Handles[i].ObjectTypeIndex = handles->Handles[i].ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handles->Handles[i].HandleAttributes;
convertedHandles->Handles[i].ObjectTypeIndex = handle->ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handle->HandleAttributes;
}
PhFree(handles);
*Handles = convertedHandles;
*FilterNeeded = FALSE;
}
}
@@ -7031,13 +7013,15 @@ NTSTATUS PhEnumHandlesGeneric(
for (i = 0; i < handles->NumberOfHandles; i++)
{
convertedHandles->Handles[i].Object = 0;
convertedHandles->Handles[i].UniqueProcessId = (ULONG_PTR)ProcessId;
convertedHandles->Handles[i].HandleValue = (ULONG_PTR)handles->Handles[i].HandleValue;
convertedHandles->Handles[i].GrantedAccess = handles->Handles[i].GrantedAccess;
PPROCESS_HANDLE_TABLE_ENTRY_INFO handle = &handles->Handles[i];
convertedHandles->Handles[i].Object = nullptr;
convertedHandles->Handles[i].UniqueProcessId = ProcessId;
convertedHandles->Handles[i].HandleValue = handle->HandleValue;
convertedHandles->Handles[i].GrantedAccess = handle->GrantedAccess;
convertedHandles->Handles[i].CreatorBackTraceIndex = 0;
convertedHandles->Handles[i].ObjectTypeIndex = (USHORT)handles->Handles[i].ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handles->Handles[i].HandleAttributes;
convertedHandles->Handles[i].ObjectTypeIndex = (USHORT)handle->ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handle->HandleAttributes;
}
PhFree(handles);
@@ -7050,12 +7034,41 @@ NTSTATUS PhEnumHandlesGeneric(
if (!NT_SUCCESS(status))
{
PSYSTEM_HANDLE_INFORMATION_EX handles;
PSYSTEM_HANDLE_INFORMATION_EX convertedHandles;
ULONG i, numberOfHandles = 0;
if (!NT_SUCCESS(status = PhEnumHandlesEx(&handles)))
return status;
if (NT_SUCCESS(status = PhEnumHandlesEx(&handles)))
{
for (i = 0; i < handles->NumberOfHandles; i++)
{
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handle = &handles->Handles[i];
*Handles = handles;
*FilterNeeded = TRUE;
if (handle->UniqueProcessId == ProcessId)
{
numberOfHandles++;
}
}
convertedHandles = PhAllocate(UFIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles[numberOfHandles]));
convertedHandles->NumberOfHandles = numberOfHandles;
for (i = 0; i < handles->NumberOfHandles; i++)
{
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handle = &handles->Handles[i];
convertedHandles->Handles[i].Object = nullptr;
convertedHandles->Handles[i].UniqueProcessId = ProcessId;
convertedHandles->Handles[i].HandleValue = handle->HandleValue;
convertedHandles->Handles[i].GrantedAccess = handle->GrantedAccess;
convertedHandles->Handles[i].CreatorBackTraceIndex = 0;
convertedHandles->Handles[i].ObjectTypeIndex = handle->ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handle->HandleAttributes;
}
PhFree(handles);
*Handles = convertedHandles;
}
}
return status;
@@ -9614,7 +9627,7 @@ NTSTATUS PhLoadAppKey(
PhGenerateGuid(&guid);
#if (PHNT_USE_NATIVE_APPEND)
#if defined(PHNT_USE_NATIVE_APPEND)
UNICODE_STRING guidStringUs;
WCHAR objectNameBuffer[MAXIMUM_FILENAME_LENGTH];
@@ -9671,7 +9684,7 @@ NTSTATUS PhLoadAppKey(
NULL
);
#if (PHNT_USE_NATIVE_APPEND)
#if defined(PHNT_USE_NATIVE_APPEND)
RtlFreeUnicodeString(&guidStringUs);
#else
PhDereferenceObject(guidString);
@@ -11066,7 +11079,7 @@ RTL_PATH_TYPE PhDetermineDosPathNameType(
_In_ PPH_STRINGREF FileName
)
{
#if (PHNT_USE_NATIVE_PATHTYPE)
#if defined(PHNT_USE_NATIVE_PATHTYPE)
return RtlDetermineDosPathNameType_U(FileName);
#else
if (FileName->Buffer[0] == OBJ_NAME_PATH_SEPARATOR || FileName->Buffer[0] == OBJ_NAME_ALTPATH_SEPARATOR)
@@ -11170,26 +11183,47 @@ NTSTATUS PhDeleteFile(
)
{
NTSTATUS status;
HANDLE fileHandle;
status = PhCreateFile(
&fileHandle,
FileName,
DELETE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_DELETE_ON_CLOSE
);
if (!NT_SUCCESS(status))
//UNICODE_STRING fileName;
//OBJECT_ATTRIBUTES objectAttributes;
//
//if (!NT_SUCCESS(status))
// return status;
//
//InitializeObjectAttributes(
// &objectAttributes,
// &fileName,
// OBJ_CASE_INSENSITIVE,
// NULL,
// NULL
// );
//
//status = NtDeleteFile(&objectAttributes);
//
//RtlFreeUnicodeString(&fileName);
//
//if (!NT_SUCCESS(status))
{
if (status == STATUS_OBJECT_NAME_NOT_FOUND)
status = STATUS_SUCCESS;
return status;
}
HANDLE fileHandle;
NtClose(fileHandle);
status = PhCreateFile(
&fileHandle,
FileName,
DELETE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_DELETE_ON_CLOSE
);
if (!NT_SUCCESS(status))
{
if (status == STATUS_OBJECT_NAME_NOT_FOUND)
status = STATUS_SUCCESS;
return status;
}
NtClose(fileHandle);
}
return status;
}
@@ -11599,7 +11633,7 @@ NTSTATUS PhCopyFileWin32(
FILE_GENERIC_WRITE,
&newFileSize,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FailIfExists ? FILE_CREATE : FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY,
NULL
@@ -11708,7 +11742,7 @@ NTSTATUS PhCopyFileChunkDirectIoWin32(
OldFileName,
FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_NO_INTERMEDIATE_BUFFERING,
EX_CREATE_FLAG_FILE_SOURCE_OPEN_FOR_COPY,
@@ -11850,7 +11884,7 @@ NTSTATUS PhCopyFileChunkWin32(
OldFileName,
FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
EX_CREATE_FLAG_FILE_SOURCE_OPEN_FOR_COPY,
@@ -11876,7 +11910,7 @@ NTSTATUS PhCopyFileChunkWin32(
NewFileName,
FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FailIfExists ? FILE_CREATE : FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
EX_CREATE_FLAG_FILE_DEST_OPEN_FOR_COPY,
@@ -12029,7 +12063,7 @@ NTSTATUS PhMoveFileWin32(
FILE_GENERIC_WRITE,
&newFileSize,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FailIfExists ? FILE_CREATE : FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY,
NULL
@@ -12640,6 +12674,7 @@ NTSTATUS PhGetProcessConsoleCodePage(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -14488,6 +14523,10 @@ NTSTATUS PhGuardGrantSuppressedCallAccess(
if (!NtSetInformationVirtualMemory_Import())
return STATUS_PROCEDURE_NOT_FOUND;
// Check if CFG is disabled. PhGetProcessIsCFGuardEnabled(NtCurrentProcess());
if (!(LdrSystemDllInitBlock.CfgBitMap && LdrSystemDllInitBlock.CfgBitMapSize))
return STATUS_SUCCESS;
memset(&cfgCallTargetRangeInfo, 0, sizeof(MEMORY_RANGE_ENTRY));
cfgCallTargetRangeInfo.VirtualAddress = PAGE_ALIGN(VirtualAddress);
cfgCallTargetRangeInfo.NumberOfBytes = PAGE_SIZE;
@@ -14532,6 +14571,10 @@ NTSTATUS PhDisableXfgOnTarget(
if (!NtSetInformationVirtualMemory_Import())
return STATUS_PROCEDURE_NOT_FOUND;
// Check if CFG is disabled. PhGetProcessIsCFGuardEnabled(NtCurrentProcess());
if (!(LdrSystemDllInitBlock.CfgBitMap && LdrSystemDllInitBlock.CfgBitMapSize))
return STATUS_SUCCESS;
memset(&cfgCallTargetRangeInfo, 0, sizeof(MEMORY_RANGE_ENTRY));
cfgCallTargetRangeInfo.VirtualAddress = PAGE_ALIGN(VirtualAddress);
cfgCallTargetRangeInfo.NumberOfBytes = PAGE_SIZE;
@@ -15647,7 +15690,7 @@ VOID PhNativeContextToEcContext(
// rev from ntdll!RtlIsEcCode (jxy-s)
NTSTATUS PhIsEcCode(
_In_ HANDLE ProcessHandle,
_In_ ULONG64 CodePointer,
_In_ PVOID CodePointer,
_Out_ PBOOLEAN IsEcCode
)
{
@@ -15661,7 +15704,7 @@ NTSTATUS PhIsEcCode(
// hack (jxy-s)
// 0x00007ffffffeffff = LdrpEcBitmapData.HighestAddress (MmHighestUserAddress)
// 0x0000000000010000 = MM_LOWEST_USER_ADDRESS
if (CodePointer > 0x00007ffffffeffff || CodePointer < 0x0000000000010000)
if ((ULONG_PTR)CodePointer > 0x00007ffffffeffff || (ULONG_PTR)CodePointer < 0x0000000000010000)
return STATUS_INVALID_PARAMETER_2;
if (!NT_SUCCESS(status = PhGetProcessPeb(ProcessHandle, &pebBaseAddress)))
@@ -15766,6 +15809,7 @@ NTSTATUS PhFlushProcessHeapsRemote(
status = PhCreateUserThread(
ProcessHandle,
NULL,
THREAD_ALL_ACCESS,
THREAD_CREATE_FLAGS_CREATE_SUSPENDED,
0,
0,
+8 -4
View File
@@ -316,7 +316,9 @@ NTSTATUS PhpEnumProcessModules(
if (!pebLdrData.Initialized)
return STATUS_UNSUCCESSFUL;
if (WindowsVersion >= WINDOWS_8)
if (WindowsVersion >= WINDOWS_11)
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN11;
else if (WindowsVersion >= WINDOWS_8)
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN8;
else
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN7;
@@ -675,7 +677,9 @@ NTSTATUS PhpEnumProcessModules32(
if (!pebLdrData.Initialized)
return STATUS_UNSUCCESSFUL;
if (WindowsVersion >= WINDOWS_8)
if (WindowsVersion >= WINDOWS_11)
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN11_32;
else if (WindowsVersion >= WINDOWS_8)
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN8_32;
else
dataTableEntrySize = LDR_DATA_TABLE_ENTRY_SIZE_WIN7_32;
@@ -1045,7 +1049,7 @@ NTSTATUS PhSetProcessModuleLoadCount32(
typedef struct _PH_ENUM_PROCESS_MODULES_LIMITED_PARAMETERS
{
PPH_ENUM_PROCESS_VIRTUAL_IMAGES_CALLBACK Callback;
PPH_ENUM_PROCESS_MODULES_LIMITED_CALLBACK Callback;
PVOID Context;
} PH_ENUM_PROCESS_MODULES_LIMITED_PARAMETERS, *PPH_ENUM_PROCESS_MODULES_LIMITED_PARAMETERS;
@@ -1121,7 +1125,7 @@ NTSTATUS NTAPI PhEnumProcessModulesLimitedCallback(
NTSTATUS PhEnumProcessModulesLimited(
_In_ HANDLE ProcessHandle,
_In_ PPH_ENUM_PROCESS_VIRTUAL_IMAGES_CALLBACK Callback,
_In_ PPH_ENUM_PROCESS_MODULES_LIMITED_CALLBACK Callback,
_In_opt_ PVOID Context
)
{
+131 -30
View File
@@ -24,14 +24,14 @@ NTSTATUS PhCreatePipe(
_Out_ PHANDLE PipeWriteHandle
)
{
return PhCreatePipeEx(PipeReadHandle, PipeWriteHandle, FALSE, NULL);
return PhCreatePipeEx(PipeReadHandle, PipeWriteHandle, NULL, NULL);
}
NTSTATUS PhCreatePipeEx(
_Out_ PHANDLE PipeReadHandle,
_Out_ PHANDLE PipeWriteHandle,
_In_ BOOLEAN InheritHandles,
_In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
_In_opt_ PSECURITY_ATTRIBUTES PipeReadAttributes,
_In_opt_ PSECURITY_ATTRIBUTES PipeWriteAttributes
)
{
NTSTATUS status;
@@ -43,6 +43,13 @@ NTSTATUS PhCreatePipeEx(
SECURITY_DESCRIPTOR securityDescriptor;
OBJECT_ATTRIBUTES objectAttributes;
IO_STATUS_BLOCK isb;
SECURITY_QUALITY_OF_SERVICE pipeSecurityQos =
{
sizeof(SECURITY_QUALITY_OF_SERVICE),
SecurityAnonymous,
SECURITY_STATIC_TRACKING,
FALSE
};
RtlInitUnicodeString(&pipeName, DEVICE_NAMED_PIPE);
InitializeObjectAttributes(
@@ -69,18 +76,27 @@ NTSTATUS PhCreatePipeEx(
InitializeObjectAttributes(
&objectAttributes,
&pipeName,
OBJ_CASE_INSENSITIVE | (InheritHandles ? OBJ_INHERIT : 0),
OBJ_CASE_INSENSITIVE,
pipeDirectoryHandle,
NULL
);
objectAttributes.SecurityQualityOfService = &pipeSecurityQos;
if (SecurityDescriptor)
if (PipeReadAttributes)
{
objectAttributes.SecurityDescriptor = SecurityDescriptor;
if (PipeReadAttributes->bInheritHandle)
{
SetFlag(objectAttributes.Attributes, OBJ_INHERIT);
}
if (PipeReadAttributes->lpSecurityDescriptor)
{
objectAttributes.SecurityDescriptor = PipeReadAttributes->lpSecurityDescriptor;
}
}
else
{
if (NT_SUCCESS(RtlDefaultNpAcl(&pipeAcl)))
if (NT_SUCCESS(PhDefaultNpAcl(&pipeAcl)))
{
RtlCreateSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
RtlSetDaclSecurityDescriptor(&securityDescriptor, TRUE, pipeAcl, FALSE);
@@ -113,10 +129,24 @@ NTSTATUS PhCreatePipeEx(
InitializeObjectAttributes(
&objectAttributes,
&pipeName,
OBJ_CASE_INSENSITIVE | (InheritHandles ? OBJ_INHERIT : 0),
OBJ_CASE_INSENSITIVE,
pipeReadHandle,
nullptr
);
objectAttributes.SecurityQualityOfService = &pipeSecurityQos;
if (PipeWriteAttributes)
{
if (PipeWriteAttributes->bInheritHandle)
{
SetFlag(objectAttributes.Attributes, OBJ_INHERIT);
}
if (PipeWriteAttributes->lpSecurityDescriptor)
{
objectAttributes.SecurityDescriptor = PipeWriteAttributes->lpSecurityDescriptor;
}
}
status = NtOpenFile(
&pipeWriteHandle,
@@ -182,7 +212,7 @@ NTSTATUS PhCreateNamedPipe(
);
objectAttributes.SecurityQualityOfService = &pipeSecurityQos;
if (NT_SUCCESS(RtlDefaultNpAcl(&pipeAcl)))
if (NT_SUCCESS(PhDefaultNpAcl(&pipeAcl)))
{
RtlCreateSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
RtlSetDaclSecurityDescriptor(&securityDescriptor, TRUE, pipeAcl, FALSE);
@@ -214,7 +244,7 @@ NTSTATUS PhCreateNamedPipe(
if (pipeAcl)
{
RtlFreeHeap(RtlProcessHeap(), 0, pipeAcl);
PhFree(pipeAcl);
}
PhDereferenceObject(pipeName);
@@ -818,34 +848,105 @@ NTSTATUS PhEnumDirectoryNamedPipe(
_In_opt_ PVOID Context
)
{
static CONST UNICODE_STRING objectName = RTL_CONSTANT_STRING(DEVICE_NAMED_PIPE);
static CONST OBJECT_ATTRIBUTES objectAttributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&objectName, OBJ_CASE_INSENSITIVE);
static PH_INITONCE initOnce = PH_INITONCE_INIT;
static HANDLE directoryHandle = NULL;
NTSTATUS status = STATUS_UNSUCCESSFUL;
IO_STATUS_BLOCK isb;
static PH_STRINGREF objectName = PH_STRINGREF_INIT(DEVICE_NAMED_PIPE);
HANDLE objectHandle;
NTSTATUS status;
if (PhBeginInitOnce(&initOnce))
{
NtOpenFile(
&directoryHandle,
FILE_LIST_DIRECTORY | SYNCHRONIZE,
(POBJECT_ATTRIBUTES)&objectAttributes,
&isb,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
);
PhEndInitOnce(&initOnce);
}
status = PhOpenFile(
&objectHandle,
&objectName,
FILE_LIST_DIRECTORY | SYNCHRONIZE,
NULL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL
);
if (directoryHandle)
if (NT_SUCCESS(status))
{
status = PhEnumDirectoryFile(
directoryHandle,
objectHandle,
SearchPattern,
Callback,
Context
);
NtClose(objectHandle);
}
return status;
}
// rev from RtlDefaultNpAcl
NTSTATUS PhDefaultNpAcl(
_Out_ PACL* DefaultNpAc
)
{
NTSTATUS status;
PACL pipeAcl;
PH_TOKEN_OWNER tokenQuery;
status = PhGetTokenOwner(
NtCurrentThreadEffectiveToken(),
&tokenQuery
);
if (NT_SUCCESS(status))
{
APPCONTAINER_SID_TYPE appContainerSidType = InvalidAppContainerSidType;
PH_TOKEN_APPCONTAINER tokenAppContainer = { 0 };
PSID appContainerSidParent = NULL;
ULONG defaultAclSize =
(ULONG)sizeof(ACL) +
(ULONG)sizeof(ACCESS_ALLOWED_ACE) +
PhLengthSid((PSID)&PhSeLocalSystemSid) +
(ULONG)sizeof(ACCESS_ALLOWED_ACE) +
PhLengthSid(PhSeAdministratorsSid()) +
(ULONG)sizeof(ACCESS_ALLOWED_ACE) +
PhLengthSid(tokenQuery.TokenOwner.Owner) +
(ULONG)sizeof(ACCESS_ALLOWED_ACE) +
PhLengthSid((PSID)&PhSeEveryoneSid) +
(ULONG)sizeof(ACCESS_ALLOWED_ACE) +
PhLengthSid((PSID)&PhSeAnonymousLogonSid);
if (NT_SUCCESS(PhGetTokenAppContainerSid(NtCurrentThreadEffectiveToken(), &tokenAppContainer)))
{
if (RtlGetAppContainerSidType_Import())
RtlGetAppContainerSidType_Import()(tokenAppContainer.AppContainer.Sid, &appContainerSidType);
if (appContainerSidType == ChildAppContainerSidType)
{
if (RtlGetAppContainerParent_Import())
RtlGetAppContainerParent_Import()(tokenAppContainer.AppContainer.Sid, &appContainerSidParent);
}
}
if (tokenAppContainer.AppContainer.Sid)
defaultAclSize += (ULONG)sizeof(ACCESS_ALLOWED_ACE) + PhLengthSid(tokenAppContainer.AppContainer.Sid);
if (appContainerSidParent)
defaultAclSize += (ULONG)sizeof(ACCESS_ALLOWED_ACE) + PhLengthSid(appContainerSidParent);
pipeAcl = PhAllocateZero(defaultAclSize);
PhCreateAcl(pipeAcl, defaultAclSize, ACL_REVISION);
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_ALL, (PSID)&PhSeLocalSystemSid);
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_ALL, (PSID)PhSeAdministratorsSid());
if (tokenAppContainer.AppContainer.Sid)
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_ALL, tokenAppContainer.AppContainer.Sid);
if (appContainerSidParent)
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_ALL, appContainerSidParent);
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_ALL, tokenQuery.TokenOwner.Owner);
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_READ, (PSID)&PhSeEveryoneSid);
RtlAddAccessAllowedAce(pipeAcl, ACL_REVISION, GENERIC_READ, (PSID)&PhSeAnonymousLogonSid);
*DefaultNpAc = pipeAcl;
if (appContainerSidParent)
{
PhFreeSid(appContainerSidParent);
}
}
return status;
+8 -5
View File
@@ -16,6 +16,9 @@
#include <lsasup.h>
#include <mapldr.h>
#define PHNT_NATIVE_METHODS 0
#define PH_NATIVE_WINDOWS_RUNTIME_STRING 1
/**
* Opens a thread.
*
@@ -73,7 +76,7 @@ NTSTATUS PhOpenThread(
NTSTATUS PhOpenThreadClientId(
_Out_ PHANDLE ThreadHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ CLIENT_ID ClientId
_In_ PCLIENT_ID ClientId
)
{
NTSTATUS status;
@@ -87,7 +90,7 @@ NTSTATUS PhOpenThreadClientId(
status = KphOpenThread(
ThreadHandle,
DesiredAccess,
&ClientId
ClientId
);
}
else
@@ -97,7 +100,7 @@ NTSTATUS PhOpenThreadClientId(
ThreadHandle,
DesiredAccess,
&objectAttributes,
&ClientId
ClientId
);
if (status == STATUS_ACCESS_DENIED && (level == KphLevelMax))
@@ -105,7 +108,7 @@ NTSTATUS PhOpenThreadClientId(
status = KphOpenThread(
ThreadHandle,
DesiredAccess,
&ClientId
ClientId
);
}
}
@@ -617,7 +620,7 @@ NTSTATUS PhImpersonateToken(
InitializeObjectAttributes(
&objectAttributes,
NULL,
0,
OBJ_EXCLUSIVE,
NULL,
NULL
);
+53 -5
View File
@@ -12,7 +12,7 @@
#include <ph.h>
#include <apiimport.h>
#include <ntuser.h>
#include <user.h>
#include <phconsole.h>
NTSTATUS PhAttachConsole(
_In_ HANDLE ProcessId
@@ -73,8 +73,9 @@ HANDLE PhGetStdHandle(
NTSTATUS PhGetConsoleProcessList(
_In_ HANDLE ProcessId,
_In_ ULONG ProcessCount,
_Out_writes_(ProcessCount) PULONG ProcessList,
_In_ ULONG ProcessCount
_Out_ PULONG ProcessTotal
)
{
NTSTATUS status;
@@ -83,7 +84,7 @@ NTSTATUS PhGetConsoleProcessList(
if (NT_SUCCESS(status))
{
if (GetConsoleProcessList(ProcessList, ProcessCount))
if (*ProcessTotal = GetConsoleProcessList(ProcessList, ProcessCount))
status = STATUS_SUCCESS;
else
status = PhGetLastWin32ErrorAsNtStatus();
@@ -94,7 +95,7 @@ NTSTATUS PhGetConsoleProcessList(
return status;
}
NTSTATUS PhConsoleControlSetForeground(
NTSTATUS PhConsoleSetForeground(
_In_ HANDLE ProcessHandle,
_In_ BOOLEAN Foreground
)
@@ -117,7 +118,54 @@ NTSTATUS PhConsoleControlSetForeground(
return status;
}
NTSTATUS PhConsoleControlEndTask(
NTSTATUS PhConsoleNotifyWindow(
_In_ HANDLE ProcessID
)
{
NTSTATUS status;
CONSOLE_PROCESS_INFO consoleProcessInfo;
if (!ConsoleControl_Import())
return STATUS_NOT_SUPPORTED;
consoleProcessInfo.Flags = CPI_NEWPROCESSWINDOW;
consoleProcessInfo.ProcessID = HandleToUlong(ProcessID);
status = ConsoleControl_Import()(
ConsoleNotifyConsoleApplication,
&consoleProcessInfo,
sizeof(CONSOLE_PROCESS_INFO)
);
return status;
}
NTSTATUS PhConsoleSetWindow(
_In_ HANDLE ProcessID,
_In_ HANDLE ThreadId,
_In_ HWND WindowHandle
)
{
NTSTATUS status;
CONSOLEWINDOWOWNER consoleInfo;
if (!ConsoleControl_Import())
return STATUS_NOT_SUPPORTED;
consoleInfo.ProcessId = HandleToUlong(ProcessID);
consoleInfo.ThreadId = HandleToUlong(ThreadId);
consoleInfo.WindowHandle = WindowHandle;
status = ConsoleControl_Import()(
ConsoleSetWindowOwner,
&consoleInfo,
sizeof(CONSOLEWINDOWOWNER)
);
return status;
}
NTSTATUS PhConsoleEndTask(
_In_ HANDLE ProcessId,
_In_ HWND WindowHandle
)
+3 -1
View File
@@ -328,6 +328,7 @@
<ClCompile Include="global.c" />
<ClCompile Include="graph.c" />
<ClCompile Include="guisup.c" />
<ClCompile Include="guisuplistview.cpp" />
<ClCompile Include="handle.c" />
<ClCompile Include="hexedit.c" />
<ClCompile Include="hndlinfo.c" />
@@ -375,6 +376,7 @@
<ClInclude Include="include\appresolver.h" />
<ClInclude Include="include\appresolverp.h" />
<ClInclude Include="include\bcd.h" />
<ClInclude Include="include\phconsole.h" />
<ClInclude Include="include\searchbox.h" />
<ClInclude Include="include\user.h" />
<ClInclude Include="include\cpysave.h" />
@@ -444,4 +446,4 @@
<ClInclude Include="include\workqueuep.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>
+7 -4
View File
@@ -185,9 +185,6 @@
<ClCompile Include="ntuser.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="counters.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nativemodule.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -206,6 +203,9 @@
<ClCompile Include="searchbox.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="guisuplistview.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\circbuf.h">
@@ -421,5 +421,8 @@
<ClInclude Include="include\searchbox.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\phconsole.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
+2 -2
View File
@@ -276,7 +276,7 @@ ACCESS_ENTRIES(Process)
ACCESS_ENTRIES(Process60)
{
{ L"Full control", STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xffff, TRUE, TRUE }, // PROCESS_ALL_ACCESS
{ L"Full control", STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | SPECIFIC_RIGHTS_ALL, TRUE, TRUE }, // PROCESS_ALL_ACCESS
{ L"Query limited information", PROCESS_QUERY_LIMITED_INFORMATION, TRUE, TRUE },
{ L"Query information", PROCESS_QUERY_INFORMATION | PROCESS_QUERY_LIMITED_INFORMATION, TRUE, TRUE },
{ L"Set information", PROCESS_SET_INFORMATION, TRUE, TRUE },
@@ -450,7 +450,7 @@ ACCESS_ENTRIES(Thread)
ACCESS_ENTRIES(Thread60)
{
{ L"Full control", STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xffff, TRUE, TRUE }, // THREAD_ALL_ACCESS
{ L"Full control", STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | SPECIFIC_RIGHTS_ALL, TRUE, TRUE }, // THREAD_ALL_ACCESS
{ L"Query limited information", THREAD_QUERY_LIMITED_INFORMATION, TRUE, TRUE },
{ L"Query information", THREAD_QUERY_INFORMATION | THREAD_QUERY_LIMITED_INFORMATION, TRUE, TRUE },
{ L"Set limited information", THREAD_SET_LIMITED_INFORMATION, TRUE, TRUE },
+43 -31
View File
@@ -396,7 +396,7 @@ ULONG STDMETHODCALLTYPE PhSecurityInformation_Release(
if (this->RefCount == 0)
{
if (this->CloseObject)
this->CloseObject(this->Context);
this->CloseObject(NULL, TRUE, this->Context);
if (this->ObjectName)
PhDereferenceObject(this->ObjectName);
@@ -1313,12 +1313,10 @@ NTSTATUS PhStdGetObjectSecurity(
if (PhEqualString2(this->ObjectType, L"Service", TRUE) || PhEqualString2(this->ObjectType, L"SCManager", TRUE))
{
status = PhGetServiceObjectSecurity(handle, SecurityInformation, SecurityDescriptor);
PhCloseServiceHandle(handle);
}
else if (PhEqualString2(this->ObjectType, L"File", TRUE) || PhEqualString2(this->ObjectType, L"FileObject", TRUE))
{
status = PhpGetObjectSecurityWithTimeout(handle, SecurityInformation, SecurityDescriptor);
NtClose(handle);
}
else if (
PhEqualString2(this->ObjectType, L"LsaAccount", TRUE) ||
@@ -1343,8 +1341,6 @@ NTSTATUS PhStdGetObjectSecurity(
);
LsaFreeMemory(securityDescriptor);
}
LsaClose(handle);
}
else if (
PhEqualString2(this->ObjectType, L"SamAlias", TRUE) ||
@@ -1385,26 +1381,41 @@ NTSTATUS PhStdGetObjectSecurity(
if (NT_SUCCESS(status))
{
ULONG allocationLength;
ULONG allocationLengthRelative = 0;
PSECURITY_DESCRIPTOR securityDescriptor;
PSECURITY_DESCRIPTOR securityRelative;
allocationLength = SECURITY_DESCRIPTOR_MIN_LENGTH + defaultDacl->DefaultDacl->AclSize;
securityDescriptor = PhAllocateZero(allocationLength);
RtlCreateSecurityDescriptor(securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
RtlSetDaclSecurityDescriptor(securityDescriptor, TRUE, defaultDacl->DefaultDacl, FALSE);
status = RtlCreateSecurityDescriptor(securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
if (!NT_SUCCESS(status))
goto CleanupExit;
status = RtlSetDaclSecurityDescriptor(securityDescriptor, TRUE, defaultDacl->DefaultDacl, FALSE);
if (!NT_SUCCESS(status))
goto CleanupExit;
assert(allocationLength == RtlLengthSecurityDescriptor(securityDescriptor));
*SecurityDescriptor = PhAllocateCopy(
securityDescriptor,
RtlLengthSecurityDescriptor(securityDescriptor)
);
PhFree(securityDescriptor);
status = RtlAbsoluteToSelfRelativeSD(securityDescriptor, NULL, &allocationLengthRelative);
if (status != STATUS_BUFFER_TOO_SMALL)
goto CleanupExit;
securityRelative = PhAllocateZero(allocationLengthRelative);
status = RtlAbsoluteToSelfRelativeSD(securityDescriptor, securityRelative, &allocationLengthRelative);
if (!NT_SUCCESS(status))
goto CleanupExit;
allocationLength = RtlLengthSecurityDescriptor(securityRelative);
assert(allocationLengthRelative == RtlLengthSecurityDescriptor(securityRelative));
*SecurityDescriptor = securityRelative;
CleanupExit:
PhFree(securityDescriptor);
PhFree(defaultDacl);
}
NtClose(handle);
}
else if (PhEqualString2(this->ObjectType, L"PowerDefault", TRUE))
{
@@ -1458,13 +1469,15 @@ NTSTATUS PhStdGetObjectSecurity(
else
{
status = PhGetObjectSecurity(handle, SecurityInformation, SecurityDescriptor);
// NtClose doesn't work for Desktop here. This was causing a huge leak of Desktop handles (Dart Vanya)
if (PhEqualString2(this->ObjectType, L"Desktop", TRUE))
CloseDesktop(handle);
else if (PhEqualString2(this->ObjectType, L"WindowStation", TRUE))
CloseWindowStation(handle);
else
NtClose(handle);
}
if (this->CloseObject)
{
this->CloseObject(
handle,
FALSE,
this->Context
);
}
return status;
@@ -1505,12 +1518,10 @@ NTSTATUS PhStdSetObjectSecurity(
if (PhEqualString2(this->ObjectType, L"Service", TRUE) || PhEqualString2(this->ObjectType, L"SCManager", TRUE))
{
status = PhSetServiceObjectSecurity(handle, SecurityInformation, SecurityDescriptor);
PhCloseServiceHandle(handle);
}
else if (PhEqualString2(this->ObjectType, L"File", TRUE) || PhEqualString2(this->ObjectType, L"FileObject", TRUE))
{
status = PhSetObjectSecurity(handle, SecurityInformation, SecurityDescriptor);
NtClose(handle);
}
else if (
PhEqualString2(this->ObjectType, L"LsaAccount", TRUE) ||
@@ -1524,8 +1535,6 @@ NTSTATUS PhStdSetObjectSecurity(
SecurityInformation,
SecurityDescriptor
);
LsaClose(handle);
}
else if (
PhEqualString2(this->ObjectType, L"SamAlias", TRUE) ||
@@ -1569,8 +1578,6 @@ NTSTATUS PhStdSetObjectSecurity(
sizeof(TOKEN_DEFAULT_DACL)
);
}
NtClose(handle);
}
else if (PhEqualString2(this->ObjectType, L"PowerDefault", TRUE))
{
@@ -1616,10 +1623,15 @@ NTSTATUS PhStdSetObjectSecurity(
else
{
status = PhSetObjectSecurity(handle, SecurityInformation, SecurityDescriptor);
if (!PhEqualString2(this->ObjectType, L"Desktop", TRUE))
NtClose(handle);
else
CloseDesktop(handle);
}
if (this->CloseObject)
{
this->CloseObject(
handle,
FALSE,
this->Context
);
}
return status;
+203
View File
@@ -26,6 +26,7 @@
#include <ph.h>
#include <guisup.h>
#include <guisupview.h>
#include <settings.h>
#include <json.h>
@@ -1184,6 +1185,184 @@ PPH_STRING PhSaveListViewColumnSettings(
return PhFinalStringBuilderString(&stringBuilder);
}
BOOLEAN PhLoadIListViewColumnSettings(
_In_ IListView* ListView,
_In_ PPH_STRING Settings
)
{
#define ORDER_LIMIT 50
HWND headerHandle = NULL;
PH_STRINGREF remainingPart;
ULONG columnIndex;
ULONG orderArray[ORDER_LIMIT]; // HACK, but reasonable limit
ULONG maxOrder;
LONG scale;
LONG dpi;
if (!SUCCEEDED(IListView_GetHeaderControl(ListView, &headerHandle)))
return FALSE;
#ifdef DEBUG
assert(Header_GetItemCount(headerHandle) < ORDER_LIMIT);
#endif
if (PhIsNullOrEmptyString(Settings))
return FALSE;
dpi = PhGetWindowDpi(headerHandle);
remainingPart = Settings->sr;
columnIndex = 0;
memset(orderArray, 0, sizeof(orderArray));
maxOrder = 0;
if (remainingPart.Length != 0 && remainingPart.Buffer[0] == L'@')
{
PH_STRINGREF scalePart;
LONG64 integer;
PhSkipStringRef(&remainingPart, sizeof(WCHAR));
PhSplitStringRefAtChar(&remainingPart, L'|', &scalePart, &remainingPart);
if (scalePart.Length == 0 || !PhStringToInteger64(&scalePart, 10, &integer))
return FALSE;
scale = (LONG)integer;
}
else
{
scale = dpi;
}
while (remainingPart.Length != 0)
{
PH_STRINGREF columnPart;
PH_STRINGREF orderPart;
PH_STRINGREF widthPart;
ULONG64 integer;
ULONG order;
LONG width;
LVCOLUMN lvColumn;
PhSplitStringRefAtChar(&remainingPart, L'|', &columnPart, &remainingPart);
if (columnPart.Length == 0)
return FALSE;
PhSplitStringRefAtChar(&columnPart, L',', &orderPart, &widthPart);
if (orderPart.Length == 0 || widthPart.Length == 0)
return FALSE;
// Order
if (!PhStringToInteger64(&orderPart, 10, &integer))
return FALSE;
order = (ULONG)integer;
if (order < ORDER_LIMIT)
{
orderArray[order] = columnIndex;
if (maxOrder < order + 1)
maxOrder = order + 1;
}
// Width
if (!PhStringToInteger64(&widthPart, 10, &integer))
return FALSE;
width = (LONG)integer;
if (scale != dpi && scale != 0)
width = PhMultiplyDivideSigned(width, dpi, scale);
lvColumn.mask = LVCF_WIDTH;
lvColumn.cx = width;
IListView_SetColumn(ListView, columnIndex, &lvColumn);
columnIndex++;
}
IListView_SetColumnOrderArray(ListView, maxOrder, orderArray);
return TRUE;
}
PPH_STRING PhSaveIListViewColumnSettings(
_In_ IListView* ListView
)
{
HWND headerHandle = NULL;
PH_STRING_BUILDER stringBuilder;
ULONG i = 0;
LVCOLUMN lvColumn;
LONG dpiValue;
if (!SUCCEEDED(IListView_GetHeaderControl(ListView, &headerHandle)))
return NULL;
PhInitializeStringBuilder(&stringBuilder, 20);
dpiValue = PhGetWindowDpi(headerHandle);
{
PH_FORMAT format[3];
SIZE_T returnLength;
WCHAR buffer[PH_INT64_STR_LEN_1];
// @%lu|
PhInitFormatC(&format[0], L'@');
PhInitFormatU(&format[1], dpiValue);
PhInitFormatC(&format[2], L'|');
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), buffer, sizeof(buffer), &returnLength))
{
PhAppendStringBuilderEx(&stringBuilder, buffer, returnLength - sizeof(UNICODE_NULL));
}
else
{
PhAppendFormatStringBuilder(&stringBuilder, L"@%lu|", dpiValue);
}
}
memset(&lvColumn, 0, sizeof(LVCOLUMN));
lvColumn.mask = LVCF_WIDTH | LVCF_ORDER;
while (SUCCEEDED(IListView_GetColumn(ListView, i, &lvColumn)))
{
PH_FORMAT format[4];
SIZE_T returnLength;
WCHAR buffer[PH_INT64_STR_LEN_1];
// %u,%u|
PhInitFormatU(&format[0], lvColumn.iOrder);
PhInitFormatC(&format[1], L',');
PhInitFormatU(&format[2], lvColumn.cx);
PhInitFormatC(&format[3], L'|');
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), buffer, sizeof(buffer), &returnLength))
{
PhAppendStringBuilderEx(&stringBuilder, buffer, returnLength - sizeof(UNICODE_NULL));
}
else
{
PhAppendFormatStringBuilder(
&stringBuilder,
L"%u,%u|",
lvColumn.iOrder,
lvColumn.cx
);
}
i++;
}
if (stringBuilder.String->Length != 0)
PhRemoveEndStringBuilder(&stringBuilder, 1);
return PhFinalStringBuilderString(&stringBuilder);
}
VOID PhLoadListViewColumnsFromSetting(
_In_ PCWSTR Name,
_In_ HWND ListViewHandle
@@ -1208,6 +1387,30 @@ VOID PhSaveListViewColumnsToSetting(
PhDereferenceObject(string);
}
VOID PhLoadIListViewColumnsFromSetting(
_In_ PCWSTR Name,
_In_ IListView* ListViewClass
)
{
PPH_STRING string;
string = PhGetStringSetting(Name);
PhLoadIListViewColumnSettings(ListViewClass, string);
PhDereferenceObject(string);
}
VOID PhSaveIListViewColumnsToSetting(
_In_ PCWSTR Name,
_In_ IListView* ListViewClass
)
{
PPH_STRING string;
string = PhSaveIListViewColumnSettings(ListViewClass);
PhSetStringSetting2(Name, &string->sr);
PhDereferenceObject(string);
}
VOID PhLoadListViewSortColumnsFromSetting(
_In_ PCWSTR Name,
_In_ HWND ListViewHandle
+71 -57
View File
@@ -38,7 +38,7 @@ typedef struct _PH_SYMBOL_MODULE
{
LIST_ENTRY ListEntry;
PH_AVL_LINKS Links;
ULONG64 BaseAddress;
PVOID BaseAddress;
ULONG Size;
PPH_STRING FileName;
USHORT Machine;
@@ -211,7 +211,7 @@ static VOID PhpSymbolProviderEventCallback(
PIMAGEHLP_DEFERRED_SYMBOL_LOADW64 callbackData = (PIMAGEHLP_DEFERRED_SYMBOL_LOADW64)CallbackData;
PPH_STRING fileName;
if (PhGetModuleFromAddress(SymbolProvider, callbackData->BaseOfImage, &fileName))
if (PhGetModuleFromAddress(SymbolProvider, (PVOID)callbackData->BaseOfImage, &fileName))
{
PPH_STRING baseName = PhGetBaseName(fileName);
PH_FORMAT format[3];
@@ -327,7 +327,7 @@ BOOL CALLBACK PhpSymbolCallbackFunction(
PPH_STRING fileName;
HANDLE fileHandle;
if (PhGetModuleFromAddress(symbolProvider, callbackData->BaseOfImage, &fileName))
if (PhGetModuleFromAddress(symbolProvider, (PVOID)callbackData->BaseOfImage, &fileName))
{
if (NT_SUCCESS(PhCreateFile(
&fileHandle,
@@ -623,13 +623,13 @@ LONG NTAPI PhpSymbolModuleCompareFunction(
PPH_SYMBOL_MODULE symbolModule1 = CONTAINING_RECORD(Links1, PH_SYMBOL_MODULE, Links);
PPH_SYMBOL_MODULE symbolModule2 = CONTAINING_RECORD(Links2, PH_SYMBOL_MODULE, Links);
return uint64cmp(symbolModule1->BaseAddress, symbolModule2->BaseAddress);
return uintptrcmp((ULONG_PTR)symbolModule1->BaseAddress, (ULONG_PTR)symbolModule2->BaseAddress);
}
_Success_(return)
BOOLEAN PhGetLineFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_ PPH_STRING *FileName,
_Out_opt_ PULONG Displacement,
_Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information
@@ -652,7 +652,7 @@ BOOLEAN PhGetLineFromAddress(
result = SymGetLineFromAddrW64_I(
SymbolProvider->ProcessHandle,
Address,
(ULONG64)Address,
&displacement,
&line
);
@@ -679,9 +679,9 @@ BOOLEAN PhGetLineFromAddress(
}
_Success_(return != 0)
ULONG64 PhGetModuleFromAddress(
PVOID PhGetModuleFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_opt_ PPH_STRING *FileName
)
{
@@ -689,10 +689,10 @@ ULONG64 PhGetModuleFromAddress(
PPH_AVL_LINKS links;
PPH_SYMBOL_MODULE module;
PPH_STRING foundFileName;
ULONG64 foundBaseAddress;
PVOID foundBaseAddress;
foundFileName = NULL;
foundBaseAddress = 0;
foundBaseAddress = NULL;
PhAcquireQueuedLockShared(&SymbolProvider->ModulesListLock);
@@ -705,7 +705,7 @@ ULONG64 PhGetModuleFromAddress(
{
module = CONTAINING_RECORD(links, PH_SYMBOL_MODULE, Links);
if (Address < module->BaseAddress + module->Size)
if ((ULONG_PTR)Address < (ULONG_PTR)PTR_ADD_OFFSET(module->BaseAddress, module->Size))
{
PhSetReference(&foundFileName, module->FileName);
foundBaseAddress = module->BaseAddress;
@@ -731,7 +731,7 @@ ULONG64 PhGetModuleFromAddress(
PPH_SYMBOL_MODULE PhGetSymbolModuleFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address
_In_ PVOID Address
)
{
PPH_SYMBOL_MODULE module = NULL;
@@ -749,7 +749,7 @@ PPH_SYMBOL_MODULE PhGetSymbolModuleFromAddress(
{
PPH_SYMBOL_MODULE entry = CONTAINING_RECORD(links, PH_SYMBOL_MODULE, Links);
if (Address < entry->BaseAddress + entry->Size)
if ((ULONG_PTR)Address < (ULONG_PTR)PTR_ADD_OFFSET(entry->BaseAddress, entry->Size))
{
module = entry;
}
@@ -763,7 +763,7 @@ PPH_SYMBOL_MODULE PhGetSymbolModuleFromAddress(
USHORT PhpGetMachineForAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_opt_ HANDLE ProcessHandle,
_In_ ULONG64 Address
_In_ PVOID Address
)
{
PH_SYMBOL_MODULE lookupModule;
@@ -787,7 +787,7 @@ USHORT PhpGetMachineForAddress(
{
module = CONTAINING_RECORD(links, PH_SYMBOL_MODULE, Links);
if (module->Machine && (Address < (module->BaseAddress + module->Size)))
if (module->Machine && ((ULONG_PTR)Address < (ULONG_PTR)PTR_ADD_OFFSET(module->BaseAddress, module->Size)))
machine = module->Machine;
}
@@ -856,7 +856,7 @@ VOID PhpSymbolInfoAnsiToUnicode(
_Success_(return != NULL)
PPH_STRING PhGetSymbolFromAddress(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_opt_ PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel,
_Out_opt_ PPH_STRING *FileName,
_Out_opt_ PPH_STRING *SymbolName,
@@ -870,7 +870,7 @@ PPH_STRING PhGetSymbolFromAddress(
ULONG64 displacement;
PPH_STRING modFileName = NULL;
PPH_STRING modBaseName = NULL;
ULONG64 modBase = 0;
PVOID modBase = NULL;
PPH_STRING symbolName = NULL;
if (Address == 0)
@@ -889,7 +889,7 @@ PPH_STRING PhGetSymbolFromAddress(
if (!SymFromAddrW_I)
return NULL;
symbolInfo = PhAllocateZero(FIELD_OFFSET(SYMBOL_INFOW, Name) + PH_MAX_SYMBOL_NAME_LEN * sizeof(WCHAR));
symbolInfo = PhAllocateZero(FIELD_OFFSET(SYMBOL_INFOW, Name[PH_MAX_SYMBOL_NAME_LEN]));
symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW);
symbolInfo->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN;
@@ -903,7 +903,7 @@ PPH_STRING PhGetSymbolFromAddress(
SymFromAddrW_I(
SymbolProvider->ProcessHandle,
Address,
(ULONG64)Address,
&displacement,
symbolInfo
);
@@ -912,13 +912,13 @@ PPH_STRING PhGetSymbolFromAddress(
if (nameLength + 1 > PH_MAX_SYMBOL_NAME_LEN)
{
PhFree(symbolInfo);
symbolInfo = PhAllocateZero(FIELD_OFFSET(SYMBOL_INFOW, Name) + nameLength * sizeof(WCHAR) + sizeof(UNICODE_NULL));
symbolInfo = PhAllocateZero(FIELD_OFFSET(SYMBOL_INFOW, Name[nameLength + sizeof(UNICODE_NULL)]));
symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW);
symbolInfo->MaxNameLen = nameLength + 1;
symbolInfo->MaxNameLen = nameLength + sizeof(UNICODE_NULL);
SymFromAddrW_I(
SymbolProvider->ProcessHandle,
Address,
(ULONG64)Address,
&displacement,
symbolInfo
);
@@ -940,7 +940,7 @@ PPH_STRING PhGetSymbolFromAddress(
{
modBase = PhGetModuleFromAddress(
SymbolProvider,
symbolInfo->ModBase,
(PVOID)symbolInfo->ModBase,
&modFileName
);
}
@@ -969,7 +969,7 @@ PPH_STRING PhGetSymbolFromAddress(
PhInitFormatSR(&format[0], modBaseName->sr);
PhInitFormatS(&format[1], L"+0x");
PhInitFormatIX(&format[2], (ULONG_PTR)(Address - modBase));
PhInitFormatIX(&format[2], (ULONG_PTR)Address - (ULONG_PTR)modBase);
symbol = PhFormat(format, 3, modBaseName->Length + 6 + 32);
goto CleanupExit;
@@ -1060,8 +1060,8 @@ BOOLEAN PhGetSymbolFromName(
if (!result)
return FALSE;
Information->Address = symbolInfo->Address;
Information->ModuleBase = symbolInfo->ModBase;
Information->Address = (PVOID)symbolInfo->Address;
Information->ModuleBase = (PVOID)symbolInfo->ModBase;
Information->Index = symbolInfo->Index;
Information->Size = symbolInfo->Size;
@@ -1071,7 +1071,7 @@ BOOLEAN PhGetSymbolFromName(
PPH_SYMBOL_MODULE PhpCreateSymbolModule(
_In_ HANDLE ProcessHandle,
_In_ PPH_STRING FileName,
_In_ ULONG64 BaseAddress,
_In_ PVOID BaseAddress,
_In_ ULONG Size
)
{
@@ -1102,7 +1102,7 @@ PPH_SYMBOL_MODULE PhpCreateSymbolModule(
BOOLEAN PhLoadModuleSymbolProvider(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_STRING FileName,
_In_ ULONG64 BaseAddress,
_In_ PVOID BaseAddress,
_In_ ULONG Size
)
{
@@ -1135,7 +1135,7 @@ BOOLEAN PhLoadModuleSymbolProvider(
NULL,
NULL,
NULL,
BaseAddress,
(ULONG64)BaseAddress,
Size,
NULL,
0
@@ -1170,7 +1170,7 @@ BOOLEAN PhLoadModuleSymbolProvider(
BOOLEAN PhLoadFileNameSymbolProvider(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_STRING FileName,
_In_ ULONG64 BaseAddress,
_In_ PVOID BaseAddress,
_In_ ULONG Size
)
{
@@ -1200,7 +1200,7 @@ BOOLEAN PhLoadFileNameSymbolProvider(
NULL,
FileName->Buffer,
NULL,
BaseAddress,
(ULONG64)BaseAddress,
Size,
NULL,
0
@@ -1233,6 +1233,7 @@ BOOLEAN PhLoadFileNameSymbolProvider(
typedef struct _PH_LOAD_SYMBOLS_CONTEXT
{
PPH_SYMBOL_PROVIDER SymbolProvider;
HANDLE ProcessId;
} PH_LOAD_SYMBOLS_CONTEXT, *PPH_LOAD_SYMBOLS_CONTEXT;
static BOOLEAN NTAPI PhpSymbolProviderEnumModulesCallback(
@@ -1242,10 +1243,23 @@ static BOOLEAN NTAPI PhpSymbolProviderEnumModulesCallback(
{
PPH_LOAD_SYMBOLS_CONTEXT context = Context;
// If we're loading kernel module symbols for a process other than System, ignore modules which
// are in user space. This may happen in Windows 7.
if (
WindowsVersion < WINDOWS_8 &&
context->ProcessId != SYSTEM_PROCESS_ID
)
{
if ((ULONG_PTR)Module->BaseAddress <= PhSystemBasicInformation.MaximumUserModeAddress)
{
return TRUE;
}
}
PhLoadModuleSymbolProvider(
context->SymbolProvider,
Module->FileName,
(ULONG64)Module->BaseAddress,
Module->BaseAddress,
Module->Size
);
@@ -1301,7 +1315,7 @@ VOID PhLoadSymbolProviderModules(
if (PhGetLoaderEntryData(&fileNames[i], &baseAddress, &sizeOfImage, &fileName))
{
PhLoadModuleSymbolProvider(SymbolProvider, fileName, (ULONG64)baseAddress, sizeOfImage);
PhLoadModuleSymbolProvider(SymbolProvider, fileName, baseAddress, sizeOfImage);
PhDereferenceObject(fileName);
}
}
@@ -1376,7 +1390,7 @@ VOID PhLoadModulesForVirtualSymbolProvider(
if (PhGetLoaderEntryData(&fileNames[i], &baseAddress, &sizeOfImage, &fileName))
{
PhLoadModuleSymbolProvider(SymbolProvider, fileName, (ULONG64)baseAddress, sizeOfImage);
PhLoadModuleSymbolProvider(SymbolProvider, fileName, baseAddress, sizeOfImage);
PhDereferenceObject(fileName);
}
}
@@ -2610,7 +2624,7 @@ BOOL CALLBACK PhEnumerateSymbolsCallback(
BOOLEAN PhEnumerateSymbols(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ HANDLE ProcessHandle,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_In_opt_ PCWSTR Mask,
_In_ PPH_ENUMERATE_SYMBOLS_CALLBACK EnumSymbolsCallback,
_In_opt_ PVOID UserContext
@@ -2639,7 +2653,7 @@ BOOLEAN PhEnumerateSymbols(
result = SymEnumSymbolsW_I(
ProcessHandle,
BaseOfDll,
(ULONG64)BaseOfDll,
Mask,
PhEnumerateSymbolsCallback,
&enumContext
@@ -2655,7 +2669,7 @@ BOOLEAN PhEnumerateSymbols(
_Success_(return)
BOOLEAN PhGetSymbolProviderDiaSource(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_Out_ PVOID* DiaSource
)
{
@@ -2674,7 +2688,7 @@ BOOLEAN PhGetSymbolProviderDiaSource(
result = !!SymGetDiaSource_I(
SymbolProvider->ProcessHandle,
BaseOfDll,
(ULONGLONG)BaseOfDll,
&source
);
//GetLastError(); // returns HRESULT
@@ -2693,7 +2707,7 @@ BOOLEAN PhGetSymbolProviderDiaSource(
_Success_(return)
BOOLEAN PhGetSymbolProviderDiaSession(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 BaseOfDll,
_In_ PVOID BaseOfDll,
_Out_ PVOID* DiaSession
)
{
@@ -2712,7 +2726,7 @@ BOOLEAN PhGetSymbolProviderDiaSession(
result = !!SymGetDiaSession_I(
SymbolProvider->ProcessHandle,
BaseOfDll,
(ULONGLONG)BaseOfDll,
&session
);
//GetLastError(); // returns HRESULT
@@ -2755,7 +2769,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
_Out_opt_ PPH_STRING *FileName,
_Out_opt_ PPH_STRING *SymbolName,
_Out_opt_ PULONG64 Displacement,
_Out_opt_ PULONG64 BaseAddress
_Out_opt_ PPVOID BaseAddress
)
{
PSYMBOL_INFOW symbolInfo;
@@ -2765,7 +2779,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
ULONG64 displacement;
PPH_STRING modFileName = NULL;
PPH_STRING modBaseName = NULL;
ULONG64 modBase = 0;
PVOID modBase = NULL;
PPH_STRING symbolName = NULL;
if (StackFrame->PcAddress == 0)
@@ -2774,7 +2788,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
if (FileName) *FileName = NULL;
if (SymbolName) *SymbolName = NULL;
if (Displacement) *Displacement = 0;
if (BaseAddress) *BaseAddress = 0;
if (BaseAddress) *BaseAddress = NULL;
return NULL;
}
@@ -2822,7 +2836,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
{
modBase = PhGetModuleFromAddress(
SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
&modFileName
);
}
@@ -2830,7 +2844,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
{
modBase = PhGetModuleFromAddress(
SymbolProvider,
symbolInfo->ModBase,
(PVOID)symbolInfo->ModBase,
&modFileName
);
}
@@ -2855,7 +2869,7 @@ PPH_STRING PhGetSymbolFromInlineContext(
PhInitFormatSR(&format[0], modBaseName->sr);
PhInitFormatS(&format[1], L"+0x");
PhInitFormatIX(&format[2], (ULONG_PTR)((ULONG64)StackFrame->PcAddress - modBase));
PhInitFormatIX(&format[2], (ULONG_PTR)((ULONG_PTR)StackFrame->PcAddress - (ULONG_PTR)modBase));
symbol = PhFormat(format, 3, modBaseName->Length + 6 + 32);
goto CleanupExit;
@@ -2899,7 +2913,7 @@ CleanupExit:
if (Displacement)
*Displacement = displacement;
if (BaseAddress)
*BaseAddress = symbolInfo->ModBase ? symbolInfo->ModBase : modBase;
*BaseAddress = symbolInfo->ModBase ? (PVOID)symbolInfo->ModBase : modBase;
PhClearReference(&modFileName);
PhClearReference(&modBaseName);
@@ -2913,7 +2927,7 @@ _Success_(return)
BOOLEAN PhGetLineFromInlineContext(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ PPH_THREAD_STACK_FRAME StackFrame,
_In_opt_ ULONG64 BaseAddress,
_In_opt_ PVOID BaseAddress,
_Out_ PPH_STRING *FileName,
_Out_opt_ PULONG Displacement,
_Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information
@@ -2938,7 +2952,7 @@ BOOLEAN PhGetLineFromInlineContext(
SymbolProvider->ProcessHandle,
(ULONG64)StackFrame->PcAddress,
StackFrame->InlineFrameContext,
BaseAddress,
(ULONG64)BaseAddress,
&displacement,
&line
);
@@ -3287,8 +3301,8 @@ CV_CFL_LANG PhGetDiaSymbolCompilandInformation(
PPH_STRING PhGetDiaSymbolLineInformation(
_In_ IDiaSession* Session,
_In_ IDiaSymbol* Symbol,
_In_ ULONG64 Address,
_In_ ULONG64 Length
_In_ PVOID Address,
_In_ ULONG Length
)
{
IDiaLineNumber* symbolLineNumber;
@@ -3304,7 +3318,7 @@ PPH_STRING PhGetDiaSymbolLineInformation(
ULONG count;
IDiaEnumLineNumbers* enumLineNumbers;
if (IDiaSession_findLinesByVA(Session, Address, (ULONG)Length, &enumLineNumbers) == S_OK)
if (IDiaSession_findLinesByVA(Session, (ULONGLONG)Address, Length, &enumLineNumbers) == S_OK)
{
if (IDiaEnumLineNumbers_Next(enumLineNumbers, 1, &symbolLineNumber, &count) == S_OK)
{
@@ -3458,12 +3472,12 @@ PPH_STRING PhGetDiaSymbolExtraInformation(
_Success_(return)
BOOLEAN PhGetDiaSymbolInformation(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address,
_In_ PVOID Address,
_Out_ PPH_DIA_SYMBOL_INFORMATION SymbolInformation
)
{
PH_DIA_SYMBOL_INFORMATION symbolInfo = { 0 };
ULONG64 baseAddress;
PVOID baseAddress;
IDiaSession* datasession;
IDiaSymbol* symbol;
@@ -3475,19 +3489,19 @@ BOOLEAN PhGetDiaSymbolInformation(
if (!PhGetSymbolProviderDiaSession(SymbolProvider, baseAddress, &datasession))
return FALSE;
if (IDiaSession_findSymbolByVA(datasession, Address, SymTagFunction, &symbol) == S_OK)
if (IDiaSession_findSymbolByVA(datasession, (ULONGLONG)Address, SymTagFunction, &symbol) == S_OK)
{
BSTR symbolUndecoratedName = NULL;
ULONG64 symbolLength = 0;
if (IDiaSymbol_get_length(symbol, &symbolLength) == S_OK)
{
symbolInfo.FunctionLength = symbolLength;
symbolInfo.FunctionLength = (ULONG)symbolLength;
symbolInfo.SymbolLangugage = PhGetDiaSymbolLineInformation(
datasession,
symbol,
Address,
symbolLength
(ULONG)symbolLength
);
}
+66 -83
View File
@@ -21,6 +21,7 @@
#include <apiimport.h>
#include <appresolver.h>
#include <guisup.h>
#include <mapimg.h>
#include <mapldr.h>
#include <lsasup.h>
@@ -172,7 +173,7 @@ LCID PhGetSystemDefaultLCID(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetSystemDefaultLCID();
#else
LCID localeId = LOCALE_SYSTEM_DEFAULT;
@@ -189,7 +190,7 @@ LCID PhGetUserDefaultLCID(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetUserDefaultLCID();
#else
LCID localeId = LOCALE_USER_DEFAULT;
@@ -206,7 +207,7 @@ LCID PhGetCurrentThreadLCID(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetThreadLocale();
#else
PTEB currentTeb;
@@ -225,7 +226,7 @@ LANGID PhGetSystemDefaultLangID(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetSystemDefaultLangID();
#else
return LANGIDFROMLCID(PhGetSystemDefaultLCID());
@@ -237,7 +238,7 @@ LANGID PhGetUserDefaultLangID(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetUserDefaultLangID();
#else
return LANGIDFROMLCID(PhGetUserDefaultLCID());
@@ -249,7 +250,7 @@ LANGID PhGetUserDefaultUILanguage(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
return GetUserDefaultUILanguage();
#else
LANGID languageId;
@@ -268,7 +269,7 @@ PPH_STRING PhGetUserDefaultLocaleName(
VOID
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
ULONG localNameLength;
WCHAR localeName[LOCALE_NAME_MAX_LENGTH] = { UNICODE_NULL };
@@ -298,7 +299,7 @@ PPH_STRING PhLCIDToLocaleName(
_In_ LCID lcid
)
{
#if (PHNT_NATIVE_LOCALE)
#if defined(PHNT_NATIVE_LOCALE)
ULONG localNameLength;
WCHAR localeName[LOCALE_NAME_MAX_LENGTH] = { UNICODE_NULL };
@@ -338,7 +339,7 @@ VOID PhLargeIntegerToSystemTime(
_In_ PLARGE_INTEGER LargeInteger
)
{
#if (PHNT_NATIVE_TIME)
#if defined(PHNT_NATIVE_TIME)
FILETIME fileTime;
fileTime.dwLowDateTime = LargeInteger->LowPart;
@@ -366,7 +367,7 @@ BOOLEAN PhSystemTimeToLargeInteger(
_In_ PSYSTEMTIME SystemTime
)
{
#if (PHNT_NATIVE_TIME)
#if defined(PHNT_NATIVE_TIME)
FILETIME fileTime;
if (!SystemTimeToFileTime(SystemTime, &fileTime))
@@ -396,7 +397,7 @@ VOID PhLargeIntegerToLocalSystemTime(
_In_ PLARGE_INTEGER LargeInteger
)
{
#if (PHNT_NATIVE_TIME)
#if defined(PHNT_NATIVE_TIME)
FILETIME fileTime;
FILETIME newFileTime;
@@ -590,8 +591,6 @@ PPH_STRING PhGetWin32Message(
if (message)
{
ULONG_PTR index;
PhTrimToNullTerminatorString(message);
// Remove any trailing newline.
@@ -599,7 +598,7 @@ PPH_STRING PhGetWin32Message(
message->Buffer[message->Length / sizeof(WCHAR) - 2] == L'\r' &&
message->Buffer[message->Length / sizeof(WCHAR) - 1] == L'\n')
{
PhMoveReference(&message, PhCreateStringEx(message->Buffer, index * sizeof(WCHAR)));
PhMoveReference(&message, PhCreateStringEx(message->Buffer, message->Length - 2 * sizeof(WCHAR)));
}
}
else
@@ -650,6 +649,46 @@ PPH_STRING PhGetWin32FormatMessage(
return messageString;
}
PPH_STRING PhGetNtFormatMessage(
_In_ NTSTATUS Status
)
{
PPH_STRING messageString = NULL;
ULONG messageLength = 0;
PWSTR messageBuffer = NULL;
messageLength = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM,
PhGetLoaderEntryDllBaseZ(L"ntdll.dll"),
Status,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(PWSTR)&messageBuffer,
0,
NULL
);
if (messageBuffer)
{
if (messageLength)
{
ULONG_PTR index;
PH_STRINGREF string;
string.Buffer = messageBuffer;
string.Length = messageLength * sizeof(WCHAR);
if ((index = PhFindStringInStringRefZ(&string, L"\r\n", FALSE)) != SIZE_MAX)
messageString = PhCreateStringEx(messageBuffer, index * sizeof(WCHAR));
else
messageString = PhCreateStringEx(messageBuffer, messageLength * sizeof(WCHAR));
}
LocalFree(messageBuffer);
}
return messageString;
}
/**
* Displays a message box.
*
@@ -4958,13 +4997,10 @@ NTSTATUS PhCreateProcessAsUser(
if (!Information->Environment)
{
if (CreateEnvironmentBlock_Import())
{
CreateEnvironmentBlock_Import()(&defaultEnvironment, tokenHandle, FALSE);
PhCreateEnvironmentBlock(&defaultEnvironment, tokenHandle, FALSE);
if (defaultEnvironment)
Flags |= PH_CREATE_PROCESS_UNICODE_ENVIRONMENT;
}
if (defaultEnvironment)
Flags |= PH_CREATE_PROCESS_UNICODE_ENVIRONMENT;
}
status = PhCreateProcessWin32Ex(
@@ -4980,8 +5016,10 @@ NTSTATUS PhCreateProcessAsUser(
ThreadHandle
);
if (DestroyEnvironmentBlock_Import() && defaultEnvironment)
DestroyEnvironmentBlock_Import()(defaultEnvironment);
if (defaultEnvironment)
{
PhDestroyEnvironmentBlock(defaultEnvironment);
}
NtClose(tokenHandle);
@@ -7786,7 +7824,7 @@ PVOID PhFileReadAllText(
FileName,
FILE_GENERIC_READ,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
)))
@@ -7811,7 +7849,7 @@ PVOID PhFileReadAllTextWin32(
FileName,
FILE_GENERIC_READ,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
)))
@@ -8349,62 +8387,6 @@ NTSTATUS PhDelayExecution(
}
}
ULONGLONG PhReadTimeStampCounter(
VOID
)
{
return ReadTimeStampCounter();
}
// rev from QueryPerformanceCounter (dmex)
/**
* Retrieves the current value of the performance counter, which is a high resolution (<1us) time stamp that can be used for time-interval measurements.
*
* \param PerformanceCounter A pointer to a variable that receives the current performance-counter value, in counts.
*
* \return Successful or errant status.
*
* \remarks On systems that run Windows XP or later, the function will always succeed and will thus never return zero.
*/
BOOLEAN PhQueryPerformanceCounter(
_Out_ PLARGE_INTEGER PerformanceCounter
)
{
#if (PH_WIN32_PERFCOUNTER)
return !!QueryPerformanceCounter(PerformanceCounter);
#elif (PH_NATIVE_PERFCOUNTER)
return NT_SUCCESS(NtQueryPerformanceCounter(PerformanceCounter, NULL));
#else
return !!RtlQueryPerformanceCounter(PerformanceCounter);
#endif
}
// rev from QueryPerformanceFrequency (dmex)
/**
* Retrieves the frequency of the performance counter.
* The frequency of the performance counter is fixed at system boot and is consistent across all processors.
* Therefore, the frequency need only be queried upon application initialization, and the result can be cached.
*
* \param PerformanceFrequency A pointer to a variable that receives the current performance-counter frequency, in counts per second.
*
* \return Successful or errant status.
*
* \remarks On systems that run Windows XP or later, the function will always succeed and will thus never return zero.
*/
BOOLEAN PhQueryPerformanceFrequency(
_Out_ PLARGE_INTEGER PerformanceFrequency
)
{
#if (PH_WIN32_PERFCOUNTER)
return !!QueryPerformanceFrequency(PerformanceFrequency);
#elif (PH_NATIVE_PERFCOUNTER)
LARGE_INTEGER performanceCounter;
return NT_SUCCESS(NtQueryPerformanceCounter(&performanceCounter, PerformanceFrequency));
#else
return !!RtlQueryPerformanceFrequency(PerformanceFrequency);
#endif
}
// rev from lucasg https://lucasg.github.io/2017/10/15/Api-set-resolution/ (dmex)
PPH_STRING PhApiSetResolveToHost(
_In_ PPH_STRINGREF ApiSetName
@@ -8663,6 +8645,7 @@ NTSTATUS PhCreateProcessRedirection(
_Out_opt_ PPH_STRING *CommandOutput
)
{
static SECURITY_ATTRIBUTES securityAttributes = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
NTSTATUS status;
PPH_STRING output = NULL;
STARTUPINFOEX startupInfo = { 0 };
@@ -8677,7 +8660,7 @@ NTSTATUS PhCreateProcessRedirection(
status = PhCreatePipeEx(
&inputReadHandle,
&inputWriteHandle,
TRUE,
&securityAttributes,
NULL
);
@@ -8687,8 +8670,8 @@ NTSTATUS PhCreateProcessRedirection(
status = PhCreatePipeEx(
&outputReadHandle,
&outputWriteHandle,
TRUE,
NULL
NULL,
&securityAttributes
);
if (!NT_SUCCESS(status))
+26 -43
View File
@@ -33,10 +33,10 @@ _CryptCATAdminReleaseContext CryptCATAdminReleaseContext;
//_WTHelperProvDataFromStateData WTHelperProvDataFromStateData_I;
//_WTHelperGetProvSignerFromChain WTHelperGetProvSignerFromChain_I;
_WinVerifyTrust WinVerifyTrust_I;
_CertNameToStr CertNameToStr_I;
_CertGetEnhancedKeyUsage CertGetEnhancedKeyUsage_I;
_CertDuplicateCertificateContext CertDuplicateCertificateContext_I;
_CertFreeCertificateContext CertFreeCertificateContext_I;
typeof(&CertNameToStrW) CertNameToStr_I;
typeof(&CertGetEnhancedKeyUsage) CertGetEnhancedKeyUsage_I;
typeof(&CertDuplicateCertificateContext) CertDuplicateCertificateContext_I;
typeof(&CertFreeCertificateContext) CertFreeCertificateContext_I;
static PH_INITONCE PhpVerifyInitOnce = PH_INITONCE_INIT;
static CONST GUID WinTrustActionGenericVerifyV2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
@@ -168,42 +168,12 @@ BOOLEAN PhIsChainedToMicrosoft(
)
{
static PH_INITONCE initOnce = PH_INITONCE_INIT;
static HCERTSTORE (WINAPI* CertOpenStore_I)(
_In_ LPCSTR lpszStoreProvider,
_In_ ULONG dwEncodingType,
_In_opt_ HCRYPTPROV_LEGACY hCryptProv,
_In_ ULONG dwFlags,
_In_opt_ const void* pvPara
) = NULL;
static BOOL (WINAPI* CertAddStoreToCollection_I)(
_In_ HCERTSTORE hCollectionStore,
_In_opt_ HCERTSTORE hSiblingStore,
_In_ ULONG dwUpdateFlags,
_In_ ULONG dwPriority
) = NULL;
static BOOL (WINAPI* CertGetCertificateChain_I)(
_In_opt_ HCERTCHAINENGINE hChainEngine,
_In_ PCCERT_CONTEXT pCertContext,
_In_opt_ LPFILETIME pTime,
_In_opt_ HCERTSTORE hAdditionalStore,
_In_ PCERT_CHAIN_PARA pChainPara,
_In_ ULONG dwFlags,
_Reserved_ LPVOID pvReserved,
_Out_ PCCERT_CHAIN_CONTEXT * ppChainContext
) = NULL;
static BOOL (WINAPI* CertVerifyCertificateChainPolicy_I)(
_In_ LPCSTR pszPolicyOID,
_In_ PCCERT_CHAIN_CONTEXT pChainContext,
_In_ PCERT_CHAIN_POLICY_PARA pPolicyPara,
_Inout_ PCERT_CHAIN_POLICY_STATUS pPolicyStatus
) = NULL;
static VOID (WINAPI* CertFreeCertificateChain_I)(
_In_ PCCERT_CHAIN_CONTEXT pChainContext
) = NULL;
static BOOL (WINAPI* CertCloseStore_I)(
_In_opt_ HCERTSTORE hCertStore,
_In_ ULONG dwFlags
) = NULL;
static typeof(&CertOpenStore) CertOpenStore_I = NULL;
static typeof(&CertAddStoreToCollection) CertAddStoreToCollection_I = NULL;
static typeof(&CertGetCertificateChain) CertGetCertificateChain_I = NULL;
static typeof(&CertVerifyCertificateChainPolicy) CertVerifyCertificateChainPolicy_I = NULL;
static typeof(&CertFreeCertificateChain) CertFreeCertificateChain_I = NULL;
static typeof(&CertCloseStore) CertCloseStore_I = NULL;
BOOLEAN status = FALSE;
HCERTSTORE cryptStoreHandle;
CERT_CHAIN_POLICY_PARA policyPara = { sizeof(CERT_CHAIN_POLICY_PARA) };
@@ -452,7 +422,7 @@ VERIFY_RESULT PhpVerifyFile(
if (UnionChoice == WTD_CHOICE_CATALOG)
trustData.pCatalog = UnionData;
if (Information->Flags & PH_VERIFY_PREVENT_NETWORK_ACCESS)
if (FlagOn(Information->Flags, PH_VERIFY_PREVENT_NETWORK_ACCESS))
{
trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
trustData.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL;
@@ -483,10 +453,16 @@ BOOLEAN PhpCalculateFileHash(
HANDLE catAdminHandle;
PUCHAR fileHash;
ULONG fileHashLength;
CERT_STRONG_SIGN_PARA strongSigPolicy;
memset(&strongSigPolicy, 0, sizeof(CERT_STRONG_SIGN_PARA));
strongSigPolicy.cbSize = sizeof(CERT_STRONG_SIGN_PARA);
strongSigPolicy.dwInfoChoice = CERT_STRONG_SIGN_OID_INFO_CHOICE;
strongSigPolicy.pszOID = szOID_CERT_STRONG_SIGN_OS_CURRENT;
if (CryptCATAdminAcquireContext2)
{
if (!CryptCATAdminAcquireContext2(&catAdminHandle, &DriverActionVerify, HashAlgorithm, NULL, 0))
if (!CryptCATAdminAcquireContext2(&catAdminHandle, &DriverActionVerify, HashAlgorithm, &strongSigPolicy, 0))
return FALSE;
}
else
@@ -548,10 +524,16 @@ BOOLEAN PhpVerifyGetHashFromFileHandle(
)
{
HANDLE catAdminHandle;
CERT_STRONG_SIGN_PARA strongSigPolicy;
memset(&strongSigPolicy, 0, sizeof(CERT_STRONG_SIGN_PARA));
strongSigPolicy.cbSize = sizeof(CERT_STRONG_SIGN_PARA);
strongSigPolicy.dwInfoChoice = CERT_STRONG_SIGN_OID_INFO_CHOICE;
strongSigPolicy.pszOID = szOID_CERT_STRONG_SIGN_OS_CURRENT;
if (CryptCATAdminAcquireContext2)
{
if (!CryptCATAdminAcquireContext2(&catAdminHandle, &DriverActionVerify, HashAlgorithm, NULL, 0))
if (!CryptCATAdminAcquireContext2(&catAdminHandle, &DriverActionVerify, HashAlgorithm, &strongSigPolicy, 0))
return FALSE;
}
else
@@ -1215,6 +1197,7 @@ VERIFY_RESULT PhVerifyFileWithAdditionalCatalog(
* \param SignerName A variable which receives a pointer to a string containing the signer name. You
* must free the string using PhDereferenceObject() when you no longer need it. Note that the signer
* name may be NULL if it is not valid.
* \param NativeFileName Specify TRUE if the file name is a native path.
* \param CachedOnly Specify TRUE to fail the function when no cached result exists.
*
* \return A VERIFY_RESULT value.
+4 -3
View File
@@ -394,6 +394,7 @@ BOOLEAN PhCreateProcessLxss(
_Out_ PPH_STRING *Result
)
{
static SECURITY_ATTRIBUTES securityAttributes = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
BOOLEAN result = FALSE;
PPH_STRING lxssOutputString = NULL;
PPH_STRING lxssCommandLine;
@@ -431,8 +432,8 @@ BOOLEAN PhCreateProcessLxss(
if (!NT_SUCCESS(PhCreatePipeEx(
&outputReadHandle,
&outputWriteHandle,
TRUE,
NULL
NULL,
&securityAttributes
)))
{
goto CleanupExit;
@@ -441,7 +442,7 @@ BOOLEAN PhCreateProcessLxss(
if (!NT_SUCCESS(PhCreatePipeEx(
&inputReadHandle,
&inputWriteHandle,
TRUE,
&securityAttributes,
NULL
)))
{
+2
View File
@@ -14,6 +14,8 @@
#include "clretw.h"
#include "clrsup.h"
#include "svcext.h"
#include <searchbox.h>
#include <evntcons.h>
#define DNATNC_STRUCTURE 0
+1 -1
View File
@@ -26,7 +26,7 @@ VOID EspLayoutServiceListControl(
RECT rect;
GetWindowRect(GetDlgItem(WindowHandle, IDC_SERVICES_LAYOUT), &rect);
MapWindowPoints(NULL, WindowHandle, (POINT *)&rect, 2);
MapWindowRect(NULL, WindowHandle, &rect);
MoveWindow(
ServiceListHandle,
+1 -1
View File
@@ -575,7 +575,7 @@ INT_PTR CALLBACK EspServiceOtherDlgProc(
config.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;
config.nDefaultButton = IDNO;
config.hwndParent = WindowHandle;
config.pszWindowTitle = L"System Informer";
config.pszWindowTitle = SystemInformer_GetWindowName();
config.pszMainIcon = TD_WARNING_ICON;
config.pszMainInstruction = L"Setting service protection will prevent the service from being controlled, modified, or deleted.";
config.pszContent = L"Do you want to continue?";
+1 -1
View File
@@ -299,7 +299,7 @@ INT_PTR CALLBACK EspServiceRecoveryDlgProc(
{
PhShowWarning2(
WindowHandle,
L"System Informer",
L"Unable to query service recovery information.",
L"The service has %lu failure actions configured, but this program only supports editing 3. "
L"If you save the recovery information using this program, the additional failure actions will be lost.",
context->NumberOfActions
+1 -2
View File
@@ -18,8 +18,7 @@
#include <settings.h>
#include <mapldr.h>
#include <workqueue.h>
#include <math.h>
#include <searchbox.h>
#include "resource.h"
+18 -17
View File
@@ -176,7 +176,9 @@ NTSTATUS EtObjectManagerOpenRealObject(
);
NTSTATUS EtObjectManagerHandleCloseCallback(
_In_ PVOID Context
_In_ HANDLE Handle,
_In_ BOOLEAN Release,
_In_opt_ PVOID Context
);
VOID NTAPI EtpObjectManagerChangeSelection(
@@ -1089,7 +1091,7 @@ NTSTATUS EtpTargetResolverWorkThreadStart(
if (NT_SUCCESS(status = PhGetSectionFileName(objectHandle, &fileName)))
{
if (newFileName = PhResolveDevicePrefix(&fileName->sr))
if (newFileName = PhGetFileName(fileName))
PhMoveReference(&fileName, newFileName);
PhMoveReference(&entry->Target, fileName);
@@ -1486,10 +1488,7 @@ NTSTATUS EtObjectManagerOpenHandle(
if (PhIsNullOrEmptyString(Context->CurrentPath))
return STATUS_INVALID_PARAMETER;
PhStringRefToUnicodeString(&Context->CurrentPath->sr, &objectName);
InitializeObjectAttributes(&objectAttributes, &objectName, OBJ_CASE_INSENSITIVE, NULL, NULL);
return NtOpenDirectoryObject(Handle, DesiredAccess, &objectAttributes);
return PhOpenDirectoryObject(Handle, DesiredAccess, NULL, &Context->CurrentPath->sr);
}
if (PhIsNullOrEmptyString(Context->Object->Name) ||
@@ -1498,13 +1497,11 @@ NTSTATUS EtObjectManagerOpenHandle(
return STATUS_INVALID_PARAMETER;
}
PhStringRefToUnicodeString(&Context->Object->BaseDirectory->sr, &objectName);
InitializeObjectAttributes(&objectAttributes, &objectName, OBJ_CASE_INSENSITIVE, NULL, NULL);
if (!NT_SUCCESS(status = NtOpenDirectoryObject(
if (!NT_SUCCESS(status = PhOpenDirectoryObject(
&directoryHandle,
DIRECTORY_QUERY,
&objectAttributes
NULL,
&Context->Object->BaseDirectory->sr
)))
{
return status;
@@ -1998,17 +1995,21 @@ NTSTATUS EtObjectManagerHandleOpenCallback(
}
NTSTATUS EtObjectManagerHandleCloseCallback(
_In_ PVOID Context
_In_ HANDLE Handle,
_In_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
PET_HANDLE_OPEN_CONTEXT context = Context;
PhClearReference(&context->CurrentPath);
PhClearReference(&context->FullName);
if (Release)
{
PhClearReference(&context->CurrentPath);
PhClearReference(&context->FullName);
PhClearReference(&context->Object);
PhFree(context);
}
PhClearReference(&context->Object);
PhFree(context);
return STATUS_SUCCESS;
}
+20 -34
View File
@@ -960,24 +960,6 @@ INT CALLBACK EtpCommonPropPageProc(
return 1;
}
static BOOLEAN NTAPI EnumGenericModulesCallback(
_In_ PPH_MODULE_INFO Module,
_In_ PVOID Context
)
{
if (Module->Type == PH_MODULE_TYPE_MODULE || Module->Type == PH_MODULE_TYPE_WOW64_MODULE)
{
PhLoadModuleSymbolProvider(
Context,
Module->FileName,
(ULONG64)Module->BaseAddress,
Module->Size
);
}
return TRUE;
}
INT_PTR CALLBACK EtpTpWorkerFactoryPageDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
@@ -1018,18 +1000,11 @@ INT_PTR CALLBACK EtpTpWorkerFactoryPageDlgProc(
if (symbolProvider = PhCreateSymbolProvider(NULL))
{
PhLoadSymbolProviderOptions(symbolProvider);
PhEnumGenericModules(
basicInfo.ProcessId,
NULL,
0,
EnumGenericModulesCallback,
symbolProvider
);
PhLoadSymbolProviderModules(symbolProvider, context->ProcessId);
symbol = PhGetSymbolFromAddress(
symbolProvider,
(ULONG64)basicInfo.StartRoutine,
basicInfo.StartRoutine,
NULL,
NULL,
NULL,
@@ -1618,8 +1593,11 @@ static NTSTATUS EtpProcessHandleCloseCallback(
{
PET_HANDLE_OPEN_CONTEXT context = Context;
PhDereferenceObject(context->HandleItem);
PhFree(context);
if (Release)
{
PhDereferenceObject(context->HandleItem);
PhFree(context);
}
return STATUS_SUCCESS;
}
@@ -2132,14 +2110,22 @@ static NTSTATUS EtpOpenSecurityDesktopHandle(
}
static NTSTATUS EtpCloseSecurityDesktop(
_In_ PVOID Context
_In_ HANDLE Handle,
_In_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
POPEN_DESKTOP_CONTEXT context = Context;
PhClearReference(&context->DesktopName);
if (context->DesktopWinStation) CloseWindowStation(context->DesktopWinStation);
PhFree(context);
if (Release)
{
PhClearReference(&context->DesktopName);
if (context->DesktopWinStation) CloseWindowStation(context->DesktopWinStation);
PhFree(context);
}
CloseWindowStation(Handle);
return STATUS_SUCCESS;
}