Skip to content

Commit c44ca0a

Browse files
committed
Update versioning for Windows 10, Fix process OS Context on Win10-RS2, Add PEB comments
1 parent e86dbba commit c44ca0a

File tree

5 files changed

+55
-25
lines changed

5 files changed

+55
-25
lines changed

ProcessHacker/appsup.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,18 @@ NTSTATUS PhGetProcessSwitchContext(
178178
if (!data)
179179
return STATUS_UNSUCCESSFUL; // no compatibility context data
180180

181-
if (WindowsVersion >= WINDOWS_10)
181+
if (WindowsVersion >= WINDOWS_10_RS2)
182+
{
183+
if (!NT_SUCCESS(status = NtReadVirtualMemory(
184+
ProcessHandle,
185+
PTR_ADD_OFFSET(data, 1544),
186+
Guid,
187+
sizeof(GUID),
188+
NULL
189+
)))
190+
return status;
191+
}
192+
else if (WindowsVersion >= WINDOWS_10)
182193
{
183194
if (!NT_SUCCESS(status = NtReadVirtualMemory(
184195
ProcessHandle,

phlib/global.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static VOID PhInitializeWindowsVersion(
163163
RTL_OSVERSIONINFOEXW versionInfo;
164164
ULONG majorVersion;
165165
ULONG minorVersion;
166+
ULONG buildVersion;
166167

167168
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
168169

@@ -175,6 +176,7 @@ static VOID PhInitializeWindowsVersion(
175176
memcpy(&PhOsVersion, &versionInfo, sizeof(RTL_OSVERSIONINFOEXW));
176177
majorVersion = versionInfo.dwMajorVersion;
177178
minorVersion = versionInfo.dwMinorVersion;
179+
buildVersion = versionInfo.dwBuildNumber;
178180

179181
if (majorVersion == 6 && minorVersion < 1 || majorVersion < 6)
180182
{
@@ -198,7 +200,24 @@ static VOID PhInitializeWindowsVersion(
198200
/* Windows 10 */
199201
else if (majorVersion == 10 && minorVersion == 0)
200202
{
201-
WindowsVersion = WINDOWS_10;
203+
switch (buildVersion)
204+
{
205+
case 10240:
206+
WindowsVersion = WINDOWS_10_TH1;
207+
break;
208+
case 10586:
209+
WindowsVersion = WINDOWS_10_TH2;
210+
break;
211+
case 14393:
212+
WindowsVersion = WINDOWS_10_RS1;
213+
break;
214+
case 15063:
215+
WindowsVersion = WINDOWS_10_RS2;
216+
break;
217+
default:
218+
WindowsVersion = WINDOWS_10;
219+
break;
220+
}
202221
}
203222
else if (majorVersion == 10 && minorVersion > 0 || majorVersion > 10)
204223
{

phlib/include/phconfig.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern "C" {
88
#define _User_set_
99

1010
PHLIBAPI extern _User_set_ PVOID PhLibImageBase;
11-
1211
PHLIBAPI extern _User_set_ PWSTR PhApplicationName;
1312
PHLIBAPI extern _User_set_ ULONG PhGlobalDpi;
1413
PHLIBAPI extern PVOID PhHeapHandle;
@@ -29,6 +28,10 @@ PHLIBAPI extern ACCESS_MASK ThreadAllAccess;
2928
#define WINDOWS_8 62
3029
#define WINDOWS_8_1 63
3130
#define WINDOWS_10 100
31+
#define WINDOWS_10_TH1 101
32+
#define WINDOWS_10_TH2 102
33+
#define WINDOWS_10_RS1 103
34+
#define WINDOWS_10_RS2 104
3235
#define WINDOWS_NEW MAXLONG
3336

3437
#define WINDOWS_HAS_IMMERSIVE (WindowsVersion >= WINDOWS_8)

phlib/svcsup.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,18 @@ PVOID PhEnumServices(
9393

9494
if (!Type)
9595
{
96-
if (WindowsVersion >= WINDOWS_10)
96+
if (WindowsVersion >= WINDOWS_10_RS1)
9797
{
98-
if (PhOsVersion.dwBuildNumber >= 14393)
99-
{
100-
Type = SERVICE_TYPE_ALL;
101-
}
102-
else
103-
{
104-
Type = SERVICE_WIN32 |
105-
SERVICE_ADAPTER |
106-
SERVICE_DRIVER |
107-
SERVICE_INTERACTIVE_PROCESS |
108-
SERVICE_USER_SERVICE |
109-
SERVICE_USERSERVICE_INSTANCE;
110-
}
98+
Type = SERVICE_TYPE_ALL;
99+
}
100+
else if (WindowsVersion >= WINDOWS_10)
101+
{
102+
Type = SERVICE_WIN32 |
103+
SERVICE_ADAPTER |
104+
SERVICE_DRIVER |
105+
SERVICE_INTERACTIVE_PROCESS |
106+
SERVICE_USER_SERVICE |
107+
SERVICE_USERSERVICE_INSTANCE;
111108
}
112109
else
113110
{

phnt/include/ntpebteb.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ typedef struct _PEB
6565
PVOID ReadOnlySharedMemoryBase;
6666
PVOID HotpatchInformation;
6767
PVOID *ReadOnlyStaticServerData;
68-
PVOID AnsiCodePageData;
69-
PVOID OemCodePageData;
70-
PVOID UnicodeCaseTableData;
68+
PVOID AnsiCodePageData; // PCPTABLEINFO
69+
PVOID OemCodePageData; // PCPTABLEINFO
70+
PVOID UnicodeCaseTableData; // PNLSTABLEINFO
7171

7272
ULONG NumberOfProcessors;
7373
ULONG NtGlobalFlag;
@@ -80,7 +80,7 @@ typedef struct _PEB
8080

8181
ULONG NumberOfHeaps;
8282
ULONG MaximumNumberOfHeaps;
83-
PVOID *ProcessHeaps;
83+
PVOID *ProcessHeaps; // PHEAP
8484

8585
PVOID GdiSharedHandleTable;
8686
PVOID ProcessStarterHelper;
@@ -112,10 +112,10 @@ typedef struct _PEB
112112

113113
UNICODE_STRING CSDVersion;
114114

115-
PVOID ActivationContextData;
116-
PVOID ProcessAssemblyStorageMap;
117-
PVOID SystemDefaultActivationContextData;
118-
PVOID SystemAssemblyStorageMap;
115+
PVOID ActivationContextData; // ACTIVATION_CONTEXT_DATA
116+
PVOID ProcessAssemblyStorageMap; // ASSEMBLY_STORAGE_MAP
117+
PVOID SystemDefaultActivationContextData; // ACTIVATION_CONTEXT_DATA
118+
PVOID SystemAssemblyStorageMap; // ASSEMBLY_STORAGE_MAP
119119

120120
SIZE_T MinimumStackCommit;
121121

0 commit comments

Comments
 (0)