📄 jwauserenv.pas
字号:
psaSecurityGroups: PSafeArray; // New security groups
pRsopToken: PRSOPTOKEN; // Rsop token for use with Rsop security Api's
pGPOList: PGROUP_POLICY_OBJECT; // Linked list of GPOs
pWbemServices: IWbemServices; // Pointer to namespace to log planning mode data
end;
{$EXTERNALSYM _RSOP_TARGET}
RSOP_TARGET = _RSOP_TARGET;
{$EXTERNALSYM RSOP_TARGET}
PRSOP_TARGET = ^RSOP_TARGET;
{$EXTERNALSYM PRSOP_TARGET}
TRsopTarget = RSOP_TARGET;
PRsopTarget = PRSOP_TARGET;
PFNGENERATEGROUPPOLICY = function (
dwFlags: DWORD; // GPO_INFO_FLAGS
var pbAbort: BOOL; // If true, then abort GPO processing
pwszSite: PWCHAR; // Site the target computer is in
pComputerTarget: PRSOP_TARGET; // Computer target info, can be null
pUserTarget: PRSOP_TARGET // User target info, can be null
): DWORD; stdcall;
{$EXTERNALSYM PFNGENERATEGROUPPOLICY}
//
// GUID that identifies the registry extension
//
const
REGISTRY_EXTENSION_GUID: GUID = (
D1: $35378EAC; D2:$683F; D3:$11D2; D4:($A8, $9A, $00, $C0, $4F, $BB, $CF, $A2));
{$EXTERNALSYM REGISTRY_EXTENSION_GUID}
//=============================================================================
//
// Group Policy Object client side asynchronous extension processing
//
// extensionId - Unique guid identifying the extension
// pAsyncHandle - Asynchronous completion handle that was passed to extension in
// ProcessGroupPolicy call
// dwStatus - Completion status of asynchronous processing
//
// The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
// function completed successfully. Otherwise it indicates that the function failed.
//
//=============================================================================
type
REFGPEXTENSIONID = LPGUID;
{$EXTERNALSYM REFGPEXTENSIONID}
function ProcessGroupPolicyCompleted(extensionId: REFGPEXTENSIONID;
pAsyncHandle: ASYNCCOMPLETIONHANDLE; dwStatus: DWORD): DWORD; stdcall;
{$EXTERNALSYM ProcessGroupPolicyCompleted}
//=============================================================================
//
// Group Policy Object client side asynchronous extension processing
//
// extensionId - Unique guid identifying the extension
// pAsyncHandle - Asynchronous completion handle that was passed to extension in
// ProcessGroupPolicy call
// dwStatus - Completion status of asynchronous processing
// RsopStatus - RSoP Logging status
//
// The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
// function completed successfully. Otherwise it indicates that the function failed.
//
//=============================================================================
function ProcessGroupPolicyCompletedEx(extensionId: REFGPEXTENSIONID; pAsyncHandle: ASYNCCOMPLETIONHANDLE;
dwStatus: DWORD; RsopStatus: HRESULT): DWORD; stdcall;
{$EXTERNALSYM ProcessGroupPolicyCompletedEx}
//=============================================================================
//
// Function: RsopAccessCheckByType
//
// Description: Determines whether the security descriptor pointed to by pSecurityDescriptor
// grants the set of access rights specified in dwDesiredAccessMask
// to the client identified by the RSOPTOKEN pointed to by pRsopToken.
//
// pSecurityDescriptor - Security Descriptor on the object
// pPrincipalSelfSid - Principal Sid
// pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
// dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
// pObjectTypeList - Object Type List
// ObjectTypeListLength - Object Type List Length
// pGenericMapping - Generic Mapping
// pPrivilegeSet - privilege set
// pdwPrivilegeSetLength- privilege set length
// pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
// the mask of standard and specific rights granted.
// If pbAccessStatus is false, it is set to 0.
// On failure, it is not modified.
// pbAccessStatus - On success, indicates wether the requested set
// of access rights was granted.
// On failure, it is not modified
//
// Returns S_OK on success or appropriate error code.
// For additional details, look at the documentation of AccessCheckByType
//=============================================================================
function RsopAccessCheckByType(pSecurityDescriptor: PSECURITY_DESCRIPTOR; pPrincipalSelfSid: PSID;
pRsopToken: PRSOPTOKEN; dwDesiredAccessMask: DWORD; pObjectTypeList: POBJECT_TYPE_LIST;
ObjectTypeListLength: DWORD; pGenericMapping: PGENERIC_MAPPING; pPrivilegeSet: PPRIVILEGE_SET;
pdwPrivilegeSetLength: LPDWORD; pdwGrantedAccessMask: LPDWORD; pbAccessStatus: LPBOOL): HRESULT; stdcall;
{$EXTERNALSYM RsopAccessCheckByType}
//=============================================================================
//
// Function: RsopFileAccessCheck
//
// Description: Determines whether the security descriptor on the file grants the set of file access
// rights specified in dwDesiredAccessMask
// to the client identified by the RSOPTOKEN pointed to by pRsopToken.
//
// pszFileName - Name of an existing filename
// pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
// dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
// pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
// the mask of standard and specific rights granted.
// If pbAccessStatus is false, it is set to 0.
// On failure, it is not modified.
// pbAccessStatus - On success, indicates wether the requested set
// of access rights was granted.
// On failure, it is not modified
//
// Returns S_OK on success or appropriate error code
//=============================================================================
function RsopFileAccessCheck(pszFileName: LPWSTR; pRsopToken: PRSOPTOKEN; dwDesiredAccessMask: DWORD;
pdwGrantedAccessMask: LPDWORD; pbAccessStatus: LPBOOL): HRESULT; stdcall;
{$EXTERNALSYM RsopFileAccessCheck}
type
_SETTINGSTATUS = (
RSOPUnspecified,
RSOPApplied,
RSOPIgnored,
RSOPFailed,
RSOPSubsettingFailed);
{$EXTERNALSYM _SETTINGSTATUS}
SETTINGSTATUS = _SETTINGSTATUS;
{$EXTERNALSYM SETTINGSTATUS}
TSettingStatus = SETTINGSTATUS;
//=============================================================================
//
// POLICYSETTINGSTATUSINFO
//
// Describes the instance of RSOP_PolicySettingStatus
//
// szKey - OPTIONAL, if NULL, the key is generated on the fly
// szEventSource - name of the source generation event log messages
// szEventLogName - name of the event log database where the messages are logged
// dwEventID - event log message ID
// status - status of the policy setting
// timeLogged - time at which the event log message was logged
//
//=============================================================================
type
_POLICYSETTINGSTATUSINFO = record
szKey: LPWSTR;
szEventSource: LPWSTR;
szEventLogName: LPWSTR;
dwEventID: DWORD;
dwErrorCode: DWORD;
status: SETTINGSTATUS;
timeLogged: SYSTEMTIME;
end;
{$EXTERNALSYM _POLICYSETTINGSTATUSINFO}
POLICYSETTINGSTATUSINFO = _POLICYSETTINGSTATUSINFO;
{$EXTERNALSYM POLICYSETTINGSTATUSINFO}
LPPOLICYSETTINGSTATUSINFO = ^POLICYSETTINGSTATUSINFO;
{$EXTERNALSYM LPPOLICYSETTINGSTATUSINFO}
TPolicySettingStatusInfo = POLICYSETTINGSTATUSINFO;
PPolicySettingStatusInfo = LPPOLICYSETTINGSTATUSINFO;
//=============================================================================
//
// RsopSetPolicySettingStatus
//
// Creates an instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
// and links RSOP_PolicySettingStatus to RSOP_PolicySetting
//
// dwFlags - flags
// pServices - RSOP namespace
// pSettingInstance - instance of RSOP_PolicySetting or its children
// nInfo - number of PolicySettingStatusInfo
// pStatus - array of PolicySettingStatusInfo
//
// Return: S_OK if successful, HRESULT otherwise
//
//=============================================================================
function RsopSetPolicySettingStatus(dwFlags: DWORD; pServices: IWbemServices;
pSettingInstance: IWbemClassObject; nInfo: DWORD;
pStatus: LPPOLICYSETTINGSTATUSINFO): HRESULT; stdcall;
{$EXTERNALSYM RsopSetPolicySettingStatus}
//=============================================================================
//
// RsopResetPolicySettingStatus
//
// Unlinks RSOP_PolicySettingStatus from RSOP_PolicySetting,
// deletes the instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
// and optionally deletes the instance of RSOP_PolicySetting
//
// dwFlags - flags
// pServices - RSOP namespace
// pSettingInstance - instance of RSOP_PolicySetting or its children
//
// Return: S_OK if successful, HRESULT otherwise
//
//=============================================================================
function RsopResetPolicySettingStatus(dwFlags: DWORD; pServices: IWbemServices;
pSettingInstance: IWbemClassObject): HRESULT; stdcall;
{$EXTERNALSYM RsopResetPolicySettingStatus}
//=============================================================================
//
// Flags for RSoP WMI providers
//
//=============================================================================
// planning mode provider flags
const
FLAG_NO_GPO_FILTER = DWORD($80000000); // GPOs are not filtered, implies FLAG_NO_CSE_INVOKE
{$EXTERNALSYM FLAG_NO_GPO_FILTER}
FLAG_NO_CSE_INVOKE = $40000000; // only GP processing done for planning mode
{$EXTERNALSYM FLAG_NO_CSE_INVOKE}
FLAG_ASSUME_SLOW_LINK = $20000000; // planning mode RSoP assumes slow link
{$EXTERNALSYM FLAG_ASSUME_SLOW_LINK}
FLAG_LOOPBACK_MERGE = $10000000; // planning mode RSoP assumes merge loop back
{$EXTERNALSYM FLAG_LOOPBACK_MERGE}
FLAG_LOOPBACK_REPLACE = $08000000; // planning mode RSoP assumes replace loop back
{$EXTERNALSYM FLAG_LOOPBACK_REPLACE}
FLAG_ASSUME_USER_WQLFILTER_TRUE = $04000000; // planning mode RSoP assumes all comp filters to be true
{$EXTERNALSYM FLAG_ASSUME_USER_WQLFILTER_TRUE}
FLAG_ASSUME_COMP_WQLFILTER_TRUE = $02000000; // planning mode RSoP assumes all user filters to be true
{$EXTERNALSYM FLAG_ASSUME_COMP_WQLFILTER_TRUE}
FLAG_PLANNING_MODE = $01000000; // flag that indicates that a given namespace was created
{$EXTERNALSYM FLAG_PLANNING_MODE} // for planning mode. This flag cannot be passed in but the
// relevant subnamespace will be marked with this flag
// diagnostic mode provider flags
FLAG_NO_USER = $00000001; // Don't get any user data
{$EXTERNALSYM FLAG_NO_USER}
FLAG_NO_COMPUTER = $00000002; // Don't get any machine data
{$EXTERNALSYM FLAG_NO_COMPUTER}
FLAG_FORCE_CREATENAMESPACE = $00000004; // Delete and recreate the namespace for this snapshot.
{$EXTERNALSYM FLAG_FORCE_CREATENAMESPACE}
//=============================================================================
//
// Extended Errors returned by RSoP WMI Providers
//
//=============================================================================
// User accessing the rsop provider doesn't have access to user data.
RSOP_USER_ACCESS_DENIED = $00000001;
{$EXTERNALSYM RSOP_USER_ACCESS_DENIED}
// User accessing the rsop provider doesn't have access to computer data.
RSOP_COMPUTER_ACCESS_DENIED = $00000002;
{$EXTERNALSYM RSOP_COMPUTER_ACCESS_DENIED}
// This user is an interactive non admin user, the temp snapshot namespace already exists
// and the FLAG_FORCE_CREATENAMESPACE was not passed in
RSOP_TEMPNAMESPACE_EXISTS = $00000004;
{$EXTERNALSYM RSOP_TEMPNAMESPACE_EXISTS}
implementation
const
userenvlib = 'userenv.dll';
{$IFDEF DYNAMIC_LINK}
var
_LoadUserProfileA: Pointer;
function LoadUserProfileA;
begin
GetProcedureAddress(_LoadUserProfileA, userenvlib, 'LoadUserProfileA');
asm
mov esp, ebp
pop ebp
jmp [_LoadUserProfileA]
end;
end;
{$ELSE}
function LoadUserProfileA; external userenvlib name 'LoadUserProfileA';
{$ENDIF DYNAMIC_LINK}
{$IFDEF DYNAMIC_LINK}
var
_LoadUserProfileW: Pointer;
function LoadUserProfileW;
begin
GetProcedureAddress(_LoadUserProfileW, userenvlib, 'LoadUserProfileW');
asm
mov esp, ebp
pop ebp
jmp [_LoadUserProfileW]
end;
end;
{$ELSE}
function LoadUserProfileW; external userenvlib name 'LoadUserProfileW';
{$ENDIF DYNAMIC_LINK}
{$IFDEF UNICODE}
{$IFDEF DYNAMIC_LINK}
var
_LoadUserProfile: Pointer;
function LoadUserProfile;
begin
GetProcedureAddress(_LoadUserProfile, userenvlib, 'LoadUserProfileW');
asm
mov esp, ebp
pop ebp
jmp [_LoadUserProfile]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -