Update to the latest SDK

This commit is contained in:
dmex
2024-12-01 16:17:11 +11:00
parent 778c94230e
commit f8757ab345
107 changed files with 2140 additions and 1320 deletions
+39 -41
View File
@@ -7,30 +7,24 @@
<SDLCheck>true</SDLCheck>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<FunctionLevelLinking>true</FunctionLevelLinking>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C Condition="'$(MSBuildVersion)' &lt; '17.11'">stdc17</LanguageStandard_C>
<LanguageStandard_C Condition="'$(MSBuildVersion)' &gt;= '17.11'">stdclatest</LanguageStandard_C>
<StringPooling>true</StringPooling>
<SupportJustMyCode>false</SupportJustMyCode>
<CallingConvention>StdCall</CallingConvention>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
<OmitFramePointers>true</OmitFramePointers>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<ConformanceMode>true</ConformanceMode>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<FloatingPointModel>Precise</FloatingPointModel>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</ClCompile>
<Link>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<CETCompat>true</CETCompat>
<LargeAddressAware>true</LargeAddressAware>
<TerminalServerAware>true</TerminalServerAware>
</Link>
<ResourceCompile>
<Culture>0x0009</Culture>
@@ -43,59 +37,48 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreferredToolArchitecture>x86</PreferredToolArchitecture>
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<!-- Release Builds -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>false</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PreferredToolArchitecture>x86</PreferredToolArchitecture>
<PlatformToolset>v143</PlatformToolset>
<SpectreMitigation>Spectre</SpectreMitigation>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>false</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<SpectreMitigation>Spectre</SpectreMitigation>
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<CharacterSet>Unicode</CharacterSet>
<UseDebugLibraries>false</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<SpectreMitigation>Spectre</SpectreMitigation>
<PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<!-- Debug|Win32 Builds -->
@@ -103,44 +86,52 @@
<ClCompile>
<AdditionalOptions>/utf-8 /d1nodatetime %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>WIN32;DEBUG;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);$(ExternalCompilerOptions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CallingConvention>StdCall</CallingConvention>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<FloatingPointModel>Precise</FloatingPointModel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /FILEALIGN:0x1000 %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
<TargetMachine>MachineX86</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>true</LinkIncremental>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
</Link>
</ItemDefinitionGroup>
<!-- Debug|x64 Builds -->
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalOptions>/utf-8 /d1nodatetime %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>WIN64;DEBUG;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);$(ExternalCompilerOptions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CallingConvention>StdCall</CallingConvention>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<FloatingPointModel>Precise</FloatingPointModel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /FILEALIGN:0x1000 %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
<TargetMachine>MachineX64</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>true</LinkIncremental>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
</Link>
</ItemDefinitionGroup>
@@ -149,25 +140,29 @@
<ClCompile>
<AdditionalOptions>/utf-8 /d1nodatetime %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>WIN64;DEBUG;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);$(ExternalCompilerOptions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CallingConvention>StdCall</CallingConvention>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<FloatingPointModel>Precise</FloatingPointModel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<GuardSignedReturns>true</GuardSignedReturns>
</ClCompile>
<Link>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /FILEALIGN:0x1000 %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<MinimumRequiredVersion>10</MinimumRequiredVersion>
<TargetMachine>MachineARM64</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>true</LinkIncremental>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
</Link>
</ItemDefinitionGroup>
<!-- Release|Win32 Builds -->
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@@ -187,21 +182,22 @@
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<CETCompat>true</CETCompat>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /PDBALTPATH:%_PDB% /FILEALIGN:0x1000 %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<Optimization>Disabled</Optimization>
<CETCompat>true</CETCompat>
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
<TargetMachine>MachineX86</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>false</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<SetChecksum>true</SetChecksum>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
</Link>
</ItemDefinitionGroup>
<!-- Release|x64 Builds -->
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -222,24 +218,25 @@
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<CETCompat>true</CETCompat>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /PDBALTPATH:%_PDB% /FILEALIGN:0x1000 /guard:xfg %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<CETCompat>true</CETCompat>
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
<TargetMachine>MachineX64</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>false</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<SetChecksum>true</SetChecksum>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
</Link>
</ItemDefinitionGroup>
<!-- Release|ARM64 Builds -->
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<AdditionalOptions>/utf-8 /d1nodatetime /d1trimfile:"$(MSBuildThisFileDirectory)\" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/utf-8 /d1nodatetime /guard:xfg /d1trimfile:"$(MSBuildThisFileDirectory)\" %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);$(ExternalCompilerOptions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
@@ -254,12 +251,13 @@
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /PDBALTPATH:%_PDB% /FILEALIGN:0x1000 %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<MinimumRequiredVersion>10</MinimumRequiredVersion>
<AdditionalOptions>/BREPRO /DEPENDENTLOADFLAG:0x800 /PDBALTPATH:%_PDB% /FILEALIGN:0x1000 /guard:xfg %(AdditionalOptions) $(ExternalLinkerOptions)</AdditionalOptions>
<AdditionalDependencies>binmode.obj;invalidcontinue.obj;noarg.obj;noenv.obj;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
<MinimumRequiredVersion>10</MinimumRequiredVersion>
<TargetMachine>MachineARM64</TargetMachine>
<UseUnicodeResponseFiles>true</UseUnicodeResponseFiles>
<GenerateDebugInformation>false</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkIncremental>false</LinkIncremental>
<SetChecksum>true</SetChecksum>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
+3
View File
@@ -590,6 +590,7 @@ EXPORTS
PhGetProcessWindowTitle
PhGetProcessWorkingSetInformation
PhGetProcessWsCounters
PhGetSectionFileName
PhGetTokenGroups
PhGetTokenIntegrityLevel
PhGetTokenIntegrityLevelRID
@@ -639,6 +640,7 @@ EXPORTS
PhSetTokenSessionId
PhSetValueKey
PhTerminateProcess
PhTraceControl
PhTransceiveNamedPipe
PhUnloadDllProcess
PhUnloadDriver
@@ -1048,6 +1050,7 @@ EXPORTS
PhGetModuleFromAddress
PhGetSymbolFromAddress
PhGetSymbolFromName
PhLoadSymbolProviderModules
PhLoadModuleSymbolProvider
PhLoadModulesForVirtualSymbolProvider
PhSetOptionsSymbolProvider
+217 -79
View File
@@ -34,6 +34,7 @@
#include <memprv.h>
#include <modprv.h>
#include <netprv.h>
#include <phconsole.h>
#include <phsvccl.h>
#include <procprv.h>
#include <srvprv.h>
@@ -1961,12 +1962,12 @@ BOOLEAN PhUiSuspendTreeProcess(
{
NTSTATUS status;
BOOLEAN success = TRUE;
BOOLEAN cont = FALSE;
BOOLEAN result = FALSE;
PVOID processes;
if (PhGetIntegerSetting(L"EnableWarnings"))
{
cont = PhShowConfirmMessage(
result = PhShowConfirmMessage(
WindowHandle,
L"suspend",
PhaConcatStrings2(Process->ProcessName->Buffer, L" and its descendants")->Buffer,
@@ -1976,10 +1977,10 @@ BOOLEAN PhUiSuspendTreeProcess(
}
else
{
cont = TRUE;
result = TRUE;
}
if (!cont)
if (!result)
return FALSE;
if (!NT_SUCCESS(status = PhEnumProcesses(&processes)))
@@ -2159,12 +2160,12 @@ BOOLEAN PhUiResumeTreeProcess(
{
NTSTATUS status;
BOOLEAN success = TRUE;
BOOLEAN cont = FALSE;
BOOLEAN result = FALSE;
PVOID processes;
if (PhGetIntegerSetting(L"EnableWarnings"))
{
cont = PhShowConfirmMessage(
result = PhShowConfirmMessage(
WindowHandle,
L"resume",
PhaConcatStrings2(Process->ProcessName->Buffer, L" and its descendants")->Buffer,
@@ -2174,10 +2175,10 @@ BOOLEAN PhUiResumeTreeProcess(
}
else
{
cont = TRUE;
result = TRUE;
}
if (!cont)
if (!result)
return FALSE;
if (!NT_SUCCESS(status = PhEnumProcesses(&processes)))
@@ -2198,7 +2199,7 @@ BOOLEAN PhUiFreezeTreeProcess(
)
{
NTSTATUS status;
BOOLEAN cont = FALSE;
BOOLEAN result = FALSE;
HANDLE freezeHandle;
if (ReadPointerAcquire(&Process->FreezeHandle))
@@ -2206,7 +2207,7 @@ BOOLEAN PhUiFreezeTreeProcess(
if (PhGetIntegerSetting(L"EnableWarnings"))
{
cont = PhShowConfirmMessage(
result = PhShowConfirmMessage(
WindowHandle,
L"freeze",
Process->ProcessName->Buffer,
@@ -2216,10 +2217,10 @@ BOOLEAN PhUiFreezeTreeProcess(
}
else
{
cont = TRUE;
result = TRUE;
}
if (!cont)
if (!result)
return FALSE;
status = PhFreezeProcess(&freezeHandle, Process->ProcessId);
@@ -2262,21 +2263,24 @@ BOOLEAN PhUiRestartProcess(
)
{
NTSTATUS status;
BOOLEAN cont = FALSE;
BOOLEAN result = FALSE;
BOOLEAN elevated = !!PhGetOwnTokenAttributes().Elevated;
BOOLEAN tokenIsStronglyNamed = FALSE;
BOOLEAN tokenIsUIAccessEnabled = FALSE;
BOOLEAN tokenRevertImpersonation = FALSE;
HANDLE processHandle = NULL;
HANDLE newProcessHandle = NULL;
HANDLE tokenHandle = NULL;
PPH_STRING fileNameWin32 = NULL;
PPH_STRING commandLine = NULL;
PPH_STRING currentDirectory = NULL;
STARTUPINFOEX startupInfo = { 0 };
PSECURITY_DESCRIPTOR processSecurityDescriptor = NULL;
PSECURITY_DESCRIPTOR tokenSecurityDescriptor = NULL;
PVOID environment = NULL;
HANDLE tokenHandle = NULL;
ULONG flags = 0;
PPROC_THREAD_ATTRIBUTE_LIST attributeList = NULL;
BOOLEAN environmentAllocated = FALSE;
PVOID environmentBuffer = NULL;
ULONG environmentLength;
if (PhGetIntegerSetting(L"EnableWarnings"))
{
@@ -2310,11 +2314,6 @@ BOOLEAN PhUiRestartProcess(
goto CleanupExit;
}
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
// Open the process and get the command line and current directory.
if (!NT_SUCCESS(status = PhOpenProcess(
@@ -2324,46 +2323,52 @@ BOOLEAN PhUiRestartProcess(
)))
goto CleanupExit;
if (!NT_SUCCESS(status = PhGetProcessCurrentDirectory(
processHandle,
!!Process->IsWow64Process,
&currentDirectory
)))
goto CleanupExit;
if (!NT_SUCCESS(status = PhGetProcessCommandLine(
processHandle,
&commandLine
)))
goto CleanupExit;
if (!NT_SUCCESS(status = PhGetProcessCurrentDirectory(
if (!NT_SUCCESS(status = PhGetProcessEnvironment(
processHandle,
!!Process->IsWow64Process,
&currentDirectory
Process->IsWow64Process ? PH_GET_PROCESS_ENVIRONMENT_WOW64 : 0,
&environmentBuffer,
&environmentLength
)))
{
goto CleanupExit;
}
NtClose(processHandle);
processHandle = NULL;
// Start the process.
// Use the existing process as the parent of the new process,
// the new process will inherit everything from the parent process (dmex)
//
// Use the existing process as the parent, and restarting the process will inherit most of the process configuration from itself (dmex)
status = PhOpenProcess(
&processHandle,
PROCESS_CREATE_PROCESS | PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE | (PhGetOwnTokenAttributes().Elevated ? READ_CONTROL : 0),
PROCESS_CREATE_PROCESS | PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE | (elevated ? READ_CONTROL : 0),
Process->ProcessId
);
if (!NT_SUCCESS(status))
goto CleanupExit;
status = PhInitializeProcThreadAttributeList(&startupInfo.lpAttributeList, 1);
status = PhInitializeProcThreadAttributeList(&attributeList, 1);
if (!NT_SUCCESS(status))
goto CleanupExit;
status = PhUpdateProcThreadAttribute(
startupInfo.lpAttributeList,
attributeList,
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
&(HANDLE){ processHandle },
&processHandle,
sizeof(HANDLE)
);
@@ -2372,7 +2377,7 @@ BOOLEAN PhUiRestartProcess(
status = PhOpenProcessToken(
processHandle,
TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | (PhGetOwnTokenAttributes().Elevated ? READ_CONTROL : 0),
TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | (elevated ? READ_CONTROL : 0),
&tokenHandle
);
@@ -2387,7 +2392,7 @@ BOOLEAN PhUiRestartProcess(
{
status = PhOpenProcessToken(
processHandle,
TOKEN_QUERY | (PhGetOwnTokenAttributes().Elevated ? READ_CONTROL : 0),
TOKEN_QUERY | (elevated ? READ_CONTROL : 0),
&tokenHandle
);
@@ -2395,7 +2400,7 @@ BOOLEAN PhUiRestartProcess(
goto CleanupExit;
}
if (PhGetOwnTokenAttributes().Elevated)
if (elevated)
{
PhGetObjectSecurity(
processHandle,
@@ -2409,9 +2414,12 @@ BOOLEAN PhUiRestartProcess(
);
}
if (CreateEnvironmentBlock_Import() && CreateEnvironmentBlock_Import()(&environment, tokenHandle, FALSE))
if (!environmentBuffer)
{
flags |= PH_CREATE_PROCESS_UNICODE_ENVIRONMENT;
if (NT_SUCCESS(PhCreateEnvironmentBlock(&environmentBuffer, tokenHandle, FALSE)))
{
environmentAllocated = TRUE;
}
}
if (NT_SUCCESS(PhGetProcessIsStronglyNamed(processHandle, &tokenIsStronglyNamed)) && tokenIsStronglyNamed)
@@ -2419,13 +2427,20 @@ BOOLEAN PhUiRestartProcess(
tokenRevertImpersonation = NT_SUCCESS(PhImpersonateToken(NtCurrentThread(), tokenHandle));
}
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
startupInfo.lpAttributeList = attributeList;
status = PhCreateProcessWin32Ex(
PhGetString(fileNameWin32),
PhGetString(commandLine),
environment,
environmentBuffer,
PhGetString(currentDirectory),
&startupInfo,
PH_CREATE_PROCESS_SUSPENDED | PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO | PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | flags,
PH_CREATE_PROCESS_SUSPENDED | PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO |
PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | PH_CREATE_PROCESS_UNICODE_ENVIRONMENT,
tokenHandle,
NULL,
&newProcessHandle,
@@ -2437,10 +2452,11 @@ BOOLEAN PhUiRestartProcess(
status = PhCreateProcessWin32Ex(
PhGetString(fileNameWin32),
PhGetString(commandLine),
environment,
environmentBuffer,
PhGetString(currentDirectory),
&startupInfo,
PH_CREATE_PROCESS_SUSPENDED | PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO | PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | flags,
PH_CREATE_PROCESS_SUSPENDED | PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO |
PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | PH_CREATE_PROCESS_UNICODE_ENVIRONMENT,
NULL,
NULL,
&newProcessHandle,
@@ -2469,12 +2485,10 @@ BOOLEAN PhUiRestartProcess(
if (NT_SUCCESS(status))
{
PROCESS_BASIC_INFORMATION basicInfo;
// See runas.c for a description of the Windows issue with PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
// requiring the reset of the security descriptor. (dmex)
if (PhGetOwnTokenAttributes().Elevated && !tokenIsUIAccessEnabled) // Skip processes with UIAccess (dmex)
if (elevated && !tokenIsUIAccessEnabled) // Skip processes with UIAccess (dmex)
{
HANDLE tokenWriteHandle = NULL;
@@ -2502,14 +2516,13 @@ BOOLEAN PhUiRestartProcess(
}
}
if (NT_SUCCESS(PhGetProcessBasicInformation(newProcessHandle, &basicInfo)))
{
AllowSetForegroundWindow(HandleToUlong(basicInfo.UniqueProcessId));
}
// Terminate the existing process.
PhTerminateProcess(processHandle, 1);
PhTerminateProcess(processHandle, STATUS_SUCCESS);
// Update the console foreground.
PhConsoleSetForeground(newProcessHandle, TRUE);
// Resume the new process.
@@ -2533,14 +2546,14 @@ CleanupExit:
NtClose(processHandle);
}
if (startupInfo.lpAttributeList)
if (attributeList)
{
PhDeleteProcThreadAttributeList(startupInfo.lpAttributeList);
PhDeleteProcThreadAttributeList(attributeList);
}
if (environment && DestroyEnvironmentBlock_Import())
if (environmentBuffer && environmentAllocated)
{
DestroyEnvironmentBlock_Import()(environment);
PhDestroyEnvironmentBlock(environmentBuffer);
}
if (tokenSecurityDescriptor)
@@ -2863,8 +2876,8 @@ BOOLEAN PhUiSetEcoModeProcess(
if (NT_SUCCESS(status))
{
if (!(
powerThrottlingState.ControlMask & POWER_THROTTLING_PROCESS_EXECUTION_SPEED &&
powerThrottlingState.StateMask & POWER_THROTTLING_PROCESS_EXECUTION_SPEED
FlagOn(powerThrottlingState.ControlMask, POWER_THROTTLING_PROCESS_EXECUTION_SPEED) &&
FlagOn(powerThrottlingState.StateMask, POWER_THROTTLING_PROCESS_EXECUTION_SPEED)
))
{
if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
@@ -2876,8 +2889,11 @@ BOOLEAN PhUiSetEcoModeProcess(
))
{
// Taskmgr sets the process priority to idle before enabling 'Eco mode'. (dmex)
PhSetProcessPriority(processHandle, PROCESS_PRIORITY_CLASS_IDLE);
PhSetProcessPriorityClass(processHandle, PROCESS_PRIORITY_CLASS_IDLE);
//
// Turn PROCESS_EXECUTION_SPEED throttling on.
//
status = PhSetProcessPowerThrottlingState(
processHandle,
POWER_THROTTLING_PROCESS_EXECUTION_SPEED,
@@ -2898,8 +2914,11 @@ BOOLEAN PhUiSetEcoModeProcess(
// Taskmgr does not properly restore the original priority after it has exited
// and you later decide to disable 'Eco mode', so we'll restore normal priority
// which isn't quite correct but still way better than what taskmgr does. (dmex)
PhSetProcessPriority(processHandle, PROCESS_PRIORITY_CLASS_NORMAL);
PhSetProcessPriorityClass(processHandle, PROCESS_PRIORITY_CLASS_NORMAL);
//
// Let system manage all power throttling.
//
status = PhSetProcessPowerThrottlingState(processHandle, 0, 0);
}
}
@@ -3201,7 +3220,7 @@ BOOLEAN PhUiSetPriorityProcesses(
{
if (Processes[i]->ProcessId != SYSTEM_PROCESS_ID)
{
status = PhSetProcessPriority(processHandle, (UCHAR)PriorityClass);
status = PhSetProcessPriorityClass(processHandle, (UCHAR)PriorityClass);
}
else
{
@@ -3361,7 +3380,7 @@ typedef struct _PH_UI_SERVICE_ITEM
#define WM_PHSVC_ERROR (WM_APP + 1)
#define WM_PHSVC_EXIT (WM_APP + 2)
VOID PhUiNavigateServiceProgressDialogPage(
VOID PhShowServiceProgressDialogStatusPage(
_In_ PPH_UI_SERVICE_PROGRESS_DIALOG Context
);
#pragma endregion
@@ -3392,7 +3411,7 @@ HRESULT CALLBACK PhpUiServiceErrorDialogCallbackProc(
if (buttonId == IDYES)
{
PhUiNavigateServiceProgressDialogPage(context);
PhShowServiceProgressDialogStatusPage(context);
return S_FALSE;
}
}
@@ -3653,7 +3672,7 @@ HRESULT CALLBACK PhpUiServiceProgressDialogCallbackProc(
return S_OK;
}
VOID PhUiNavigateServiceProgressDialogPage(
VOID PhShowServiceProgressDialogStatusPage(
_In_ PPH_UI_SERVICE_PROGRESS_DIALOG Context
)
{
@@ -3691,7 +3710,7 @@ HRESULT CALLBACK PhpUiServiceConfirmDialogCallbackProc(
if (buttonId == IDYES)
{
PhUiNavigateServiceProgressDialogPage(context);
PhShowServiceProgressDialogStatusPage(context);
return S_FALSE;
}
}
@@ -3839,9 +3858,16 @@ HRESULT CALLBACK PhpUiServiceInitializeDialogCallbackProc(
PhSetWindowContext(WindowHandle, MAXCHAR, context);
PhSetWindowProcedure(WindowHandle, PhpUiServiceProgressDialogWndProc);
PhShowServiceProgressDialogConfirmMessage(context);
if (PhGetIntegerSetting(L"EnableWarnings"))
{
PhShowServiceProgressDialogConfirmMessage(context);
}
else
{
PhShowServiceProgressDialogStatusPage(context);
}
PhInitializeWindowTheme(WindowHandle, PhEnableThemeSupport);
PhSetWindowTheme(WindowHandle);
}
break;
}
@@ -3945,14 +3971,13 @@ static BOOLEAN PhpShowContinueMessageServices(
_In_ ULONG NumberOfServices
)
{
PCWSTR object;
BOOLEAN cont = FALSE;
if (NumberOfServices == 0)
return FALSE;
if (PhGetIntegerSetting(L"EnableWarnings"))
{
PCWSTR object;
if (NumberOfServices == 1)
{
object = L"the selected service";
@@ -3962,7 +3987,6 @@ static BOOLEAN PhpShowContinueMessageServices(
object = L"the selected services";
}
cont = PhShowConfirmMessage(
WindowHandle,
Verb,
object,
@@ -3972,10 +3996,8 @@ static BOOLEAN PhpShowContinueMessageServices(
}
else
{
cont = TRUE;
return TRUE;
}
return cont;
}
static NTSTATUS PhpCheckServiceStatus(
@@ -3985,17 +4007,18 @@ static NTSTATUS PhpCheckServiceStatus(
{
NTSTATUS status;
SERVICE_STATUS_PROCESS serviceStatus;
ULONG checkpoint;
ULONG64 serviceTicks;
ULONG serviceCheck;
status = PhQueryServiceStatus(ServiceHandle, &serviceStatus);
if (!NT_SUCCESS(status))
return status;
if (serviceStatus.dwCurrentState == WaitForState)
return STATUS_SUCCESS;
checkpoint = serviceStatus.dwCheckPoint;
serviceTicks = NtGetTickCount64();
serviceCheck = serviceStatus.dwCheckPoint;
while (
serviceStatus.dwCurrentState == SERVICE_START_PENDING ||
@@ -4004,7 +4027,14 @@ static NTSTATUS PhpCheckServiceStatus(
serviceStatus.dwCurrentState == SERVICE_PAUSE_PENDING
)
{
PhDelayExecution(serviceStatus.dwWaitHint);
ULONG statusWaitHint = serviceStatus.dwWaitHint / 10;
if (statusWaitHint < 1000)
statusWaitHint = 1000;
if (statusWaitHint > 10000)
statusWaitHint = 10000;
PhDelayExecution(statusWaitHint);
status = PhQueryServiceStatus(ServiceHandle, &serviceStatus);
@@ -4014,17 +4044,25 @@ static NTSTATUS PhpCheckServiceStatus(
if (serviceStatus.dwCurrentState == WaitForState)
return STATUS_SUCCESS;
if (checkpoint == serviceStatus.dwCheckPoint && (
if (!(
serviceStatus.dwCurrentState == SERVICE_START_PENDING ||
serviceStatus.dwCurrentState == SERVICE_STOP_PENDING ||
serviceStatus.dwCurrentState == SERVICE_CONTINUE_PENDING ||
serviceStatus.dwCurrentState == SERVICE_PAUSE_PENDING
))
{
return STATUS_SUCCESS;
}
checkpoint = serviceStatus.dwCheckPoint;
if (serviceStatus.dwCheckPoint > serviceCheck)
{
serviceTicks = NtGetTickCount64();
serviceCheck = serviceStatus.dwCheckPoint;
}
else if ((NtGetTickCount64() - serviceTicks) > serviceStatus.dwWaitHint)
{
// Service doesn't report progress.
}
}
return status;
@@ -4937,6 +4975,106 @@ BOOLEAN PhUiDeleteService(
return success;
}
BOOLEAN PhUiRestartServices(
_In_ HWND WindowHandle,
_In_ PPH_SERVICE_ITEM* Services,
_In_ ULONG NumberOfServices
)
{
BOOLEAN success = TRUE;
BOOLEAN cancelled = FALSE;
ULONG i;
if (PhGetIntegerSetting(L"EnableServiceProgressDialog"))
{
PhShowServiceProgressDialog(
WindowHandle,
L"stop",
L"Restarting a service might prevent the system from functioning properly.",
FALSE,
Services,
NumberOfServices,
PhUiServiceStopCallback,
PhSvcControlServiceStop
);
return FALSE;
}
if (!PhpShowContinueMessageServices(
WindowHandle,
L"restart",
L"Restarting a service might prevent the system from functioning properly.",
FALSE,
Services,
NumberOfServices
))
return FALSE;
for (i = 0; i < NumberOfServices; i++)
{
NTSTATUS status;
SC_HANDLE serviceHandle;
success = FALSE;
status = PhOpenService(&serviceHandle, SERVICE_START | SERVICE_STOP, PhGetString(Services[i]->Name));
if (NT_SUCCESS(status))
{
status = PhStopService(serviceHandle);
if (NT_SUCCESS(status))
{
status = PhStartService(serviceHandle, 0, nullptr);
if (NT_SUCCESS(status))
success = TRUE;
}
PhCloseServiceHandle(serviceHandle);
}
if (!success)
{
BOOLEAN connected;
success = FALSE;
if (!cancelled && PhpShowErrorAndConnectToPhSvc(
WindowHandle,
PhaConcatStrings2(L"Unable to restart ", PhGetString(Services[i]->Name))->Buffer,
status,
&connected,
&cancelled
))
{
if (connected)
{
if (NT_SUCCESS(status = PhSvcCallControlService(PhGetString(Services[i]->Name), PhSvcControlServiceStop)))
success = TRUE;
else
PhpShowErrorService(WindowHandle, L"restart", Services[i], status, 0);
PhUiDisconnectFromPhSvc();
}
else
{
cancelled = TRUE;
}
}
else
{
if (cancelled)
break;
if (!PhpShowErrorService(WindowHandle, L"restart", Services[i], status, 0))
break;
}
}
}
return success;
}
BOOLEAN PhUiCloseConnections(
_In_ HWND WindowHandle,
_In_ PPH_NETWORK_ITEM *Connections,
+3 -3
View File
@@ -844,7 +844,7 @@ NTSTATUS PhSetProcessItemPriority(
if (NT_SUCCESS(status))
{
status = PhSetProcessPriority(processHandle, PriorityClass);
status = PhSetProcessPriorityClass(processHandle, PriorityClass);
NtClose(processHandle);
}
@@ -894,14 +894,14 @@ NTSTATUS PhSetProcessItemThrottlingState(
{
if (ClearThrottlingState)
{
PhSetProcessPriority(processHandle, PROCESS_PRIORITY_CLASS_NORMAL);
PhSetProcessPriorityClass(processHandle, PROCESS_PRIORITY_CLASS_NORMAL);
status = PhSetProcessPowerThrottlingState(processHandle, 0, 0);
}
else
{
// Taskmgr sets the process priority to idle before enabling 'Eco mode'. (dmex)
PhSetProcessPriority(processHandle, PROCESS_PRIORITY_CLASS_IDLE);
PhSetProcessPriorityClass(processHandle, PROCESS_PRIORITY_CLASS_IDLE);
status = PhSetProcessPowerThrottlingState(
processHandle,
+5 -5
View File
@@ -267,7 +267,7 @@ BOOLEAN NTAPI PhpWalkThreadStackAnalyzeCallback(
name = PhGetSymbolFromAddress(
context->SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
NULL,
NULL,
NULL,
@@ -301,22 +301,22 @@ BOOLEAN NTAPI PhpWalkThreadStackAnalyzeCallback(
{
BOOLEAN alertable = !!StackFrame->Params[0];
PVOID timeoutAddress = StackFrame->Params[1];
LARGE_INTEGER timeout;
LONGLONG timeout;
if (NT_SUCCESS(NtReadVirtualMemory(
context->ProcessHandle,
timeoutAddress,
&timeout,
sizeof(LARGE_INTEGER),
sizeof(LONGLONG),
NULL
)))
{
if (timeout.QuadPart < 0)
if (timeout < 0)
{
PhAppendFormatStringBuilder(
&context->StringBuilder,
L"Thread is sleeping. Timeout: %I64u milliseconds.",
-timeout.QuadPart / PH_TIMEOUT_MS
-timeout / PH_TIMEOUT_MS
);
}
else
+19 -2
View File
@@ -21,6 +21,7 @@
#include <phappres.h>
#include <phsvccl.h>
#include <thirdparty.h>
#include <phconsole.h>
/**
* Determines whether a process is suspended.
@@ -908,10 +909,25 @@ VOID PhShellExecuteUserString(
else
{
NTSTATUS status;
HANDLE processHandle;
status = PhCreateProcessWin32(NULL, executeString->Buffer, NULL, NULL, 0, NULL, NULL, NULL);
status = PhCreateProcessWin32(
NULL,
executeString->Buffer,
NULL,
NULL,
0,
NULL,
&processHandle,
NULL
);
if (!NT_SUCCESS(status))
if (NT_SUCCESS(status))
{
PhConsoleSetForeground(processHandle, TRUE);
NtClose(processHandle);
}
else
{
if (ErrorMessage)
{
@@ -1499,6 +1515,7 @@ BOOLEAN PhCreateProcessIgnoreIfeoDebugger(
// Ignore the debug object status.
result = TRUE;
PhConsoleSetForeground(processHandle, TRUE);
NtClose(processHandle);
}
+12 -22
View File
@@ -155,39 +155,29 @@ VOID PhpColumnsResetListBox(
VOID NTAPI PhpInactiveColumnsSearchControlCallback(
_In_ ULONG_PTR MatchHandle,
_In_opt_ PVOID Context
_In_ PCOLUMNS_DIALOG_CONTEXT Context
)
{
PCOLUMNS_DIALOG_CONTEXT context = Context;
assert(context);
PhpColumnsResetListBox(
context->InactiveWindowHandle,
Context->InactiveWindowHandle,
MatchHandle,
context->InactiveListArray,
Context->InactiveListArray,
PhpInactiveColumnsCompareNameTn
);
}
VOID NTAPI PhpActiveColumnsSearchControlCallback(
_In_ ULONG_PTR MatchHandle,
_In_opt_ PVOID Context
)
{
PCOLUMNS_DIALOG_CONTEXT context = Context;
assert(context);
PhpColumnsResetListBox(
context->ActiveWindowHandle,
Context->ActiveWindowHandle,
MatchHandle,
context->ActiveListArray,
Context->ActiveListArray,
NULL
);
}
INT_PTR CALLBACK PhpColumnsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
@@ -261,7 +251,7 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
Button_Enable(context->MoveUpHandle, FALSE);
Button_Enable(context->MoveDownHandle, FALSE);
if (PhGetIntegerSetting(L"EnableThemeSupport"))
if (PhEnableThemeSupport)
{
context->BrushNormal = CreateSolidBrush(PhThemeWindowBackgroundColor);
context->BrushHot = CreateSolidBrush(PhThemeWindowHighlightColor);
@@ -391,10 +381,10 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
{
#define ORDER_LIMIT 210
ULONG i;
LONG orderArray[ORDER_LIMIT];
LONG maxOrder;
ULONG orderArray[ORDER_LIMIT];
ULONG maxOrder;
#ifdef DEBUG
assert(TreeNew_GetColumnCount(context->ControlHandle) < ORDER_LIMIT); // bump ORDER_LIMIT macro (dmex)
assert(TreeNew_GetColumnCount(context->ControlHandle) < ORDER_LIMIT); // ORDER_LIMIT must be defined a value greater than ColumnCount // (dmex)
#endif
memset(orderArray, 0, sizeof(orderArray));
maxOrder = 0;
@@ -419,7 +409,7 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
{
orderArray[index] = column->Id;
if ((ULONG)maxOrder < index + 1)
if (maxOrder < index + 1)
maxOrder = index + 1;
}
}
@@ -437,7 +427,7 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
break;
case IDC_INACTIVE:
{
switch (HIWORD(wParam))
switch (GET_WM_COMMAND_CMD(wParam, lParam))
{
case LBN_DBLCLK:
{
@@ -456,7 +446,7 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
break;
case IDC_ACTIVE:
{
switch (HIWORD(wParam))
switch (GET_WM_COMMAND_CMD(wParam, lParam))
{
case LBN_DBLCLK:
{
+8 -28
View File
@@ -24,6 +24,7 @@
#include <mapldr.h>
#include <workqueue.h>
#include <workqueuep.h>
#include <phconsole.h>
#include <procprv.h>
#include <srvprv.h>
@@ -113,7 +114,7 @@ VOID PhCloseDebugConsole(
_wfreopen(L"NUL", L"w", stderr);
_wfreopen(L"NUL", L"r", stdin);
FreeConsole();
PhFreeConsole();
}
static BOOL ConsoleHandlerRoutine(
@@ -132,30 +133,12 @@ static BOOL ConsoleHandlerRoutine(
return FALSE;
}
static BOOLEAN NTAPI PhpLoadCurrentProcessSymbolsCallback(
_In_ PPH_MODULE_INFO Module,
_In_ PVOID Context
)
{
if (!PhLoadModuleSymbolProvider(
(PPH_SYMBOL_PROVIDER)Context,
Module->FileName,
(ULONG64)Module->BaseAddress,
Module->Size
))
{
wprintf(L"Unable to load symbols: %s\n", PhGetStringOrEmpty(Module->FileName));
}
return TRUE;
}
static PWSTR PhpGetSymbolForAddress(
_In_ PVOID Address
)
{
return PH_AUTO_T(PH_STRING, PhGetSymbolFromAddress(
DebugConsoleSymbolProvider, (ULONG64)Address, NULL, NULL, NULL, NULL
DebugConsoleSymbolProvider, Address, NULL, NULL, NULL, NULL
))->Buffer;
}
@@ -430,7 +413,7 @@ static NTSTATUS PhpLeakEnumerationRoutine(
{
PPH_STRING symbol;
symbol = PhGetSymbolFromAddress(DebugConsoleSymbolProvider, (ULONG64)StackTrace[i], NULL, NULL, NULL, NULL);
symbol = PhGetSymbolFromAddress(DebugConsoleSymbolProvider, StackTrace[i], NULL, NULL, NULL, NULL);
if (symbol)
{
@@ -663,12 +646,9 @@ NTSTATUS PhpDebugConsoleThreadStart(
}
}
PhEnumGenericModules(
NtCurrentProcessId(),
NtCurrentProcess(),
0,
PhpLoadCurrentProcessSymbolsCallback,
DebugConsoleSymbolProvider
PhLoadSymbolProviderModules(
DebugConsoleSymbolProvider,
NtCurrentProcessId()
);
#ifdef DEBUG
@@ -1426,7 +1406,7 @@ NTSTATUS PhpDebugConsoleThreadStart(
wprintf(L"Process item at %Ix: %s (%u)\n", (ULONG_PTR)process, process->ProcessName->Buffer, HandleToUlong(process->ProcessId));
wprintf(L"\tRecord at %Ix\n", (ULONG_PTR)process->Record);
wprintf(L"\tQuery handle %Ix\n", (ULONG_PTR)process->QueryHandle);
wprintf(L"\tFile name at %Ix: %s\n", (ULONG_PTR)process->FileNameWin32, PhGetStringOrDefault(process->FileNameWin32, L"(null)"));
wprintf(L"\tFile name at %Ix: %s\n", (ULONG_PTR)process->FileName, PhGetStringOrDefault(process->FileName, L"(null)"));
wprintf(L"\tCommand line at %Ix: %s\n", (ULONG_PTR)process->CommandLine, PhGetStringOrDefault(process->CommandLine, L"(null)"));
wprintf(L"\tFlags: %u\n", process->Flags);
wprintf(L"\n");
+5 -10
View File
@@ -64,8 +64,7 @@ LRESULT CALLBACK PhMenuWindowHookProcedure(
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport)
@@ -117,8 +116,7 @@ LRESULT CALLBACK PhDialogWindowHookProcedure(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport && PhDefaultEnableThemeAcrylicWindowSupport)
@@ -178,8 +176,7 @@ LRESULT CALLBACK PhComboBoxWindowHookProcedure(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(info.hwndList, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(info.hwndList, WDA_EXCLUDEFROMCAPTURE);
}
}
}
@@ -1580,8 +1577,7 @@ HWND PhCreateWindowExHook(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(windowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(windowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport && PhDefaultEnableThemeAcrylicWindowSupport)
@@ -1869,8 +1865,7 @@ BOOLEAN CALLBACK PhInitializeTaskDialogTheme(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
PhInitializeThemeWindowFrame(WindowHandle);
+24 -5
View File
@@ -95,6 +95,7 @@ typedef struct _HANDLE_PROPERTIES_CONTEXT
HWND ListViewHandle;
HWND ParentWindow;
HANDLE ProcessId;
PVOID ListViewClass;
PPH_HANDLE_ITEM HandleItem;
PH_LAYOUT_MANAGER LayoutManager;
INT ListViewRowCache[PH_HANDLE_GENERAL_INDEX_MAXIMUM];
@@ -173,6 +174,17 @@ static NTSTATUS PhpDuplicateHandleFromProcess(
return status;
}
static NTSTATUS PhpDuplicateHandleCloseProcess(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle)
NtClose(Handle);
return STATUS_SUCCESS;
}
typedef struct _HANDLE_PROPERTIES_THREAD_CONTEXT
{
HWND ParentWindowHandle;
@@ -266,6 +278,7 @@ NTSTATUS PhpShowHandlePropertiesThread(
{
pages[propSheetHeader.nPages++] = PhCreateTokenPage(
PhpDuplicateHandleFromProcess,
PhpDuplicateHandleCloseProcess,
context.ProcessId,
&context,
NULL
@@ -1972,12 +1985,12 @@ VOID PhpUpdateHandleGeneral(
{
SYSTEMTIME time;
PhLargeIntegerToLocalSystemTime(&time, &times.CreateTime);
PhLargeIntegerToLocalSystemTime(&time, (PLARGE_INTEGER)&times.CreateTime);
PhSetListViewSubItem(Context->ListViewHandle, Context->ListViewRowCache[PH_HANDLE_GENERAL_INDEX_PROCESSTHREADCREATETIME], 1, PhaFormatDateTime(&time)->Buffer);
if (exitStatus != STATUS_PENDING)
{
PhLargeIntegerToLocalSystemTime(&time, &times.ExitTime);
PhLargeIntegerToLocalSystemTime(&time, (PLARGE_INTEGER)&times.ExitTime);
PhSetListViewSubItem(Context->ListViewHandle, Context->ListViewRowCache[PH_HANDLE_GENERAL_INDEX_PROCESSTHREADEXITTIME], 1, PhaFormatDateTime(&time)->Buffer);
}
}
@@ -2173,12 +2186,12 @@ VOID PhpUpdateHandleGeneral(
{
SYSTEMTIME time;
PhLargeIntegerToLocalSystemTime(&time, &times.CreateTime);
PhLargeIntegerToLocalSystemTime(&time, (PLARGE_INTEGER)&times.CreateTime);
PhSetListViewSubItem(Context->ListViewHandle, Context->ListViewRowCache[PH_HANDLE_GENERAL_INDEX_PROCESSTHREADCREATETIME], 1, PhaFormatDateTime(&time)->Buffer);
if (isTerminated)
{
PhLargeIntegerToLocalSystemTime(&time, &times.ExitTime);
PhLargeIntegerToLocalSystemTime(&time, (PLARGE_INTEGER)&times.ExitTime);
PhSetListViewSubItem(Context->ListViewHandle, Context->ListViewRowCache[PH_HANDLE_GENERAL_INDEX_PROCESSTHREADEXITTIME], 1, PhaFormatDateTime(&time)->Buffer);
}
}
@@ -2226,6 +2239,7 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc(
{
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ParentWindow = GetParent(hwndDlg);
context->ListViewClass = PhGetListViewInterface(context->ListViewHandle);
PhSetApplicationWindowIcon(context->ParentWindow);
@@ -2287,6 +2301,11 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc(
PhDeleteLayoutManager(&context->LayoutManager);
PhRemoveWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
if (context->ListViewClass)
{
IListView_Release((struct IListView*)context->ListViewClass);
}
}
break;
case WM_SIZE:
@@ -2327,7 +2346,7 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc(
if (point.x == -1 && point.y == -1)
PhGetListViewContextMenuPoint(context->ListViewHandle, &point);
PhGetSelectedListViewItemParams(context->ListViewHandle, &listviewItems, &numberOfItems);
PhGetSelectedIListViewItemParams(context->ListViewClass, &listviewItems, &numberOfItems);
if (numberOfItems != 0)
{
+11 -32
View File
@@ -343,7 +343,6 @@ VOID PhHandleProviderUpdate(
static ULONG fileObjectTypeIndex = ULONG_MAX;
PPH_HANDLE_PROVIDER handleProvider = (PPH_HANDLE_PROVIDER)Object;
PSYSTEM_HANDLE_INFORMATION_EX handleInfo;
BOOLEAN filterNeeded;
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handles;
ULONG numberOfHandles;
ULONG i;
@@ -357,8 +356,7 @@ VOID PhHandleProviderUpdate(
handleProvider->ProcessId,
handleProvider->ProcessHandle,
PhCsEnableHandleSnapshot,
&handleInfo,
&filterNeeded
&handleInfo
)))
goto UpdateExit;
@@ -379,35 +377,15 @@ VOID PhHandleProviderUpdate(
handles = handleInfo->Handles;
numberOfHandles = (ULONG)handleInfo->NumberOfHandles;
// Make a list of the relevant handles.
if (filterNeeded)
for (i = 0; i < numberOfHandles; i++)
{
for (i = 0; i < numberOfHandles; i++)
{
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handle = &handles[i];
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handle = &handles[i];
if (handle->UniqueProcessId == (ULONG_PTR)handleProvider->ProcessId)
{
PhAddItemSimpleHashtable(
handleProvider->TempListHashtable,
(PVOID)handle->HandleValue,
handle
);
}
}
}
else
{
for (i = 0; i < numberOfHandles; i++)
{
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handle = &handles[i];
PhAddItemSimpleHashtable(
handleProvider->TempListHashtable,
(PVOID)handle->HandleValue,
handle
);
}
PhAddItemSimpleHashtable(
handleProvider->TempListHashtable,
(PVOID)handle->HandleValue,
handle
);
}
// Look for closed handles.
@@ -457,10 +435,11 @@ VOID PhHandleProviderUpdate(
else
{
if (
handleItem->Handle == (HANDLE)(*tempHashtableValue)->HandleValue &&
handleItem->Handle == (*tempHashtableValue)->HandleValue &&
handleItem->GrantedAccess == (*tempHashtableValue)->GrantedAccess &&
handleItem->TypeIndex == (*tempHashtableValue)->ObjectTypeIndex &&
handleItem->Attributes == (*tempHashtableValue)->HandleAttributes
handleItem->Attributes == (*tempHashtableValue)->HandleAttributes &&
handleProvider->ProcessId == (*tempHashtableValue)->UniqueProcessId
)
{
found = TRUE;
+8 -8
View File
@@ -45,7 +45,6 @@ VOID PhShowHandleStatisticsDialog(
{
NTSTATUS status;
HANDLE_STATISTICS_CONTEXT context;
BOOLEAN filterNeeded;
ULONG i;
memset(&context, 0, sizeof(HANDLE_STATISTICS_CONTEXT));
@@ -65,8 +64,7 @@ VOID PhShowHandleStatisticsDialog(
context.ProcessId,
context.ProcessHandle,
PhCsEnableHandleSnapshot,
&context.Handles,
&filterNeeded
&context.Handles
);
if (!NT_SUCCESS(status))
@@ -169,14 +167,14 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
handleInfo = &context->Handles->Handles[i];
if (handleInfo->UniqueProcessId != (ULONG_PTR)processId)
if (handleInfo->UniqueProcessId != processId)
continue;
if (handleInfo->ObjectTypeIndex >= MAX_OBJECT_TYPE_NUMBER)
continue;
entry = &context->Entries[handleInfo->ObjectTypeIndex];
if (!entry->Name)
if (PhIsNullOrEmptyString(entry->Name))
{
entry->Name = PhGetObjectTypeIndexName(handleInfo->ObjectTypeIndex);
@@ -186,7 +184,7 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
PhGetHandleInformation(
context->ProcessHandle,
(HANDLE)handleInfo->HandleValue,
handleInfo->HandleValue,
handleInfo->ObjectTypeIndex,
NULL,
&typeName,
@@ -215,7 +213,7 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
unknownType = NULL;
if (!entry->Name)
if (PhIsNullOrEmptyString(entry->Name))
unknownType = PhFormatString(L"(unknown: %lu)", (ULONG)i);
countString = PhFormatUInt64(entry->Count, TRUE);
@@ -223,11 +221,13 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
lvItemIndex = PhAddListViewItem(
context->ListViewHandle,
MAXINT,
entry->Name ? entry->Name->Buffer : unknownType->Buffer,
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);
PhDereferenceObject(countString);
if (unknownType)
+5 -3
View File
@@ -31,10 +31,10 @@
#include <phnet.h>
#include "../resource.h"
#include <phfwddef.h>
#include <appsup.h>
#include <minidumpapiset.h>
#include <searchbox.h>
// main
@@ -75,7 +75,7 @@ typedef struct _PH_STARTUP_PARAMETERS
PPH_LIST PluginParameters;
PPH_STRING SelectTab;
PPH_STRING SysInfo;
PPH_STRING Channel;
ULONG UpdateChannel;
} PH_STARTUP_PARAMETERS, *PPH_STARTUP_PARAMETERS;
extern BOOLEAN PhPluginsEnabled;
@@ -874,6 +874,7 @@ BOOLEAN PhGetElevationTypeString(
VOID PhShowTokenProperties(
_In_ HWND ParentWindowHandle,
_In_ PPH_OPEN_OBJECT OpenObject,
_In_ PPH_CLOSE_OBJECT CloseObject,
_In_ HANDLE ProcessId,
_In_ PVOID Context,
_In_opt_ PCWSTR Title
@@ -887,6 +888,7 @@ INT CALLBACK PhpTokenSheetProc(
HPROPSHEETPAGE PhCreateTokenPage(
_In_ PPH_OPEN_OBJECT OpenObject,
_In_ PPH_CLOSE_OBJECT CloseObject,
_In_ HANDLE ProcessId,
_In_opt_ PVOID Context,
_In_opt_ DLGPROC HookProc
+5 -7
View File
@@ -112,9 +112,6 @@ extern PH_CIRCULAR_BUFFER_ULONG64 PhMaxIoWriteHistory;
#endif
// begin_phapppub
#define DPCS_PROCESS_ID ((HANDLE)(LONG_PTR)-2)
#define INTERRUPTS_PROCESS_ID ((HANDLE)(LONG_PTR)-3)
// DPCs, Interrupts and System Idle Process are not real.
// Non-"real" processes can never be opened.
#define PH_IS_REAL_PROCESS_ID(ProcessId) ((LONG_PTR)(ProcessId) > 0)
@@ -127,7 +124,6 @@ extern PH_CIRCULAR_BUFFER_ULONG64 PhMaxIoWriteHistory;
// end_phapppub
// begin_phapppub
typedef enum _VERIFY_RESULT VERIFY_RESULT;
typedef struct _PH_PROCESS_RECORD *PPH_PROCESS_RECORD;
typedef struct _PH_IMAGELIST_ITEM
@@ -172,7 +168,7 @@ typedef struct _PH_PROCESS_ITEM
PSID Sid;
TOKEN_ELEVATION_TYPE ElevationType;
PH_INTEGRITY_LEVEL IntegrityLevel;
PH_STRINGREF IntegrityString;
PPH_STRINGREF IntegrityString;
PS_PROTECTION Protection;
PPH_STRING ProtectionString;
@@ -187,7 +183,7 @@ typedef struct _PH_PROCESS_ITEM
// Signature, Packed
VERIFY_RESULT VerifyResult;
ULONG VerifyResult;
PPH_STRING VerifySignerName;
ULONG ImportFunctions;
ULONG ImportModules;
@@ -227,7 +223,8 @@ typedef struct _PH_PROCESS_ITEM
ULONG IsXfgAuditEnabled : 1;
ULONG IsPowerThrottling : 1;
ULONG IsSystemProcess : 1;
ULONG Spare : 4;
ULONG IsSecureSystem : 1;
ULONG Spare : 3;
};
};
@@ -380,6 +377,7 @@ PhEnumProcessItems(
);
// end_phapppub
typedef enum _VERIFY_RESULT VERIFY_RESULT;
typedef struct _PH_VERIFY_FILE_INFO *PPH_VERIFY_FILE_INFO;
VERIFY_RESULT PhVerifyFileWithAdditionalCatalog(
+13 -14
View File
@@ -190,12 +190,16 @@ typedef struct _PH_PROCESS_NODE
// Window
HWND WindowHandle;
PPH_STRING WindowText;
BOOLEAN WindowHung;
// DEP status
ULONG DepStatus;
// Token
BOOLEAN WindowHung;
BOOLEAN VirtualizationAllowed;
BOOLEAN VirtualizationEnabled;
BOOLEAN BreakOnTerminationEnabled;
BOOLEAN PowerThrottling;
BOOLEAN PriorityBoost;
// OS Context
GUID OsContextGuid;
ULONG OsContextVersion;
@@ -220,14 +224,8 @@ typedef struct _PH_PROCESS_NODE
// File attributes
LARGE_INTEGER FileLastWriteTime;
LARGE_INTEGER FileEndOfFile;
// Critical
BOOLEAN BreakOnTerminationEnabled;
// Code page
USHORT CodePage;
// Power throttling
BOOLEAN PowerThrottling;
// Priority boost
BOOLEAN PriorityBoost;
// TLS bitmap
USHORT TlsBitmapCount;
// Reference count
@@ -240,8 +238,8 @@ typedef struct _PH_PROCESS_NODE
// Text buffers
WCHAR CpuUsageText[PH_INT32_STR_LEN_1 + 3];
WCHAR IoTotalRateText[PH_INT64_STR_LEN_1 + 3];
WCHAR PrivateBytesText[PH_INT64_STR_LEN_1];
PPH_STRING IoTotalRateText;
PPH_STRING PrivateBytesText;
PPH_STRING PeakPrivateBytesText;
PPH_STRING WorkingSetText;
PPH_STRING PeakWorkingSetText;
@@ -260,9 +258,9 @@ typedef struct _PH_PROCESS_NODE
PPH_STRING IoRoRateText;
PPH_STRING IoWRateText;
PPH_STRING StartTimeText;
WCHAR TotalCpuTimeText[PH_TIMESPAN_STR_LEN_1];
WCHAR KernelCpuTimeText[PH_TIMESPAN_STR_LEN_1];
WCHAR UserCpuTimeText[PH_TIMESPAN_STR_LEN_1];
PPH_STRING TotalCpuTimeText;
PPH_STRING KernelCpuTimeText;
PPH_STRING UserCpuTimeText;
PPH_STRING RelativeStartTimeText;
PPH_STRING WindowTitleText;
PPH_STRING DepStatusText;
@@ -389,8 +387,9 @@ PhGetSelectedProcessItem(
VOID
);
_Success_(return)
PHAPPAPI
VOID
BOOLEAN
NTAPI
PhGetSelectedProcessItems(
_Out_ PPH_PROCESS_ITEM **Processes,
+18 -6
View File
@@ -64,7 +64,7 @@ NTSTATUS PhpCreateLiveKernelDump(
else
{
liveDumpControl.Version = SYSDBG_LIVEDUMP_CONTROL_VERSION_1;
length = RTL_SIZEOF_THROUGH_FIELD(SYSDBG_LIVEDUMP_CONTROL, AddPagesControl);
length = sizeof(SYSDBG_LIVEDUMP_CONTROL_V1);
}
liveDumpControl.DumpFileHandle = Context->FileHandle;
@@ -140,12 +140,24 @@ HRESULT CALLBACK PhpLiveDumpProgressDialogCallbackProc(
PH_FORMAT format[2];
WCHAR string[MAX_PATH];
PhInitFormatS(&format[0], L"Size: ");
PhInitFormatSize(&format[1], fileSize.QuadPart);
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), string, sizeof(string), NULL))
if (fileSize.QuadPart)
{
SendMessage(context->WindowHandle, TDM_SET_ELEMENT_TEXT, TDE_CONTENT, (LPARAM)string);
PhInitFormatS(&format[0], L"Size: ");
PhInitFormatSize(&format[1], fileSize.QuadPart);
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), string, sizeof(string), NULL))
{
SendMessage(context->WindowHandle, TDM_SET_ELEMENT_TEXT, TDE_CONTENT, (LPARAM)string);
}
}
else
{
PhInitFormatS(&format[0], L"Initializing...");
if (PhFormatToBuffer(format, 1, string, sizeof(string), NULL))
{
SendMessage(context->WindowHandle, TDM_SET_ELEMENT_TEXT, TDE_CONTENT, (LPARAM)string);
}
}
}
else
+65 -12
View File
@@ -12,7 +12,6 @@
#include <phapp.h>
#include <phplug.h>
#include <phsettings.h>
#include <settings.h>
#include <mainwnd.h>
#include <emenu.h>
@@ -29,9 +28,13 @@ INT_PTR CALLBACK PhpLogDlgProc(
HWND PhLogWindowHandle = NULL;
static PH_LAYOUT_MANAGER WindowLayoutManager;
static RECT MinimumSize;
static HWND AutoScrollHandle;
static HWND ListViewHandle;
static IListView* ListViewClass;
static ULONG ListViewCount;
static PH_CALLBACK_REGISTRATION LoggedRegistration;
static BOOLEAN ListViewStateInitializing = FALSE;
static BOOLEAN ListViewAutoScroll = FALSE;
VOID PhShowLogDialog(
VOID
@@ -61,7 +64,10 @@ static VOID NTAPI LoggedCallback(
_In_opt_ PVOID Context
)
{
PostMessage(PhLogWindowHandle, WM_PH_LOG_UPDATED, 0, 0);
if (PhLogWindowHandle)
{
PostMessage(PhLogWindowHandle, WM_PH_LOG_UPDATED, 0, 0);
}
}
static VOID PhpUpdateLogList(
@@ -69,13 +75,22 @@ static VOID PhpUpdateLogList(
)
{
ListViewCount = PhLogBuffer.Count;
ListView_SetItemCountEx(ListViewHandle, ListViewCount, LVSICF_NOSCROLL);
IListView_SetItemCount(ListViewClass, ListViewCount, LVSICF_NOSCROLL);
if (ListViewCount >= 2 && Button_GetCheck(GetDlgItem(PhLogWindowHandle, IDC_AUTOSCROLL)) == BST_CHECKED)
if (ListViewCount >= 2 && ReadBooleanAcquire(&ListViewAutoScroll))
{
if (ListView_IsItemVisible(ListViewHandle, ListViewCount - 2))
LVITEMINDEX itemIndex;
BOOL itemVisible;
itemIndex.iItem = (LONG)(ListViewCount - 2);
itemIndex.iGroup = 0;
if (SUCCEEDED(IListView_IsItemVisible(ListViewClass, itemIndex, &itemVisible)) && itemVisible)
{
ListView_EnsureVisible(ListViewHandle, ListViewCount - 1, FALSE);
itemIndex.iItem = (LONG)(ListViewCount - 1);
itemIndex.iGroup = 0;
IListView_EnsureItemVisible(ListViewClass, itemIndex, FALSE);
}
}
}
@@ -102,8 +117,10 @@ static PPH_STRING PhpGetStringForSelectedLogEntries(
if (!All)
{
ULONG itemState;
// The list view displays the items in reverse order...
if (!(ListView_GetItemState(ListViewHandle, ListViewCount - i - 1, LVIS_SELECTED) & LVIS_SELECTED))
if (!(HR_SUCCESS(IListView_GetItemState(ListViewClass, ListViewCount - i - 1, 0, LVIS_SELECTED, &itemState)) && FlagOn(itemState, LVIS_SELECTED)))
{
goto ContinueLoop;
}
@@ -149,7 +166,10 @@ INT_PTR CALLBACK PhpLogDlgProc(
{
PhSetApplicationWindowIcon(hwndDlg);
AutoScrollHandle = GetDlgItem(hwndDlg, IDC_AUTOSCROLL);
ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
ListViewClass = PhGetListViewInterface(ListViewHandle);
PhSetListViewStyle(ListViewHandle, FALSE, TRUE);
PhSetControlTheme(ListViewHandle, L"explorer");
PhAddListViewColumn(ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 140, L"Time");
@@ -161,7 +181,7 @@ INT_PTR CALLBACK PhpLogDlgProc(
PhAddLayoutItem(&WindowLayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
PhAddLayoutItem(&WindowLayoutManager, GetDlgItem(hwndDlg, IDC_COPY), NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
PhAddLayoutItem(&WindowLayoutManager, GetDlgItem(hwndDlg, IDC_SAVE), NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
PhAddLayoutItem(&WindowLayoutManager, GetDlgItem(hwndDlg, IDC_AUTOSCROLL), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT);
PhAddLayoutItem(&WindowLayoutManager, AutoScrollHandle, NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT);
PhAddLayoutItem(&WindowLayoutManager, GetDlgItem(hwndDlg, IDC_CLEAR), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT);
MinimumSize.left = 0;
@@ -175,11 +195,13 @@ INT_PTR CALLBACK PhpLogDlgProc(
else
PhCenterWindow(hwndDlg, PhMainWndHandle);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_AUTOSCROLL), BST_CHECKED);
ListViewStateInitializing = TRUE;
WriteBooleanRelease(&ListViewAutoScroll, TRUE);
Button_SetCheck(AutoScrollHandle, BST_CHECKED);
ListViewStateInitializing = FALSE;
PhRegisterCallback(PhGetGeneralCallback(GeneralCallbackLoggedEvent), LoggedCallback, NULL, &LoggedRegistration);
PhpUpdateLogList();
ListView_EnsureVisible(ListViewHandle, ListViewCount - 1, FALSE);
PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
}
@@ -194,6 +216,12 @@ INT_PTR CALLBACK PhpLogDlgProc(
PhUnregisterCallback(PhGetGeneralCallback(GeneralCallbackLoggedEvent), &LoggedRegistration);
PhUnregisterDialog(PhLogWindowHandle);
PhLogWindowHandle = NULL;
if (ListViewClass)
{
IListView_Release(ListViewClass);
ListViewClass = NULL;
}
}
break;
case WM_COMMAND:
@@ -213,9 +241,9 @@ INT_PTR CALLBACK PhpLogDlgProc(
case IDC_COPY:
{
PPH_STRING string;
ULONG selectedCount;
ULONG selectedCount = 0;
selectedCount = ListView_GetSelectedCount(ListViewHandle);
IListView_GetSelectedCount(ListViewClass, &selectedCount);
if (selectedCount == 0)
{
@@ -325,6 +353,31 @@ INT_PTR CALLBACK PhpLogDlgProc(
}
}
break;
case LVN_ITEMCHANGED:
{
LPNM_LISTVIEW listView = (LPNM_LISTVIEW)lParam;
if (FlagOn(listView->uChanged, LVIF_STATE))
{
if (ListViewStateInitializing)
break;
switch (FlagOn(listView->uNewState, LVIS_STATEIMAGEMASK))
{
case INDEXTOSTATEIMAGEMASK(2): // checked
{
WriteBooleanRelease(&ListViewAutoScroll, TRUE);
}
break;
case INDEXTOSTATEIMAGEMASK(1): // unchecked
{
WriteBooleanRelease(&ListViewAutoScroll, FALSE);
}
break;
}
}
}
break;
}
}
break;
+16 -24
View File
@@ -249,7 +249,7 @@ INT WINAPI wWinMain(
if (PhStartupParameters.PriorityClass != 0)
priorityClass = (UCHAR)PhStartupParameters.PriorityClass;
PhSetProcessPriority(NtCurrentProcess(), priorityClass);
PhSetProcessPriorityClass(NtCurrentProcess(), priorityClass);
}
if (PhEnableKsiSupport)
@@ -495,6 +495,8 @@ static BOOLEAN NTAPI PhpPreviousInstancesCallback(
if (!PhEqualSid(tokenUser.User.Sid, PhGetOwnTokenAttributes().TokenSid))
goto CleanupExit;
PhConsoleSetForeground(processHandle, TRUE);
// Try to locate the window a few times because some users reported that it might not yet have been created. (dmex)
do
{
@@ -1228,21 +1230,9 @@ VOID PhpInitializeSettings(
PhSetIntegerSetting(L"SampleCount", sampleCount);
}
if (!PhIsNullOrEmptyString(PhStartupParameters.Channel))
if (PhStartupParameters.UpdateChannel)
{
static PH_STRINGREF stableChannel = PH_STRINGREF_INIT(L"release");
static PH_STRINGREF previewChannel = PH_STRINGREF_INIT(L"preview");
static PH_STRINGREF canaryChannel = PH_STRINGREF_INIT(L"canary");
static PH_STRINGREF developerChannel = PH_STRINGREF_INIT(L"developer");
if (PhEqualStringRef(&PhStartupParameters.Channel->sr, &stableChannel, FALSE))
PhSetIntegerSetting(L"ReleaseChannel", PhReleaseChannel);
else if (PhEqualStringRef(&PhStartupParameters.Channel->sr, &previewChannel, FALSE))
PhSetIntegerSetting(L"ReleaseChannel", PhPreviewChannel);
else if (PhEqualStringRef(&PhStartupParameters.Channel->sr, &canaryChannel, FALSE))
PhSetIntegerSetting(L"ReleaseChannel", PhCanaryChannel);
else if (PhEqualStringRef(&PhStartupParameters.Channel->sr, &developerChannel, FALSE))
PhSetIntegerSetting(L"ReleaseChannel", PhDeveloperChannel);
PhSetIntegerSetting(L"ReleaseChannel", PhStartupParameters.UpdateChannel);
}
}
@@ -1384,7 +1374,16 @@ BOOLEAN NTAPI PhpCommandLineOptionCallback(
PhStartupParameters.KphStartupMax = TRUE;
break;
case PH_ARG_CHANNEL:
PhSwapReference(&PhStartupParameters.Channel, Value);
{
if (Value && PhEqualString2(Value, L"release", FALSE))
PhStartupParameters.UpdateChannel = PhReleaseChannel;
else if (Value && PhEqualString2(Value, L"preview", FALSE))
PhStartupParameters.UpdateChannel = PhPreviewChannel;
else if (Value && PhEqualString2(Value, L"canary", FALSE))
PhStartupParameters.UpdateChannel = PhCanaryChannel;
else if (Value && PhEqualString2(Value, L"developer", FALSE))
PhStartupParameters.UpdateChannel = PhDeveloperChannel;
}
break;
}
}
@@ -1455,12 +1454,6 @@ VOID PhpProcessStartupParameters(
NULL
) || PhStartupParameters.Help)
{
if (PhStartupParameters.Help)
{
PhGuiSupportInitialization();
PhpInitializeSettings();
PhInitializeSuperclassControls();
}
PhShowInformation2(
NULL,
L"Command line options:",
@@ -1484,8 +1477,7 @@ VOID PhpProcessStartupParameters(
L"-v"
);
if (PhStartupParameters.Help)
PhExitApplication(STATUS_SUCCESS);
PhExitApplication(STATUS_SUCCESS);
}
if (PhStartupParameters.Elevate && !PhGetOwnTokenAttributes().Elevated)
+59 -19
View File
@@ -28,6 +28,7 @@
#include <netlist.h>
#include <netprv.h>
#include <notifico.h>
#include <phconsole.h>
#include <phplug.h>
#include <phsvccl.h>
#include <procprv.h>
@@ -691,6 +692,17 @@ static NTSTATUS PhpOpenServiceControlManager(
return PhGetLastWin32ErrorAsNtStatus();
}
static NTSTATUS PhpCloseServiceControlManager(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle)
PhCloseServiceHandle(Handle);
return STATUS_SUCCESS;
}
static NTSTATUS PhpOpenSecurityDummyHandle(
_Inout_ PHANDLE Handle,
_In_ ACCESS_MASK DesiredAccess,
@@ -722,6 +734,17 @@ static NTSTATUS PhpOpenSecurityDesktopHandle(
return STATUS_UNSUCCESSFUL;
}
static NTSTATUS PhpCloseSecurityDesktopHandle(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle)
CloseDesktop(Handle);
return STATUS_SUCCESS;
}
static NTSTATUS PhpOpenSecurityStationHandle(
_Inout_ PHANDLE Handle,
_In_ ACCESS_MASK DesiredAccess,
@@ -743,6 +766,17 @@ static NTSTATUS PhpOpenSecurityStationHandle(
return STATUS_UNSUCCESSFUL;
}
static NTSTATUS PhpCloseSecurityStationHandle(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle)
CloseWindowStation(Handle);
return STATUS_SUCCESS;
}
static VOID PhpMwpOnDumpCommand(
_In_ HWND WindowHandle,
_In_ ULONG Id,
@@ -1300,7 +1334,7 @@ VOID PhMwpOnCommand(
L"Service Control Manager",
L"SCManager",
PhpOpenServiceControlManager,
NULL,
PhpCloseServiceControlManager,
NULL
);
}
@@ -1348,7 +1382,7 @@ VOID PhMwpOnCommand(
L"Current Window Desktop",
L"Desktop",
PhpOpenSecurityDesktopHandle,
NULL,
PhpCloseSecurityDesktopHandle,
NULL
);
}
@@ -1360,7 +1394,7 @@ VOID PhMwpOnCommand(
L"Current Window Station",
L"WindowStation",
PhpOpenSecurityStationHandle,
NULL,
PhpCloseSecurityStationHandle,
NULL
);
}
@@ -1420,14 +1454,16 @@ VOID PhMwpOnCommand(
PPH_PROCESS_ITEM *processes;
ULONG numberOfProcesses;
PhGetSelectedProcessItems(&processes, &numberOfProcesses);
PhReferenceObjects(processes, numberOfProcesses);
if (PhGetSelectedProcessItems(&processes, &numberOfProcesses))
{
PhReferenceObjects(processes, numberOfProcesses);
if (PhUiTerminateProcesses(WindowHandle, processes, numberOfProcesses))
PhDeselectAllProcessNodes();
if (PhUiTerminateProcesses(WindowHandle, processes, numberOfProcesses))
PhDeselectAllProcessNodes();
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
}
}
break;
case ID_PROCESS_TERMINATETREE:
@@ -1450,11 +1486,13 @@ VOID PhMwpOnCommand(
PPH_PROCESS_ITEM *processes;
ULONG numberOfProcesses;
PhGetSelectedProcessItems(&processes, &numberOfProcesses);
PhReferenceObjects(processes, numberOfProcesses);
PhUiSuspendProcesses(WindowHandle, processes, numberOfProcesses);
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
if (PhGetSelectedProcessItems(&processes, &numberOfProcesses))
{
PhReferenceObjects(processes, numberOfProcesses);
PhUiSuspendProcesses(WindowHandle, processes, numberOfProcesses);
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
}
}
break;
case ID_PROCESS_SUSPENDTREE:
@@ -1474,11 +1512,13 @@ VOID PhMwpOnCommand(
PPH_PROCESS_ITEM *processes;
ULONG numberOfProcesses;
PhGetSelectedProcessItems(&processes, &numberOfProcesses);
PhReferenceObjects(processes, numberOfProcesses);
PhUiResumeProcesses(WindowHandle, processes, numberOfProcesses);
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
if (PhGetSelectedProcessItems(&processes, &numberOfProcesses))
{
PhReferenceObjects(processes, numberOfProcesses);
PhUiResumeProcesses(WindowHandle, processes, numberOfProcesses);
PhDereferenceObjects(processes, numberOfProcesses);
PhFree(processes);
}
}
break;
case ID_PROCESS_RESUMETREE:
+6 -6
View File
@@ -262,7 +262,7 @@ static NTSTATUS PhpLimitedSymbolProviderLookupFunction(
PhLoadFileNameSymbolProvider(
result->Context->SymbolProvider,
entry->FileName,
(ULONG64)entry->ImageBase,
entry->ImageBase,
(ULONG)entry->SizeOfImage
);
}
@@ -284,7 +284,7 @@ static NTSTATUS PhpLimitedSymbolProviderLookupFunction(
result->Symbol = PhGetSymbolFromAddress(
result->Context->SymbolProvider,
(ULONG64)result->Address,
result->Address,
NULL,
&result->FileName,
NULL,
@@ -368,10 +368,10 @@ static VOID PhpProcessSymbolLookupResults(
// Get a basic symbol name (module+offset).
static PPH_STRING PhpLimitedSymbolProviderGetBasicSymbol(
_In_ PPH_SYMBOL_PROVIDER SymbolProvider,
_In_ ULONG64 Address
_In_ PVOID Address
)
{
ULONG64 modBase;
PVOID modBase;
PPH_STRING fileName = NULL;
PPH_STRING baseName = NULL;
PPH_STRING symbol;
@@ -381,7 +381,7 @@ static PPH_STRING PhpLimitedSymbolProviderGetBasicSymbol(
if (!fileName)
{
symbol = PhCreateStringEx(NULL, PH_PTR_STR_LEN * sizeof(WCHAR));
PhPrintPointer(symbol->Buffer, (PVOID)Address);
PhPrintPointer(symbol->Buffer, Address);
PhTrimToNullTerminatorString(symbol);
}
else
@@ -392,7 +392,7 @@ static PPH_STRING PhpLimitedSymbolProviderGetBasicSymbol(
PhInitFormatSR(&format[0], baseName->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, baseName->Length + 6 + 32);
}
+5 -5
View File
@@ -551,18 +551,18 @@ NTSTATUS PhpUpdateMemoryRegionTypes(
// HYPERVISOR_SHARED_DATA
if (WindowsVersion >= WINDOWS_10_RS4)
{
static PVOID hypervisorSharedUserVa = NULL;
static PSYSTEM_HYPERVISOR_USER_SHARED_DATA hypervisorSharedUserData = NULL;
static PH_INITONCE hypervisorSharedUserInitOnce = PH_INITONCE_INIT;
if (PhBeginInitOnce(&hypervisorSharedUserInitOnce))
{
PhGetSystemHypervisorSharedPageInformation(&hypervisorSharedUserVa);
PhGetSystemHypervisorSharedPageInformation(&hypervisorSharedUserData);
PhEndInitOnce(&hypervisorSharedUserInitOnce);
}
if (hypervisorSharedUserVa)
if (hypervisorSharedUserData)
{
PhpSetMemoryRegionType(List, hypervisorSharedUserVa, TRUE, HypervisorSharedDataRegion);
PhpSetMemoryRegionType(List, hypervisorSharedUserData, TRUE, HypervisorSharedDataRegion);
}
}
@@ -979,7 +979,7 @@ NTSTATUS PhpUpdateMemoryRegionTypes(
SIZE_T bytesRead;
// HACK: Windows 10 RS2 and above 'added TEB/PEB sub-VAD segments' and we need to tag individual sections.
if (memoryItem = PhpSetMemoryRegionType(List, thread->TebBase, WindowsVersion < WINDOWS_10_RS2 ? TRUE : FALSE, TebRegion))
if (memoryItem = PhpSetMemoryRegionType(List, (PVOID)thread->TebBase, WindowsVersion < WINDOWS_10_RS2 ? TRUE : FALSE, TebRegion))
memoryItem->u.Teb.ThreadId = thread->ThreadInfo.ClientId.UniqueThread;
if (NT_SUCCESS(NtReadVirtualMemory(ProcessHandle, thread->TebBase, &ntTib, sizeof(NT_TIB), &bytesRead)) &&
+1 -1
View File
@@ -1522,7 +1522,7 @@ VOID PhDeselectAllModuleNodes(
}
// Copied from proctree.c (dmex)
static FLOAT LowImageCoherencyThreshold = 0.5f;
const FLOAT LowImageCoherencyThreshold = 0.5f;
BOOLEAN PhShouldShowModuleCoherency(
_In_ PPH_MODULE_ITEM ModuleItem,
+1 -1
View File
@@ -457,7 +457,7 @@ VOID PhMwpSetProcessMenuPriorityChecks(
{
if (SetPriority)
{
if (!NT_SUCCESS(PhGetProcessPriority(
if (!NT_SUCCESS(PhGetProcessPriorityClass(
processHandle,
&priorityClass
)))
+1 -1
View File
@@ -666,7 +666,7 @@ BOOLEAN PhpShowToastNotification(
if (PhBeginInitOnce(&initOnce))
{
iconFileName = PhGetApplicationDirectoryFileNameZ(L"icon.png", FALSE);
iconFileName = PhGetApplicationDirectoryFileNameZ(L"Resources\\icon.png", FALSE);
if (!PhDoesFileExistWin32(PhGetString(iconFileName)))
PhClearReference(&iconFileName);
+1 -1
View File
@@ -1692,7 +1692,7 @@ static VOID PhpAdvancedPageSave(
SetSettingForLvItemCheck(listViewHandle, PHP_OPTIONS_INDEX_PROPAGATE_CPU_USAGE, L"PropagateCpuUsage");
SetSettingForLvItemCheck(listViewHandle, PHP_OPTIONS_INDEX_SHOW_ADVANCED_OPTIONS, L"EnableAdvancedOptions");
if (PhGetIntegerSetting(L"EnableThemeSupport"))
if (PhEnableThemeSupport)
{
PhSetIntegerSetting(L"GraphColorMode", 1); // HACK switch to dark theme. (dmex)
}
+1 -1
View File
@@ -516,7 +516,7 @@ NTSTATUS PhSvcApiControlProcess(
UCHAR priorityClass;
priorityClass = (UCHAR)Payload->u.ControlProcess.i.Argument;
status = PhSetProcessPriority(processHandle, priorityClass);
status = PhSetProcessPriorityClass(processHandle, priorityClass);
NtClose(processHandle);
}
+10 -20
View File
@@ -330,10 +330,11 @@ LRESULT CALLBACK PhpPropSheetWndProc(
break;
case PSM_ISDIALOGMESSAGE:
{
MSG* msg = (MSG*)lParam;
if (msg->message == WM_KEYDOWN)
PMSG dialog = (PMSG)lParam;
if (dialog->message == WM_KEYDOWN)
{
switch (msg->wParam)
switch (dialog->wParam)
{
case VK_F5:
SystemInformer_Refresh();
@@ -363,21 +364,16 @@ BOOLEAN PhpInitializePropSheetLayoutStage1(
PPH_LAYOUT_ITEM tabPageItem;
tabControlHandle = PropSheet_GetTabControl(hwnd);
tabControlItem = PhAddLayoutItem(&Context->LayoutManager, tabControlHandle,
NULL, PH_ANCHOR_ALL | PH_LAYOUT_IMMEDIATE_RESIZE);
tabPageItem = PhAddLayoutItem(&Context->LayoutManager, tabControlHandle,
NULL, PH_LAYOUT_TAB_CONTROL); // dummy item to fix multiline tab control
Context->TabPageItem = tabPageItem;
PhAddLayoutItem(&Context->LayoutManager, GetDlgItem(hwnd, IDCANCEL),
NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
tabControlItem = PhAddLayoutItem(&Context->LayoutManager, tabControlHandle, NULL, PH_ANCHOR_ALL | PH_LAYOUT_IMMEDIATE_RESIZE);
tabPageItem = PhAddLayoutItem(&Context->LayoutManager, tabControlHandle, NULL, PH_LAYOUT_TAB_CONTROL); // dummy item to fix multiline tab control
PhAddLayoutItem(&Context->LayoutManager, GetDlgItem(hwnd, IDCANCEL), NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);
// Hide the OK button.
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
// Set the Cancel button's text to "Close".
PhSetDialogItemText(hwnd, IDCANCEL, L"Close");
Context->TabPageItem = tabPageItem;
Context->LayoutInitialized = TRUE;
return TRUE;
@@ -555,13 +551,7 @@ VOID PhpCreateProcessPropSheetWaitContext(
PPH_PROCESS_WAITPROPCONTEXT waitContext;
HANDLE processHandle;
if (!processItem->QueryHandle)
return;
if (processItem->ProcessId == NtCurrentProcessId())
return;
// On Windows 8.1 and above, processes without threads are reflected processes
// which will not terminate if we have a handle open. (wj32)
if (processItem->UserTime.QuadPart + processItem->KernelTime.QuadPart == 0 && processItem->NumberOfThreads == 0)
if (!processItem->QueryHandle || processItem->ProcessId == NtCurrentProcessId())
return;
if (!NT_SUCCESS(PhOpenProcess(
@@ -882,7 +872,7 @@ NTSTATUS PhpProcessPropertiesThreadStart(
// Token
PhAddProcessPropPage2(
PropContext,
PhCreateTokenPage(PhpOpenProcessTokenForPage, PropContext->ProcessItem->ProcessId, (PVOID)PropContext->ProcessItem->ProcessId, PhpProcessTokenHookProc)
PhCreateTokenPage(PhpOpenProcessTokenForPage, PhpCloseProcessTokenForPage, PropContext->ProcessItem->ProcessId, (PVOID)PropContext->ProcessItem->ProcessId, PhpProcessTokenHookProc)
);
// Modules
+4 -4
View File
@@ -1316,7 +1316,7 @@ VOID PhpFillProcessItem(
BOOLEAN isElevated;
BOOLEAN tokenIsUIAccessEnabled;
PH_INTEGRITY_LEVEL integrityLevel;
PH_STRINGREF integrityString;
PPH_STRINGREF integrityString;
// User
if (NT_SUCCESS(PhGetTokenUser(tokenHandle, &tokenUser)))
@@ -1552,7 +1552,7 @@ VOID PhpUpdateDynamicInfoProcessItem(
{
UCHAR priorityClass;
if (NT_SUCCESS(PhGetProcessPriority(ProcessItem->QueryHandle, &priorityClass)))
if (NT_SUCCESS(PhGetProcessPriorityClass(ProcessItem->QueryHandle, &priorityClass)))
{
ProcessItem->PriorityClass = priorityClass;
}
@@ -2799,7 +2799,7 @@ VOID PhProcessProviderUpdate(
//BOOLEAN isElevated;
//TOKEN_ELEVATION_TYPE elevationType;
PH_INTEGRITY_LEVEL integrityLevel;
PH_STRINGREF integrityString;
PPH_STRINGREF integrityString;
if (FlagOn(PhProcessProviderFlagsMask, PH_PROCESS_PROVIDER_FLAG_USERNAME))
{
@@ -3246,7 +3246,7 @@ PPH_PROCESS_RECORD PhpCreateProcessRecord(
processRecord->CreateTime = ProcessItem->CreateTime;
PhSetReference(&processRecord->ProcessName, ProcessItem->ProcessName);
PhSetReference(&processRecord->FileName, ProcessItem->FileNameWin32);
PhSetReference(&processRecord->FileName, ProcessItem->FileName);
PhSetReference(&processRecord->CommandLine, ProcessItem->CommandLine);
//PhSetReference(&processRecord->UserName, ProcessItem->UserName);
+176 -46
View File
@@ -39,8 +39,6 @@
#include <procprv.h>
#include <procmtgn.h>
#include <math.h>
typedef enum _PHP_AGGREGATE_TYPE
{
AggregateTypeFloat,
@@ -632,6 +630,8 @@ VOID PhpRemoveProcessNode(
PhClearReference(&ProcessNode->TooltipText);
PhClearReference(&ProcessNode->IoTotalRateText);
PhClearReference(&ProcessNode->PrivateBytesText);
PhClearReference(&ProcessNode->PeakPrivateBytesText);
PhClearReference(&ProcessNode->WorkingSetText);
PhClearReference(&ProcessNode->PeakWorkingSetText);
@@ -650,6 +650,9 @@ VOID PhpRemoveProcessNode(
PhClearReference(&ProcessNode->IoRoRateText);
PhClearReference(&ProcessNode->IoWRateText);
PhClearReference(&ProcessNode->StartTimeText);
PhClearReference(&ProcessNode->TotalCpuTimeText);
PhClearReference(&ProcessNode->KernelCpuTimeText);
PhClearReference(&ProcessNode->UserCpuTimeText);
PhClearReference(&ProcessNode->RelativeStartTimeText);
PhClearReference(&ProcessNode->WindowTitleText);
PhClearReference(&ProcessNode->DepStatusText);
@@ -2867,6 +2870,10 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
getCellText->Text.Buffer = node->CpuUsageText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL); // minus null terminator
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
else if (cpuUsage != 0 && PhCsShowCpuBelow001)
{
@@ -2881,6 +2888,10 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
getCellText->Text.Buffer = node->CpuUsageText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
}
break;
@@ -2899,34 +2910,22 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
if (number != 0)
{
SIZE_T returnLength;
PH_FORMAT format[2];
PhInitFormatSize(&format[0], number);
PhInitFormatS(&format[1], L"/s");
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), node->IoTotalRateText, sizeof(node->IoTotalRateText), &returnLength))
{
getCellText->Text.Buffer = node->IoTotalRateText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
}
PhMoveReference(&node->IoTotalRateText, PhFormat(format, 2, 0));
getCellText->Text = node->IoTotalRateText->sr;
}
}
break;
case PHPRTLC_PRIVATEBYTES:
{
SIZE_T value = 0;
SIZE_T returnLength;
PH_FORMAT format[1];
PhpAggregateFieldIfNeeded(node, AggregateTypeIntPtr, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, VmCounters.PagefileUsage), &value);
PhInitFormatSize(&format[0], value);
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), node->PrivateBytesText, sizeof(node->PrivateBytesText), &returnLength))
{
getCellText->Text.Buffer = node->PrivateBytesText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
}
PhMoveReference(&node->IoWRateText, PhFormatSize(value, ULONG_MAX));
getCellText->Text = node->IoWRateText->sr;
}
break;
case PHPRTLC_USERNAME:
@@ -3123,7 +3122,17 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
}
break;
case PHPRTLC_INTEGRITY:
getCellText->Text = processItem->IntegrityString;
{
if (processItem->IntegrityString)
{
getCellText->Text.Buffer = processItem->IntegrityString->Buffer;
getCellText->Text.Length = processItem->IntegrityString->Length;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case PHPRTLC_IOPRIORITY:
{
@@ -3136,6 +3145,10 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
getCellText->Text.Buffer = ioPriority.Buffer;
getCellText->Text.Length = ioPriority.Length;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case PHPRTLC_PAGEPRIORITY:
@@ -3149,6 +3162,10 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
getCellText->Text.Buffer = pagePriority.Buffer;
getCellText->Text.Length = pagePriority.Length;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case PHPRTLC_STARTTIME:
@@ -3166,51 +3183,84 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
case PHPRTLC_TOTALCPUTIME:
{
SIZE_T returnLength;
WCHAR totalCpuTimeText[PH_TIMESPAN_STR_LEN_1];
if (PhPrintTimeSpanToBuffer(
processItem->KernelTime.QuadPart + processItem->UserTime.QuadPart,
PH_TIMESPAN_DHMSM,
node->TotalCpuTimeText,
sizeof(node->TotalCpuTimeText),
totalCpuTimeText,
sizeof(totalCpuTimeText),
&returnLength
))
{
getCellText->Text.Buffer = node->TotalCpuTimeText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
PH_STRINGREF string =
{
.Buffer = totalCpuTimeText,
.Length = returnLength - sizeof(UNICODE_NULL)
};
PhMoveReference(&node->TotalCpuTimeText, PhCreateString2(&string));
getCellText->Text = node->TotalCpuTimeText->sr;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case PHPRTLC_KERNELCPUTIME:
{
SIZE_T returnLength;
WCHAR kernelCpuTimeText[PH_TIMESPAN_STR_LEN_1];
if (PhPrintTimeSpanToBuffer(
processItem->KernelTime.QuadPart,
PH_TIMESPAN_DHMSM,
node->KernelCpuTimeText,
sizeof(node->KernelCpuTimeText),
kernelCpuTimeText,
sizeof(kernelCpuTimeText),
&returnLength
))
{
getCellText->Text.Buffer = node->KernelCpuTimeText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
PH_STRINGREF string =
{
.Buffer = kernelCpuTimeText,
.Length = returnLength - sizeof(UNICODE_NULL)
};
PhMoveReference(&node->KernelCpuTimeText, PhCreateString2(&string));
getCellText->Text = node->KernelCpuTimeText->sr;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case PHPRTLC_USERCPUTIME:
{
SIZE_T returnLength;
WCHAR userCpuTimeText[PH_TIMESPAN_STR_LEN_1];
if (PhPrintTimeSpanToBuffer(
processItem->UserTime.QuadPart,
PH_TIMESPAN_DHMSM,
node->UserCpuTimeText,
sizeof(node->UserCpuTimeText),
userCpuTimeText,
sizeof(userCpuTimeText),
&returnLength
))
{
getCellText->Text.Buffer = node->UserCpuTimeText;
getCellText->Text.Length = returnLength - sizeof(UNICODE_NULL);
PH_STRINGREF string =
{
.Buffer = userCpuTimeText,
.Length = returnLength - sizeof(UNICODE_NULL)
};
PhMoveReference(&node->UserCpuTimeText, PhCreateString2(&string));
getCellText->Text = node->UserCpuTimeText->sr;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
@@ -3715,6 +3765,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
PhInitializeStringRef(&getCellText->Text, L"XF Guard");
else if (processItem->IsControlFlowGuardEnabled)
PhInitializeStringRef(&getCellText->Text, L"CF Guard");
else
PhInitializeEmptyStringRef(&getCellText->Text);
}
break;
case PHPRTLC_TIMESTAMP:
@@ -3799,6 +3851,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
if (node->BreakOnTerminationEnabled)
PhInitializeStringRef(&getCellText->Text, L"Critical");
else
PhInitializeEmptyStringRef(&getCellText->Text);
}
break;
case PHPRTLC_PIDHEX:
@@ -4301,7 +4355,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
PhCsUseColorSystemProcesses &&
(processItem->IsSystemProcess ||
(processItem->Sid && PhEqualSid(processItem->Sid, (PSID)&PhSeLocalSystemSid)) ||
PH_IS_FAKE_PROCESS_ID(processItem->ProcessId)))
PH_IS_FAKE_PROCESS_ID(processItem->ProcessId) || processItem->ProcessId == SYSTEM_PROCESS_ID
))
getNodeColor->BackColor = PhCsColorSystemProcesses;
else if (
PhCsUseColorOwnProcesses &&
@@ -4690,7 +4745,6 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
if (data.Selection->Id == PH_TN_COLUMN_MENU_HIDE_COLUMN_ID ||
data.Selection->Id == PH_TN_COLUMN_MENU_CHOOSE_COLUMNS_ID)
{
// TODO: Reset flags for enabled/disabled columns. (dmex)
PhReloadSettingsProcessTreeList();
}
}
@@ -4764,6 +4818,9 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
case PHPRTLC_PRIVATEBYTESDELTA:
case PHPRTLC_CPUCORECYCLES:
case PHPRTLC_COMMITSIZE:
case PHPRTLC_CPUAVERAGE:
case PHPRTLC_CPUKERNEL:
case PHPRTLC_CPUUSER:
break;
default:
return FALSE;
@@ -4947,6 +5004,15 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
case PHPRTLC_COMMITSIZE:
PhpAggregateFieldTotal(node, AggregateTypeIntPtr, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, SharedCommitCharge), &number);
break;
case PHPRTLC_CPUAVERAGE:
PhpAggregateFieldTotal(node, AggregateTypeIntPtr, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CpuAverageUsage), &number);
break;
case PHPRTLC_CPUKERNEL:
PhpAggregateFieldTotal(node, AggregateTypeIntPtr, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CpuKernelUsage), &number);
break;
case PHPRTLC_CPUUSER:
PhpAggregateFieldTotal(node, AggregateTypeIntPtr, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CpuUserUsage), &number);
break;
}
}
@@ -5105,14 +5171,13 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
case TreeNewMiddleClick:
{
PPH_TREENEW_MOUSE_EVENT mouseEvent = Parameter1;
if (!mouseEvent)
break;
node = (PPH_PROCESS_NODE)mouseEvent->Node;
if (GetKeyState(VK_CONTROL) >= 0)
{
PhDeselectAllProcessNodes();
}
node = (PPH_PROCESS_NODE)mouseEvent->Node;
if (!node)
break;
@@ -5192,7 +5257,8 @@ PPH_PROCESS_ITEM PhGetSelectedProcessItem(
return processItem;
}
VOID PhGetSelectedProcessItems(
_Success_(return)
BOOLEAN PhGetSelectedProcessItems(
_Out_ PPH_PROCESS_ITEM **Processes,
_Out_ PULONG NumberOfProcesses
)
@@ -5207,11 +5273,42 @@ VOID PhGetSelectedProcessItems(
PPH_PROCESS_NODE node = ProcessNodeList->Items[i];
if (node->Node.Visible && node->Node.Selected)
{
PhAddItemArray(&array, &node->ProcessItem);
}
}
*NumberOfProcesses = (ULONG)array.Count;
*Processes = PhFinalArrayItems(&array);
if (PhFinalArrayCount(&array))
{
*NumberOfProcesses = (ULONG)PhFinalArrayCount(&array);
*Processes = PhFinalArrayItems(&array);
return TRUE;
}
else
{
return FALSE;
}
}
PPH_PROCESS_NODE PhGetSelectedProcessNode(
VOID
)
{
PPH_PROCESS_NODE processNode = NULL;
ULONG i;
for (i = 0; i < ProcessNodeList->Count; i++)
{
PPH_PROCESS_NODE node = ProcessNodeList->Items[i];
if (node->Node.Selected)
{
processNode = node;
break;
}
}
return processNode;
}
VOID PhGetSelectedProcessNodes(
@@ -5232,10 +5329,44 @@ VOID PhGetSelectedProcessNodes(
PhAddItemArray(&array, &node);
}
*NumberOfNodes = (ULONG)array.Count;
*NumberOfNodes = (ULONG)PhFinalArrayCount(&array);
*Nodes = PhFinalArrayItems(&array);
}
BOOLEAN PhGetProcessItemServices(
_In_ PPH_PROCESS_ITEM ProcessItem,
_Out_ PPH_SERVICE_ITEM** Services,
_Out_ PULONG NumberOfServices
)
{
PH_ARRAY array;
ULONG enumerationKey = 0;
PPH_SERVICE_ITEM serviceItem;
if (!(ProcessItem->ServiceList && ProcessItem->ServiceList->Count != 0))
return FALSE;
PhInitializeArray(&array, sizeof(PVOID), 2);
PhAcquireQueuedLockShared(&ProcessItem->ServiceListLock);
while (PhEnumPointerList(
ProcessItem->ServiceList,
&enumerationKey,
&serviceItem
))
{
PhReferenceObject(serviceItem);
PhAddItemArray(&array, &serviceItem);
}
PhReleaseQueuedLockShared(&ProcessItem->ServiceListLock);
*NumberOfServices = (ULONG)PhFinalArrayCount(&array);
*Services = PhFinalArrayItems(&array);
return TRUE;
}
static VOID PhpAddAndPropagateProcessItems(
_In_ PPH_ARRAY ProcessesArray,
_In_ PPH_PROCESS_NODE ProcessNode
@@ -5281,7 +5412,7 @@ VOID PhGetSelectedAndPropagateProcessItems(
}
}
*NumberOfProcesses = (ULONG)array.Count;
*NumberOfProcesses = (ULONG)PhFinalArrayCount(&array);
*Processes = PhFinalArrayItems(&array);
}
@@ -5585,7 +5716,7 @@ BOOLEAN PhpShouldShowImageCoherency(
_In_ BOOLEAN CheckThreshold
)
{
static FLOAT LowImageCoherencyThreshold = 0.5f; /**< Limit for displaying "low image coherency" */
const FLOAT LowImageCoherencyThreshold = 0.5f; /**< Limit for displaying "low image coherency" */
if (PhCsImageCoherencyScanLevel == 0)
{
@@ -5610,8 +5741,7 @@ BOOLEAN PhpShouldShowImageCoherency(
//
// Exclude the fake processes and system idle PID
//
if (PH_IS_FAKE_PROCESS_ID(ProcessItem->ProcessId) ||
(ProcessItem->ProcessId == SYSTEM_IDLE_PROCESS_ID))
if (!PH_IS_REAL_PROCESS_ID(ProcessItem->ProcessId))
{
return FALSE;
}
@@ -5619,7 +5749,7 @@ BOOLEAN PhpShouldShowImageCoherency(
//
// Do not show if the process has no image file name (Secure System)
//
if (!ProcessItem->FileNameWin32)
if (PhIsNullOrEmptyString(ProcessItem->FileName))
{
return FALSE;
}
+23 -28
View File
@@ -232,19 +232,16 @@ VOID PhpRefreshEnvironmentList(
HANDLE tokenHandle;
ULONG flags = 0;
if (CreateEnvironmentBlock_Import())
{
CreateEnvironmentBlock_Import()(&systemDefaultEnvironment, NULL, FALSE);
PhCreateEnvironmentBlock(&systemDefaultEnvironment, NULL, FALSE);
if (NT_SUCCESS(PhOpenProcessToken(
processHandle,
TOKEN_QUERY | TOKEN_DUPLICATE,
&tokenHandle
)))
{
CreateEnvironmentBlock_Import()(&userDefaultEnvironment, tokenHandle, FALSE);
NtClose(tokenHandle);
}
if (NT_SUCCESS(PhOpenProcessToken(
processHandle,
TOKEN_QUERY | TOKEN_DUPLICATE,
&tokenHandle
)))
{
PhCreateEnvironmentBlock(&userDefaultEnvironment, tokenHandle, FALSE);
NtClose(tokenHandle);
}
#ifdef _WIN64
@@ -366,13 +363,10 @@ VOID PhpRefreshEnvironmentList(
PhApplyTreeNewFilters(&Context->TreeFilterSupport);
TreeNew_NodesStructured(Context->TreeNewHandle);
if (DestroyEnvironmentBlock_Import())
{
if (systemDefaultEnvironment)
DestroyEnvironmentBlock_Import()(systemDefaultEnvironment);
if (userDefaultEnvironment)
DestroyEnvironmentBlock_Import()(userDefaultEnvironment);
}
if (systemDefaultEnvironment)
PhDestroyEnvironmentBlock(systemDefaultEnvironment);
if (userDefaultEnvironment)
PhDestroyEnvironmentBlock(userDefaultEnvironment);
}
NTSTATUS PhpEditDlgSetEnvironment(
@@ -577,7 +571,7 @@ INT_PTR CALLBACK PhpEditEnvDlgProc(
PhSetDialogItemText(hwndDlg, IDC_VALUE, context->Value ? context->Value : L"");
PhSetWindowContext(windowhandle, PH_WINDOW_CONTEXT_DEFAULT, PhGetWindowProcedure(windowhandle));
PhSetWindowProcedure(windowhandle, PhpEditEnvSubclassProc);
PhSetWindowProcedure(windowhandle, (WNDPROC)PhpEditEnvSubclassProc);
PhSetDialogFocus(hwndDlg, GetDlgItem(hwndDlg, IDCANCEL));
@@ -881,8 +875,8 @@ PPHP_PROCESS_ENVIRONMENT_TREENODE PhpAddEnvironmentNode(
PhAddEntryHashtable(Context->NodeHashtable, &node);
PhAddItemList(Context->NodeList, node);
if (Context->TreeFilterSupport.FilterList)
node->Node.Visible = PhApplyTreeNewFiltersToNode(&Context->TreeFilterSupport, &node->Node);
//if (Context->TreeFilterSupport.FilterList)
// node->Node.Visible = PhApplyTreeNewFiltersToNode(&Context->TreeFilterSupport, &node->Node);
if (ParentNode)
{
@@ -901,6 +895,8 @@ PPHP_PROCESS_ENVIRONMENT_TREENODE PhpAddEnvironmentNode(
PhAddItemList(Context->NodeRootList, node);
}
//TreeNew_NodesStructured(Context->TreeNewHandle);
return node;
}
@@ -1322,15 +1318,16 @@ VOID PhpInitializeEnvironmentTree(
PhSetControlTheme(Context->TreeNewHandle, L"explorer");
TreeNew_SetRedraw(Context->TreeNewHandle, FALSE);
TreeNew_SetCallback(Context->TreeNewHandle, PhpEnvironmentTreeNewCallback, Context);
// Default columns
PhAddTreeNewColumn(Context->TreeNewHandle, ENVIRONMENT_COLUMN_ITEM_NAME, TRUE, L"Name", 250, PH_ALIGN_LEFT, 0, 0);
PhAddTreeNewColumn(Context->TreeNewHandle, ENVIRONMENT_COLUMN_ITEM_VALUE, TRUE, L"Value", 250, PH_ALIGN_LEFT, 1, 0);
// Customizable columns
// ...
// Search filters
PhCmInitializeManager(&Context->Cm, Context->TreeNewHandle, PHMOTLC_MAXIMUM, PhpEnvironmentTreeNewPostSortFunction);
PhInitializeTreeNewFilterSupport(&Context->TreeFilterSupport, Context->TreeNewHandle, Context->NodeList);
TreeNew_SetTriState(Context->TreeNewHandle, TRUE);
TreeNew_SetSort(Context->TreeNewHandle, ENVIRONMENT_COLUMN_ITEM_NAME, NoSortOrder);
TreeNew_SetRedraw(Context->TreeNewHandle, TRUE);
}
@@ -1351,14 +1348,12 @@ VOID PhpDeleteEnvironmentTree(
BOOLEAN PhpProcessEnvironmentTreeFilterCallback(
_In_ PPH_TREENEW_NODE Node,
_In_opt_ PVOID Context
_In_ PVOID Context
)
{
PPH_ENVIRONMENT_CONTEXT context = Context;
PPHP_PROCESS_ENVIRONMENT_TREENODE environmentNode = (PPHP_PROCESS_ENVIRONMENT_TREENODE)Node;
if (!context)
return FALSE;
if (!environmentNode->Parent && environmentNode->Children && environmentNode->Children->Count == 0)
return FALSE;
if (context->TreeNewSortOrder != NoSortOrder && environmentNode->HasChildren)
+13 -1
View File
@@ -13,6 +13,7 @@
#include <phapp.h>
#include <procprp.h>
#include <procprpp.h>
#include <phconsole.h>
#include <emenu.h>
#include <mapimg.h>
@@ -149,6 +150,17 @@ NTSTATUS PhpProcessGeneralOpenProcess(
return STATUS_UNSUCCESSFUL;
}
NTSTATUS PhpProcessGeneralCloseHandle(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle)
NtClose(Handle);
return STATUS_SUCCESS;
}
FORCEINLINE PWSTR PhpGetStringOrNa(
_In_opt_ _Maybenull_ PPH_STRING String
)
@@ -730,7 +742,7 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc(
PhGetStringOrEmpty(processItem->ProcessName),
L"Process",
PhpProcessGeneralOpenProcess,
NULL,
PhpProcessGeneralCloseHandle,
processItem->ProcessId
);
}
+13 -3
View File
@@ -366,13 +366,23 @@ NTSTATUS PhpProcessHandleOpenCallback(
}
NTSTATUS PhpProcessHandleCloseCallback(
_In_ PVOID Context
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
PHANDLE_OPEN_CONTEXT context = Context;
PhDereferenceObject(context->HandleItem);
PhFree(context);
if (Handle)
{
NtClose(Handle);
}
if (Release && context)
{
PhDereferenceObject(context->HandleItem);
PhFree(context);
}
return STATUS_SUCCESS;
}
+22 -2
View File
@@ -145,12 +145,15 @@ VOID PhShowMemoryContextMenu(
PH_PLUGIN_MENU_INFORMATION menuInfo;
menu = PhCreateEMenu();
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_READWRITEMEMORY, L"&Read/Write memory", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_SAVE, L"&Save...", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_READWRITEMEMORY, L"&Read/Write memory...", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_CHANGEPROTECTION, L"Change &protection...", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_EMPTYWORKINGSET, L"&Empty working set...", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuSeparator(), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_FREE, L"&Free", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_DECOMMIT, L"&Decommit", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuSeparator(), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_SAVE, L"&Save...", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuSeparator(), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, ID_MEMORY_COPY, L"&Copy\bCtrl+C", NULL, NULL), ULONG_MAX);
PhSetFlagsEMenuItem(menu, ID_MEMORY_READWRITEMEMORY, PH_EMENU_DEFAULT, PH_EMENU_DEFAULT);
PhpInitializeMemoryMenu(menu, ProcessItem->ProcessId, memoryNodes, numberOfMemoryNodes);
@@ -807,6 +810,23 @@ INT_PTR CALLBACK PhpProcessMemoryDlgProc(
}
}
break;
case ID_MEMORY_EMPTYWORKINGSET:
{
PPH_MEMORY_NODE memoryNode = PhGetSelectedMemoryNode(&memoryContext->ListContext);
if (memoryNode)
{
PhReferenceObject(memoryNode->MemoryItem);
if (PhUiEmptyProcessMemoryWorkingSet(hwndDlg, processItem->ProcessId, memoryNode->MemoryItem))
{
// Refresh counters or statistics.
}
PhDereferenceObject(memoryNode->MemoryItem);
}
}
break;
case ID_MEMORY_COPY:
{
PPH_STRING text;
+1 -1
View File
@@ -22,7 +22,7 @@ static VOID PhpLayoutServiceListControl(
RECT rect;
GetWindowRect(GetDlgItem(hwndDlg, IDC_SERVICES_LAYOUT), &rect);
MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
MapWindowRect(NULL, hwndDlg, &rect);
MoveWindow(
ServiceListHandle,
+21
View File
@@ -308,6 +308,16 @@ static NTSTATUS NTAPI PhpThreadPermissionsOpenThread(
return STATUS_UNSUCCESSFUL;
}
static NTSTATUS PhpThreadPermissionsCloseHandle(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle) NtClose(Handle);
return STATUS_SUCCESS;
}
static NTSTATUS NTAPI PhpOpenThreadTokenObject(
_Out_ PHANDLE Handle,
_In_ ACCESS_MASK DesiredAccess,
@@ -320,6 +330,16 @@ static NTSTATUS NTAPI PhpOpenThreadTokenObject(
return STATUS_UNSUCCESSFUL;
}
static NTSTATUS PhpCloseThreadTokenObject(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle) NtClose(Handle);
return STATUS_SUCCESS;
}
BOOLEAN PhpThreadTreeFilterCallback(
_In_ PPH_TREENEW_NODE Node,
_In_opt_ PPH_THREADS_CONTEXT Context
@@ -1323,6 +1343,7 @@ INT_PTR CALLBACK PhpProcessThreadsDlgProc(
PhShowTokenProperties(
hwndDlg,
PhpOpenThreadTokenObject,
PhpCloseThreadTokenObject,
threadsContext->Provider->ProcessId,
(PVOID)threadHandle,
NULL
+10
View File
@@ -58,6 +58,16 @@ NTSTATUS NTAPI PhpOpenProcessTokenForPage(
return status;
}
NTSTATUS PhpCloseProcessTokenForPage(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle) NtClose(Handle);
return STATUS_SUCCESS;
}
INT_PTR CALLBACK PhpProcessTokenHookProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
+61 -36
View File
@@ -57,7 +57,7 @@
#include <appresolver.h>
#include <actions.h>
#include <lsasup.h>
#include <mapldr.h>
#include <phconsole.h>
#include <phsvc.h>
#include <phsvccl.h>
#include <phsettings.h>
@@ -350,7 +350,7 @@ static VOID PhpFreeAccountsComboBox(
BOOLEAN PhpEnumerateRecentProgramsToComboBox(
_In_ PPH_STRINGREF Command,
_In_opt_ PVOID Context
_In_ PVOID Context
)
{
ComboBox_AddString(Context, PhGetStringRefZ(Command));
@@ -359,7 +359,7 @@ BOOLEAN PhpEnumerateRecentProgramsToComboBox(
NTSTATUS PhpEnumerateAccountsToComboBox(
_In_ PPH_STRING AccountName,
_In_opt_ PVOID Context
_In_ PVOID Context
)
{
ComboBox_AddString(Context, PhGetString(AccountName));
@@ -989,6 +989,7 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
PH_CREATE_PROCESS_AS_USER_INFO createInfo;
PPH_STRING domainPart = NULL;
PPH_STRING userPart = NULL;
HANDLE newProcessHandle;
PhpSplitUserName(username->Buffer, &domainPart, &userPart);
@@ -1011,10 +1012,16 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
&createInfo,
PH_CREATE_PROCESS_WITH_PROFILE | PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | (createSuspended ? PH_CREATE_PROCESS_SUSPENDED : 0),
NULL,
NULL,
&newProcessHandle,
NULL
);
if (NT_SUCCESS(status))
{
PhConsoleSetForeground(newProcessHandle, TRUE);
NtClose(newProcessHandle);
}
CleanupAsUserExit:
if (domainPart) PhDereferenceObject(domainPart);
if (userPart) PhDereferenceObject(userPart);
@@ -1026,6 +1033,7 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
HANDLE processHandle = NULL;
HANDLE newProcessHandle;
STARTUPINFOEX startupInfo = { 0 };
PPROC_THREAD_ATTRIBUTE_LIST attributeList = NULL;
PSECURITY_DESCRIPTOR processSecurityDescriptor = NULL;
PSECURITY_DESCRIPTOR tokenSecurityDescriptor = NULL;
PVOID environment = NULL;
@@ -1072,11 +1080,6 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
if (commandString) PhDereferenceObject(commandString);
}
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
status = PhOpenProcess(
&processHandle,
PROCESS_CREATE_PROCESS | (PhGetOwnTokenAttributes().Elevated ? PROCESS_QUERY_LIMITED_INFORMATION | READ_CONTROL : 0),
@@ -1086,13 +1089,13 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
if (!NT_SUCCESS(status))
goto CleanupExit;
status = PhInitializeProcThreadAttributeList(&startupInfo.lpAttributeList, 1);
status = PhInitializeProcThreadAttributeList(&attributeList, 1);
if (!NT_SUCCESS(status))
goto CleanupExit;
status = PhUpdateProcThreadAttribute(
startupInfo.lpAttributeList,
attributeList,
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
&(HANDLE){ processHandle },
sizeof(HANDLE)
@@ -1125,7 +1128,7 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
);
}
if (CreateEnvironmentBlock_Import() && CreateEnvironmentBlock_Import()(&environment, tokenHandle, FALSE))
if (NT_SUCCESS(PhCreateEnvironmentBlock(&environment, tokenHandle, FALSE)))
{
flags |= PH_CREATE_PROCESS_UNICODE_ENVIRONMENT;
}
@@ -1138,12 +1141,18 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
if (!NT_SUCCESS(status))
goto CleanupExit;
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
startupInfo.lpAttributeList = attributeList;
status = PhCreateProcessWin32Ex(
NULL,
PhGetString(program),
environment,
NULL,
&startupInfo.StartupInfo,
&startupInfo,
PH_CREATE_PROCESS_SUSPENDED | PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO | PH_CREATE_PROCESS_DEFAULT_ERROR_MODE | flags,
NULL,
NULL,
@@ -1153,8 +1162,6 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
if (NT_SUCCESS(status))
{
PROCESS_BASIC_INFORMATION basicInfo;
if (PhGetOwnTokenAttributes().Elevated)
{
// Note: This is needed to workaround a severe bug with PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
@@ -1186,20 +1193,18 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
}
}
if (NT_SUCCESS(PhGetProcessBasicInformation(newProcessHandle, &basicInfo)))
{
AllowSetForegroundWindow(ASFW_ANY); // HandleToUlong(basicInfo.UniqueProcessId));
}
PhConsoleSetForeground(newProcessHandle, TRUE);
NtResumeProcess(newProcessHandle);
NtClose(newProcessHandle);
}
CleanupExit:
if (environment && DestroyEnvironmentBlock_Import())
if (environment)
{
DestroyEnvironmentBlock_Import()(environment);
PhDestroyEnvironmentBlock(environment);
}
if (tokenSecurityDescriptor)
@@ -1212,9 +1217,9 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
PhFree(processSecurityDescriptor);
}
if (startupInfo.lpAttributeList)
if (attributeList)
{
PhDeleteProcThreadAttributeList(startupInfo.lpAttributeList);
PhDeleteProcThreadAttributeList(attributeList);
}
if (processHandle)
@@ -1786,6 +1791,7 @@ NTSTATUS PhInvokeRunAsService(
PPH_STRING domainName;
PPH_STRING userName;
PH_CREATE_PROCESS_AS_USER_INFO createInfo;
HANDLE newProcessHandle;
ULONG flags;
if (Parameters->UserName)
@@ -1828,10 +1834,16 @@ NTSTATUS PhInvokeRunAsService(
&createInfo,
flags,
NULL,
NULL,
&newProcessHandle,
NULL
);
if (NT_SUCCESS(status))
{
PhConsoleSetForeground(newProcessHandle, TRUE);
NtClose(newProcessHandle);
}
if (domainName) PhDereferenceObject(domainName);
if (userName) PhDereferenceObject(userName);
@@ -2123,9 +2135,11 @@ NTSTATUS RunAsCreateProcessThread(
{
PPH_STRING command = Parameter;
NTSTATUS status;
PPROC_THREAD_ATTRIBUTE_LIST attributeList = NULL;
SERVICE_STATUS_PROCESS serviceStatus = { 0 };
SC_HANDLE serviceHandle = NULL;
HANDLE processHandle = NULL;
HANDLE newProcessHandle;
STARTUPINFOEX startupInfo;
PPH_STRING commandLine = NULL;
PPH_STRING filePathString;
@@ -2135,11 +2149,6 @@ NTSTATUS RunAsCreateProcessThread(
else
PhSetReference(&commandLine, command);
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
if (!NT_SUCCESS(status = PhOpenService(&serviceHandle, SERVICE_QUERY_STATUS | SERVICE_START, L"TrustedInstaller")))
goto CleanupExit;
@@ -2183,11 +2192,17 @@ NTSTATUS RunAsCreateProcessThread(
if (!NT_SUCCESS(status = PhOpenProcess(&processHandle, PROCESS_CREATE_PROCESS, UlongToHandle(serviceStatus.dwProcessId))))
goto CleanupExit;
if (!NT_SUCCESS(status = PhInitializeProcThreadAttributeList(&startupInfo.lpAttributeList, 1)))
if (!NT_SUCCESS(status = PhInitializeProcThreadAttributeList(&attributeList, 1)))
goto CleanupExit;
PROC_THREAD_ATTRIBUTE extended;
extended.Attribute = PROC_THREAD_ATTRIBUTE_EXTENDED_FLAGS;
extended.Size = sizeof(ULONG);
extended.Value = (ULONG_PTR)EXTENDED_PROCESS_CREATION_FLAG_FORCELUA;
attributeList->ExtendedFlagsAttribute = &extended;
status = PhUpdateProcThreadAttribute(
startupInfo.lpAttributeList,
attributeList,
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
&(HANDLE){ processHandle },
sizeof(HANDLE)
@@ -2196,21 +2211,31 @@ NTSTATUS RunAsCreateProcessThread(
if (!NT_SUCCESS(status))
goto CleanupExit;
AllowSetForegroundWindow(ASFW_ANY);
memset(&startupInfo, 0, sizeof(STARTUPINFOEX));
startupInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
startupInfo.StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.StartupInfo.wShowWindow = SW_SHOWNORMAL;
startupInfo.lpAttributeList = attributeList;
status = PhCreateProcessWin32Ex(
NULL,
PhGetString(commandLine),
NULL,
NULL,
&startupInfo.StartupInfo,
&startupInfo,
PH_CREATE_PROCESS_NEW_CONSOLE | PH_CREATE_PROCESS_EXTENDED_STARTUPINFO | PH_CREATE_PROCESS_DEFAULT_ERROR_MODE,
NULL,
NULL,
NULL,
&newProcessHandle,
NULL
);
if (NT_SUCCESS(status))
{
PhConsoleSetForeground(newProcessHandle, TRUE);
NtClose(newProcessHandle);
}
CleanupExit:
if (processHandle)
@@ -2219,9 +2244,9 @@ CleanupExit:
if (serviceHandle)
PhCloseServiceHandle(serviceHandle);
if (startupInfo.lpAttributeList)
if (attributeList)
{
PhDeleteProcThreadAttributeList(startupInfo.lpAttributeList);
PhDeleteProcThreadAttributeList(attributeList);
}
if (commandLine)
+13 -2
View File
@@ -88,10 +88,21 @@ static NTSTATUS PhpOpenServiceCallback(
}
NTSTATUS PhpCloseServiceCallback(
_In_ PVOID Context
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
PhDereferenceObject(((PPH_SERVICE_ITEM)Context));
if (Handle)
{
PhCloseServiceHandle(Handle);
}
if (Release && Context)
{
PhDereferenceObject(((PPH_SERVICE_ITEM)Context));
}
return STATUS_SUCCESS;
}
+2 -8
View File
@@ -14,9 +14,6 @@
#include <settings.h>
#include <sysinfo.h>
#include <sysinfop.h>
#include <math.h>
#include <procprv.h>
#include <phsettings.h>
@@ -1029,7 +1026,7 @@ VOID PhSipUpdateCpuPanel(
#ifdef _ARM64_
ULONG64 currentExceptionLevel;
#else
INT cpubrand[4];
LONG cpubrand[4];
#endif
PH_FORMAT format[5];
WCHAR formatBuffer[256];
@@ -1044,7 +1041,7 @@ VOID PhSipUpdateCpuPanel(
}
}
if (!distributionSucceeded)
if (!distributionSucceeded || cpuGhz == 0.0)
cpuGhz = (DOUBLE)PowerInformation[0].CurrentMhz;
// %.2f%%
@@ -1190,9 +1187,7 @@ VOID PhSipUpdateCpuPanel(
// Do not optimize (dmex)
PhQueryPerformanceCounter(&performanceCounterStart);
MemoryBarrier();
timeStampCounterStart = PhReadTimeStampCounter();
MemoryBarrier();
#ifdef _ARM64_
// 0b11 0b000 0b0100 0b0010 0b010 CurrentEL Current Exception Level
currentExceptionLevel = _ReadStatusReg(ARM64_SYSREG(3, 0, 4, 2, 2));
@@ -1201,7 +1196,6 @@ VOID PhSipUpdateCpuPanel(
#endif
MemoryBarrier();
timeStampCounterEnd = PhReadTimeStampCounter();
MemoryBarrier();
PhQueryPerformanceCounter(&performanceCounterEnd);
performanceCounterTicks.QuadPart = performanceCounterEnd.QuadPart - performanceCounterStart.QuadPart;
+1 -1
View File
@@ -1045,7 +1045,7 @@ NTSTATUS PhSipLoadMmAddresses(
PhLoadModuleSymbolProvider(
symbolProvider,
kernelFileName,
(ULONG64)kernelImageBase,
kernelImageBase,
kernelImageSize
);
+17 -24
View File
@@ -624,7 +624,7 @@ BOOLEAN NTAPI ThreadStackTreeNewCallback(
if (PhGetLineFromAddress(
context->SymbolProvider,
(ULONG64)node->StackFrame.PcAddress,
node->StackFrame.PcAddress,
&fileName,
NULL,
&lineInfo
@@ -1302,7 +1302,7 @@ BOOLEAN NTAPI PhpWalkThreadStackCallback(
PPH_STRING fileName = NULL;
PPH_STRING lineText = NULL;
PTHREAD_STACK_ITEM item;
ULONG64 baseAddress = 0;
PVOID baseAddress = NULL;
BOOLEAN enableStackFrameInlineInfo;
BOOLEAN enableStackFrameLineInfo;
@@ -1400,7 +1400,7 @@ BOOLEAN NTAPI PhpWalkThreadStackCallback(
{
symbol = PhGetSymbolFromAddress(
threadStackContext->SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
NULL,
&fileName,
NULL,
@@ -1437,7 +1437,7 @@ BOOLEAN NTAPI PhpWalkThreadStackCallback(
if (PhGetLineFromAddress(
threadStackContext->SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
&lineFileName,
NULL,
&lineInfo
@@ -1578,7 +1578,7 @@ LRESULT CALLBACK PhpThreadStackTaskDialogSubclassProc(
{
case WM_NCDESTROY:
{
SetWindowLongPtr(hwndDlg, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
PhSetWindowProcedure(hwndDlg, oldWndProc);
PhRemoveWindowContext(hwndDlg, 0xF);
}
break;
@@ -1652,11 +1652,11 @@ HRESULT CALLBACK PhpThreadStackTaskDialogCallback(
SendMessage(hwndDlg, TDM_SET_MARQUEE_PROGRESS_BAR, TRUE, 0);
SendMessage(hwndDlg, TDM_SET_PROGRESS_BAR_MARQUEE, TRUE, 1);
context->SymbolProgressMarquee = TRUE;
InterlockedExchange8(&context->SymbolProgressMarquee, TRUE);
context->ThreadStackStatusDefaultWindowProc = (WNDPROC)GetWindowLongPtr(hwndDlg, GWLP_WNDPROC);
context->ThreadStackStatusDefaultWindowProc = PhGetWindowProcedure(hwndDlg);
PhSetWindowContext(hwndDlg, 0xF, context);
SetWindowLongPtr(hwndDlg, GWLP_WNDPROC, (LONG_PTR)PhpThreadStackTaskDialogSubclassProc);
PhSetWindowProcedure(hwndDlg, PhpThreadStackTaskDialogSubclassProc);
PhRegisterCallback(
&PhSymbolEventCallback,
@@ -1692,29 +1692,22 @@ HRESULT CALLBACK PhpThreadStackTaskDialogCallback(
PPH_STRING content;
ULONG progress = 0;
PhAcquireQueuedLockExclusive(&context->StatusLock);
message = context->StatusMessage;
content = context->StatusContent;
progress = context->SymbolProgress;
if (message) PhReferenceObject(message);
if (content) PhReferenceObject(content);
PhReleaseQueuedLockExclusive(&context->StatusLock);
PhSetReference(&message, InterlockedExchangePointer(&context->StatusMessage, NULL));
PhSetReference(&content, InterlockedExchangePointer(&context->StatusContent, NULL));
progress = InterlockedExchange(&context->SymbolProgress, 0);
SendMessage(context->TaskDialogHandle, TDM_SET_ELEMENT_TEXT, TDE_MAIN_INSTRUCTION, (LPARAM)PhGetStringOrDefault(message, L" "));
SendMessage(context->TaskDialogHandle, TDM_SET_ELEMENT_TEXT, TDE_CONTENT, (LPARAM)PhGetStringOrDefault(content, L" "));
if (message) PhDereferenceObject(message);
if (content) PhDereferenceObject(content);
PhClearReference(&message);
PhClearReference(&content);
if (context->SymbolProgressReset)
{
SendMessage(hwndDlg, TDM_SET_MARQUEE_PROGRESS_BAR, TRUE, 0);
SendMessage(hwndDlg, TDM_SET_PROGRESS_BAR_MARQUEE, TRUE, 1);
context->SymbolProgressMarquee = TRUE;
context->SymbolProgressReset = FALSE;
InterlockedExchange8(&context->SymbolProgressMarquee, TRUE);
InterlockedExchange8(&context->SymbolProgressReset, FALSE);
}
if (progress)
@@ -1723,7 +1716,7 @@ HRESULT CALLBACK PhpThreadStackTaskDialogCallback(
{
SendMessage(hwndDlg, TDM_SET_MARQUEE_PROGRESS_BAR, FALSE, 0);
SendMessage(hwndDlg, TDM_SET_PROGRESS_BAR_MARQUEE, FALSE, 0);
context->SymbolProgressMarquee = FALSE;
InterlockedExchange8(&context->SymbolProgressMarquee, FALSE);
}
SendMessage(hwndDlg, TDM_SET_PROGRESS_BAR_POS, (WPARAM)progress, 0);
@@ -1734,7 +1727,7 @@ HRESULT CALLBACK PhpThreadStackTaskDialogCallback(
{
SendMessage(hwndDlg, TDM_SET_MARQUEE_PROGRESS_BAR, TRUE, 0);
SendMessage(hwndDlg, TDM_SET_PROGRESS_BAR_MARQUEE, TRUE, 1);
context->SymbolProgressMarquee = TRUE;
InterlockedExchange8(&context->SymbolProgressMarquee, TRUE);
}
}
}
+7 -7
View File
@@ -71,7 +71,7 @@ typedef struct _PH_THREAD_STACKS_THREAD_NODE
HANDLE ThreadId;
HANDLE ThreadHandle;
ULONG64 StartAddress;
PVOID StartAddress;
PPH_STRING ThreadName;
WCHAR ThreadIdString[PH_INT32_STR_LEN_1];
WCHAR StartAddressString[PH_PTR_STR_LEN_1];
@@ -386,15 +386,15 @@ VOID PhpThreadStacksCreateThreadNode(
ULONG_PTR startAddress;
if (NT_SUCCESS(PhGetThreadStartAddress(node->Thread.ThreadHandle, &startAddress)))
node->Thread.StartAddress = (ULONG64)startAddress;
node->Thread.StartAddress = (PVOID)startAddress;
PhGetThreadName(node->Thread.ThreadHandle, &node->Thread.ThreadName);
}
if (!node->Thread.StartAddress)
node->Thread.StartAddress = (ULONG64)ThreadInfo->StartAddress;
node->Thread.StartAddress = (PVOID)ThreadInfo->StartAddress;
PhPrintPointer(node->Thread.StartAddressString, (PVOID)node->Thread.StartAddress);
PhPrintPointer(node->Thread.StartAddressString, node->Thread.StartAddress);
if (!PhIsNullOrEmptyString(node->Thread.ThreadName))
node->Symbol = PhReferenceObject(node->Thread.ThreadName);
@@ -496,7 +496,7 @@ PPH_STRING PhpThreadStacksInitFrameNode(
PPH_STRING symbol = NULL;
PPH_STRING fileName = NULL;
PPH_STRING lineText = NULL;
ULONG64 baseAddress = 0;
PVOID baseAddress = NULL;
PPH_STRING lineFileName;
PH_SYMBOL_LINE_INFORMATION lineInfo;
@@ -551,7 +551,7 @@ PPH_STRING PhpThreadStacksInitFrameNode(
{
symbol = PhGetSymbolFromAddress(
FrameNode->Thread->Process->SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
NULL,
&fileName,
NULL,
@@ -576,7 +576,7 @@ PPH_STRING PhpThreadStacksInitFrameNode(
if (PhGetLineFromAddress(
FrameNode->Thread->Process->SymbolProvider,
(ULONG64)StackFrame->PcAddress,
StackFrame->PcAddress,
&lineFileName,
NULL,
&lineInfo
+209 -151
View File
@@ -69,6 +69,7 @@ typedef struct _PHP_TOKEN_USER_RESOLVE_CONTEXT
typedef struct _PHP_TOKEN_GROUP_RESOLVE_CONTEXT
{
HWND ListViewHandle;
IListView* ListView;
PPHP_TOKEN_PAGE_LISTVIEW_ITEM LvItem;
PSID TokenGroupSid;
} PHP_TOKEN_GROUP_RESOLVE_CONTEXT, *PPHP_TOKEN_GROUP_RESOLVE_CONTEXT;
@@ -93,11 +94,13 @@ typedef struct _PH_TOKEN_ATTRIBUTE_TREE_CONTEXT
typedef struct _TOKEN_PAGE_CONTEXT
{
PPH_OPEN_OBJECT OpenObject;
PPH_CLOSE_OBJECT CloseObject;
PVOID Context;
DLGPROC HookProc;
HANDLE ProcessId;
HWND ListViewHandle;
IListView* ListViewClass;
HIMAGELIST ListViewImageList;
PH_LAYOUT_MANAGER LayoutManager;
BOOLEAN SinglePageContext;
@@ -279,15 +282,17 @@ NTSTATUS PhpTokenDialogThread(
VOID PhCreateTokenDialog(
_In_ PPH_OPEN_OBJECT OpenObject,
_In_ PPH_CLOSE_OBJECT CloseObject,
_In_ HANDLE ProcessId,
_In_ PVOID Context,
_In_opt_ DLGPROC HookProc
)
{
NTSTATUS status;
PTOKEN_PAGE_CONTEXT tokenPageContext;
HANDLE tokenHandle = NULL;
if (!NT_SUCCESS(NtDuplicateObject(
if (!NT_SUCCESS(status = NtDuplicateObject(
NtCurrentProcess(),
Context,
NtCurrentProcess(),
@@ -297,13 +302,14 @@ VOID PhCreateTokenDialog(
DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES
)))
{
PhShowError2(NULL, L"Unable to duplicate the token.", L"%s", L"");
PhShowStatus(NULL, L"Unable to duplicate the token.", status, 0);
return;
}
tokenPageContext = PhCreateAlloc(sizeof(TOKEN_PAGE_CONTEXT));
memset(tokenPageContext, 0, sizeof(TOKEN_PAGE_CONTEXT));
tokenPageContext->OpenObject = OpenObject;
tokenPageContext->CloseObject = CloseObject;
tokenPageContext->Context = tokenHandle;
//tokenPageContext->HookProc = HookProc;
tokenPageContext->ProcessId = ProcessId;
@@ -315,12 +321,13 @@ VOID PhCreateTokenDialog(
VOID PhShowTokenProperties(
_In_ HWND ParentWindowHandle,
_In_ PPH_OPEN_OBJECT OpenObject,
_In_ PPH_CLOSE_OBJECT CloseObject,
_In_ HANDLE ProcessId,
_In_ PVOID Context,
_In_opt_ PCWSTR Title
)
{
PhCreateTokenDialog(OpenObject, ProcessId, Context, NULL);
PhCreateTokenDialog(OpenObject, CloseObject, ProcessId, Context, NULL);
}
INT CALLBACK PhpTokenSheetProc(
@@ -343,6 +350,7 @@ INT CALLBACK PhpTokenSheetProc(
HPROPSHEETPAGE PhCreateTokenPage(
_In_ PPH_OPEN_OBJECT OpenObject,
_In_ PPH_CLOSE_OBJECT CloseObject,
_In_ HANDLE ProcessId,
_In_opt_ PVOID Context,
_In_opt_ DLGPROC HookProc
@@ -355,6 +363,7 @@ HPROPSHEETPAGE PhCreateTokenPage(
tokenPageContext = PhCreateAlloc(sizeof(TOKEN_PAGE_CONTEXT));
memset(tokenPageContext, 0, sizeof(TOKEN_PAGE_CONTEXT));
tokenPageContext->OpenObject = OpenObject;
tokenPageContext->CloseObject = CloseObject;
tokenPageContext->Context = Context;
tokenPageContext->HookProc = HookProc;
tokenPageContext->ProcessId = ProcessId;
@@ -680,15 +689,15 @@ VOID PhpTokenPageFreeListViewEntries(
{
LONG index = INT_ERROR;
while ((index = PhFindListViewItemByFlags(
TokenPageContext->ListViewHandle,
while ((index = PhFindIListViewItemByFlags(
TokenPageContext->ListViewClass,
index,
LVNI_ALL
)) != INT_ERROR)
{
PPHP_TOKEN_PAGE_LISTVIEW_ITEM entry;
if (PhGetListViewItemParam(TokenPageContext->ListViewHandle, index, &entry))
if (PhGetIListViewItemParam(TokenPageContext->ListViewClass, index, &entry))
{
PhFree(entry);
}
@@ -723,8 +732,8 @@ static NTSTATUS NTAPI PhpTokenGroupResolveWorker(
SID_NAME_USE sidUse;
LONG lvItemIndex;
lvItemIndex = PhFindListViewItemByParam(
context->ListViewHandle,
lvItemIndex = PhFindIListViewItemByParam(
context->ListView,
INT_ERROR,
context->LvItem
);
@@ -773,15 +782,15 @@ static NTSTATUS NTAPI PhpTokenGroupResolveWorker(
if (sidString)
{
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_NAME, PhGetString(sidString));
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_NAME, PhGetString(sidString));
PhDereferenceObject(sidString);
}
else
{
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_NAME, L"[Unknown SID]");
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_NAME, L"[Unknown SID]");
}
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_TYPE, PhGetSidAccountTypeString(context->TokenGroupSid));
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_TYPE, PhGetSidAccountTypeString(context->TokenGroupSid));
}
if (NT_SUCCESS(PhLookupSid(context->TokenGroupSid, NULL, NULL, &sidUse)))
@@ -790,16 +799,16 @@ static NTSTATUS NTAPI PhpTokenGroupResolveWorker(
if (PhGetTokenSidTypeString(sidUse, &tokenSidType))
{
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, tokenSidType);
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, tokenSidType);
}
else
{
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, L"N/A");
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, L"N/A");
}
}
else
{
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, L"N/A");
PhSetIListViewSubItem(context->ListView, lvItemIndex, PH_PROCESS_TOKEN_INDEX_USE, L"N/A");
}
PhFree(context->TokenGroupSid);
@@ -809,7 +818,7 @@ static NTSTATUS NTAPI PhpTokenGroupResolveWorker(
}
VOID PhpUpdateSidsFromTokenGroups(
_In_ HWND ListViewHandle,
_In_ PTOKEN_PAGE_CONTEXT TokenPageContext,
_In_ PTOKEN_GROUPS Groups,
_In_ BOOLEAN Restricted
)
@@ -826,8 +835,8 @@ VOID PhpUpdateSidsFromTokenGroups(
lvitem->ItemCategory = Restricted ? PH_PROCESS_TOKEN_CATEGORY_RESTRICTED : PH_PROCESS_TOKEN_CATEGORY_GROUPS;
lvitem->TokenGroup = &Groups->Groups[i];
lvItemIndex = PhAddListViewGroupItem(
ListViewHandle,
lvItemIndex = PhAddIListViewGroupItem(
TokenPageContext->ListViewClass,
lvitem->ItemCategory,
MAXINT,
L"Resolving...",
@@ -836,7 +845,7 @@ VOID PhpUpdateSidsFromTokenGroups(
if (attributesString = PhGetGroupAttributesString(Groups->Groups[i].Attributes, Restricted))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetString(attributesString));
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetString(attributesString));
PhDereferenceObject(attributesString);
}
@@ -848,13 +857,13 @@ VOID PhpUpdateSidsFromTokenGroups(
if (descriptionString)
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetString(descriptionString));
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetString(descriptionString));
PhDereferenceObject(descriptionString);
}
if (stringUserSid = PhSidToStringSid(Groups->Groups[i].Sid))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhGetString(stringUserSid));
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhGetString(stringUserSid));
PhDereferenceObject(stringUserSid);
}
@@ -862,7 +871,8 @@ VOID PhpUpdateSidsFromTokenGroups(
PPHP_TOKEN_GROUP_RESOLVE_CONTEXT tokenGroupResolve;
tokenGroupResolve = PhAllocateZero(sizeof(PHP_TOKEN_GROUP_RESOLVE_CONTEXT));
tokenGroupResolve->ListViewHandle = ListViewHandle;
tokenGroupResolve->ListViewHandle = TokenPageContext->ListViewHandle;
tokenGroupResolve->ListView = TokenPageContext->ListViewClass;
tokenGroupResolve->LvItem = lvitem;
tokenGroupResolve->TokenGroupSid = PhAllocateCopy(Groups->Groups[i].Sid, PhLengthSid(Groups->Groups[i].Sid));
@@ -883,12 +893,12 @@ BOOLEAN PhpUpdateTokenGroups(
if (NT_SUCCESS(PhGetTokenGroups(TokenHandle, &groups)))
{
PhpUpdateSidsFromTokenGroups(ListViewHandle, groups, FALSE);
PhpUpdateSidsFromTokenGroups(TokenPageContext, groups, FALSE);
}
if (NT_SUCCESS(PhGetTokenRestrictedSids(TokenHandle, &restrictedSIDs)))
{
PhpUpdateSidsFromTokenGroups(ListViewHandle, restrictedSIDs, TRUE);
PhpUpdateSidsFromTokenGroups(TokenPageContext, restrictedSIDs, TRUE);
}
if (TokenPageContext->RestrictedSids)
@@ -939,19 +949,19 @@ NTSTATUS NTAPI PhpEnumeratePrivilegesCallback(
lvitem->TokenPrivilege->Attributes = SE_PRIVILEGE_REMOVED;
// Name
lvItemIndex = PhAddListViewGroupItem(
tokenPageContext->ListViewHandle,
lvItemIndex = PhAddIListViewGroupItem(
tokenPageContext->ListViewClass,
PH_PROCESS_TOKEN_CATEGORY_PRIVILEGES,
MAXINT,
PhGetString(privilegeName),
lvitem
);
// Status
PhSetListViewSubItem(tokenPageContext->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetPrivilegeAttributesString(lvitem->TokenPrivilege->Attributes));
PhSetIListViewSubItem(tokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetPrivilegeAttributesString(lvitem->TokenPrivilege->Attributes));
// Description
PhSetListViewSubItem(tokenPageContext->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetStringOrEmpty(privilegeDisplayName));
PhSetIListViewSubItem(tokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetStringOrEmpty(privilegeDisplayName));
// Privilege value
PhSetListViewSubItem(tokenPageContext->ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhaFormatUInt64(Privileges[i].LocalValue.LowPart, FALSE)->Buffer);
PhSetIListViewSubItem(tokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhaFormatUInt64(Privileges[i].LocalValue.LowPart, FALSE)->Buffer);
if (privilegeDisplayName) PhDereferenceObject(privilegeDisplayName);
PhDereferenceObject(privilegeName);
@@ -994,19 +1004,19 @@ BOOLEAN PhpUpdateTokenPrivileges(
PhLookupPrivilegeDisplayName(&privilegeName->sr, &privilegeDisplayName);
// Name
lvItemIndex = PhAddListViewGroupItem(
ListViewHandle,
lvItemIndex = PhAddIListViewGroupItem(
TokenPageContext->ListViewClass,
PH_PROCESS_TOKEN_CATEGORY_PRIVILEGES,
MAXINT,
privilegeName->Buffer,
lvitem
);
// Status
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetPrivilegeAttributesString(privileges->Privileges[i].Attributes));
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_STATUS, PhGetPrivilegeAttributesString(privileges->Privileges[i].Attributes));
// Description
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetStringOrEmpty(privilegeDisplayName));
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_DESCRIPTION, PhGetStringOrEmpty(privilegeDisplayName));
// Value
PhSetListViewSubItem(ListViewHandle, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhaFormatUInt64(privileges->Privileges[i].Luid.LowPart, FALSE)->Buffer);
PhSetIListViewSubItem(TokenPageContext->ListViewClass, lvItemIndex, PH_PROCESS_TOKEN_INDEX_SID, PhaFormatUInt64(privileges->Privileges[i].Luid.LowPart, FALSE)->Buffer);
if (privilegeDisplayName) PhDereferenceObject(privilegeDisplayName);
PhDereferenceObject(privilegeName);
@@ -1027,7 +1037,7 @@ BOOLEAN PhpUpdateTokenPrivileges(
}
VOID PhpUpdateTokenDangerousFlagItem(
_In_ HWND ListViewHandle,
_In_ IListView* ListView,
_In_ PH_PROCESS_TOKEN_FLAG Flag,
_In_ BOOLEAN State,
_In_ PWSTR Name,
@@ -1042,30 +1052,30 @@ VOID PhpUpdateTokenDangerousFlagItem(
lvitem->ItemFlag = Flag;
lvitem->ItemFlagState = State;
lvItemIndex = PhAddListViewGroupItem(
ListViewHandle,
lvItemIndex = PhAddIListViewGroupItem(
ListView,
lvitem->ItemCategory,
MAXINT,
Name,
lvitem
);
PhSetListViewSubItem(
ListViewHandle,
PhSetIListViewSubItem(
ListView,
lvItemIndex,
PH_PROCESS_TOKEN_INDEX_STATUS,
State ? L"Enabled (modified)" : L"Disabled (modified)"
);
PhSetListViewSubItem(
ListViewHandle,
PhSetIListViewSubItem(
ListView,
lvItemIndex,
PH_PROCESS_TOKEN_INDEX_DESCRIPTION,
Description
);
PhSetListViewSubItem(
ListViewHandle,
PhSetIListViewSubItem(
ListView,
lvItemIndex,
PH_PROCESS_TOKEN_INDEX_SID,
PhaFormatUInt64(Flag, FALSE)->Buffer
@@ -1089,7 +1099,7 @@ BOOLEAN PhpUpdateTokenDangerousFlags(
if ((mandatoryPolicy.Policy & TOKEN_MANDATORY_POLICY_NO_WRITE_UP) == 0)
{
PhpUpdateTokenDangerousFlagItem(
ListViewHandle,
TokenPageContext->ListViewClass,
PH_PROCESS_TOKEN_FLAG_NO_WRITE_UP,
FALSE,
L"No-Write-Up Policy",
@@ -1104,7 +1114,7 @@ BOOLEAN PhpUpdateTokenDangerousFlags(
if (isSandboxInert)
{
PhpUpdateTokenDangerousFlagItem(
ListViewHandle,
TokenPageContext->ListViewClass,
PH_PROCESS_TOKEN_FLAG_SANDBOX_INERT,
TRUE,
L"Sandbox Inert",
@@ -1119,7 +1129,7 @@ BOOLEAN PhpUpdateTokenDangerousFlags(
if (isUIAccess)
{
PhpUpdateTokenDangerousFlagItem(
ListViewHandle,
TokenPageContext->ListViewClass,
PH_PROCESS_TOKEN_FLAG_UIACCESS,
TRUE,
L"UIAccess",
@@ -1304,6 +1314,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
HANDLE tokenHandle;
tokenPageContext->ListViewHandle = GetDlgItem(hwndDlg, IDC_GROUPS);
tokenPageContext->ListViewClass = PhGetListViewInterface(tokenPageContext->ListViewHandle);
PhSetListViewStyle(tokenPageContext->ListViewHandle, TRUE, TRUE);
PhSetControlTheme(tokenPageContext->ListViewHandle, L"explorer");
@@ -1447,7 +1458,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
ExtendedListView_SortItems(tokenPageContext->ListViewHandle);
ExtendedListView_SetRedraw(tokenPageContext->ListViewHandle, TRUE);
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
if (tokenPageContext->SinglePageContext)
@@ -1500,6 +1511,9 @@ INT_PTR CALLBACK PhpTokenPageProc(
if (tokenPageContext->Groups) PhFree(tokenPageContext->Groups);
if (tokenPageContext->RestrictedSids) PhFree(tokenPageContext->RestrictedSids);
if (tokenPageContext->Privileges) PhFree(tokenPageContext->Privileges);
if (tokenPageContext->ListViewClass)
IListView_Release(tokenPageContext->ListViewClass);
}
break;
case WM_SIZE:
@@ -1541,8 +1555,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
HANDLE tokenHandle;
ULONG i;
PhGetSelectedListViewItemParams(
tokenPageContext->ListViewHandle,
PhGetSelectedIListViewItemParams(
tokenPageContext->ListViewClass,
&listViewItems,
&numberOfItems
);
@@ -1632,8 +1646,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
newAttributes
))
{
LONG lvItemIndex = PhFindListViewItemByParam(
tokenPageContext->ListViewHandle,
LONG lvItemIndex = PhFindIListViewItemByParam(
tokenPageContext->ListViewClass,
INT_ERROR,
listViewItems[i]
);
@@ -1644,8 +1658,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
{
// Refresh the status text (and background color).
listViewItems[i]->TokenPrivilege->Attributes = newAttributes;
PhSetListViewSubItem(
tokenPageContext->ListViewHandle,
PhSetIListViewSubItem(
tokenPageContext->ListViewClass,
lvItemIndex,
PH_PROCESS_TOKEN_INDEX_STATUS,
PhGetPrivilegeAttributesString(newAttributes)
@@ -1693,7 +1707,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
ExtendedListView_SortItems(tokenPageContext->ListViewHandle);
ExtendedListView_SetRedraw(tokenPageContext->ListViewHandle, TRUE);
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
else
{
@@ -1714,8 +1728,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
HANDLE tokenHandle;
ULONG i;
PhGetSelectedListViewItemParams(
tokenPageContext->ListViewHandle,
PhGetSelectedIListViewItemParams(
tokenPageContext->ListViewClass,
&listViewItems,
&numberOfItems
);
@@ -1778,8 +1792,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
LONG lvItemIndex;
attributesString = PhGetGroupAttributesString(newAttributes, FALSE);
lvItemIndex = PhFindListViewItemByParam(
tokenPageContext->ListViewHandle,
lvItemIndex = PhFindIListViewItemByParam(
tokenPageContext->ListViewClass,
INT_ERROR,
listViewItems[i]
);
@@ -1788,8 +1802,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
{
// Refresh the status text (and background color).
listViewItems[i]->TokenGroup->Attributes = newAttributes;
PhSetListViewSubItem(
tokenPageContext->ListViewHandle,
PhSetIListViewSubItem(
tokenPageContext->ListViewClass,
lvItemIndex,
PH_PROCESS_TOKEN_INDEX_STATUS,
attributesString->Buffer
@@ -1828,7 +1842,11 @@ INT_PTR CALLBACK PhpTokenPageProc(
ExtendedListView_SortItems(tokenPageContext->ListViewHandle);
ExtendedListView_SetRedraw(tokenPageContext->ListViewHandle, TRUE);
NtClose(tokenHandle);
tokenPageContext->CloseObject(
tokenHandle,
FALSE,
tokenPageContext->Context
);
}
else
{
@@ -1891,8 +1909,8 @@ INT_PTR CALLBACK PhpTokenPageProc(
if (NT_SUCCESS(status))
{
LONG lvItemIndex = PhFindListViewItemByParam(
tokenPageContext->ListViewHandle,
LONG lvItemIndex = PhFindIListViewItemByParam(
tokenPageContext->ListViewClass,
INT_ERROR,
listViewItems[0]
);
@@ -1910,7 +1928,11 @@ INT_PTR CALLBACK PhpTokenPageProc(
ExtendedListView_SortItems(tokenPageContext->ListViewHandle);
ExtendedListView_SetRedraw(tokenPageContext->ListViewHandle, TRUE);
NtClose(tokenHandle);
tokenPageContext->CloseObject(
tokenHandle,
FALSE,
tokenPageContext->Context
);
}
else
{
@@ -1927,7 +1949,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
L"Default Token",
L"TokenDefault",
tokenPageContext->OpenObject,
NULL,
tokenPageContext->CloseObject,
tokenPageContext->Context // ProcessId
);
}
@@ -1939,7 +1961,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
L"Token",
L"Token",
tokenPageContext->OpenObject,
NULL,
tokenPageContext->CloseObject,
tokenPageContext->Context // ProcessId
);
}
@@ -2011,7 +2033,11 @@ INT_PTR CALLBACK PhpTokenPageProc(
}
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(
tokenHandle,
FALSE,
tokenPageContext->Context
);
}
if (!NT_SUCCESS(status))
@@ -2114,7 +2140,11 @@ INT_PTR CALLBACK PhpTokenPageProc(
ExtendedListView_SetRedraw(tokenPageContext->ListViewHandle, TRUE);
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(
tokenHandle,
FALSE,
tokenPageContext->Context
);
}
if (!NT_SUCCESS(status))
@@ -2148,7 +2178,11 @@ INT_PTR CALLBACK PhpTokenPageProc(
PhClearReference(&packageName);
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(
tokenHandle,
FALSE,
tokenPageContext->Context
);
}
PhpShowTokenAdvancedProperties(hwndDlg, tokenPageContext, tokenIsAppContainer);
@@ -2445,6 +2479,16 @@ static NTSTATUS PhpOpenLinkedToken(
return STATUS_UNSUCCESSFUL;
}
static NTSTATUS PhpCloseLinkedToken(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle) NtClose(Handle);
return STATUS_SUCCESS;
}
INT_PTR CALLBACK PhpTokenGeneralPageProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
@@ -2539,7 +2583,7 @@ INT_PTR CALLBACK PhpTokenGeneralPageProc(
tokenUIAccess = isUIAccessEnabled ? L"Enabled": L"Disabled";
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
if (NT_SUCCESS(tokenPageContext->OpenObject(
@@ -2563,7 +2607,7 @@ INT_PTR CALLBACK PhpTokenGeneralPageProc(
PhPrintPointer(tokenSourceLuid, UlongToPtr(tokenSource.SourceIdentifier.LowPart));
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
PhSetDialogItemText(hwndDlg, IDC_USER, PhGetStringOrDefault(tokenUserName, L"Unknown"));
@@ -2609,8 +2653,16 @@ INT_PTR CALLBACK PhpTokenGeneralPageProc(
tokenPageContext->Context // ProcessId
)))
{
PhShowTokenProperties(hwndDlg, PhpOpenLinkedToken, tokenPageContext->ProcessId, (PVOID)tokenHandle, L"Linked Token");
NtClose(tokenHandle);
PhShowTokenProperties(
hwndDlg,
PhpOpenLinkedToken,
PhpCloseLinkedToken,
tokenPageContext->ProcessId,
(PVOID)tokenHandle,
L"Linked Token"
);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
else
{
@@ -2645,6 +2697,7 @@ typedef struct _PHP_TOKEN_ADVANCED_CONTEXT
{
HWND WindowHandle;
HWND ListViewHandle;
IListView* ListView;
PH_LAYOUT_MANAGER LayoutManager;
} PHP_TOKEN_ADVANCED_CONTEXT, *PPHP_TOKEN_ADVANCED_CONTEXT;
@@ -2699,6 +2752,8 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc(
PPH_STRING tokenSystemIdForUser = NULL;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ListView = PhGetListViewInterface(context->ListViewHandle);
PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 120, L"Name");
@@ -2709,20 +2764,20 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc(
PhAddLayoutItem(&context->LayoutManager, context->ListViewHandle, NULL, PH_ANCHOR_ALL);
ListView_EnableGroupView(context->ListViewHandle, TRUE);
PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"General");
PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"LUIDs");
PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"Memory");
PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"Properties");
PhAddListViewGroupItem(context->ListViewHandle, 0, MAXINT, L"Type", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 0, MAXINT, L"Impersonation level", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"Token LUID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"Authentication LUID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"ModifiedId LUID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"Origin LUID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 2, MAXINT, L"Memory used", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 2, MAXINT, L"Memory available", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 3, MAXINT, L"Token object path", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 3, MAXINT, L"Token SDDL", NULL);
PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"General");
PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"LUIDs");
PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"Memory");
PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"Properties");
PhAddIListViewGroupItem(context->ListView, 0, MAXINT, L"Type", NULL);
PhAddIListViewGroupItem(context->ListView, 0, MAXINT, L"Impersonation level", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"Token LUID", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"Authentication LUID", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"ModifiedId LUID", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"Origin LUID", NULL);
PhAddIListViewGroupItem(context->ListView, 2, MAXINT, L"Memory used", NULL);
PhAddIListViewGroupItem(context->ListView, 2, MAXINT, L"Memory available", NULL);
PhAddIListViewGroupItem(context->ListView, 3, MAXINT, L"Token object path", NULL);
PhAddIListViewGroupItem(context->ListView, 3, MAXINT, L"Token SDDL", NULL);
if (NT_SUCCESS(tokenPageContext->OpenObject(
&tokenHandle,
@@ -2766,12 +2821,11 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc(
LONG trustLevelSidIndex;
LONG trustLevelNameIndex;
trustLevelGroupIndex = PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"TrustLevel");
trustLevelSidIndex = PhAddListViewGroupItem(context->ListViewHandle, trustLevelGroupIndex, MAXINT, L"TrustLevel Sid", NULL);
trustLevelNameIndex = PhAddListViewGroupItem(context->ListViewHandle, trustLevelGroupIndex, MAXINT, L"TrustLevel Name", NULL);
PhSetListViewSubItem(context->ListViewHandle, trustLevelSidIndex, 1, PhGetStringOrDefault(tokenTrustLevelSidString, L"N/A"));
PhSetListViewSubItem(context->ListViewHandle, trustLevelNameIndex, 1, PhGetStringOrDefault(tokenTrustLevelNameString, L"N/A"));
trustLevelGroupIndex = PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"TrustLevel");
trustLevelSidIndex = PhAddIListViewGroupItem(context->ListView, trustLevelGroupIndex, MAXINT, L"TrustLevel Sid", NULL);
trustLevelNameIndex = PhAddIListViewGroupItem(context->ListView, trustLevelGroupIndex, MAXINT, L"TrustLevel Name", NULL);
PhSetIListViewSubItem(context->ListView, trustLevelSidIndex, 1, PhGetStringOrDefault(tokenTrustLevelSidString, L"N/A"));
PhSetIListViewSubItem(context->ListView, trustLevelNameIndex, 1, PhGetStringOrDefault(tokenTrustLevelNameString, L"N/A"));
PhClearReference(&tokenTrustLevelNameString);
PhClearReference(&tokenTrustLevelSidString);
@@ -2796,22 +2850,22 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc(
LONG profileFolderIndex;
LONG profileRegistryIndex;
profileGroupIndex = PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"Profile");
profileFolderIndex = PhAddListViewGroupItem(context->ListViewHandle, profileGroupIndex, MAXINT, L"Folder path", NULL);
profileRegistryIndex = PhAddListViewGroupItem(context->ListViewHandle, profileGroupIndex, MAXINT, L"Registry path", NULL);
profileGroupIndex = PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"Profile");
profileFolderIndex = PhAddIListViewGroupItem(context->ListView, profileGroupIndex, MAXINT, L"Folder path", NULL);
profileRegistryIndex = PhAddIListViewGroupItem(context->ListView, profileGroupIndex, MAXINT, L"Registry path", NULL);
PhSetListViewSubItem(context->ListViewHandle, profileFolderIndex, 1, PhGetStringOrDefault(tokenProfilePathString, L"N/A"));
PhSetIListViewSubItem(context->ListView, profileFolderIndex, 1, PhGetStringOrDefault(tokenProfilePathString, L"N/A"));
if (tokenProfileRegistryString = PhpGetTokenRegistryPath(tokenHandle))
{
PhSetListViewSubItem(context->ListViewHandle, profileRegistryIndex, 1, PhGetStringOrDefault(tokenProfileRegistryString, L"N/A"));
PhSetIListViewSubItem(context->ListView, profileRegistryIndex, 1, PhGetStringOrDefault(tokenProfileRegistryString, L"N/A"));
PhDereferenceObject(tokenProfileRegistryString);
}
PhDereferenceObject(tokenProfilePathString);
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
if (SUCCEEDED(PhGetProcessSystemIdentification(
@@ -2824,27 +2878,27 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc(
LONG systemIdPublisherIndex;
LONG systemIdUserIndex;
systemIdGroupIndex = PhAddListViewGroup(context->ListViewHandle, listViewGroupIndex++, L"System ID");
systemIdPublisherIndex = PhAddListViewGroupItem(context->ListViewHandle, systemIdGroupIndex, MAXINT, L"HWID (Publisher)", NULL);
systemIdUserIndex = PhAddListViewGroupItem(context->ListViewHandle, systemIdGroupIndex, MAXINT, L"HWID (User)", NULL);
systemIdGroupIndex = PhAddIListViewGroup(context->ListView, listViewGroupIndex++, L"System ID");
systemIdPublisherIndex = PhAddIListViewGroupItem(context->ListView, systemIdGroupIndex, MAXINT, L"HWID (Publisher)", NULL);
systemIdUserIndex = PhAddIListViewGroupItem(context->ListView, systemIdGroupIndex, MAXINT, L"HWID (User)", NULL);
PhSetListViewSubItem(context->ListViewHandle, systemIdPublisherIndex, 1, PhGetStringOrDefault(tokenSystemIdForPublisher, L"N/A"));
PhSetListViewSubItem(context->ListViewHandle, systemIdUserIndex, 1, PhGetStringOrDefault(tokenSystemIdForUser, L"N/A"));
PhSetIListViewSubItem(context->ListView, systemIdPublisherIndex, 1, PhGetStringOrDefault(tokenSystemIdForPublisher, L"N/A"));
PhSetIListViewSubItem(context->ListView, systemIdUserIndex, 1, PhGetStringOrDefault(tokenSystemIdForUser, L"N/A"));
PhClearReference(&tokenSystemIdForPublisher);
PhClearReference(&tokenSystemIdForUser);
}
PhSetListViewSubItem(context->ListViewHandle, 0, 1, tokenType);
PhSetListViewSubItem(context->ListViewHandle, 1, 1, tokenImpersonationLevel);
PhSetListViewSubItem(context->ListViewHandle, 2, 1, tokenLuid);
PhSetListViewSubItem(context->ListViewHandle, 3, 1, authenticationLuid);
PhSetListViewSubItem(context->ListViewHandle, 4, 1, tokenModifiedLuid);
PhSetListViewSubItem(context->ListViewHandle, 5, 1, tokenOriginLogonSession);
PhSetListViewSubItem(context->ListViewHandle, 6, 1, PhGetStringOrDefault(memoryUsed, L"Unknown"));
PhSetListViewSubItem(context->ListViewHandle, 7, 1, PhGetStringOrDefault(memoryAvailable, L"Unknown"));
PhSetListViewSubItem(context->ListViewHandle, 8, 1, PhGetStringOrDefault(tokenNamedObjectPathString, L"Unknown"));
PhSetListViewSubItem(context->ListViewHandle, 9, 1, PhGetStringOrDefault(tokenSecurityDescriptorString, L"Unknown"));
PhSetIListViewSubItem(context->ListView, 0, 1, tokenType);
PhSetIListViewSubItem(context->ListView, 1, 1, tokenImpersonationLevel);
PhSetIListViewSubItem(context->ListView, 2, 1, tokenLuid);
PhSetIListViewSubItem(context->ListView, 3, 1, authenticationLuid);
PhSetIListViewSubItem(context->ListView, 4, 1, tokenModifiedLuid);
PhSetIListViewSubItem(context->ListView, 5, 1, tokenOriginLogonSession);
PhSetIListViewSubItem(context->ListView, 6, 1, PhGetStringOrDefault(memoryUsed, L"Unknown"));
PhSetIListViewSubItem(context->ListView, 7, 1, PhGetStringOrDefault(memoryAvailable, L"Unknown"));
PhSetIListViewSubItem(context->ListView, 8, 1, PhGetStringOrDefault(tokenNamedObjectPathString, L"Unknown"));
PhSetIListViewSubItem(context->ListView, 9, 1, PhGetStringOrDefault(tokenSecurityDescriptorString, L"Unknown"));
PhClearReference(&memoryUsed);
PhClearReference(&memoryAvailable);
@@ -3258,7 +3312,7 @@ BOOLEAN PhpAddTokenCapabilities(
}
}
NtClose(tokenHandle);
TokenPageContext->CloseObject(tokenHandle, FALSE, TokenPageContext->Context);
return TRUE;
}
@@ -3670,7 +3724,7 @@ BOOLEAN PhpAddTokenClaimAttributes(
PhFree(info);
}
NtClose(tokenHandle);
TokenPageContext->CloseObject(tokenHandle, FALSE, TokenPageContext->Context);
return TRUE;
}
@@ -3847,7 +3901,7 @@ BOOLEAN PhpAddTokenAttributes(
PhFree(info);
}
NtClose(tokenHandle);
TokenPageContext->CloseObject(tokenHandle, FALSE, TokenPageContext->Context);
return TRUE;
}
@@ -4248,6 +4302,7 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
PPH_STRING tokenNamedObjectPathString = NULL;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ListView = PhGetListViewInterface(context->ListViewHandle);
PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
@@ -4259,24 +4314,24 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
PhAddLayoutItem(&context->LayoutManager, context->ListViewHandle, NULL, PH_ANCHOR_ALL);
ListView_EnableGroupView(context->ListViewHandle, TRUE);
PhAddListViewGroup(context->ListViewHandle, 0, L"General");
PhAddListViewGroup(context->ListViewHandle, 1, L"Properties");
PhAddListViewGroup(context->ListViewHandle, 2, L"Parent");
PhAddListViewGroup(context->ListViewHandle, 3, L"Package");
PhAddListViewGroup(context->ListViewHandle, 4, L"Profile");
PhAddIListViewGroup(context->ListView, 0, L"General");
PhAddIListViewGroup(context->ListView, 1, L"Properties");
PhAddIListViewGroup(context->ListView, 2, L"Parent");
PhAddIListViewGroup(context->ListView, 3, L"Package");
PhAddIListViewGroup(context->ListView, 4, L"Profile");
PhAddListViewGroupItem(context->ListViewHandle, 0, MAXINT, L"Name", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 0, MAXINT, L"Type", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 0, MAXINT, L"SID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"Number", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"LPAC", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 1, MAXINT, L"Token object path", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 2, MAXINT, L"Name", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 2, MAXINT, L"SID", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 3, MAXINT, L"Name", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 3, MAXINT, L"Path", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 4, MAXINT, L"Folder path", NULL);
PhAddListViewGroupItem(context->ListViewHandle, 4, MAXINT, L"Registry path", NULL);
PhAddIListViewGroupItem(context->ListView, 0, MAXINT, L"Name", NULL);
PhAddIListViewGroupItem(context->ListView, 0, MAXINT, L"Type", NULL);
PhAddIListViewGroupItem(context->ListView, 0, MAXINT, L"SID", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"Number", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"LPAC", NULL);
PhAddIListViewGroupItem(context->ListView, 1, MAXINT, L"Token object path", NULL);
PhAddIListViewGroupItem(context->ListView, 2, MAXINT, L"Name", NULL);
PhAddIListViewGroupItem(context->ListView, 2, MAXINT, L"SID", NULL);
PhAddIListViewGroupItem(context->ListView, 3, MAXINT, L"Name", NULL);
PhAddIListViewGroupItem(context->ListView, 3, MAXINT, L"Path", NULL);
PhAddIListViewGroupItem(context->ListView, 4, MAXINT, L"Folder path", NULL);
PhAddIListViewGroupItem(context->ListView, 4, MAXINT, L"Registry path", NULL);
if (NT_SUCCESS(tokenPageContext->OpenObject(
&tokenHandle,
@@ -4306,23 +4361,23 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
if (appContainerName)
{
PhSetListViewSubItem(context->ListViewHandle, 0, 1, appContainerName->Buffer);
PhSetIListViewSubItem(context->ListView, 0, 1, appContainerName->Buffer);
PhDereferenceObject(appContainerName);
}
switch (appContainerSidType)
{
case ChildAppContainerSidType:
PhSetListViewSubItem(context->ListViewHandle, 1, 1, L"Child");
PhSetIListViewSubItem(context->ListView, 1, 1, L"Child");
break;
case ParentAppContainerSidType:
PhSetListViewSubItem(context->ListViewHandle, 1, 1, L"Parent");
PhSetIListViewSubItem(context->ListView, 1, 1, L"Parent");
break;
}
if (appContainerSidString)
{
PhSetListViewSubItem(context->ListViewHandle, 2, 1, appContainerSidString->Buffer);
PhSetIListViewSubItem(context->ListView, 2, 1, appContainerSidString->Buffer);
PhDereferenceObject(appContainerSidString);
}
@@ -4333,16 +4388,16 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
WCHAR string[PH_INT64_STR_LEN_1] = L"Unknown";
PhPrintUInt32(string, appContainerNumber);
PhSetListViewSubItem(context->ListViewHandle, 3, 1, string);
PhSetIListViewSubItem(context->ListView, 3, 1, string);
}
PhGetTokenIsLessPrivilegedAppContainer(tokenHandle, &isLessPrivilegedAppContainer);
PhSetListViewSubItem(context->ListViewHandle, 4, 1, isLessPrivilegedAppContainer ? L"True" : L"False");
PhSetIListViewSubItem(context->ListView, 4, 1, isLessPrivilegedAppContainer ? L"True" : L"False");
}
if (NT_SUCCESS(PhGetAppContainerNamedObjectPath(tokenHandle, NULL, FALSE, &tokenNamedObjectPathString)))
{
PhSetListViewSubItem(context->ListViewHandle, 5, 1, PhGetStringOrDefault(tokenNamedObjectPathString, L"Unknown"));
PhSetIListViewSubItem(context->ListView, 5, 1, PhGetStringOrDefault(tokenNamedObjectPathString, L"Unknown"));
PhDereferenceObject(tokenNamedObjectPathString);
}
@@ -4350,13 +4405,13 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
{
if (appContainerName = PhGetAppContainerName(appContainerSidParent))
{
PhSetListViewSubItem(context->ListViewHandle, 6, 1, appContainerName->Buffer);
PhSetIListViewSubItem(context->ListView, 6, 1, appContainerName->Buffer);
PhDereferenceObject(appContainerName);
}
if (appContainerSidString = PhSidToStringSid(appContainerSidParent))
{
PhSetListViewSubItem(context->ListViewHandle, 7, 1, appContainerSidString->Buffer);
PhSetIListViewSubItem(context->ListView, 7, 1, appContainerSidString->Buffer);
PhDereferenceObject(appContainerSidString);
}
@@ -4365,18 +4420,18 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
if (packageFullName = PhGetTokenPackageFullName(tokenHandle))
{
PhSetListViewSubItem(context->ListViewHandle, 8, 1, packageFullName->Buffer);
PhSetIListViewSubItem(context->ListView, 8, 1, packageFullName->Buffer);
if (packagePath = PhGetPackagePath(packageFullName))
{
PhSetListViewSubItem(context->ListViewHandle, 9, 1, packagePath->Buffer);
PhSetIListViewSubItem(context->ListView, 9, 1, packagePath->Buffer);
PhDereferenceObject(packagePath);
}
PhDereferenceObject(packageFullName);
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
tokenHandle = NULL;
@@ -4424,7 +4479,7 @@ INT_PTR CALLBACK PhpTokenContainerPageProc(
PhDereferenceObject(appContainerRegistryPath);
}
NtClose(tokenHandle);
tokenPageContext->CloseObject(tokenHandle, FALSE, tokenPageContext->Context);
}
PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
@@ -4572,7 +4627,8 @@ typedef enum _AppModelPolicy_Type
AppModelPolicy_Type_AppInstancingErrorBehavior = 56, // since WIN11
AppModelPolicy_Type_BackgroundTaskRegistrationType = 57,
AppModelPolicy_Type_ModsPowerNotification = 58,
AppModelPolicy_Type_Count = 58,
AppModelPolicy_Type_DamRegistration = 59, // since 24H2
AppModelPolicy_Type_Count = 59,
} AppModelPolicy_Type;
typedef enum _AppModelPolicy_PolicyValue
@@ -4706,6 +4762,8 @@ typedef enum _AppModelPolicy_PolicyValue
AppModelPolicy_Type_ModsPowerNotification_Disabled = 0x3a0000,
AppModelPolicy_Type_ModsPowerNotification_Enabled = 0x3a0001,
AppModelPolicy_Type_ModsPowerNotification_QueryDam = 0x3a0002,
AppModelPolicy_Type_DamRegistration_DoNotRegister = 0x3B0000,
AppModelPolicy_Type_DamRegistration_RegisterAtLaunch = 0x3B0001,
} AppModelPolicy_PolicyValue;
#define WM_PH_APPMODEL_SYMBOL_RESULT (WM_APP + 101)
@@ -4736,15 +4794,15 @@ NTSTATUS PhGetAppModelPolicy(
if (PhGetLoaderEntryDataZ(L"kernelbase.dll", &baseAddress, &sizeOfImage, &fileName))
{
PhLoadModuleSymbolProvider(symbolProvider, fileName, (ULONG64)baseAddress, sizeOfImage);
PhLoadModuleSymbolProvider(symbolProvider, fileName, baseAddress, sizeOfImage);
PhDereferenceObject(fileName);
}
if (PhGetSymbolFromName(symbolProvider, L"GetAppModelPolicy", &symbolInfo))
{
if (NT_SUCCESS(PhGuardGrantSuppressedCallAccess(NtCurrentProcess(), (PVOID)symbolInfo.Address)))
if (NT_SUCCESS(PhGuardGrantSuppressedCallAccess(NtCurrentProcess(), symbolInfo.Address)))
{
GetAppModelPolicy_I = (PVOID)symbolInfo.Address;
GetAppModelPolicy_I = symbolInfo.Address;
}
}
@@ -5721,7 +5779,7 @@ VOID PhEnumTokenAppModelPolicy(
}
}
NtClose(TokenHandle);
TokenPageContext->CloseObject(TokenHandle, FALSE, TokenPageContext->Context);
}
#define SORT_FUNCTION(Column) PhpAppPolicyTreeNewCompare##Column
+7 -1
View File
@@ -9,6 +9,12 @@ if not exist %BUILD_TOOL% (
exit /b 1
)
start /B /W "" %BUILD_TOOL% "-sdk"
REM start /B /W "" %BUILD_TOOL% "-sdk" "-Debug" "-Win32"
REM start /B /W "" %BUILD_TOOL% "-sdk" "-Debug" "-x64"
REM start /B /W "" %BUILD_TOOL% "-sdk" "-Debug" "-arm64"
REM start /B /W "" %BUILD_TOOL% "-sdk" "-Release" "-Win32"
start /B /W "" %BUILD_TOOL% "-sdk" "-Release" "-x64"
REM start /B /W "" %BUILD_TOOL% "-sdk" "-Release" "-arm64"
pause
+7 -2
View File
@@ -27,11 +27,16 @@ VOID KphMsgQuerySystemTime(
#ifdef _KERNEL_MODE
KeQuerySystemTime(SystemTime);
#else
do
while (TRUE)
{
SystemTime->HighPart = USER_SHARED_DATA->SystemTime.High1Time;
SystemTime->LowPart = USER_SHARED_DATA->SystemTime.LowPart;
} while (SystemTime->HighPart != USER_SHARED_DATA->SystemTime.High2Time);
if (SystemTime->HighPart == USER_SHARED_DATA->SystemTime.High2Time)
break;
YieldProcessor();
}
#endif
}
+2 -3
View File
@@ -54,7 +54,7 @@ PVOID PhpImportProcedure(
{
if (procedure = PhGetDllBaseProcedureAddress(module, ProcedureName, 0))
{
*Cookie = (ULONG_PTR)NtGetTickCount64();
*Cookie = (ULONG_PTR)PhReadTimeStampCounter();
*Cache = (PVOID)((ULONG_PTR)procedure ^ (ULONG_PTR)*Cookie);
}
}
@@ -111,7 +111,7 @@ PVOID PhpImportProcedureNative(
&procedure
)))
{
*Cookie = (ULONG_PTR)NtGetTickCount64();
*Cookie = (ULONG_PTR)PhReadTimeStampCounter();
*Cache = (PVOID)((ULONG_PTR)procedure ^ (ULONG_PTR)*Cookie);
}
}
@@ -193,7 +193,6 @@ PH_DEFINE_IMPORT(L"userenv.dll", DestroyEnvironmentBlock);
PH_DEFINE_IMPORT(L"userenv.dll", GetAppContainerRegistryLocation);
PH_DEFINE_IMPORT(L"userenv.dll", GetAppContainerFolderPath);
PH_DEFINE_IMPORT(L"user32.dll", SetWindowDisplayAffinity);
PH_DEFINE_IMPORT(L"user32.dll", ConsoleControl);
// CRT
+10 -10
View File
@@ -35,9 +35,9 @@ static PVOID PhpQueryAppResolverInterface(
if (PhBeginInitOnce(&initOnce))
{
if (WindowsVersion < WINDOWS_8)
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IApplicationResolver61_I, &resolverInterface);
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IApplicationResolver_I, &resolverInterface);
else
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IApplicationResolver62_I, &resolverInterface);
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IApplicationResolver2_I, &resolverInterface);
PhEndInitOnce(&initOnce);
}
@@ -60,9 +60,9 @@ static PVOID PhpQueryStartMenuCacheInterface(
if (PhBeginInitOnce(&initOnce))
{
if (WindowsVersion < WINDOWS_8)
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IStartMenuAppItems61_I, &startMenuInterface);
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IStartMenuAppItems_I, &startMenuInterface);
else
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IStartMenuAppItems62_I, &startMenuInterface);
PhGetClassObject(L"appresolver.dll", &CLSID_StartMenuCacheAndAppResolver_I, &IID_IStartMenuAppItems2_I, &startMenuInterface);
PhEndInitOnce(&initOnce);
}
@@ -134,7 +134,7 @@ HRESULT PhAppResolverGetAppIdForProcess(
if (WindowsVersion < WINDOWS_8)
{
status = IApplicationResolver_GetAppIDForProcess(
(IApplicationResolver61*)resolverInterface,
(IApplicationResolver*)resolverInterface,
HandleToUlong(ProcessId),
&appIdText,
NULL,
@@ -145,7 +145,7 @@ HRESULT PhAppResolverGetAppIdForProcess(
else
{
status = IApplicationResolver2_GetAppIDForProcess(
(IApplicationResolver62*)resolverInterface,
(IApplicationResolver2*)resolverInterface,
HandleToUlong(ProcessId),
&appIdText,
NULL,
@@ -210,7 +210,7 @@ HRESULT PhAppResolverGetAppIdForWindow(
if (WindowsVersion < WINDOWS_8)
{
status = IApplicationResolver_GetAppIDForWindow(
(IApplicationResolver61*)resolverInterface,
(IApplicationResolver*)resolverInterface,
WindowHandle,
&appIdText,
NULL,
@@ -221,7 +221,7 @@ HRESULT PhAppResolverGetAppIdForWindow(
else
{
status = IApplicationResolver_GetAppIDForWindow(
(IApplicationResolver62*)resolverInterface,
(IApplicationResolver2*)resolverInterface,
WindowHandle,
&appIdText,
NULL,
@@ -1232,7 +1232,7 @@ HRESULT PhAppResolverGetPackageStartMenuPropertyStore(
if (WindowsVersion < WINDOWS_8)
{
status = IStartMenuAppItems_GetItem(
(IStartMenuAppItems61*)startMenuInterface,
(IStartMenuAppItems*)startMenuInterface,
SMAIF_DEFAULT,
PhGetString(applicationUserModelId),
&IID_IPropertyStore,
@@ -1242,7 +1242,7 @@ HRESULT PhAppResolverGetPackageStartMenuPropertyStore(
else
{
status = IStartMenuAppItems2_GetItem(
(IStartMenuAppItems62*)startMenuInterface,
(IStartMenuAppItems2*)startMenuInterface,
SMAIF_DEFAULT,
PhGetString(applicationUserModelId),
&IID_IPropertyStore,
+13 -13
View File
@@ -13,7 +13,7 @@
#include <mapldr.h>
#include <appresolver.h>
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
#pragma comment(lib, "runtimeobject.lib")
#include <roapi.h>
#include <winstring.h>
@@ -36,7 +36,7 @@ PPH_STRING PhCreateStringFromWindowsRuntimeString(
_In_ HSTRING String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
UINT32 stringLength;
PCWSTR string;
@@ -44,7 +44,7 @@ PPH_STRING PhCreateStringFromWindowsRuntimeString(
{
if (stringLength >= sizeof(UNICODE_NULL))
{
return PhCreateStringEx((PWCHAR)string, stringLength * sizeof(WCHAR));
return PhCreateStringEx(string, stringLength * sizeof(WCHAR));
}
}
#else
@@ -52,7 +52,7 @@ PPH_STRING PhCreateStringFromWindowsRuntimeString(
if (string && string->Length >= sizeof(UNICODE_NULL))
{
return PhCreateStringEx((PWCHAR)string->Buffer, string->Length * sizeof(WCHAR));
return PhCreateStringEx(string->Buffer, string->Length * sizeof(WCHAR));
}
#endif
@@ -73,7 +73,7 @@ HRESULT PhCreateWindowsRuntimeStringReference(
_Out_ PVOID String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
HSTRING stringHandle;
return WindowsCreateStringReference(
@@ -109,7 +109,7 @@ HRESULT PhCreateWindowsRuntimeStringReferenceEx(
_Out_ PVOID String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
HSTRING stringHandle;
return WindowsCreateStringReference(
@@ -143,7 +143,7 @@ HRESULT PhCreateWindowsRuntimeString(
_Out_ HSTRING* String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
return WindowsCreateString(
SourceString,
(UINT32)PhCountStringZ(SourceString),
@@ -189,7 +189,7 @@ VOID PhDeleteWindowsRuntimeString(
_In_opt_ HSTRING String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
WindowsDeleteString(String);
#else
HSTRING_INSTANCE* string = (HSTRING_INSTANCE*)String;
@@ -217,11 +217,11 @@ VOID PhDeleteWindowsRuntimeString(
*
* \return Successful or errant status.
*/
UINT32 PhGetWindowsRuntimeStringLength(
ULONG PhGetWindowsRuntimeStringLength(
_In_opt_ HSTRING String
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
return WindowsGetStringLen(String);
#else
HSTRING_INSTANCE* string = (HSTRING_INSTANCE*)String;
@@ -246,10 +246,10 @@ UINT32 PhGetWindowsRuntimeStringLength(
*/
PCWSTR PhGetWindowsRuntimeStringBuffer(
_In_opt_ HSTRING String,
_Out_opt_ PUINT32 Length
_Out_opt_ PULONG Length
)
{
#if (PH_NATIVE_WINDOWS_RUNTIME_STRING)
#if defined(PH_NATIVE_WINDOWS_RUNTIME_STRING)
return WindowsGetStringRawBuffer(String, Length);
#else
HSTRING_INSTANCE* string = (HSTRING_INSTANCE*)String;
@@ -323,7 +323,7 @@ PPH_STRING PhDataReaderBufferToHexString(
PPH_STRING string = NULL;
__x_ABI_CWindows_CStorage_CStreams_CIDataReaderStatics* dataReaderStatics;
__x_ABI_CWindows_CStorage_CStreams_CIDataReader* dataReader;
UINT32 dataBufferLength = 0;
ULONG dataBufferLength = 0;
UCHAR dataBuffer[128] = { 0 };
if (SUCCEEDED(__x_ABI_CWindows_CStorage_CStreams_CIBuffer_get_Length(Buffer, &dataBufferLength)) && dataBufferLength < sizeof(dataBuffer))
+299 -125
View File
@@ -52,16 +52,23 @@
*/
#include <phbase.h>
#include <math.h>
#include <objbase.h>
#include <phintrnl.h>
#include <phnative.h>
#include <phnativeinl.h>
#include <phintrin.h>
#include <circbuf.h>
#ifndef PH_NATIVE_STRING_CONVERSION
#define PH_NATIVE_STRING_CONVERSION 1
#endif
#ifndef PH_NATIVE_THREAD_CREATE
#define PH_NATIVE_THREAD_CREATE 1
#endif
#ifndef PHNT_NATIVE_TIME
#define PHNT_NATIVE_TIME 1
#endif
typedef struct _PHP_BASE_THREAD_CONTEXT
{
@@ -201,11 +208,12 @@ NTSTATUS PhpBaseThreadStart(
}
/**
* \brief Creates a thread.
* Creates a thread.
*
* \param ProcessHandle A handle to the process in which the thread is to be created.
* \param ThreadSecurityDescriptor A pointer to a security descriptor for the new thread and
* \a determines whether child processes can inherit the thread handle.
* \param DesiredAccess The desired access to the thread.
* \param CreateFlags The flags that control the creation of the thread.
* \param ZeroBits The number of high-order address bits that must be zero.
* \a If this parameter is zero, the new thread uses the default for the executable.
@@ -223,6 +231,7 @@ NTSTATUS PhpBaseThreadStart(
NTSTATUS 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,
@@ -233,20 +242,7 @@ NTSTATUS PhCreateUserThread(
_Out_opt_ PCLIENT_ID ClientId
)
{
#if (PH_NATIVE_THREAD_CREATE)
return RtlCreateUserThread(
ProcessHandle,
ThreadSecurityDescriptor,
BooleanFlagOn(CreateFlags, THREAD_CREATE_FLAGS_CREATE_SUSPENDED),
(ULONG)ZeroBits,
MaximumStackSize,
StackSize,
StartRoutine,
Argument,
ThreadHandle,
ClientId
);
#else
#if defined(PH_NATIVE_THREAD_CREATE)
NTSTATUS status;
HANDLE threadHandle;
OBJECT_ATTRIBUTES objectAttributes;
@@ -263,7 +259,7 @@ NTSTATUS PhCreateUserThread(
status = NtCreateThreadEx(
&threadHandle,
THREAD_ALL_ACCESS,
DesiredAccess,
&objectAttributes,
ProcessHandle,
StartRoutine,
@@ -293,6 +289,19 @@ NTSTATUS PhCreateUserThread(
}
return status;
#else
return RtlCreateUserThread(
ProcessHandle,
ThreadSecurityDescriptor,
BooleanFlagOn(CreateFlags, THREAD_CREATE_FLAGS_CREATE_SUSPENDED),
(ULONG)ZeroBits,
MaximumStackSize,
StackSize,
StartRoutine,
Argument,
ThreadHandle,
ClientId
);
#endif
}
@@ -320,6 +329,7 @@ HANDLE PhCreateThread(
status = PhCreateUserThread(
NtCurrentProcess(),
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -360,6 +370,7 @@ NTSTATUS PhCreateThreadEx(
status = PhCreateUserThread(
NtCurrentProcess(),
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -399,6 +410,7 @@ NTSTATUS PhCreateThread2(
status = PhCreateUserThread(
NtCurrentProcess(),
NULL,
THREAD_ALL_ACCESS,
0,
0,
0,
@@ -467,6 +479,79 @@ NTSTATUS PhQueueUserWorkItem(
return status;
}
/**
* Reads the time stamp counter.
*
* This function reads the time stamp counter using the `__rdtscp` instruction,
* which is a serializing variant of the `rdtsc` instruction. It also includes
* a memory fence to ensure proper ordering of memory operations.
* @return The current value of the time stamp counter.
*/
ULONGLONG PhReadTimeStampCounter(
VOID
)
{
#if defined(PHNT_NATIVE_TIME)
ULONG64 value;
value = ReadTimeStampCounter();
SpeculationFence();
#else
ULONG64 value;
ULONG index;
value = __rdtscp(&index);
#endif
return value;
}
// 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 defined(PH_WIN32_PERFCOUNTER)
return !!QueryPerformanceCounter(PerformanceCounter);
#elif defined(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 defined(PH_WIN32_PERFCOUNTER)
return !!QueryPerformanceFrequency(PerformanceFrequency);
#elif defined(PH_NATIVE_PERFCOUNTER)
LARGE_INTEGER performanceCounter;
return NT_SUCCESS(NtQueryPerformanceCounter(&performanceCounter, PerformanceFrequency));
#else
return !!RtlQueryPerformanceFrequency(PerformanceFrequency);
#endif
}
/**
* Gets the current interrupt-time count.
*/
@@ -474,11 +559,7 @@ VOID PhQueryInterruptTime(
_Out_ PULARGE_INTEGER InterruptTime
)
{
#ifdef _WIN64
InterruptTime->QuadPart = *(volatile ULONG64*)&USER_SHARED_DATA->InterruptTime;
#else
#if defined(PHNT_NATIVE_TIME)
while (TRUE)
{
@@ -491,6 +572,22 @@ VOID PhQueryInterruptTime(
YieldProcessor();
}
#elif defined(PHNT_SYSTEM_TIME)
ULONGLONG interruptTime;
QueryInterruptTime(&interruptTime);
InterruptTime->QuadPart = interruptTime;
#else
do
{
InterruptTime->HighPart = (ULONG)UUSER_SHARED_DATA->InterruptTime.High1Time;
InterruptTime->LowPart = USER_SHARED_DATA->InterruptTime.LowPart;
} while (InterruptTime->HighPart != (ULONG)UUSER_SHARED_DATA->InterruptTime.High2Time);
#endif
}
@@ -503,12 +600,7 @@ VOID PhQuerySystemTime(
_Out_ PLARGE_INTEGER SystemTime
)
{
#ifndef PHNT_NATIVE_TIME
#ifdef _WIN64
SystemTime->QuadPart = *(volatile ULONG64*)&USER_SHARED_DATA->SystemTime;
#else
#if defined(PHNT_NATIVE_TIME)
while (TRUE)
{
@@ -521,7 +613,17 @@ VOID PhQuerySystemTime(
YieldProcessor();
}
#endif
#elif defined(PHNT_SYSTRM_TIME)
SYSTEMTIME systemTime;
FILETIME fileTime;
GetSystemTime(&systemTime);
SystemTimeToFileTime(&systemTime, &fileTime);
SystemTime->LowPart = fileTime.dwLowDateTime;
SystemTime->HighPart = fileTime.dwHighDateTime;
#else
do
@@ -542,12 +644,7 @@ VOID PhQueryTimeZoneBias(
_Out_ PLARGE_INTEGER TimeZoneBias
)
{
#ifndef PHNT_NATIVE_TIME
#ifdef _WIN64
TimeZoneBias->QuadPart = *(volatile ULONG64*)&USER_SHARED_DATA->TimeZoneBias;
#else
#if defined(PHNT_NATIVE_TIME)
while (TRUE)
{
@@ -560,21 +657,19 @@ VOID PhQueryTimeZoneBias(
YieldProcessor();
}
#endif
#else
#elif defined(PHNT_SYSTEM_TIME)
#if (PHNT_NATIVE_TIME)
SYSTEM_TIMEOFDAY_INFORMATION timeOfDayInfo;
SYSTEM_TIMEOFDAY_INFORMATION timeOfDayInfo = { 0 };
if (NT_SUCCESS(NtQuerySystemInformation(
NtQuerySystemInformation(
SystemTimeOfDayInformation,
&timeOfDayInfo,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL
)))
{
TimeZoneBias->QuadPart = timeOfDayInfo.TimeZoneBias.QuadPart;
}
);
TimeZoneBias->QuadPart = timeOfDayInfo.TimeZoneBias.QuadPart;
#else
do
@@ -583,8 +678,6 @@ VOID PhQueryTimeZoneBias(
TimeZoneBias->LowPart = USER_SHARED_DATA->TimeZoneBias.LowPart;
} while (TimeZoneBias->HighPart != USER_SHARED_DATA->TimeZoneBias.High2Time);
#endif
#endif
}
@@ -603,15 +696,15 @@ VOID PhSystemTimeToLocalTime(
_Out_ PLARGE_INTEGER LocalTime
)
{
#if (PHNT_NATIVE_TIME)
RtlSystemTimeToLocalTime(SystemTime, LocalTime);
#else
#if defined(PHNT_NATIVE_TIME)
LARGE_INTEGER timeZoneBias;
PhQueryTimeZoneBias(&timeZoneBias);
LocalTime->QuadPart = SystemTime->QuadPart - timeZoneBias.QuadPart;
#else
RtlSystemTimeToLocalTime(SystemTime, LocalTime);
#endif
}
@@ -630,15 +723,15 @@ VOID PhLocalTimeToSystemTime(
_Out_ PLARGE_INTEGER SystemTime
)
{
#if (PHNT_NATIVE_TIME)
RtlLocalTimeToSystemTime(LocalTime, SystemTime);
#else
#if defined(PHNT_NATIVE_TIME)
LARGE_INTEGER timeZoneBias;
PhQueryTimeZoneBias(&timeZoneBias);
SystemTime->QuadPart = LocalTime->QuadPart + timeZoneBias.QuadPart;
#else
RtlLocalTimeToSystemTime(LocalTime, SystemTime);
#endif
}
@@ -647,13 +740,11 @@ BOOLEAN PhTimeToSecondsSince1980(
_Out_ PULONG ElapsedSeconds
)
{
#if (PHNT_NATIVE_TIME)
return RtlTimeToSecondsSince1980(Time, ElapsedSeconds);
#else
ULARGE_INTEGER time;
#if defined(PHNT_NATIVE_TIME)
LARGE_INTEGER time;
time.QuadPart = Time->QuadPart - (SecondsToStartOf1980 * PH_TICKS_PER_SEC);
time.QuadPart = time.QuadPart / PH_TICKS_PER_SEC;
time.QuadPart /= PH_TICKS_PER_SEC;
if (time.HighPart)
{
@@ -663,6 +754,8 @@ BOOLEAN PhTimeToSecondsSince1980(
*ElapsedSeconds = time.LowPart;
return TRUE;
#else
return RtlTimeToSecondsSince1980(Time, ElapsedSeconds);
#endif
}
@@ -671,13 +764,11 @@ BOOLEAN PhTimeToSecondsSince1970(
_Out_ PULONG ElapsedSeconds
)
{
#if (PHNT_NATIVE_TIME)
return RtlTimeToSecondsSince1970(Time, ElapsedSeconds);
#else
ULARGE_INTEGER time;
#if defined(PHNT_NATIVE_TIME)
LARGE_INTEGER time;
time.QuadPart = Time->QuadPart - (SecondsToStartOf1970 * PH_TICKS_PER_SEC);
time.QuadPart = time.QuadPart / PH_TICKS_PER_SEC;
time.QuadPart /= PH_TICKS_PER_SEC;
if (time.HighPart)
{
@@ -687,6 +778,8 @@ BOOLEAN PhTimeToSecondsSince1970(
*ElapsedSeconds = time.LowPart;
return TRUE;
#else
return RtlTimeToSecondsSince1970(Time, ElapsedSeconds);
#endif
}
@@ -695,10 +788,10 @@ VOID PhSecondsSince1980ToTime(
_Out_ PLARGE_INTEGER Time
)
{
#if (PHNT_NATIVE_TIME)
RtlSecondsSince1980ToTime(ElapsedSeconds, Time);
#else
#if defined(PHNT_NATIVE_TIME)
Time->QuadPart = PH_TICKS_PER_SEC * (SecondsToStartOf1980 + ElapsedSeconds);
#else
RtlSecondsSince1980ToTime(ElapsedSeconds, Time);
#endif
}
@@ -707,10 +800,10 @@ VOID PhSecondsSince1970ToTime(
_Out_ PLARGE_INTEGER Time
)
{
#if (PHNT_NATIVE_TIME)
RtlSecondsSince1970ToTime(ElapsedSeconds, Time);
#else
#if defined(PHNT_NATIVE_TIME)
Time->QuadPart = PH_TICKS_PER_SEC * (SecondsToStartOf1970 + ElapsedSeconds);
#else
RtlSecondsSince1970ToTime(ElapsedSeconds, Time);
#endif
}
@@ -918,47 +1011,6 @@ PVOID PhAllocatePage(
}
}
//NTSTATUS PhAllocatePageAligned(
// _In_ SIZE_T Size,
// _In_ SIZE_T Alignment,
// _Out_opt_ PSIZE_T NewSize,
// _Out_ PVOID* BaseAddress
// )
//{
// NTSTATUS status;
// PVOID baseAddress = NULL;
// MEM_EXTENDED_PARAMETER extended[1];
// MEM_ADDRESS_REQUIREMENTS requirements;
//
// memset(&requirements, 0, sizeof(MEM_ADDRESS_REQUIREMENTS));
// requirements.HighestEndingAddress = (PVOID)(ULONG_PTR)0x7fffffff; // Below 2GB
// requirements.Alignment = Alignment;
//
// memset(extended, 0, sizeof(extended));
// extended[0].Type = MemExtendedParameterAddressRequirements;
// extended[0].Pointer = &requirements;
//
// status = NtAllocateVirtualMemoryEx(
// NtCurrentProcess(),
// &baseAddress,
// &Size,
// MEM_RESERVE | MEM_COMMIT,
// PAGE_READWRITE,
// extended,
// RTL_NUMBER_OF(extended)
// );
//
// if (NT_SUCCESS(status))
// {
// if (NewSize)
// *NewSize = Size;
// if (BaseAddress)
// *BaseAddress = baseAddress;
// }
//
// return status;
//}
/**
* Frees pages of memory allocated with PhAllocatePage().
*
@@ -971,6 +1023,67 @@ VOID PhFreePage(
PhFreeVirtualMemory(NtCurrentProcess(), Memory, MEM_RELEASE);
}
/**
* Allocates pages of memory.
*
* \param Size The number of bytes to allocate. The number of pages allocated will be large enough to contain \a Size bytes.
* \param Alignment The alignment value, which must be an integer power of 2.
* \return A pointer to the allocated block of memory, or NULL if the block could not be allocated.
*/
_Use_decl_annotations_
PVOID PhAllocatePageAligned(
_In_ SIZE_T Size,
_In_ SIZE_T Alignment
)
{
return _aligned_malloc(Size, Alignment);;
//NTSTATUS status;
//PVOID baseAddress = NULL;
//MEM_EXTENDED_PARAMETER extended[1];
//MEM_ADDRESS_REQUIREMENTS requirements;
//
//memset(&requirements, 0, sizeof(MEM_ADDRESS_REQUIREMENTS));
////requirements.HighestEndingAddress = (PVOID)(ULONG_PTR)0x7fffffff; // Below 2GB
//requirements.Alignment = Alignment;
//
//memset(extended, 0, sizeof(extended));
//extended[0].Type = MemExtendedParameterAddressRequirements;
//extended[0].Pointer = &requirements;
//
//status = NtAllocateVirtualMemoryEx(
// NtCurrentProcess(),
// &baseAddress,
// &Size,
// MEM_RESERVE | MEM_COMMIT,
// PAGE_READWRITE,
// extended,
// RTL_NUMBER_OF(extended)
// );
//
//if (NT_SUCCESS(status))
//{
// if (NewSize)
// *NewSize = Size;
// if (BaseAddress)
// *BaseAddress = baseAddress;
//}
//
//return status;
}
/**
* Frees pages of memory allocated with PhAllocatePageAligned().
*
* \param Memory A pointer to a block of memory.
*/
VOID PhFreePageAligned(
_In_ _Post_invalid_ PVOID Memory
)
{
_aligned_free(Memory);
}
/**
* Reserves, commits, or both, a region of pages within the user-mode virtual address space of a specified process.
*
@@ -981,7 +1094,6 @@ VOID PhFreePage(
* \param AllocationSize The size of the region of memory to allocate, in bytes. If BaseAddress is NULL, the function rounds Size up to the next page boundary.
* \param AllocationType The type of memory allocation.
* \param Protection The type of memory protection.
*
* \return Successful or errant status.
*/
NTSTATUS PhAllocateVirtualMemory(
@@ -1019,7 +1131,6 @@ NTSTATUS PhAllocateVirtualMemory(
* \param ProcessHandle A handle to the process.
* \param BaseAddress The pointer that specifies a desired starting address for the region of pages that you want to allocate.
* \param FreeType A bitmask containing flags that describe the type of free operation.
*
* \return Successful or errant status.
*/
NTSTATUS PhFreeVirtualMemory(
@@ -1039,6 +1150,40 @@ NTSTATUS PhFreeVirtualMemory(
);
}
/**
* Reads virtual memory from a specified process.
*
* @param ProcessHandle Handle to the process from which the memory is to be read.
* @param BaseAddress Optional pointer to the base address in the specified process from which to read.
* @param Buffer Pointer to a buffer that receives the contents from the address space of the specified process.
* @param BufferSize Size of the buffer, in bytes.
* @param NumberOfBytesRead Optional pointer to a variable that receives the number of bytes read into the buffer.
* \return Successful or errant status.
*/
NTSTATUS PhReadVirtualMemory(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_Out_writes_bytes_(BufferSize) PVOID Buffer,
_In_ SIZE_T BufferSize,
_Out_opt_ PSIZE_T NumberOfBytesRead
)
{
if (ProcessHandle == NtCurrentProcess())
{
RtlMoveMemory(Buffer, BaseAddress, BufferSize);
*NumberOfBytesRead = BufferSize;
return STATUS_SUCCESS;
}
return NtReadVirtualMemory(
ProcessHandle,
BaseAddress,
Buffer,
BufferSize,
NumberOfBytesRead
);
}
/**
* Determines the length of the specified string, in characters.
*
@@ -2736,12 +2881,35 @@ PPH_STRING PhCreateStringEx(
_In_ SIZE_T Length
)
{
PH_STRINGREF sr;
PPH_STRING string;
sr.Buffer = (PWCH)Buffer;
sr.Length = Length;
string = PhCreateObject(
UFIELD_OFFSET(PH_STRING, Data) + Length + sizeof(UNICODE_NULL),
PhStringType
);
return PhCreateString3(&sr, 0, NULL);
assert(!(Length & 1));
string->Length = Length;
string->Buffer = string->Data;
*(PWCHAR)PTR_ADD_OFFSET(string->Buffer, Length) = UNICODE_NULL;
if (Buffer)
{
memcpy(string->Buffer, Buffer, Length);
}
if (Buffer)
{
SIZE_T len = string->Length;
SIZE_T len2 = PhCountStringZ(string->Buffer) * sizeof(WCHAR);
if (len != len2)
{
dprintf("PhTrimToNullTerminatorString\n");
}
}
return string;
}
/**
@@ -6371,7 +6539,7 @@ BOOLEAN PhHexStringToBuffer(
BOOLEAN PhHexStringToBufferEx(
_In_ PPH_STRINGREF String,
_In_ ULONG BufferLength,
_In_ SIZE_T BufferLength,
_Out_writes_bytes_(BufferLength) PVOID Buffer
)
{
@@ -6395,7 +6563,6 @@ BOOLEAN PhHexStringToBufferEx(
return TRUE;
}
/**
* Converts a byte array into a sequence of hexadecimal digits.
*
@@ -6406,7 +6573,7 @@ BOOLEAN PhHexStringToBufferEx(
*/
PPH_STRING PhBufferToHexString(
_In_reads_bytes_(Length) PUCHAR Buffer,
_In_ ULONG Length
_In_ SIZE_T Length
)
{
return PhBufferToHexStringEx(Buffer, Length, FALSE);
@@ -6423,7 +6590,7 @@ PPH_STRING PhBufferToHexString(
*/
PPH_STRING PhBufferToHexStringEx(
_In_reads_bytes_(Length) PUCHAR Buffer,
_In_ ULONG Length,
_In_ SIZE_T Length,
_In_ BOOLEAN UpperCase
)
{
@@ -6461,7 +6628,11 @@ BOOLEAN PhBufferToHexStringBuffer(
ULONG i;
if (OutputLength < InputLength * sizeof(WCHAR) * 2)
{
if (ReturnLength)
*ReturnLength = InputLength * sizeof(WCHAR) * 2;
return FALSE;
}
if (UpperCase)
table = PhIntegerToCharUpper;
@@ -6492,7 +6663,7 @@ BOOLEAN PhBufferToHexStringBuffer(
BOOLEAN PhpStringToInteger64(
_In_ PPH_STRINGREF String,
_In_ ULONG Base,
_Out_ PULONG64 Integer
_Out_opt_ PULONG64 Integer
)
{
BOOLEAN valid = TRUE;
@@ -6515,7 +6686,10 @@ BOOLEAN PhpStringToInteger64(
valid = FALSE;
}
*Integer = result;
if (Integer)
{
*Integer = result;
}
return valid;
}
@@ -7756,7 +7930,7 @@ ULONG PhCountBitsUlongPtr(
#ifdef _WIN64
if (PhHasPopulationCount)
{
return PhPopulationCount64(Value);
return (ULONG)PhPopulationCount64(Value);
}
else
#endif
+32 -32
View File
@@ -56,7 +56,7 @@ BOOLEAN PhInitializeGDIPlus(
if (PhBeginInitOnce(&initOnce))
{
static ULONG_PTR gdiplusToken = 0;
static GdiplusStartupInput gdiplusStartupInput{};
static GdiplusStartupInput gdiplusStartupInput = { nullptr, false, true };
if (GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr) == Status::Ok)
{
@@ -101,39 +101,39 @@ HICON PhGdiplusConvertBitmapToIcon(
if (PhInitializeGDIPlus())
{
Bitmap* image = PhGdiplusCreateBitmapFromDIB(OriginalBitmap);
DIBSECTION dib;
if (image != nullptr)
RtlZeroMemory(&dib, sizeof(DIBSECTION));
if (GetObject(OriginalBitmap, sizeof(DIBSECTION), &dib) != sizeof(DIBSECTION))
return nullptr;
LONG width = dib.dsBmih.biWidth;
LONG height = dib.dsBmih.biHeight;
LONG pitch = dib.dsBm.bmWidthBytes;
BYTE* bitmapBuffer = static_cast<BYTE*>(dib.dsBm.bmBits);
Bitmap image(width, height, pitch, PixelFormat32bppARGB, bitmapBuffer);
Bitmap buffer(Width, Height, PixelFormat32bppARGB);
Graphics graphics(&buffer);
if (Background)
{
Bitmap* buffer = new Bitmap(Width, Height, PixelFormat32bppARGB);
Graphics* graphics = Graphics::FromImage(buffer);
Color color(Color::DodgerBlue);
color.SetFromCOLORREF(Background);
graphics.Clear(color);
}
else
{
graphics.Clear(Color::DodgerBlue);
}
if (Background)
if (graphics.DrawImage(&image, 0, 0) == Status::Ok)
{
if (buffer.GetHICON(&icon) == Status::Ok)
{
Color color(Color::DodgerBlue);
color.SetFromCOLORREF(Background);
graphics->Clear(color);
return icon;
}
else
{
graphics->Clear(Color::DodgerBlue);
}
if (graphics->DrawImage(image, 0, 0) == Status::Ok)
{
if (buffer->GetHICON(&icon) == Status::Ok)
{
delete graphics;
delete buffer;
delete image;
return icon;
}
}
delete graphics;
delete buffer;
delete image;
}
}
@@ -144,16 +144,16 @@ HICON PhGdiplusConvertHBitmapToHIcon(
_In_ HBITMAP NitmapHandle
)
{
HICON hIcon = nullptr;
HICON iconHandle = nullptr;
if (PhInitializeGDIPlus())
{
Bitmap bitmap(NitmapHandle, nullptr);
bitmap.GetHICON(&hIcon);
bitmap.GetHICON(&iconHandle);
}
return hIcon;
return iconHandle;
}
+63 -9
View File
@@ -13,13 +13,11 @@
#include <ph.h>
#include <apiimport.h>
#include <guisup.h>
#include <guisupview.h>
#include <mapimg.h>
#include <mapldr.h>
#include <settings.h>
#include <guisupp.h>
#include <math.h>
#include <commoncontrols.h>
#include <shellscalingapi.h>
#include <wincodec.h>
@@ -149,14 +147,15 @@ VOID PhGuiSupportInitialization(
}
}
PhGuiSupportUpdateSystemMetrics(NULL);
PhGuiSupportUpdateSystemMetrics(NULL, 0);
}
VOID PhGuiSupportUpdateSystemMetrics(
_In_opt_ HWND WindowHandle
_In_opt_ HWND WindowHandle,
_In_opt_ LONG WindowDpi
)
{
PhSystemDpi = WindowHandle ? PhGetWindowDpi(WindowHandle) : PhGetSystemDpi();
PhSystemDpi = WindowDpi ? WindowDpi : (WindowHandle ? PhGetWindowDpi(WindowHandle) : PhGetSystemDpi());
PhSmallIconSize.X = PhGetSystemMetrics(SM_CXSMICON, PhSystemDpi);
PhSmallIconSize.Y = PhGetSystemMetrics(SM_CYSMICON, PhSystemDpi);
PhLargeIconSize.X = PhGetSystemMetrics(SM_CXICON, PhSystemDpi);
@@ -164,10 +163,11 @@ VOID PhGuiSupportUpdateSystemMetrics(
}
VOID PhInitializeFont(
_In_ HWND WindowHandle
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
)
{
LONG windowDpi = PhGetWindowDpi(WindowHandle);
LONG windowDpi = WindowDpi ? WindowDpi : PhGetWindowDpi(WindowHandle);
HFONT oldFont = PhApplicationFont;
if (
@@ -182,10 +182,11 @@ VOID PhInitializeFont(
}
VOID PhInitializeMonospaceFont(
_In_ HWND WindowHandle
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
)
{
LONG windowDpi = PhGetWindowDpi(WindowHandle);
LONG windowDpi = WindowDpi ? WindowDpi : PhGetWindowDpi(WindowHandle);
HFONT oldFont = PhMonospaceFont;
if (
@@ -2443,6 +2444,59 @@ VOID PhWindowNotifyTopMostEvent(
PhReleaseQueuedLockExclusive(&WindowCallbackListLock);
}
/**
* Retrieves the environment variables for the specified user.
*
* @param Environment A pointer to the new environment block.
* @param TokenHandle Token to query for user environment variables.
* If this is a primary token, the token must have TOKEN_QUERY and TOKEN_DUPLICATE access.
* If the token is an impersonation token, it must have TOKEN_QUERY access.
* If this parameter is NULL, the returned environment block contains system variables only.
* @param Inherit Specifies whether to inherit variables from the current process' environment. If this value is TRUE, the process inherits the current process' environment.
* @return A pointer to the imported procedure, or NULL if the procedure could not be imported.
* @remarks User-specific environment variables such as %USERPROFILE% are set only when the user's profile is loaded. To load a user's profile, call the LoadUserProfile function.
*/
NTSTATUS PhCreateEnvironmentBlock(
_Outptr_ PVOID* Environment,
_In_opt_ HANDLE TokenHandle,
_In_ BOOLEAN Inherit
)
{
//#include <UserEnv.h>
//HANDLE profileHandle;
//
//if (TokenHandle)
//{
// PROFILEINFO profileInfo = { sizeof(PROFILEINFO) };
// LoadUserProfile(TokenHandle, &profileInfo);
// profileHandle = profileInfo.hProfile;
//}
if (CreateEnvironmentBlock_Import()(Environment, TokenHandle, Inherit))
{
return STATUS_SUCCESS;
}
//if (TokenHandle && profileHandle)
//{
// UnloadUserProfile(TokenHandle, profileHandle);
//}
return PhGetLastWin32ErrorAsNtStatus();
}
/**
* Frees environment variables created by the CreateEnvironmentBlock function.
*
* @param Environment A pointer to the new environment block.
*/
VOID PhDestroyEnvironmentBlock(
_In_ _Post_invalid_ PVOID Environment
)
{
DestroyEnvironmentBlock_Import()(Environment);
}
_Success_(return)
BOOLEAN PhRegenerateUserEnvironment(
_Out_opt_ PVOID* NewEnvironment,
+2 -2
View File
@@ -480,9 +480,8 @@ VOID PhInitializeEtwTraceGuidCache(
PVOID jsonObject;
ULONG arrayLength;
if (guidListFileName = PhGetApplicationDirectory())
if (guidListFileName = PhGetApplicationDirectoryFileNameZ(L"Resources\\EtwGuids.txt", TRUE))
{
PhMoveReference(&guidListFileName, PhConcatStringRefZ(&guidListFileName->sr, L"etwguids.txt"));
guidListString = PhFileReadAllText(&guidListFileName->sr, TRUE);
PhDereferenceObject(guidListFileName);
}
@@ -2242,6 +2241,7 @@ NTSTATUS PhpCallWithTimeout(
if (!NT_SUCCESS(status = PhCreateUserThread(
NtCurrentProcess(),
NULL,
THREAD_ALL_ACCESS,
0,
0,
UInt32x32To64(32, 1024),
+5 -5
View File
@@ -1433,7 +1433,7 @@ PDNS_RECORD PhDnsQuery(
DnsQuery_W_I(
DnsQueryMessage,
DnsQueryMessageType,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE | DNS_QUERY_NO_MULTICAST,
&dnsServerAddressList,
&dnsRecordList,
NULL
@@ -1444,7 +1444,7 @@ PDNS_RECORD PhDnsQuery(
DnsQuery_W_I(
DnsQueryMessage,
DnsQueryMessageType,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE | DNS_QUERY_NO_MULTICAST,
NULL,
&dnsRecordList,
NULL
@@ -1485,7 +1485,7 @@ PDNS_RECORD PhDnsQuery2(
DnsQuery_W_I(
DnsQueryMessage,
DnsQueryMessageType,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE,
DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE | DNS_QUERY_NO_MULTICAST,
&dnsServerAddressList,
&dnsRecordList,
NULL
@@ -1496,7 +1496,7 @@ PDNS_RECORD PhDnsQuery2(
DnsQuery_W_I(
DnsQueryMessage,
DnsQueryMessageType,
DnsQueryMessageOptions,
DnsQueryMessageOptions | DNS_QUERY_NO_HOSTS_FILE | DNS_QUERY_NO_MULTICAST,
NULL,
&dnsRecordList,
NULL
@@ -1627,7 +1627,7 @@ NTSTATUS PhDnsCreateDnsServerList(
return status;
}
// HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Dnscache\Parameters\DohWellKnownServers
NTSTATUS PhDnsCreateCustomDnsServerList(
_In_ PCWSTR AddressString,
_Inout_ DNS_CUSTOM_SERVER* DnsCustomServerList
-1
View File
@@ -66,7 +66,6 @@ PH_DECLARE_IMPORT(GetAppContainerFolderPath);
// User32
PH_DECLARE_IMPORT(SetWindowDisplayAffinity);
PH_DECLARE_IMPORT(ConsoleControl);
EXTERN_C_END
@@ -9,8 +9,8 @@
*
*/
#ifndef _PH_USER_H
#define _PH_USER_H
#ifndef _PH_CONSOLE_H
#define _PH_CONSOLE_H
PHLIBAPI
NTSTATUS
@@ -38,14 +38,15 @@ NTSTATUS
NTAPI
PhGetConsoleProcessList(
_In_ HANDLE ProcessId,
_In_ ULONG ProcessCount,
_Out_writes_(ProcessCount) PULONG ProcessList,
_In_ ULONG ProcessCount
_Out_ PULONG ProcessTotal
);
PHLIBAPI
NTSTATUS
NTAPI
PhConsoleControlSetForeground(
PhConsoleSetForeground(
_In_ HANDLE ProcessHandle,
_In_ BOOLEAN Foreground
);
@@ -53,7 +54,16 @@ PhConsoleControlSetForeground(
PHLIBAPI
NTSTATUS
NTAPI
PhConsoleControlEndTask(
PhConsoleSetWindow(
_In_ HANDLE ProcessID,
_In_ HANDLE ThreadId,
_In_ HWND WindowHandle
);
PHLIBAPI
NTSTATUS
NTAPI
PhConsoleEndTask(
_In_ HANDLE ProcessId,
_In_ HWND WindowHandle
);
+58 -52
View File
@@ -39,35 +39,35 @@ typedef struct _GPU_DETAILS_CONTEXT
{
HWND DialogHandle;
HWND ListViewHandle;
IListView* ListViewClass;
PH_CALLBACK_REGISTRATION ProcessesUpdatedCallbackRegistration;
PH_LAYOUT_MANAGER LayoutManager;
PGPU_DEVICE_DETAILS_DIALOG_CONTEXT DetailsContext;
} GPU_DETAILS_CONTEXT, *PGPU_DETAILS_CONTEXT;
VOID EtpGpuDetailsAddListViewItemGroups(
_In_ HWND ListViewHandle,
_In_ INT GpuGroupId)
_In_ IListView* ListViewClass)
{
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_PHYSICALLOCTION, L"Physical Location", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DRIVERDATE, L"Driver Date", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DRIVERVERSION, L"Driver Version", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_WDDMVERSION, L"WDDM Version", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_VENDORID, L"Vendor ID", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DEVICEID, L"Device ID", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_TOTALMEMORY, L"Total Memory", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, L"Reserved Memory", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, L"Memory Frequency", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, L"Memory Bandwidth", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, L"PCIE Bandwidth", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_FANRPM, L"Fan RPM", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, L"Power Usage", NULL);
PhAddListViewItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, L"Temperature", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_PHYSICALLOCTION, L"Physical Location", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DRIVERDATE, L"Driver Date", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DRIVERVERSION, L"Driver Version", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_WDDMVERSION, L"WDDM Version", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_VENDORID, L"Vendor ID", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DEVICEID, L"Device ID", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_TOTALMEMORY, L"Total Memory", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, L"Reserved Memory", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, L"Memory Frequency", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, L"Memory Bandwidth", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, L"PCIE Bandwidth", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_FANRPM, L"Fan RPM", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, L"Power Usage", NULL);
PhAddIListViewItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, L"Temperature", NULL);
}
VOID EtpQueryAdapterDeviceProperties(
_In_ PGPU_DETAILS_CONTEXT Context,
_In_ PCWSTR DeviceName,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
PPH_STRING driverDate;
PPH_STRING driverVersion;
@@ -76,18 +76,18 @@ VOID EtpQueryAdapterDeviceProperties(
if (GraphicsQueryDeviceProperties(DeviceName, NULL, &driverDate, &driverVersion, &locationInfo, &installedMemory, NULL))
{
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DRIVERDATE, 1, PhGetStringOrEmpty(driverDate));
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DRIVERVERSION, 1, PhGetStringOrEmpty(driverVersion));
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_PHYSICALLOCTION, 1, PhGetStringOrEmpty(locationInfo));
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DRIVERDATE, 1, PhGetStringOrEmpty(driverDate));
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DRIVERVERSION, 1, PhGetStringOrEmpty(driverVersion));
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_PHYSICALLOCTION, 1, PhGetStringOrEmpty(locationInfo));
if (installedMemory != ULLONG_MAX)
{
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_TOTALMEMORY, 1, PhaFormatSize(installedMemory, ULONG_MAX)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_TOTALMEMORY, 1, PhaFormatSize(installedMemory, ULONG_MAX)->Buffer);
if (Context->DetailsContext->DeviceEntry->DedicatedLimit != 0)
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, 1, PhaFormatSize(installedMemory - Context->DetailsContext->DeviceEntry->DedicatedLimit, ULONG_MAX)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, 1, PhaFormatSize(installedMemory - Context->DetailsContext->DeviceEntry->DedicatedLimit, ULONG_MAX)->Buffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, 1, PhaFormatSize(installedMemory - Context->DetailsContext->DeviceEntry->SharedLimit, ULONG_MAX)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_RESERVEDMEMORY, 1, PhaFormatSize(installedMemory - Context->DetailsContext->DeviceEntry->SharedLimit, ULONG_MAX)->Buffer);
}
PhClearReference(&locationInfo);
@@ -98,7 +98,7 @@ VOID EtpQueryAdapterDeviceProperties(
VOID EtpQueryAdapterRegistryInfo(
_In_ D3DKMT_HANDLE AdapterHandle,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
D3DKMT_ADAPTERREGISTRYINFO adapterInfo;
@@ -117,7 +117,7 @@ VOID EtpQueryAdapterRegistryInfo(
VOID EtpQueryAdapterDriverModel(
_In_ D3DKMT_HANDLE AdapterHandle,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
D3DKMT_DRIVERVERSION d3dkmtDriverVersion;
@@ -133,14 +133,14 @@ VOID EtpQueryAdapterDriverModel(
ULONG majorVersion = d3dkmtDriverVersion / 1000;
ULONG minorVersion = (d3dkmtDriverVersion - majorVersion * 1000) / 100;
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_WDDMVERSION, 1,
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_WDDMVERSION, 1,
PhaFormatString(L"WDDM %lu.%lu", majorVersion, minorVersion)->Buffer);
}
}
VOID EtpQueryAdapterDriverVersion(
_In_ D3DKMT_HANDLE AdapterHandle,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
D3DKMT_UMD_DRIVER_VERSION driverUserVersion;
D3DKMT_KMD_DRIVER_VERSION driverKernelVersion;
@@ -185,7 +185,7 @@ VOID EtpQueryAdapterDriverVersion(
VOID EtpQueryAdapterDeviceIds(
_In_ D3DKMT_HANDLE AdapterHandle,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
D3DKMT_QUERY_DEVICE_IDS adapterDeviceId;
@@ -201,10 +201,10 @@ VOID EtpQueryAdapterDeviceIds(
WCHAR value[PH_PTR_STR_LEN_1];
PhPrintPointer(value, UlongToPtr(adapterDeviceId.DeviceIds.VendorID));
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_VENDORID, 1, value);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_VENDORID, 1, value);
PhPrintPointer(value, UlongToPtr(adapterDeviceId.DeviceIds.DeviceID));
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_DEVICEID, 1, value);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_DEVICEID, 1, value);
//PhPrintPointer(value, UlongToPtr(adapterDeviceId.DeviceIds.SubVendorID));
//PhPrintPointer(value, UlongToPtr(adapterDeviceId.DeviceIds.SubSystemID));
@@ -215,7 +215,7 @@ VOID EtpQueryAdapterDeviceIds(
VOID EtpQueryAdapterPerfInfo(
_In_ D3DKMT_HANDLE AdapterHandle,
_In_ HWND ListViewHandle)
_In_ IListView* ListViewClass)
{
D3DKMT_ADAPTER_PERFDATA adapterPerfData;
@@ -235,38 +235,38 @@ VOID EtpQueryAdapterPerfInfo(
PhInitFormatS(&format[1], L" MHz");
if (PhFormatToBuffer(format, 2, formatBuffer, sizeof(formatBuffer), NULL))
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, 1, formatBuffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, 1, PhaFormatString(L"%I64u MHz", adapterPerfData.MemoryFrequency / 1000 / 1000)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYFREQUENCY, 1, PhaFormatString(L"%I64u MHz", adapterPerfData.MemoryFrequency / 1000 / 1000)->Buffer);
PhInitFormatSize(&format[0], adapterPerfData.MemoryBandwidth);
if (PhFormatToBuffer(format, 1, formatBuffer, sizeof(formatBuffer), NULL))
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, 1, formatBuffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, 1, PhaFormatSize(adapterPerfData.MemoryBandwidth, ULONG_MAX)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_MEMORYBANDWIDTH, 1, PhaFormatSize(adapterPerfData.MemoryBandwidth, ULONG_MAX)->Buffer);
PhInitFormatSize(&format[0], adapterPerfData.PCIEBandwidth);
if (PhFormatToBuffer(format, 1, formatBuffer, sizeof(formatBuffer), NULL))
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, 1, formatBuffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, 1, PhaFormatSize(adapterPerfData.PCIEBandwidth, ULONG_MAX)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_PCIEBANDWIDTH, 1, PhaFormatSize(adapterPerfData.PCIEBandwidth, ULONG_MAX)->Buffer);
PhInitFormatI64U(&format[0], adapterPerfData.FanRPM);
if (PhFormatToBuffer(format, 1, formatBuffer, sizeof(formatBuffer), NULL))
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_FANRPM, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_FANRPM, 1, formatBuffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_FANRPM, 1, PhaFormatUInt64(adapterPerfData.FanRPM, FALSE)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_FANRPM, 1, PhaFormatUInt64(adapterPerfData.FanRPM, FALSE)->Buffer);
PhInitFormatI64U(&format[0], adapterPerfData.Power * 100 / 1000);
PhInitFormatS(&format[1], L"%");
if (PhFormatToBuffer(format, 2, formatBuffer, sizeof(formatBuffer), NULL))
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, 1, formatBuffer);
else
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, 1, PhaFormatString(L"%lu%%", adapterPerfData.Power * 100 / 1000)->Buffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_POWERUSAGE, 1, PhaFormatString(L"%lu%%", adapterPerfData.Power * 100 / 1000)->Buffer);
//if (PhGetIntegerSetting(SETTING_NAME_ENABLE_FAHRENHEIT))
//{
@@ -298,11 +298,11 @@ VOID EtpQueryAdapterPerfInfo(
if (PhFormatToBuffer(format, RTL_NUMBER_OF(format), formatBuffer, sizeof(formatBuffer), NULL))
{
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, 1, formatBuffer);
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, 1, formatBuffer);
}
else
{
PhSetListViewSubItem(ListViewHandle, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, 1, PhaFormatString(
PhSetIListViewSubItem(ListViewClass, GPUADAPTER_DETAILS_INDEX_TEMPERATURE, 1, PhaFormatString(
L"%lu\u00b0C",
gpuCurrentTemp
)->Buffer);
@@ -321,15 +321,15 @@ VOID GraphicsDeviceQueryAdapterDetails(
if (!NT_SUCCESS(GraphicsOpenAdapterFromDeviceName(&adapterHandle, &adapterLuid, PhGetString(Context->DetailsContext->DeviceEntry->Id.DevicePath))))
return;
EtpGpuDetailsAddListViewItemGroups(Context->ListViewHandle, 0);
EtpGpuDetailsAddListViewItemGroups(Context->ListViewClass);
EtpQueryAdapterDeviceProperties(Context, PhGetString(Context->DetailsContext->DeviceEntry->Id.DevicePath), Context->ListViewHandle);
EtpQueryAdapterDeviceProperties(Context, PhGetString(Context->DetailsContext->DeviceEntry->Id.DevicePath), Context->ListViewClass);
//EtpQueryAdapterRegistryInfo(adapterHandle, Context->ListViewHandle);
EtpQueryAdapterDriverModel(adapterHandle, Context->ListViewHandle);
EtpQueryAdapterDriverModel(adapterHandle, Context->ListViewClass);
//EtpQueryAdapterDriverVersion(adapterHandle, Context->ListViewHandle);
EtpQueryAdapterDeviceIds(adapterHandle, Context->ListViewHandle);
EtpQueryAdapterDeviceIds(adapterHandle, Context->ListViewClass);
//EtQueryAdapterFeatureLevel(adapterLuid);
EtpQueryAdapterPerfInfo(adapterHandle, Context->ListViewHandle);
EtpQueryAdapterPerfInfo(adapterHandle, Context->ListViewClass);
GraphicsCloseAdapterHandle(adapterHandle);
}
@@ -372,13 +372,14 @@ INT_PTR CALLBACK GraphicsDeviceDetailsDlgProc(
{
context->DialogHandle = hwndDlg;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_GPULIST);
context->ListViewClass = PhGetListViewInterface(hwndDlg);
PhSetApplicationWindowIcon(hwndDlg);
PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 230, L"Property");
PhAddListViewColumn(context->ListViewHandle, 1, 1, 1, LVCFMT_LEFT, 200, L"Value");
PhAddIListViewColumn(context->ListViewClass, 0, 0, 0, LVCFMT_LEFT, 230, L"Property");
PhAddIListViewColumn(context->ListViewClass, 1, 1, 1, LVCFMT_LEFT, 200, L"Value");
PhSetExtendedListView(context->ListViewHandle);
PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
@@ -389,7 +390,7 @@ INT_PTR CALLBACK GraphicsDeviceDetailsDlgProc(
else
PhCenterWindow(hwndDlg, GetParent(hwndDlg));
PhInitializeWindowTheme(hwndDlg, !!PhGetIntegerSetting(L"EnableThemeSupport"));
PhSetWindowTheme(hwndDlg);
GraphicsDeviceQueryAdapterDetails(context);
@@ -409,6 +410,11 @@ INT_PTR CALLBACK GraphicsDeviceDetailsDlgProc(
PhDeleteLayoutManager(&context->LayoutManager);
if (context->ListViewClass)
{
IListView_Release(context->ListViewClass);
}
PostQuitMessage(0);
}
break;
@@ -465,7 +471,7 @@ INT_PTR CALLBACK GraphicsDeviceDetailsDlgProc(
if (point.x == -1 && point.y == -1)
PhGetListViewContextMenuPoint(context->ListViewHandle, &point);
PhGetSelectedListViewItemParams(context->ListViewHandle, &listviewItems, &numberOfItems);
PhGetSelectedIListViewItemParams(context->ListViewClass, &listviewItems, &numberOfItems);
if (numberOfItems != 0)
{
+2 -1
View File
@@ -12,11 +12,11 @@
#include "devices.h"
#include <hndlinfo.h>
#include <secedit.h>
PPH_PLUGIN PluginInstance = NULL;
BOOLEAN NetAdapterEnableNdis = FALSE;
ULONG NetWindowsVersion = WINDOWS_ANCIENT;
ULONG NetUpdateInterval = 0;
PPH_OBJECT_TYPE NetworkDeviceEntryType = NULL;
PPH_LIST NetworkDevicesList = NULL;
@@ -48,6 +48,7 @@ VOID NTAPI LoadSettings(
{
NetAdapterEnableNdis = !!PhGetIntegerSetting(SETTING_NAME_ENABLE_NDIS);
NetWindowsVersion = PhWindowsVersion;
NetUpdateInterval = PhGetIntegerSetting(L"UpdateInterval");
}
VOID NTAPI LoadCallback(
-6
View File
@@ -460,12 +460,6 @@ VOID FindRaplDevices(
NtClose(deviceHandle);
}
if (deviceEntry->DevicePresent && !deviceEntry->DeviceSupported)
{
// TODO: Remove this once we know our channel names are correct. (dmex)
PhMoveReference(&deviceEntry->DeviceName, PhConcatStringRefZ(&deviceEntry->DeviceName->sr, L" [UNKNOWN DEVICE - PLEASE REPORT ON GITHUB]"));
}
PhAddItemList(deviceList, deviceEntry);
PhDereferenceObject(deviceDescription);
+1 -1
View File
@@ -111,7 +111,7 @@ VOID VirusTotalBuildJsonArray(
PVOID entry;
Entry->FileHash = hashString;
Entry->FileHashAnsi = PhConvertUtf16ToMultiByte(hashString->Buffer);
Entry->FileHashAnsi = PhConvertUtf16ToUtf8(hashString->Buffer);
entry = PhCreateJsonObject();
PhAddJsonObject(entry, "autostart_location", "");
+5 -3
View File
@@ -84,9 +84,11 @@ BOOLEAN ProcessTreeFilterCallback(
return TRUE;
}
if (PhSearchControlMatch(SearchMatchHandle, &processNode->ProcessItem->IntegrityString))
return TRUE;
if (processNode->ProcessItem->IntegrityString)
{
if (PhSearchControlMatch(SearchMatchHandle, processNode->ProcessItem->IntegrityString))
return TRUE;
}
if (processNode->ProcessItem->Protection.Level ||
processNode->ProcessItem->IsSecureProcess ||
+4 -6
View File
@@ -101,7 +101,7 @@ VOID RebarCreateOrUpdateWindow(
{
if (!ToolBarImageList || DpiChanged)
{
LONG windowDpi = PhGetWindowDpi(MainWindowHandle);
LONG windowDpi = SystemInformer_GetWindowDpi();
if (ToolStatusConfig.ToolBarLargeIcons)
{
@@ -295,9 +295,7 @@ VOID RebarCreateOrUpdateWindow(
// Add the Searchbox band into the rebar control.
if (!RebarBandExists(REBAR_BAND_ID_SEARCHBOX))
{
LONG dpiValue;
dpiValue = PhGetWindowDpi(RebarHandle);
LONG dpiValue = SystemInformer_GetWindowDpi();
RebarBandInsert(REBAR_BAND_ID_SEARCHBOX, SearchboxHandle, PhGetDpi(215, dpiValue), height);
}
@@ -699,7 +697,7 @@ VOID ToolbarLoadDefaultButtonSettings(
VOID
)
{
LONG dpiValue = PhGetWindowDpi(MainWindowHandle);
LONG dpiValue = SystemInformer_GetWindowDpi();
// Pre-cache the images in the Toolbar array.
@@ -767,7 +765,7 @@ VOID ToolbarLoadButtonSettings(
}
count = (INT)countInteger;
dpiValue = PhGetWindowDpi(MainWindowHandle);
dpiValue = SystemInformer_GetWindowDpi();
// Allocate the button array
buttonArray = _malloca(count * sizeof(TBBUTTON));
+3
View File
@@ -16,7 +16,10 @@
#include <phdk.h>
#include <phapppub.h>
#include <phappresource.h>
#include <phconsole.h>
#include <hndlinfo.h>
#include <settings.h>
#include <searchbox.h>
#include "resource.h"
#include <toolstatusintf.h>
+5 -5
View File
@@ -449,7 +449,7 @@ HRESULT CALLBACK TaskDialogBootstrapCallback(
config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW;
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
config.pszMainIcon = TD_ERROR_ICON;
config.pszWindowTitle = L"System Informer";
config.pszWindowTitle = SystemInformer_GetWindowName();
config.pszMainInstruction = L"Unable to update the IFEO key for priority.";
config.cxWidth = 200;
@@ -492,7 +492,7 @@ HRESULT CALLBACK TaskDialogBootstrapCallback(
config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW;
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
config.pszMainIcon = TD_ERROR_ICON;
config.pszWindowTitle = L"System Informer";
config.pszWindowTitle = SystemInformer_GetWindowName();
config.pszMainInstruction = L"Unable to update the IFEO key for priority.";
config.cxWidth = 200;
@@ -535,7 +535,7 @@ HRESULT CALLBACK TaskDialogBootstrapCallback(
config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW;
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
config.pszMainIcon = TD_ERROR_ICON;
config.pszWindowTitle = L"System Informer";
config.pszWindowTitle = SystemInformer_GetWindowName();
config.pszMainInstruction = L"Unable to update the IFEO key for priority.";
config.cxWidth = 200;
@@ -955,7 +955,7 @@ VOID NTAPI MenuItemCallback(
if (processItem->QueryHandle)
{
status = PhGetProcessPriority(processItem->QueryHandle, &priorityClass);
status = PhGetProcessPriorityClass(processItem->QueryHandle, &priorityClass);
}
if (NT_SUCCESS(status))
@@ -991,7 +991,7 @@ VOID NTAPI MenuItemCallback(
if (processItem->QueryHandle)
{
status = PhGetProcessPriority(processItem->QueryHandle, &priorityClass);
status = PhGetProcessPriorityClass(processItem->QueryHandle, &priorityClass);
}
if (NT_SUCCESS(status))
+1
View File
@@ -17,6 +17,7 @@
#include <phapppub.h>
#include <phappresource.h>
#include <settings.h>
#include <searchbox.h>
#include <mapldr.h>
#include "resource.h"
+10 -10
View File
@@ -259,21 +259,21 @@ namespace CustomBuildTool
if (Flags.HasFlag(BuildFlags.BuildDebug))
{
if (Flags.HasFlag(BuildFlags.Build32bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Debug32\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Debug32\\Resources\\{file.Value}", Flags);
if (Flags.HasFlag(BuildFlags.Build64bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Debug64\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Debug64\\Resources\\{file.Value}", Flags);
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\DebugARM64\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\DebugARM64\\Resources\\{file.Value}", Flags);
}
if (Flags.HasFlag(BuildFlags.BuildRelease))
{
if (Flags.HasFlag(BuildFlags.Build32bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Release32\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Release32\\Resources\\{file.Value}", Flags);
if (Flags.HasFlag(BuildFlags.Build64bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Release64\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\Release64\\Resources\\{file.Value}", Flags);
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\ReleaseARM64\\{file.Value}", Flags);
Win32.CopyIfNewer($"SystemInformer\\resources\\{file.Key}", $"bin\\ReleaseARM64\\Resources\\{file.Value}", Flags);
}
}
@@ -455,14 +455,14 @@ namespace CustomBuildTool
// Copy the plugin SDK headers
foreach (string file in BuildConfig.Build_Phnt_Headers)
Win32.CopyIfNewer($"phnt\\include\\{file}", $"sdk\\include\\{file}");
Win32.CopyIfNewer($"phnt\\include\\{file}", $"sdk\\include\\{file}", Flags);
foreach (string file in BuildConfig.Build_Phlib_Headers)
Win32.CopyIfNewer($"phlib\\include\\{file}", $"sdk\\include\\{file}");
Win32.CopyIfNewer($"phlib\\include\\{file}", $"sdk\\include\\{file}", Flags);
foreach (string file in BuildConfig.Build_Kphlib_Headers)
Win32.CopyIfNewer($"kphlib\\include\\{file}", $"sdk\\include\\{file}");
Win32.CopyIfNewer($"kphlib\\include\\{file}", $"sdk\\include\\{file}", Flags);
// Copy readme
Win32.CopyIfNewer("SystemInformer\\sdk\\readme.txt", "sdk\\readme.txt");
Win32.CopyIfNewer("SystemInformer\\sdk\\readme.txt", "sdk\\readme.txt", Flags);
// Copy symbols
//Win32.CopyIfNewer("bin\\Release32\\SystemInformer.pdb", "sdk\\dbg\\i386\\SystemInformer.pdb");
//Win32.CopyIfNewer("bin\\Release64\\SystemInformer.pdb", "sdk\\dbg\\amd64\\SystemInformer.pdb");
+10 -6
View File
@@ -63,12 +63,14 @@ namespace CustomBuildTool
if (ProgramArgs.ContainsKey("-Debug"))
{
flags |= BuildFlags.BuildDebug;
if (ProgramArgs.ContainsKey("-Win32"))
flags |= BuildFlags.BuildDebug | BuildFlags.Build32bit;
flags |= BuildFlags.Build32bit;
else if (ProgramArgs.ContainsKey("-x64"))
flags |= BuildFlags.BuildDebug | BuildFlags.Build64bit;
flags |= BuildFlags.Build64bit;
else if (ProgramArgs.ContainsKey("-arm64"))
flags |= BuildFlags.BuildDebug | BuildFlags.BuildArm64bit;
flags |= BuildFlags.BuildArm64bit;
else
{
Environment.Exit(1);
@@ -76,12 +78,14 @@ namespace CustomBuildTool
}
else if (ProgramArgs.ContainsKey("-release"))
{
flags |= BuildFlags.BuildRelease;
if (ProgramArgs.ContainsKey("-Win32"))
flags |= BuildFlags.BuildRelease | BuildFlags.Build32bit;
flags |= BuildFlags.Build32bit;
else if (ProgramArgs.ContainsKey("-x64"))
flags |= BuildFlags.BuildRelease | BuildFlags.Build64bit;
flags |= BuildFlags.Build64bit;
else if (ProgramArgs.ContainsKey("-arm64"))
flags |= BuildFlags.BuildRelease | BuildFlags.BuildArm64bit;
flags |= BuildFlags.BuildArm64bit;
else
{
Environment.Exit(1);
+4 -4
View File
@@ -228,9 +228,9 @@ namespace CustomBuildTool
}
if (updated)
Program.PrintColorMessage($"[Success] {SourceFile} copied to {DestinationFile}", ConsoleColor.White, true, Flags);
Program.PrintColorMessage($"[Success] {SourceFile} copied to {DestinationFile}", ConsoleColor.Green, true, Flags);
else
Program.PrintColorMessage($"[Skipped] {SourceFile} was older than {DestinationFile}", ConsoleColor.Yellow, true, Flags);
Program.PrintColorMessage($"[Skipped] {SourceFile} was older than {DestinationFile}", ConsoleColor.DarkGray, true, Flags);
}
public static void CopyVersionIfNewer(string SourceFile, string DestinationFile, BuildFlags Flags = BuildFlags.None)
@@ -276,9 +276,9 @@ namespace CustomBuildTool
}
if (updated)
Program.PrintColorMessage($"[Success] {SourceFile} copied to {DestinationFile}", ConsoleColor.White, true, Flags);
Program.PrintColorMessage($"[Success] {SourceFile} copied to {DestinationFile}", ConsoleColor.Green, true, Flags);
else
Program.PrintColorMessage($"[Skipped] {SourceFile} was older than {DestinationFile}", ConsoleColor.Yellow, true, Flags);
Program.PrintColorMessage($"[Skipped] {SourceFile} was older than {DestinationFile}", ConsoleColor.DarkGray, true, Flags);
}
/// <summary>
+2 -2
View File
@@ -65,7 +65,7 @@ VOID PvPeAddListViewCfgFunctionEntry(
{
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, cfgFunctionEntry.Rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, cfgFunctionEntry.Rva),
&symbolResolveLevel,
NULL,
&symbolName,
@@ -76,7 +76,7 @@ VOID PvPeAddListViewCfgFunctionEntry(
{
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, cfgFunctionEntry.Rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, cfgFunctionEntry.Rva),
&symbolResolveLevel,
NULL,
&symbolName,
+1 -1
View File
@@ -306,7 +306,7 @@ INT_PTR CALLBACK PvColumnsDlgProc(
Button_Enable(GetDlgItem(hwndDlg, IDC_MOVEUP), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_MOVEDOWN), FALSE);
if (PhGetIntegerSetting(L"EnableThemeSupport"))
if (PhEnableThemeSupport)
{
context->BrushNormal = CreateSolidBrush(PhThemeWindowBackgroundColor);
context->BrushHot = CreateSolidBrush(PhThemeWindowHighlightColor);
+5 -10
View File
@@ -64,8 +64,7 @@ LRESULT CALLBACK PhMenuWindowHookProcedure(
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport)
@@ -117,8 +116,7 @@ LRESULT CALLBACK PhDialogWindowHookProcedure(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport && PhDefaultEnableThemeAcrylicWindowSupport)
@@ -178,8 +176,7 @@ LRESULT CALLBACK PhComboBoxWindowHookProcedure(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(info.hwndList, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(info.hwndList, WDA_EXCLUDEFROMCAPTURE);
}
}
}
@@ -1579,8 +1576,7 @@ HWND PhCreateWindowExHook(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(windowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(windowHandle, WDA_EXCLUDEFROMCAPTURE);
}
if (PhEnableThemeSupport && PhDefaultEnableThemeAcrylicWindowSupport)
@@ -1868,8 +1864,7 @@ BOOLEAN CALLBACK PhInitializeTaskDialogTheme(
{
if (PhDefaultEnableStreamerMode)
{
if (SetWindowDisplayAffinity_Import())
SetWindowDisplayAffinity_Import()(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
SetWindowDisplayAffinity(WindowHandle, WDA_EXCLUDEFROMCAPTURE);
}
PhInitializeThemeWindowFrame(WindowHandle);
+2 -2
View File
@@ -54,7 +54,7 @@ VOID PvEnumerateEHContinuationEntries(
{
if (!(symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, rva),
&symbolResolveLevel,
NULL,
&symbolName,
@@ -68,7 +68,7 @@ VOID PvEnumerateEHContinuationEntries(
{
if (!(symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, rva),
&symbolResolveLevel,
NULL,
&symbolName,
+2 -2
View File
@@ -304,7 +304,7 @@ NTSTATUS PvpPeExportsEnumerateThread(
{
exportSymbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, exportFunction.Function),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, exportFunction.Function),
NULL,
NULL,
&exportSymbolName,
@@ -315,7 +315,7 @@ NTSTATUS PvpPeExportsEnumerateThread(
{
exportSymbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, exportFunction.Function),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, exportFunction.Function),
NULL,
NULL,
&exportSymbolName,
+13 -9
View File
@@ -1100,8 +1100,8 @@ BOOLEAN PvGetMappedImageImphash(
if (!PhIsNullOrEmptyString(stringBuilder.String))
{
PPH_STRING importStringFinal;
PPH_STRING importStringFuzzy;
PPH_BYTES importStringUtf8;
char* importStringFuzzy;
importStringFinal = PhFinalStringBuilderString(&stringBuilder);
importStringUtf8 = PhConvertUtf16ToUtf8Ex(importStringFinal->Buffer, importStringFinal->Length);
@@ -1115,7 +1115,8 @@ BOOLEAN PvGetMappedImageImphash(
if (fuzzy_hash_buffer((PBYTE)importStringUtf8->Buffer, importStringUtf8->Length, &importStringFuzzy))
{
hashFuzzyString = importStringFuzzy;
hashFuzzyString = PhConvertUtf8ToUtf16(importStringFuzzy);
free(importStringFuzzy);
}
PhDereferenceObject(importStringUtf8);
@@ -1159,7 +1160,8 @@ NTSTATUS PvPeFileHashThread(
PPH_STRING imphashFuzzyString = NULL;
PPH_STRING impMsftHashString = NULL;
PPH_STRING ssdeepHashString = NULL;
PPH_STRING tlshHashString = NULL;
char* tlshHashString = NULL;
char* ssdeepHashStringUtf8 = NULL;
// File hashes
@@ -1192,7 +1194,7 @@ NTSTATUS PvPeFileHashThread(
}
PhSetFilePosition(fileHandle, NULL);
fuzzy_hash_file(fileHandle, &ssdeepHashString);
fuzzy_hash_file(fileHandle, &ssdeepHashStringUtf8);
PhSetFilePosition(fileHandle, NULL);
PvGetTlshFileHash(fileHandle, &tlshHashString);
@@ -1209,12 +1211,12 @@ NTSTATUS PvPeFileHashThread(
// Fuzzy hashes
if (PhIsNullOrEmptyString(ssdeepHashString))
if (!ssdeepHashStringUtf8)
{
fuzzy_hash_buffer(PvMappedImage.ViewBase, PvMappedImage.ViewSize, &ssdeepHashString);
fuzzy_hash_buffer(PvMappedImage.ViewBase, PvMappedImage.ViewSize, &ssdeepHashStringUtf8);
}
if (PhIsNullOrEmptyString(tlshHashString))
if (!tlshHashString)
{
PvGetTlshBufferHash(PvMappedImage.ViewBase, PvMappedImage.ViewSize, &tlshHashString);
}
@@ -1254,9 +1256,11 @@ NTSTATUS PvPeFileHashThread(
results->ImphashString = imphashString;
results->ImphashFuzzyString = imphashFuzzyString;
results->ImpMsftHashString = impMsftHashString;
results->SsdeepHashString = ssdeepHashString;
results->TlshHashString = tlshHashString;
results->SsdeepHashString = PhConvertUtf8ToUtf16(ssdeepHashStringUtf8);
results->TlshHashString = PhConvertUtf8ToUtf16(tlshHashString);
results->PageHashList = pagehashesList;
free(ssdeepHashStringUtf8);
free(tlshHashString);
PostMessage(Context->WindowHandle, WM_PV_HASH_FINISHED, 0, (LPARAM)results);
}
+2 -2
View File
@@ -222,14 +222,14 @@ PPH_STRING PvpQueryModuleOrdinalName(
if (PhLoadModuleSymbolProvider(
moduleSymbolProvider,
exportFileName,
(ULONG64)mappedImage.ViewBase,
mappedImage.ViewBase,
(ULONG)mappedImage.ViewSize
))
{
// Try find the export name using symbols.
exportSymbol = PhGetSymbolFromAddress(
moduleSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(mappedImage.ViewBase, exportFunction.Function),
PTR_ADD_OFFSET(mappedImage.ViewBase, exportFunction.Function),
NULL,
NULL,
&exportSymbolName,
+7 -1
View File
@@ -76,6 +76,12 @@ NTSTATUS PhpOpenFileSecurity(
_In_opt_ PVOID Context
);
NTSTATUS PhpCloseFileSecurity(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
);
// libprp
VOID PvLibProperties(
@@ -291,8 +297,8 @@ typedef struct _PV_SYMBOL_NODE
ULONG64 Size;
ULONG64 Address;
PPH_STRING Name;
PPH_STRING Data;
PPH_STRING SizeText;
PPH_STRINGREF Data;
WCHAR Index[PH_INT64_STR_LEN_1];
WCHAR Pointer[PH_PTR_STR_LEN_1];
+6 -6
View File
@@ -572,7 +572,7 @@ PPH_STRING PvLayoutPeFormatDateTime(
}
PPH_STRING PvLayoutGetRelativeTimeString(
_In_ PLARGE_INTEGER Time
_In_ PLONGLONG Time
)
{
LARGE_INTEGER time;
@@ -581,7 +581,7 @@ PPH_STRING PvLayoutGetRelativeTimeString(
PPH_STRING timeRelativeString;
PPH_STRING timeString;
time = *Time;
time.QuadPart = *Time;
PhQuerySystemTime(&currentTime);
timeRelativeString = PH_AUTO(PhFormatTimeSpanRelative(currentTime.QuadPart - time.QuadPart));
@@ -1099,10 +1099,10 @@ NTSTATUS PvLayoutEnumerateFileLayouts(
PvAddChildLayoutNode(Context, NULL, L"File reference number", PhFormatString(L"%I64u (0x%I64x)", fileLayoutEntry->FileReferenceNumber, fileLayoutEntry->FileReferenceNumber));
PvAddChildLayoutNode(Context, NULL, L"File attributes", PhFormatUInt64(fileLayoutEntry->FileAttributes, FALSE));
PvAddChildLayoutNode(Context, NULL, L"File entry flags", PhFormatUInt64(fileLayoutEntry->Flags, FALSE));
PvAddChildLayoutNode(Context, NULL, L"Creation time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.CreationTime));
//PvAddChildLayoutNode(Context, NULL, L"Access time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.LastAccessTime));
PvAddChildLayoutNode(Context, NULL, L"Write time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.LastWriteTime));
PvAddChildLayoutNode(Context, NULL, L"Change time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.ChangeTime));
PvAddChildLayoutNode(Context, NULL, L"Creation time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.CreationTime.QuadPart));
//PvAddChildLayoutNode(Context, NULL, L"Access time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.LastAccessTime.QuadPart));
PvAddChildLayoutNode(Context, NULL, L"Write time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.LastWriteTime.QuadPart));
PvAddChildLayoutNode(Context, NULL, L"Change time", PvLayoutGetRelativeTimeString(&fileLayoutInfoEntry->BasicInformation.ChangeTime.QuadPart));
PvAddChildLayoutNode(Context, NULL, L"LastUsn", PhFormatUInt64(fileLayoutInfoEntry->Usn, FALSE));
PvAddChildLayoutNode(Context, NULL, L"OwnerId", PhFormatUInt64(fileLayoutInfoEntry->OwnerId, FALSE));
PvAddChildLayoutNode(Context, NULL, L"SecurityId", PhFormatUInt64(fileLayoutInfoEntry->SecurityId, FALSE));
+91 -91
View File
@@ -22,90 +22,90 @@ ULONG SearchResultsAddIndex = 0;
PPH_LIST SearchResults = NULL;
PH_QUEUED_LOCK SearchResultsLock = PH_QUEUED_LOCK_INIT;
PWSTR rgBaseType[] =
PPH_STRINGREF rgBaseType[] =
{
L"<NoType>", // btNoType = 0,
L"void", // btVoid = 1,
L"char", // btChar = 2,
L"wchar_t", // btWChar = 3,
L"signed char",
L"unsigned char",
L"int", // btInt = 6,
L"unsigned int", // btUInt = 7,
L"float", // btFloat = 8,
L"<BCD>", // btBCD = 9,
L"bool", // btBool = 10,
L"short",
L"unsigned short",
L"long", // btLong = 13,
L"unsigned long", // btULong = 14,
L"__int8",
L"__int16",
L"__int32",
L"__int64",
L"__int128",
L"unsigned __int8",
L"unsigned __int16",
L"unsigned __int32",
L"unsigned __int64",
L"unsigned __int128",
L"<currency>", // btCurrency = 25,
L"<date>", // btDate = 26,
L"VARIANT", // btVariant = 27,
L"<complex>", // btComplex = 28,
L"<bit>", // btBit = 29,
L"BSTR", // btBSTR = 30,
L"HRESULT", // btHresult = 31
L"char16_t", // btChar16 = 32
L"char32_t" // btChar32 = 33
L"char8_t", // btChar8 = 34
SREF(L"<NoType>"), // btNoType = 0,
SREF(L"void"), // btVoid = 1,
SREF(L"char"), // btChar = 2,
SREF(L"wchar_t"), // btWChar = 3,
SREF(L"signed char"),
SREF(L"unsigned char"),
SREF(L"int"), // btInt = 6,
SREF(L"unsigned int"), // btUInt = 7,
SREF(L"float"), // btFloat = 8,
SREF(L"<BCD>"), // btBCD = 9,
SREF(L"bool"), // btBool = 10,
SREF(L"short"),
SREF(L"unsigned short"),
SREF(L"long"), // btLong = 13,
SREF(L"unsigned long"), // btULong = 14,
SREF(L"__int8"),
SREF(L"__int16"),
SREF(L"__int32"),
SREF(L"__int64"),
SREF(L"__int128"),
SREF(L"unsigned __int8"),
SREF(L"unsigned __int16"),
SREF(L"unsigned __int32"),
SREF(L"unsigned __int64"),
SREF(L"unsigned __int128"),
SREF(L"<currency>"), // btCurrency = 25,
SREF(L"<date>"), // btDate = 26,
SREF(L"VARIANT"), // btVariant = 27,
SREF(L"<complex>"), // btComplex = 28,
SREF(L"<bit>"), // btBit = 29,
SREF(L"BSTR"), // btBSTR = 30,
SREF(L"HRESULT"), // btHresult = 31
SREF(L"char16_t"), // btChar16 = 32
SREF(L"char32_t"), // btChar32 = 33
SREF(L"char8_t") // btChar8 = 34
};
PWSTR rgTags[] =
PPH_STRINGREF rgTags[] =
{
L"(SymTagNull)", // SymTagNull
L"Executable (Global)", // SymTagExe
L"Compiland", // SymTagCompiland
L"CompilandDetails", // SymTagCompilandDetails
L"CompilandEnv", // SymTagCompilandEnv
L"Function", // SymTagFunction
L"Block", // SymTagBlock
L"Data", // SymTagData
L"Annotation", // SymTagAnnotation
L"Label", // SymTagLabel
L"PublicSymbol", // SymTagPublicSymbol
L"UserDefinedType", // SymTagUDT
L"Enum", // SymTagEnum
L"FunctionType", // SymTagFunctionType
L"PointerType", // SymTagPointerType
L"ArrayType", // SymTagArrayType
L"BaseType", // SymTagBaseType
L"Typedef", // SymTagTypedef
L"BaseClass", // SymTagBaseClass
L"Friend", // SymTagFriend
L"FunctionArgType", // SymTagFunctionArgType
L"FuncDebugStart", // SymTagFuncDebugStart
L"FuncDebugEnd", // SymTagFuncDebugEnd
L"UsingNamespace", // SymTagUsingNamespace
L"VTableShape", // SymTagVTableShape
L"VTable", // SymTagVTable
L"Custom", // SymTagCustom
L"Thunk", // SymTagThunk
L"CustomType", // SymTagCustomType
L"ManagedType", // SymTagManagedType
L"Dimension", // SymTagDimension
L"CallSite", // SymTagCallSite
L"InlineSite", // SymTagInlineSite
L"BaseInterface", // SymTagBaseInterface
L"VectorType", // SymTagVectorType
L"MatrixType", // SymTagMatrixType
L"HLSLType", // SymTagHLSLType
L"Caller", // SymTagCaller,
L"Callee", // SymTagCallee,
L"Export", // SymTagExport,
L"HeapAllocationSite", // SymTagHeapAllocationSite
L"CoffGroup", // SymTagCoffGroup
L"Inlinee", // SymTagInlinee
SREF(L"(SymTagNull)"), // SymTagNull
SREF(L"Executable (Global)"), // SymTagExe
SREF(L"Compiland"), // SymTagCompiland
SREF(L"CompilandDetails"), // SymTagCompilandDetails
SREF(L"CompilandEnv"), // SymTagCompilandEnv
SREF(L"Function"), // SymTagFunction
SREF(L"Block"), // SymTagBlock
SREF(L"Data"), // SymTagData
SREF(L"Annotation"), // SymTagAnnotation
SREF(L"Label"), // SymTagLabel
SREF(L"PublicSymbol"), // SymTagPublicSymbol
SREF(L"UserDefinedType"), // SymTagUDT
SREF(L"Enum"), // SymTagEnum
SREF(L"FunctionType"), // SymTagFunctionType
SREF(L"PointerType"), // SymTagPointerType
SREF(L"ArrayType"), // SymTagArrayType
SREF(L"BaseType"), // SymTagBaseType
SREF(L"Typedef"), // SymTagTypedef
SREF(L"BaseClass"), // SymTagBaseClass
SREF(L"Friend"), // SymTagFriend
SREF(L"FunctionArgType"), // SymTagFunctionArgType
SREF(L"FuncDebugStart"), // SymTagFuncDebugStart
SREF(L"FuncDebugEnd"), // SymTagFuncDebugEnd
SREF(L"UsingNamespace"), // SymTagUsingNamespace
SREF(L"VTableShape"), // SymTagVTableShape
SREF(L"VTable"), // SymTagVTable
SREF(L"Custom"), // SymTagCustom
SREF(L"Thunk"), // SymTagThunk
SREF(L"CustomType"), // SymTagCustomType
SREF(L"ManagedType"), // SymTagManagedType
SREF(L"Dimension"), // SymTagDimension
SREF(L"CallSite"), // SymTagCallSite
SREF(L"InlineSite"), // SymTagInlineSite
SREF(L"BaseInterface"), // SymTagBaseInterface
SREF(L"VectorType"), // SymTagVectorType
SREF(L"MatrixType"), // SymTagMatrixType
SREF(L"HLSLType"), // SymTagHLSLType
SREF(L"Caller"), // SymTagCaller
SREF(L"Callee"), // SymTagCallee
SREF(L"Export"), // SymTagExport
SREF(L"HeapAllocationSite"), // SymTagHeapAllocationSite
SREF(L"CoffGroup"), // SymTagCoffGroup
SREF(L"Inlinee"), // SymTagInlinee
};
PWSTR rgLocationTypeString[] =
@@ -156,7 +156,8 @@ VOID PrintSymTag(
_In_ ULONG SymbolTag
)
{
PhAppendFormatStringBuilder(StringBuilder, L"%s: ", rgTags[SymbolTag]);
PhAppendStringBuilder(StringBuilder, rgTags[SymbolTag]);
PhAppendFormatStringBuilder(StringBuilder, L": ");
}
VOID PrintVariant(
@@ -920,8 +921,7 @@ VOID PePdbPrintDiaSymbol(
symbol->Address = symbolRva;
symbol->Size = symbolLength;
symbol->Name = PhCreateString(bstrUndname ? bstrUndname : bstrName);
symbol->Data = PhCreateString(rgTags[symbolTag]);
symbol->Data = rgTags[symbolTag];
//symbol->Data = SymbolInfo_GetTypeName(
// context,
// SymbolInfo->TypeIndex,
@@ -1036,7 +1036,7 @@ VOID PePdbPrintDiaSymbol(
symbol->Size = symbolLength;
symbol->Name = PhCreateString(bstrUndname ? bstrUndname : bstrName);
//PhCreateStringEx(SymbolInfo->Name, SymbolInfo->NameLen * sizeof(WCHAR));
symbol->Data = PhCreateString(rgTags[symbolTag]);
symbol->Data = rgTags[symbolTag];
//symbol->Data = SymbolInfo_GetTypeName(context, SymbolInfo->TypeIndex, SymbolInfo->Name);
//SymbolInfo_SymbolLocationStr(SymbolInfo, symbol->Pointer);
PhPrintPointer(symbol->Pointer, UlongToPtr(symbolRva));
@@ -1079,7 +1079,7 @@ VOID PePdbPrintDiaSymbol(
symbol->Address = symbolRva;
symbol->Size = symbolLength;
symbol->Name = PhCreateString(bstrUndname ? bstrUndname : bstrName);
symbol->Data = PhCreateString(rgTags[symbolTag]);
symbol->Data = rgTags[symbolTag];
//symbol->Data = SymbolInfo_GetTypeName(context, SymbolInfo->TypeIndex, SymbolInfo->Name);
//SymbolInfo_SymbolLocationStr(SymbolInfo, symbol->Pointer);
PhPrintPointer(symbol->Pointer, UlongToPtr(symbolRva));
@@ -1255,16 +1255,16 @@ NTSTATUS PeDumpFileSymbols(
_In_ PPDB_SYMBOL_CONTEXT Context
)
{
ULONG64 baseOfDll = ULLONG_MAX;
PVOID baseOfDll = NULL;
IDiaSession* idiaSession;
IDiaSymbol* idiaSymbol;
if (PvMappedImage.Signature) // HACK: Null when opening a pdb file.
{
if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
baseOfDll = (ULONG64)PvMappedImage.NtHeaders32->OptionalHeader.ImageBase;
baseOfDll = PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, 0);
else
baseOfDll = (ULONG64)PvMappedImage.NtHeaders->OptionalHeader.ImageBase;
baseOfDll = PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, 0);
}
else
{
@@ -1304,11 +1304,11 @@ NTSTATUS PeDumpFileSymbols(
if (PhLoadFileNameSymbolProvider(
PvSymbolProvider,
PvFileName,
(ULONG64)viewBase,
viewBase,
(ULONG)size
))
{
baseOfDll = (ULONG64)viewBase;
baseOfDll = viewBase;
}
}
@@ -1322,7 +1322,7 @@ NTSTATUS PeDumpFileSymbols(
}
}
if (baseOfDll == ULLONG_MAX)
if (!baseOfDll)
{
PostMessage(Context->WindowHandle, WM_PV_SEARCH_FINISHED, 0, 0);
PhShowStatus(NULL, L"Unable to load the file.", STATUS_UNSUCCESSFUL, 0);
+13 -3
View File
@@ -259,7 +259,7 @@ END_SORT_FUNCTION
BEGIN_SORT_FUNCTION(Data)
{
sortResult = PhCompareStringWithNull(node1->Data, node2->Data, TRUE);
sortResult = PhCompareStringRefWithNullSortOrder(node1->Data, node2->Data, ((PPDB_SYMBOL_CONTEXT)_context)->TreeNewSortOrder, TRUE);
}
END_SORT_FUNCTION
@@ -414,7 +414,17 @@ BOOLEAN NTAPI PvSymbolTreeNewCallback(
getCellText->Text = PhGetStringRef(node->Name);
break;
case TREE_COLUMN_ITEM_SYMBOL:
getCellText->Text = PhGetStringRef(node->Data);
{
if (node->Data)
{
getCellText->Text.Buffer = node->Data->Buffer;
getCellText->Text.Length = node->Data->Length;
}
else
{
PhInitializeEmptyStringRef(&getCellText->Text);
}
}
break;
case TREE_COLUMN_ITEM_SIZE:
{
@@ -707,7 +717,7 @@ BOOLEAN PvSymbolTreeFilterCallback(
if (!PhIsNullOrEmptyString(node->Data))
{
if (PvSearchControlMatch(context->SearchMatchHandle, &node->Data->sr))
if (PvSearchControlMatch(context->SearchMatchHandle, node->Data))
return TRUE;
}
+1 -1
View File
@@ -54,7 +54,7 @@ PPH_STRING PvpCHPERvaToSymbol(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)va,
va,
&level,
NULL,
NULL,
+7 -5
View File
@@ -281,7 +281,7 @@ VOID PvpPeEnumerateImageDataDirectory(
__try
{
PPH_STRING ssdeepHashString = NULL;
char* ssdeepHashString = NULL;
fuzzy_hash_buffer(
imageDirectoryData,
@@ -291,7 +291,8 @@ VOID PvpPeEnumerateImageDataDirectory(
if (ssdeepHashString)
{
directoryNode->SsdeepString = ssdeepHashString;
directoryNode->SsdeepString = PhConvertUtf8ToUtf16(ssdeepHashString);
free(ssdeepHashString);
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
@@ -302,7 +303,7 @@ VOID PvpPeEnumerateImageDataDirectory(
__try
{
PPH_STRING tlshHashString = NULL;
char* tlshHashString = NULL;
//
// This can fail in TLSH library during finalization when
@@ -314,9 +315,10 @@ VOID PvpPeEnumerateImageDataDirectory(
&tlshHashString
);
if (!PhIsNullOrEmptyString(tlshHashString))
if (tlshHashString)
{
directoryNode->TlshString = tlshHashString;
directoryNode->TlshString = PhConvertUtf8ToUtf16(tlshHashString);
free(tlshHashString);
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
+1 -1
View File
@@ -209,7 +209,7 @@ VOID PvEnumerateDynamicRelocationEntries(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)entry->ImageBaseVa,
entry->ImageBaseVa,
NULL,
NULL,
NULL,
+3 -3
View File
@@ -79,7 +79,7 @@ VOID PvEnumerateExceptionEntries(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, entry),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, entry),
NULL,
NULL,
&symbolName,
@@ -143,7 +143,7 @@ VOID PvEnumerateExceptionEntries(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry->BeginAddress),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry->BeginAddress),
NULL,
NULL,
&symbolName,
@@ -250,7 +250,7 @@ VOID PvEnumerateExceptionEntries(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry->BeginAddress),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry->BeginAddress),
NULL,
NULL,
&symbolName,
+13 -9
View File
@@ -114,16 +114,18 @@ VOID PvEnumerateImagePogoSections(
__try
{
PPH_STRING ssdeepHashString = NULL;
char* ssdeepHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
fuzzy_hash_buffer(imageSectionData, entry->Size, &ssdeepHashString);
if (!PhIsNullOrEmptyString(ssdeepHashString))
if (ssdeepHashString)
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 8, ssdeepHashString->Buffer);
PhDereferenceObject(ssdeepHashString);
PPH_STRING ssdeepString = PhConvertUtf8ToUtf16(ssdeepHashString);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 8, ssdeepString->Buffer);
PhDereferenceObject(ssdeepString);
free(ssdeepHashString);
}
}
}
@@ -139,7 +141,7 @@ VOID PvEnumerateImagePogoSections(
__try
{
PPH_STRING tlshHashString = NULL;
char* tlshHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
@@ -149,10 +151,12 @@ VOID PvEnumerateImagePogoSections(
//
PvGetTlshBufferHash(imageSectionData, entry->Size, &tlshHashString);
if (!PhIsNullOrEmptyString(tlshHashString))
if (tlshHashString)
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 9, tlshHashString->Buffer);
PhDereferenceObject(tlshHashString);
PPH_STRING hashString = PhConvertUtf8ToUtf16(tlshHashString);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 9, hashString->Buffer);
PhDereferenceObject(hashString);
free(tlshHashString);
}
}
}
@@ -397,7 +401,7 @@ VOID PvEnumerateCrtInitializers(
initSymbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(baseAddress, PTR_ADD_OFFSET(array, UInt32x32To64(i, size))),
PTR_ADD_OFFSET(baseAddress, PTR_ADD_OFFSET(array, UInt32x32To64(i, size))),
&symbolResolveLevel,
NULL,
&initSymbolName,
+14 -4
View File
@@ -120,7 +120,7 @@ VOID PvPeProperties(
PhLoadModuleSymbolProvider(
PvSymbolProvider,
fileName,
(ULONG64)PvMappedImage.NtHeaders32->OptionalHeader.ImageBase,
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, 0),
PvMappedImage.NtHeaders32->OptionalHeader.SizeOfImage
);
}
@@ -129,7 +129,7 @@ VOID PvPeProperties(
PhLoadModuleSymbolProvider(
PvSymbolProvider,
fileName,
(ULONG64)PvMappedImage.NtHeaders->OptionalHeader.ImageBase,
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, 0),
PvMappedImage.NtHeaders->OptionalHeader.SizeOfImage
);
}
@@ -1168,7 +1168,7 @@ static NTSTATUS PvpEntryPointImageThreadStart(
{
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, addressOfEntryPoint),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, addressOfEntryPoint),
&symbolResolveLevel,
&fileName,
&symbolName,
@@ -1179,7 +1179,7 @@ static NTSTATUS PvpEntryPointImageThreadStart(
{
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, addressOfEntryPoint),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, addressOfEntryPoint),
&symbolResolveLevel,
&fileName,
&symbolName,
@@ -1956,6 +1956,16 @@ NTSTATUS PhpOpenFileSecurity(
return status;
}
NTSTATUS PhpCloseFileSecurity(
_In_opt_ HANDLE Handle,
_In_opt_ BOOLEAN Release,
_In_opt_ PVOID Context
)
{
if (Handle) NtClose(Handle);
return STATUS_SUCCESS;
}
static COLORREF NTAPI PvpPeCharacteristicsColorFunction(
_In_ INT Index,
_In_ PVOID Param,
+3 -3
View File
@@ -807,7 +807,7 @@ INT_PTR CALLBACK PvTabWindowDialogProc(
PhLoadModuleSymbolProvider(
PvSymbolProvider,
fileName,
(ULONG64)PvMappedImage.NtHeaders32->OptionalHeader.ImageBase,
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, 0),
PvMappedImage.NtHeaders32->OptionalHeader.SizeOfImage
);
}
@@ -816,7 +816,7 @@ INT_PTR CALLBACK PvTabWindowDialogProc(
PhLoadModuleSymbolProvider(
PvSymbolProvider,
fileName,
(ULONG64)PvMappedImage.NtHeaders->OptionalHeader.ImageBase,
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, 0),
PvMappedImage.NtHeaders->OptionalHeader.SizeOfImage
);
}
@@ -890,7 +890,7 @@ INT_PTR CALLBACK PvTabWindowDialogProc(
PhGetString(PvFileName),
L"FileObject",
PhpOpenFileSecurity,
NULL,
PhpCloseFileSecurity,
NULL
);
}
+2 -2
View File
@@ -99,7 +99,7 @@ VOID PvEnumerateRelocationEntries(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)entry->ImageBaseVa,
entry->ImageBaseVa,
NULL,
NULL,
NULL,
@@ -136,7 +136,7 @@ VOID PvEnumerateRelocationEntries(
{
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
reloc,
(PVOID)reloc,
NULL,
NULL,
NULL,
+8 -6
View File
@@ -348,7 +348,7 @@ NTSTATUS PvpPeSectionsEnumerateThread(
__try
{
PPH_STRING ssdeepHashString = NULL;
char* ssdeepHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, PvMappedImage.Sections[i].VirtualAddress, NULL))
{
@@ -360,7 +360,8 @@ NTSTATUS PvpPeSectionsEnumerateThread(
if (ssdeepHashString)
{
sectionNode->SsdeepString = ssdeepHashString;
sectionNode->SsdeepString = PhConvertUtf8ToUtf16(ssdeepHashString);
free(ssdeepHashString);
}
}
}
@@ -372,7 +373,7 @@ NTSTATUS PvpPeSectionsEnumerateThread(
__try
{
PPH_STRING tlshHashString = NULL;
char* tlshHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, PvMappedImage.Sections[i].VirtualAddress, NULL))
{
@@ -386,9 +387,10 @@ NTSTATUS PvpPeSectionsEnumerateThread(
&tlshHashString
);
if (!PhIsNullOrEmptyString(tlshHashString))
if (tlshHashString)
{
sectionNode->TlshString = tlshHashString;
sectionNode->TlshString = PhConvertUtf8ToUtf16(tlshHashString);
free(tlshHashString);
}
}
}
@@ -486,7 +488,7 @@ INT_PTR CALLBACK PvPeSectionsDlgProc(
PhCreateThread2(PvpPeSectionsEnumerateThread, context);
PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
PhSetWindowTheme(hwndDlg);
}
break;
case WM_DESTROY:
+2 -2
View File
@@ -402,7 +402,7 @@ BEGIN
CONTROL "",IDC_SECTIONTREE,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_TRACKSELECT | TVS_FULLROWSELECT | WS_HSCROLL | WS_TABSTOP,2,1,103,381
CONTROL "",IDD_CONTAINER,"#32770",0x44c,107,0,573,384,WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT | 0xc0000800L
PUSHBUTTON "Options",IDC_OPTIONS,108,386,50,14
PUSHBUTTON "Security",IDC_SECURITY,160,386,50,14
PUSHBUTTON "Permissions",IDC_SECURITY,160,386,50,14
END
IDD_PEGENERAL DIALOGEX 0, 0, 300, 280
@@ -679,7 +679,7 @@ END
IDD_PESECURITY DIALOGEX 0, 0, 301, 280
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Security"
CAPTION "Permissions"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_TREELIST,"PhTreeNew",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0x2,3,21,295,256,WS_EX_CLIENTEDGE
+3 -4
View File
@@ -136,7 +136,7 @@ LRESULT CALLBACK PvpButtonWndProc(
PhGetString(PvFileName),
L"FileObject",
PhpOpenFileSecurity,
NULL,
PhpCloseFileSecurity,
NULL
);
}
@@ -164,7 +164,7 @@ static HWND PvpCreateOptionsButton(
// Create the Reset button.
GetClientRect(optionsWindow, &clientRect);
GetWindowRect(GetDlgItem(optionsWindow, IDCANCEL), &rect);
MapWindowPoints(NULL, optionsWindow, (POINT*)&rect, 2);
MapWindowRect(NULL, optionsWindow, &rect);
OptionsButton = CreateWindowEx(
WS_EX_NOPARENTNOTIFY,
WC_BUTTON,
@@ -207,7 +207,7 @@ static HWND PvpCreateSecurityButton(
SecurityButton = CreateWindowEx(
WS_EX_NOPARENTNOTIFY,
WC_BUTTON,
L"Security",
L"Permissions",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
rect.right + 3,
rect.top,
@@ -224,7 +224,6 @@ static HWND PvpCreateSecurityButton(
return SecurityButton;
}
static HFONT PvpCreateFont(
_In_ PWSTR Name,
_In_ ULONG Size,
+1 -1
View File
@@ -51,7 +51,7 @@ VOID PvpPeEnumerateTlsCallbacks(
symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)entry.Address,
(PVOID)entry.Address,
NULL,
NULL,
&symbolName,
+3 -3
View File
@@ -70,12 +70,12 @@ BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "Winsider Seminars & Solutions"
VALUE "FileDescription", "Portable Executable View"
VALUE "FileDescription", "Portable Executable Viewer"
VALUE "FileVersion", PHAPP_VERSION_STRING
VALUE "InternalName", "Portable Executable View"
VALUE "InternalName", "Portable Executable Viewer"
VALUE "LegalCopyright", "Copyright (c) Winsider Seminars & Solutions, Inc. All rights reserved."
VALUE "OriginalFilename", "peview.exe"
VALUE "ProductName", "Portable Executable View"
VALUE "ProductName", "Portable Executable Viewer"
VALUE "ProductVersion", PHAPP_VERSION_STRING
END
END
+2 -2
View File
@@ -68,7 +68,7 @@ VOID PvEnumerateVolatileEntries(
{
if (!(symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, entry.Rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, entry.Rva),
&symbolResolveLevel,
NULL,
&symbolName,
@@ -82,7 +82,7 @@ VOID PvEnumerateVolatileEntries(
{
if (!(symbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry.Rva),
PTR_ADD_OFFSET(PvMappedImage.NtHeaders->OptionalHeader.ImageBase, entry.Rva),
&symbolResolveLevel,
NULL,
&symbolName,
+2
View File
@@ -229,3 +229,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
#define _CRT_SECURE_NO_WARNINGS 1
+10 -11
View File
@@ -101,8 +101,8 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
if (!tok)
{
_json_c_set_last_err(
"json_object_from_fd_ex: unable to allocate json_tokener(depth=%d): %s\n",
depth, strerror(errno));
"json_object_from_fd_ex: unable to allocate json_tokener(depth=%d)\n",
depth);
printbuf_free(pb);
return NULL;
}
@@ -115,7 +115,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
#error "Can't append more than INT_MAX bytes at a time"
#endif
_json_c_set_last_err(
"json_object_from_fd_ex: failed to printbuf_memappend after reading %d+%d bytes: %s", printbuf_length(pb), (int)ret, strerror(errno));
"json_object_from_fd_ex: failed to printbuf_memappend after reading %d+%d bytes", printbuf_length(pb), (int)ret);
json_tokener_free(tok);
printbuf_free(pb);
return NULL;
@@ -123,8 +123,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
}
if (ret < 0)
{
_json_c_set_last_err("json_object_from_fd_ex: error reading fd %d: %s\n", fd,
strerror(errno));
_json_c_set_last_err("json_object_from_fd_ex: error reading fd %d\n", fd);
json_tokener_free(tok);
printbuf_free(pb);
return NULL;
@@ -147,8 +146,8 @@ struct json_object *json_object_from_file(const char *filename)
if ((fd = open(filename, O_RDONLY)) < 0)
{
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n",
filename, strerror(errno));
_json_c_set_last_err("json_object_from_file: error opening file %s\n",
filename);
return NULL;
}
obj = json_object_from_fd(fd);
@@ -171,8 +170,8 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0)
{
_json_c_set_last_err("json_object_to_file_ext: error opening file %s: %s\n",
filename, strerror(errno));
_json_c_set_last_err("json_object_to_file_ext: error opening file %s\n",
filename);
return -1;
}
ret = _json_object_to_fd(fd, obj, flags, filename);
@@ -211,8 +210,8 @@ static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const
{
if ((ret = _write(fd, json_str + wpos, (unsigned int)(wsize - wpos))) < 0)
{
_json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n",
filename, strerror(errno));
_json_c_set_last_err("json_object_to_fd: error writing file %s\n",
filename);
return -1;
}
+48 -48
View File
@@ -60,51 +60,51 @@ static struct
// Enabled during tests
static int _json_c_strerror_enable = 0;
extern char *getenv(const char *name); // Avoid including stdlib.h
#define PREFIX "ERRNO="
static char errno_buf[128] = PREFIX;
char *_json_c_strerror(int errno_in)
{
int start_idx;
char digbuf[20];
int ii, jj;
if (!_json_c_strerror_enable)
_json_c_strerror_enable = (getenv("_JSON_C_STRERROR_ENABLE") == NULL) ? -1 : 1;
if (_json_c_strerror_enable == -1)
return strerror(errno_in);
// Avoid standard functions, so we don't need to include any
// headers, or guess at signatures.
for (ii = 0; errno_list[ii].errno_str != (char *)0; ii++)
{
const char *errno_str = errno_list[ii].errno_str;
if (errno_list[ii].errno_value != errno_in)
continue;
for (start_idx = sizeof(PREFIX) - 1, jj = 0; errno_str[jj] != '\0';
jj++, start_idx++)
{
errno_buf[start_idx] = errno_str[jj];
}
errno_buf[start_idx] = '\0';
return errno_buf;
}
// It's not one of the known errno values, return the numeric value.
for (ii = 0; errno_in >= 10; errno_in /= 10, ii++)
{
digbuf[ii] = "0123456789"[(errno_in % 10)];
}
digbuf[ii] = "0123456789"[(errno_in % 10)];
// Reverse the digits
for (start_idx = sizeof(PREFIX) - 1; ii >= 0; ii--, start_idx++)
{
errno_buf[start_idx] = digbuf[ii];
}
errno_buf[start_idx] = '\0';
return errno_buf;
}
//extern char *getenv(const char *name); // Avoid including stdlib.h
//
//#define PREFIX "ERRNO="
//static char errno_buf[128] = PREFIX;
//char *_json_c_strerror(int errno_in)
//{
// int start_idx;
// char digbuf[20];
// int ii, jj;
//
// if (!_json_c_strerror_enable)
// _json_c_strerror_enable = (getenv("_JSON_C_STRERROR_ENABLE") == NULL) ? -1 : 1;
// if (_json_c_strerror_enable == -1)
// return strerror(errno_in);
//
// // Avoid standard functions, so we don't need to include any
// // headers, or guess at signatures.
//
// for (ii = 0; errno_list[ii].errno_str != (char *)0; ii++)
// {
// const char *errno_str = errno_list[ii].errno_str;
// if (errno_list[ii].errno_value != errno_in)
// continue;
//
// for (start_idx = sizeof(PREFIX) - 1, jj = 0; errno_str[jj] != '\0';
// jj++, start_idx++)
// {
// errno_buf[start_idx] = errno_str[jj];
// }
// errno_buf[start_idx] = '\0';
// return errno_buf;
// }
//
// // It's not one of the known errno values, return the numeric value.
// for (ii = 0; errno_in >= 10; errno_in /= 10, ii++)
// {
// digbuf[ii] = "0123456789"[(errno_in % 10)];
// }
// digbuf[ii] = "0123456789"[(errno_in % 10)];
//
// // Reverse the digits
// for (start_idx = sizeof(PREFIX) - 1; ii >= 0; ii--, start_idx++)
// {
// errno_buf[start_idx] = digbuf[ii];
// }
// errno_buf[start_idx] = '\0';
// return errno_buf;
//}
+1 -1
View File
@@ -17,7 +17,7 @@ extern "C" {
#include <string.h>
JSON_EXPORT char *_json_c_strerror(int errno_in);
//JSON_EXPORT char *_json_c_strerror(int errno_in);
#ifndef STRERROR_OVERRIDE_IMPL
#define strerror _json_c_strerror
+6 -6
View File
@@ -12,18 +12,18 @@
// Allocate an MMDB_data_pool_s. It initially has space for size
// MMDB_entry_data_list_s structs.
MMDB_data_pool_s *data_pool_new(size_t const size) {
MMDB_data_pool_s *const pool = PhAllocateSafe(sizeof(MMDB_data_pool_s));
MMDB_data_pool_s* const pool = calloc(1, sizeof(MMDB_data_pool_s));
if (!pool) {
return NULL;
}
memset(pool, 0, sizeof(MMDB_data_pool_s));
if (size == 0 ||
!can_multiply(SIZE_MAX, size, sizeof(MMDB_entry_data_list_s))) {
data_pool_destroy(pool);
return NULL;
}
pool->size = size;
pool->blocks[0] = PhAllocateSafe(pool->size * sizeof(MMDB_entry_data_list_s));
pool->blocks[0] = calloc(pool->size, sizeof(MMDB_entry_data_list_s));
if (!pool->blocks[0]) {
data_pool_destroy(pool);
return NULL;
@@ -57,10 +57,10 @@ void data_pool_destroy(MMDB_data_pool_s *const pool) {
}
for (size_t i = 0; i <= pool->index; i++) {
PhFree(pool->blocks[i]);
free(pool->blocks[i]);
}
PhFree(pool);
free(pool);
}
// Claim a new struct from the pool. Doing this may cause the pool's size to
@@ -92,7 +92,7 @@ MMDB_entry_data_list_s *data_pool_alloc(MMDB_data_pool_s *const pool) {
if (!can_multiply(SIZE_MAX, new_size, sizeof(MMDB_entry_data_list_s))) {
return NULL;
}
pool->blocks[new_index] = PhAllocateSafe(new_size * sizeof(MMDB_entry_data_list_s));
pool->blocks[new_index] = calloc(new_size, sizeof(MMDB_entry_data_list_s));
if (!pool->blocks[new_index]) {
return NULL;
}
+2 -2
View File
@@ -140,7 +140,7 @@ static char *mmdb_strdup(const char *str) {
char *copy;
len = strlen(str) + 1;
if ((copy = PhAllocateSafe(len)) == NULL)
if ((copy = malloc(len)) == NULL)
return (NULL);
memcpy(copy, str, len);
return (copy);
@@ -151,7 +151,7 @@ static char *mmdb_strndup(const char *str, size_t n) {
char *copy;
len = strnlen(str, n);
if ((copy = PhAllocateSafe(len + 1)) == NULL)
if ((copy = malloc(len + 1)) == NULL)
return (NULL);
memcpy(copy, str, len);
copy[len] = '\0';
+47 -27
View File
@@ -47,7 +47,7 @@ typedef ADDRESS_FAMILY sa_family_t;
abort(); \
} \
fprintf(stderr, fmt "\n", binary); \
PhFree(binary); \
free(binary); \
} while (0)
#define DEBUG_NL fprintf(stderr, "\n")
#else
@@ -59,11 +59,10 @@ typedef ADDRESS_FAMILY sa_family_t;
#ifdef MMDB_DEBUG
char *byte_to_binary(uint8_t byte) {
char *bits = PhAllocateSafe(9 * sizeof(char));
char* bits = calloc(9, sizeof(char));
if (NULL == bits) {
return bits;
}
memset(bits, 0, 9 * sizeof(char));
for (uint8_t i = 0; i < 8; i++) {
bits[i] = byte & (128 >> i) ? '1' : '0';
@@ -238,7 +237,7 @@ static char *bytes_to_hex(uint8_t const *bytes, uint32_t size);
#define FREE_AND_SET_NULL(p) \
{ \
PhFree((void *)(p)); \
free((void *)(p)); \
(p) = NULL; \
}
@@ -351,16 +350,14 @@ cleanup:
static LPWSTR utf8_to_utf16(const char *utf8_str) {
int wide_chars = MultiByteToWideChar(CP_UTF8, 0, utf8_str, -1, NULL, 0);
wchar_t *utf16_str = (wchar_t *)PhAllocateSafe(wide_chars * sizeof(wchar_t));
wchar_t* utf16_str = (wchar_t*)calloc(wide_chars, sizeof(wchar_t));
if (!utf16_str) {
return NULL;
}
//memset(utf16_str, 0, wide_chars * sizeof(wchar_t));
if (MultiByteToWideChar(CP_UTF8, 0, utf8_str, -1, utf16_str, wide_chars) <
1) {
PhFree(utf16_str);
free(utf16_str);
return NULL;
}
@@ -372,24 +369,49 @@ static int map_file(MMDB_s* const mmdb, PPH_STRINGREF filename) // dmex: modifie
NTSTATUS status;
HANDLE fileHandle;
HANDLE sectionHandle;
LARGE_INTEGER fileSize;
FILE_STANDARD_INFORMATION basicInfo;
UNICODE_STRING fileName;
OBJECT_ATTRIBUTES objectAttributes;
IO_STATUS_BLOCK ioStatusBlock;
SIZE_T viewSize;
PVOID viewBase;
status = PhCreateFile(
fileName.Length = (USHORT)filename->Length;
fileName.MaximumLength = (USHORT)filename->Length + sizeof(UNICODE_NULL);
fileName.Buffer = filename->Buffer;
InitializeObjectAttributes(
&objectAttributes,
&fileName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL
);
status = NtCreateFile(
&fileHandle,
filename,
FILE_READ_ATTRIBUTES | FILE_READ_DATA | SYNCHRONIZE,
&objectAttributes,
&ioStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);
if (!NT_SUCCESS(status))
return MMDB_FILE_OPEN_ERROR;
status = PhGetFileSize(fileHandle, &fileSize);
status = NtQueryInformationFile(
fileHandle,
&ioStatusBlock,
&basicInfo,
sizeof(FILE_STANDARD_INFORMATION),
FileStandardInformation
);
if (!NT_SUCCESS(status))
{
@@ -401,7 +423,7 @@ static int map_file(MMDB_s* const mmdb, PPH_STRINGREF filename) // dmex: modifie
&sectionHandle,
SECTION_QUERY | SECTION_MAP_READ,
NULL,
&fileSize,
&basicInfo.EndOfFile,
PAGE_READONLY,
SEC_COMMIT,
fileHandle
@@ -412,7 +434,7 @@ static int map_file(MMDB_s* const mmdb, PPH_STRINGREF filename) // dmex: modifie
if (!NT_SUCCESS(status))
return MMDB_FILE_OPEN_ERROR;
viewSize = (SIZE_T)fileSize.QuadPart;
viewSize = (SIZE_T)basicInfo.EndOfFile.QuadPart;
viewBase = NULL;
status = NtMapViewOfSection(
@@ -827,21 +849,19 @@ static int populate_description_metadata(MMDB_s *mmdb,
MMDB_INVALID_METADATA_ERROR);
mmdb->metadata.description.descriptions =
PhAllocateSafe(map_size * sizeof(MMDB_description_s *));
calloc(map_size, sizeof(MMDB_description_s*));
if (NULL == mmdb->metadata.description.descriptions) {
status = MMDB_OUT_OF_MEMORY_ERROR;
goto cleanup;
}
memset(mmdb->metadata.description.descriptions, 0, map_size * sizeof(MMDB_description_s*));
for (uint32_t i = 0; i < map_size; i++) {
mmdb->metadata.description.descriptions[i] =
PhAllocateSafe(sizeof(MMDB_description_s));
calloc(1, sizeof(MMDB_description_s));
if (NULL == mmdb->metadata.description.descriptions[i]) {
status = MMDB_OUT_OF_MEMORY_ERROR;
goto cleanup;
}
memset(mmdb->metadata.description.descriptions[i], 0, sizeof(MMDB_description_s));
mmdb->metadata.description.count = i + 1;
mmdb->metadata.description.descriptions[i]->language = NULL;
@@ -1167,7 +1187,7 @@ int MMDB_vget_value(MMDB_entry_s *const start,
return MMDB_INVALID_METADATA_ERROR;
}
const char **path = PhAllocateSafe((length + 1) * sizeof(const char *));
const char** path = calloc(length + 1, sizeof(const char*));
if (NULL == path) {
return MMDB_OUT_OF_MEMORY_ERROR;
}
@@ -1180,7 +1200,7 @@ int MMDB_vget_value(MMDB_entry_s *const start,
int status = MMDB_aget_value(start, entry_data, path);
PhFree(path);
free(path);
return status;
}
@@ -1602,7 +1622,7 @@ static int decode_one(const MMDB_s *const mmdb,
abort();
}
DEBUG_MSGF("string value: %s", string);
PhFree(string);
free(string);
#endif
} else if (type == MMDB_DATA_TYPE_BYTES) {
entry_data->bytes = &mem[offset];
@@ -1988,7 +2008,7 @@ dump_entry_data_list(FILE *stream,
print_indentation(stream, indent);
fprintf(stream, "\"%s\": \n", key);
PhFree(key);
free(key);
entry_data_list = entry_data_list->next;
entry_data_list = dump_entry_data_list(
@@ -2033,7 +2053,7 @@ dump_entry_data_list(FILE *stream,
}
print_indentation(stream, indent);
fprintf(stream, "\"%s\" <utf8_string>\n", string);
PhFree(string);
free(string);
entry_data_list = entry_data_list->next;
} break;
case MMDB_DATA_TYPE_BYTES: {
@@ -2048,7 +2068,7 @@ dump_entry_data_list(FILE *stream,
print_indentation(stream, indent);
fprintf(stream, "%s <bytes>\n", hex_string);
PhFree(hex_string);
free(hex_string);
entry_data_list = entry_data_list->next;
} break;
@@ -2102,7 +2122,7 @@ dump_entry_data_list(FILE *stream,
return NULL;
}
fprintf(stream, "0x%s <uint128>\n", hex_string);
PhFree(hex_string);
free(hex_string);
#else
uint64_t high = entry_data_list->entry_data.uint128 >> 64;
uint64_t low = (uint64_t)entry_data_list->entry_data.uint128;
@@ -2139,7 +2159,7 @@ static char *bytes_to_hex(uint8_t const *bytes, uint32_t size) {
char *hex_string;
MAYBE_CHECK_SIZE_OVERFLOW(size, SIZE_MAX / 2 - 1, NULL);
hex_string = PhAllocateSafe(((size * 2) + 1) * sizeof(char));
hex_string = calloc((size * 2) + 1, sizeof(char));
if (NULL == hex_string) {
return NULL;
}
+6 -6
View File
@@ -3068,7 +3068,7 @@ extern "C" {
static WCHAR* mz_utf8z_to_widechar(const char* str)
{
int reqChars = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
WCHAR* wStr = (WCHAR*)PhAllocateSafe(reqChars * sizeof(WCHAR));
WCHAR* wStr = (WCHAR*)malloc(reqChars * sizeof(WCHAR));
MultiByteToWideChar(CP_UTF8, 0, str, -1, wStr, reqChars);
return wStr;
}
@@ -3079,8 +3079,8 @@ static FILE *mz_fopen(const char *pFilename, const char *pMode)
WCHAR* wMode = mz_utf8z_to_widechar(pMode);
FILE* pFile = NULL;
errno_t err = _wfopen_s(&pFile, wFilename, wMode);
PhFree(wFilename);
PhFree(wMode);
free(wFilename);
free(wMode);
return err ? NULL : pFile;
}
@@ -3090,8 +3090,8 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
WCHAR* wMode = mz_utf8z_to_widechar(pMode);
FILE* pFile = NULL;
errno_t err = _wfreopen_s(&pFile, wPath, wMode, pStream);
PhFree(wPath);
PhFree(wMode);
free(wPath);
free(wMode);
return err ? NULL : pFile;
}
@@ -3099,7 +3099,7 @@ static int mz_stat64(const char *path, struct __stat64 *buffer)
{
WCHAR* wPath = mz_utf8z_to_widechar(path);
int res = _wstat64(wPath, buffer);
PhFree(wPath);
free(wPath);
return res;
}

Some files were not shown because too many files have changed in this diff Show More