Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex authored Sep 13, 2024
2 parents 33f252b + 05f6de0 commit aaba59c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
4 changes: 1 addition & 3 deletions KSystemInformer/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ NTSTATUS KphReadVirtualMemory(

if (AccessMode != KernelMode)
{
if ((Add2Ptr(BaseAddress, BufferSize) < BaseAddress) ||
(Add2Ptr(Buffer, BufferSize) < Buffer) ||
(Add2Ptr(Buffer, BufferSize) > MmHighestUserAddress))
if (Add2Ptr(BaseAddress, BufferSize) < BaseAddress)
{
status = STATUS_ACCESS_VIOLATION;
goto Exit;
Expand Down
2 changes: 2 additions & 0 deletions SystemInformer/include/phsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ EXT BOOLEAN PhEnableLinuxSubsystemSupport;
EXT BOOLEAN PhEnableNetworkResolveDoHSupport;
EXT BOOLEAN PhEnableVersionShortText;
EXT BOOLEAN PhEnableDeferredLayout;
EXT BOOLEAN PhEnableKsiWarnings;
EXT BOOLEAN PhEnableKsiSupport;

EXT ULONG PhCsForceNoParent;
EXT ULONG PhCsHighlightingDuration;
Expand Down
8 changes: 5 additions & 3 deletions SystemInformer/ksisup.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ VOID PhShowKsiStatus(
{
KPH_PROCESS_STATE processState;

if (!PhGetIntegerSetting(L"KsiEnableWarnings") || PhStartupParameters.PhSvc)
if (!PhEnableKsiWarnings || PhStartupParameters.PhSvc)
return;

processState = KphGetCurrentProcessState();
Expand Down Expand Up @@ -254,6 +254,7 @@ VOID PhShowKsiStatus(
PhGetString(infoString)
))
{
PhEnableKsiWarnings = FALSE;
PhSetIntegerSetting(L"KsiEnableWarnings", FALSE);
}

Expand All @@ -279,7 +280,7 @@ VOID PhpShowKsiMessage(
PPH_STRING messageString;
ULONG processState;

if (!Force && !PhGetIntegerSetting(L"KsiEnableWarnings") || PhStartupParameters.PhSvc)
if (!Force && !PhEnableKsiWarnings || PhStartupParameters.PhSvc)
return;

versionString = PhGetApplicationVersionString(FALSE);
Expand Down Expand Up @@ -351,7 +352,7 @@ VOID PhpShowKsiMessage(
PhAppendStringBuilder2(&stringBuilder, L"\r\n");
}

if (Force && !PhGetIntegerSetting(L"KsiEnableWarnings"))
if (Force && !PhEnableKsiWarnings)
{
PhAppendStringBuilder2(&stringBuilder, L"Driver warnings are disabled.");
PhAppendStringBuilder2(&stringBuilder, L"\r\n");
Expand Down Expand Up @@ -384,6 +385,7 @@ VOID PhpShowKsiMessage(
PhGetString(messageString)
))
{
PhEnableKsiWarnings = FALSE;
PhSetIntegerSetting(L"KsiEnableWarnings", FALSE);
}
}
Expand Down
16 changes: 6 additions & 10 deletions SystemInformer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ INT WINAPI wWinMain(
}
}

if (PhGetIntegerSetting(L"KsiEnable") &&
!PhStartupParameters.NoKph &&
!PhStartupParameters.ShowOptions &&
!PhIsExecutingInWow64())
if (PhEnableKsiSupport &&
!PhStartupParameters.ShowOptions)
{
PhInitializeKsi();
}
Expand Down Expand Up @@ -252,9 +250,7 @@ INT WINAPI wWinMain(
PhSetProcessPriority(NtCurrentProcess(), priorityClass);
}

if (PhGetIntegerSetting(L"KsiEnable") &&
!PhStartupParameters.NoKph &&
!PhIsExecutingInWow64())
if (PhEnableKsiSupport)
{
PhShowKsiStatus();
}
Expand All @@ -273,9 +269,7 @@ INT WINAPI wWinMain(

PhEnableTerminationPolicy(FALSE);

if (PhGetIntegerSetting(L"KsiEnable") &&
!PhStartupParameters.NoKph &&
!PhIsExecutingInWow64())
if (PhEnableKsiSupport)
{
PhCleanupKsi();
}
Expand Down Expand Up @@ -1206,6 +1200,8 @@ VOID PhpInitializeSettings(
PhEnableServiceNonPoll = !!PhGetIntegerSetting(L"EnableServiceNonPoll");
PhEnableServiceNonPollNotify = !!PhGetIntegerSetting(L"EnableServiceNonPollNotify");
PhServiceNonPollFlushInterval = PhGetIntegerSetting(L"NonPollFlushInterval");
PhEnableKsiSupport = !!PhGetIntegerSetting(L"KsiEnable") && !PhStartupParameters.NoKph && !PhIsExecutingInWow64();
PhEnableKsiWarnings = !!PhGetIntegerSetting(L"KsiEnableWarnings");

if (PhGetIntegerSetting(L"SampleCountAutomatic"))
{
Expand Down
2 changes: 2 additions & 0 deletions phlib/mapldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ VOID PhLoaderEntryGrantSuppressedCall(
PhLoaderEntryCacheHashtable = PhCreateSimpleHashtable(10);
PhGuardGrantSuppressedCallAccess(NtCurrentProcess(), NtSetInformationVirtualMemory_Import());
}

return;
}

if (PhLoaderEntryCacheHashtable && !PhFindItemSimpleHashtable(PhLoaderEntryCacheHashtable, ExportAddress))
Expand Down
12 changes: 10 additions & 2 deletions phlib/native.c
Original file line number Diff line number Diff line change
Expand Up @@ -17950,6 +17950,11 @@ NTSTATUS PhGuardGrantSuppressedCallAccess(
CFG_CALL_TARGET_LIST_INFORMATION cfgCallTargetListInfo;
ULONG numberOfEntriesProcessed = 0;

if (!NtSetInformationVirtualMemory_Import())
return STATUS_PROCEDURE_NOT_FOUND;
if (VirtualAddress == (PVOID)MAXULONG_PTR)
return STATUS_SUCCESS;

memset(&cfgCallTargetRangeInfo, 0, sizeof(MEMORY_RANGE_ENTRY));
cfgCallTargetRangeInfo.VirtualAddress = PAGE_ALIGN(VirtualAddress);
cfgCallTargetRangeInfo.NumberOfBytes = PAGE_SIZE;
Expand All @@ -17964,7 +17969,7 @@ NTSTATUS PhGuardGrantSuppressedCallAccess(
cfgCallTargetListInfo.NumberOfEntriesProcessed = &numberOfEntriesProcessed;
cfgCallTargetListInfo.CallTargetInfo = &cfgCallTargetInfo;

status = NtSetInformationVirtualMemory(
status = NtSetInformationVirtualMemory_Import()(
ProcessHandle,
VmCfgCallTargetInformation,
1,
Expand All @@ -17991,6 +17996,9 @@ NTSTATUS PhDisableXfgOnTarget(
CFG_CALL_TARGET_LIST_INFORMATION cfgCallTargetListInfo;
ULONG numberOfEntriesProcessed = 0;

if (!NtSetInformationVirtualMemory_Import())
return STATUS_PROCEDURE_NOT_FOUND;

memset(&cfgCallTargetRangeInfo, 0, sizeof(MEMORY_RANGE_ENTRY));
cfgCallTargetRangeInfo.VirtualAddress = PAGE_ALIGN(VirtualAddress);
cfgCallTargetRangeInfo.NumberOfBytes = PAGE_SIZE;
Expand All @@ -18005,7 +18013,7 @@ NTSTATUS PhDisableXfgOnTarget(
cfgCallTargetListInfo.NumberOfEntriesProcessed = &numberOfEntriesProcessed;
cfgCallTargetListInfo.CallTargetInfo = &cfgCallTargetInfo;

status = NtSetInformationVirtualMemory(
status = NtSetInformationVirtualMemory_Import()(
ProcessHandle,
VmCfgCallTargetInformation,
1,
Expand Down

0 comments on commit aaba59c

Please sign in to comment.