You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop definition of PSAPI_WORKING_SET_EX_BLOCK, move functions to PSAPI_WORKING_SET_EX_INFORMATION, adjust function names
The definition of PSAPI_WORKING_SET_EX_BLOCK was not correct. The outer
definition is a UNION with two members:
- ULONG_PTR Flags and
- another anonymous union holding two bitfield definitions
It effectively defines a union with 3 defintions.
The bitfield definition differs between 32bit and 64bit. The 32bit
version defines data elements filling exactly the 32bits a single
ULONG_PTR can hold. The 64bit version adds an additional 32bit reserved
element, which agains fill the full size a single ULONG_PTR can hold on
64bit.
The two bitfield definitions both map to ULONG_PTR, so
PSAPI_WORKING_SET_EX_BLOCK is basicly just a ULONG_PTR with C syntactic
sugar for decoding.
The PSAPI_WORKING_SET_EX_BLOCK is only used in
PSAPI_WORKING_SET_EX_INFORMATION and given that the union definition
of PSAPI_WORKING_SET_EX_BLOCK is syntactic sugar, we can drop the
definition and integrate the decoding logic directly into
PSAPI_WORKING_SET_EX_INFORMATION.
-----------------------------------------------------------------------
typedef struct _PSAPI_WORKING_SET_EX_INFORMATION {
PVOID VirtualAddress;
PSAPI_WORKING_SET_EX_BLOCK VirtualAttributes;
} PSAPI_WORKING_SET_EX_INFORMATION, *PPSAPI_WORKING_SET_EX_INFORMATION;
typedef union _PSAPI_WORKING_SET_EX_BLOCK {
ULONG_PTR Flags;
union {
struct {
ULONG_PTR Valid : 1;
ULONG_PTR ShareCount : 3;
ULONG_PTR Win32Protection : 11;
ULONG_PTR Shared : 1;
ULONG_PTR Node : 6;
ULONG_PTR Locked : 1;
ULONG_PTR LargePage : 1;
ULONG_PTR Reserved : 7;
ULONG_PTR Bad : 1;
#if defined(_WIN64)
ULONG_PTR ReservedUlong : 32;
#endif
};
struct {
ULONG_PTR Valid : 1; // Valid = 0 in this format.
ULONG_PTR Reserved0 : 14;
ULONG_PTR Shared : 1;
ULONG_PTR Reserved1 : 15;
ULONG_PTR Bad : 1;
#if defined(_WIN64)
ULONG_PTR ReservedUlong : 32;
#endif
} Invalid;
};
} PSAPI_WORKING_SET_EX_BLOCK, *PPSAPI_WORKING_SET_EX_BLOCK;
0 commit comments