Skip to content

Commit 55490e5

Browse files
committed
Add PhGetProcessGroupInformation, PhGetProcessGroupAffinity, PhSetProcessGroupAffinity, PhGetSystemProcessorPerformanceInformation, PhGetSystemInterruptInformation
1 parent 53dd6f5 commit 55490e5

File tree

1 file changed

+116
-7
lines changed

1 file changed

+116
-7
lines changed

phlib/include/phnativeinl.h

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,18 @@ PhGetProcessAffinityMask(
590590
_Out_ PKAFFINITY AffinityMask
591591
)
592592
{
593+
//NTSTATUS status;
594+
//PROCESS_BASIC_INFORMATION basicInfo;
595+
//
596+
//status = PhGetProcessBasicInformation(ProcessHandle, &basicInfo);
597+
//
598+
//if (NT_SUCCESS(status))
599+
//{
600+
// *AffinityMask = basicInfo.AffinityMask;
601+
//}
602+
//
603+
//return status;
604+
593605
return NtQueryInformationProcess(
594606
ProcessHandle,
595607
ProcessAffinityMask,
@@ -622,7 +634,7 @@ PhSetProcessAffinityMask(
622634

623635
FORCEINLINE
624636
NTSTATUS
625-
PhGetProcessGroupAffinity(
637+
PhGetProcessGroupInformation(
626638
_In_ HANDLE ProcessHandle,
627639
_Inout_ PUSHORT GroupCount,
628640
_Out_ PUSHORT GroupArray
@@ -649,6 +661,37 @@ PhGetProcessGroupAffinity(
649661
return status;
650662
}
651663

664+
FORCEINLINE
665+
NTSTATUS
666+
PhGetProcessGroupAffinity(
667+
_In_ HANDLE ProcessHandle,
668+
_Out_ PGROUP_AFFINITY GroupAffinity
669+
)
670+
{
671+
return NtQueryInformationProcess(
672+
ProcessHandle,
673+
ProcessAffinityMask,
674+
GroupAffinity,
675+
sizeof(GROUP_AFFINITY),
676+
NULL
677+
);
678+
}
679+
680+
FORCEINLINE
681+
NTSTATUS
682+
PhSetProcessGroupAffinity(
683+
_In_ HANDLE ProcessHandle,
684+
_In_ GROUP_AFFINITY GroupAffinity
685+
)
686+
{
687+
return NtSetInformationProcess(
688+
ProcessHandle,
689+
ProcessAffinityMask,
690+
&GroupAffinity,
691+
sizeof(GROUP_AFFINITY)
692+
);
693+
}
694+
652695
FORCEINLINE
653696
NTSTATUS
654697
PhGetProcessIsCFGuardEnabled(
@@ -2000,6 +2043,40 @@ PhGetSystemShadowStackInformation(
20002043
);
20012044
}
20022045

2046+
2047+
FORCEINLINE
2048+
NTSTATUS
2049+
PhGetSystemProcessorPerformanceInformation(
2050+
_Out_ PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Buffer,
2051+
_In_ ULONG BufferLength
2052+
)
2053+
{
2054+
return NtQuerySystemInformation(
2055+
SystemProcessorPerformanceInformation,
2056+
Buffer,
2057+
BufferLength,
2058+
NULL
2059+
);
2060+
}
2061+
2062+
FORCEINLINE
2063+
NTSTATUS
2064+
PhGetSystemProcessorPerformanceInformationEx(
2065+
_In_ USHORT ProcessorGroup,
2066+
_Out_ PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Buffer,
2067+
_In_ ULONG BufferLength
2068+
)
2069+
{
2070+
return NtQuerySystemInformationEx(
2071+
SystemProcessorPerformanceInformation,
2072+
&ProcessorGroup,
2073+
sizeof(USHORT),
2074+
Buffer,
2075+
BufferLength,
2076+
NULL
2077+
);
2078+
}
2079+
20032080
FORCEINLINE
20042081
NTSTATUS
20052082
PhGetSystemProcessorIdleCycleTime(
@@ -2018,15 +2095,15 @@ PhGetSystemProcessorIdleCycleTime(
20182095
FORCEINLINE
20192096
NTSTATUS
20202097
PhGetSystemProcessorIdleCycleTimeEx(
2021-
_In_ USHORT Group,
2098+
_In_ USHORT ProcessorGroup,
20222099
_Out_ PLARGE_INTEGER Buffer,
20232100
_In_ ULONG BufferLength
20242101
)
20252102
{
20262103
return NtQuerySystemInformationEx(
20272104
SystemProcessorIdleCycleTimeInformation,
2028-
&Group,
2029-
sizeof(Group),
2105+
&ProcessorGroup,
2106+
sizeof(USHORT),
20302107
Buffer,
20312108
BufferLength,
20322109
NULL
@@ -2051,19 +2128,51 @@ PhGetSystemProcessorCycleTime(
20512128
FORCEINLINE
20522129
NTSTATUS
20532130
PhGetSystemProcessorCycleTimeEx(
2054-
_In_ USHORT Group,
2131+
_In_ USHORT ProcessorGroup,
20552132
_Out_ PLARGE_INTEGER Buffer,
20562133
_In_ ULONG BufferLength
20572134
)
20582135
{
20592136
return NtQuerySystemInformationEx(
20602137
SystemProcessorCycleTimeInformation,
2061-
&Group,
2062-
sizeof(Group),
2138+
&ProcessorGroup,
2139+
sizeof(USHORT),
2140+
Buffer,
2141+
BufferLength,
2142+
NULL
2143+
);
2144+
}
2145+
2146+
FORCEINLINE
2147+
NTSTATUS
2148+
PhGetSystemInterruptInformation(
2149+
_Out_ PSYSTEM_INTERRUPT_INFORMATION Buffer,
2150+
_In_ ULONG BufferLength
2151+
)
2152+
{
2153+
return NtQuerySystemInformation(
2154+
SystemInterruptInformation,
20632155
Buffer,
20642156
BufferLength,
20652157
NULL
20662158
);
20672159
}
20682160

2161+
FORCEINLINE
2162+
NTSTATUS
2163+
PhGetSystemInterruptInformationEx(
2164+
_In_ USHORT ProcessorGroup,
2165+
_Out_ PSYSTEM_INTERRUPT_INFORMATION Buffer,
2166+
_In_ ULONG BufferLength
2167+
)
2168+
{
2169+
return NtQuerySystemInformationEx(
2170+
SystemInterruptInformation,
2171+
&ProcessorGroup,
2172+
sizeof(USHORT),
2173+
Buffer,
2174+
BufferLength,
2175+
NULL
2176+
);
2177+
}
20692178
#endif

0 commit comments

Comments
 (0)