1. added irql checks to various rtl and security functions

2. RtlGetVersion needs to be implemented differently in ntoskrnl and ntdll, ntoskrnl's version must not access the PEB (which might not be present) while ntdlls gets most information from the PEB structure
3. can't use spinlocks to serialize access to the security descriptor cache since it calls sd rtl functions which require to run < apc level

svn path=/trunk/; revision=13712
This commit is contained in:
Thomas Bluemel 2005-02-22 17:58:19 +00:00
parent 2020a93026
commit ea5929db62
26 changed files with 399 additions and 86 deletions

View file

@ -129,7 +129,7 @@ typedef union _SLIST_HEADER
ULONGLONG Alignment; ULONGLONG Alignment;
struct struct
{ {
SINGLE_LIST_ENTRY Next; SLIST_ENTRY Next;
USHORT Depth; USHORT Depth;
USHORT Sequence; USHORT Sequence;
}; /* now anonymous */ }; /* now anonymous */

View file

@ -42,3 +42,10 @@
#define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24)) #define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
#define MAGIC_HEAP MAGIC( 'H','E','A','P' ) #define MAGIC_HEAP MAGIC( 'H','E','A','P' )
#ifdef DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
#else
#define PAGED_CODE_RTL()
#endif

View file

@ -14,6 +14,12 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
#else
#define PAGED_CODE_RTL()
#endif
#ifndef __USE_W32API #ifndef __USE_W32API

View file

@ -13,6 +13,10 @@ TARGET_CFLAGS = -g -D__NTDLL__ -Werror -Wall
# require os code to explicitly request A/W version of structs/functions # require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS TARGET_CFLAGS += -D_DISABLE_TIDENTS
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
TARGET_ASFLAGS = -I $(PATH_TO_TOP)/include TARGET_ASFLAGS = -I $(PATH_TO_TOP)/include
TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \ TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \

View file

@ -55,3 +55,12 @@ ExFreePool(IN PVOID Mem)
0, 0,
Mem); Mem);
} }
#ifdef DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
/* meaningless in user mode */
}
#endif

View file

@ -324,4 +324,47 @@ RtlCreateUserProcess(PUNICODE_STRING ImageFileName,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(RTL_OSVERSIONINFOW *Info)
{
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
PPEB Peb = NtCurrentPeb();
Info->dwMajorVersion = Peb->OSMajorVersion;
Info->dwMinorVersion = Peb->OSMinorVersion;
Info->dwBuildNumber = Peb->OSBuildNumber;
Info->dwPlatformId = Peb->OSPlatformId;
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
{
int i = _snwprintf(Info->szCSDVersion,
(sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1,
L"Service Pack %d",
((Peb->OSCSDVersion >> 8) & 0xFF));
Info->szCSDVersion[i] = L'\0';
}
else
{
RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion));
}
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask;
InfoEx->wProductType = SharedUserData->NtProductType;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}
/* EOF */ /* EOF */

View file

@ -12,7 +12,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntos/rtl.h> #include <ntdll/rtl.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -27,6 +27,8 @@ RtlFirstFreeAce(PACL Acl,
PVOID AclEnd; PVOID AclEnd;
ULONG i; ULONG i;
PAGED_CODE_RTL();
Current = (PACE)(Acl + 1); Current = (PACE)(Acl + 1);
*Ace = NULL; *Ace = NULL;
i = 0; i = 0;
@ -71,6 +73,8 @@ RtlGetAce(PACL Acl,
{ {
ULONG i; ULONG i;
PAGED_CODE_RTL();
*Ace = (PACE)(Acl + 1); *Ace = (PACE)(Acl + 1);
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||
@ -112,6 +116,8 @@ RtlpAddKnownAce (PACL Acl,
{ {
PACE Ace; PACE Ace;
PAGED_CODE_RTL();
if (!RtlValidSid(Sid)) if (!RtlValidSid(Sid))
{ {
return(STATUS_INVALID_SID); return(STATUS_INVALID_SID);
@ -158,6 +164,8 @@ RtlAddAccessAllowedAce (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask, IN ACCESS_MASK AccessMask,
IN PSID Sid) IN PSID Sid)
{ {
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl, return RtlpAddKnownAce (Acl,
Revision, Revision,
0, 0,
@ -177,6 +185,8 @@ RtlAddAccessAllowedAceEx (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask, IN ACCESS_MASK AccessMask,
IN PSID Sid) IN PSID Sid)
{ {
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl, return RtlpAddKnownAce (Acl,
Revision, Revision,
Flags, Flags,
@ -195,6 +205,8 @@ RtlAddAccessDeniedAce (PACL Acl,
ACCESS_MASK AccessMask, ACCESS_MASK AccessMask,
PSID Sid) PSID Sid)
{ {
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl, return RtlpAddKnownAce (Acl,
Revision, Revision,
0, 0,
@ -214,6 +226,8 @@ RtlAddAccessDeniedAceEx (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask, IN ACCESS_MASK AccessMask,
IN PSID Sid) IN PSID Sid)
{ {
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl, return RtlpAddKnownAce (Acl,
Revision, Revision,
Flags, Flags,
@ -260,6 +274,8 @@ RtlAddAce(PACL Acl,
PACE Current; PACE Current;
ULONG j; ULONG j;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION) Acl->AclRevision > MAX_ACL_REVISION)
{ {
@ -340,6 +356,8 @@ RtlAddAuditAccessAce(PACL Acl,
PACE Ace; PACE Ace;
ULONG Flags = 0; ULONG Flags = 0;
PAGED_CODE_RTL();
if (Success != FALSE) if (Success != FALSE)
{ {
Flags |= SUCCESSFUL_ACCESS_ACE_FLAG; Flags |= SUCCESSFUL_ACCESS_ACE_FLAG;
@ -409,6 +427,8 @@ RtlAddAuditAccessAceEx(PACL Acl,
{ {
PACE Ace; PACE Ace;
PAGED_CODE_RTL();
if (Success != FALSE) if (Success != FALSE)
{ {
Flags |= SUCCESSFUL_ACCESS_ACE_FLAG; Flags |= SUCCESSFUL_ACCESS_ACE_FLAG;
@ -495,6 +515,8 @@ RtlDeleteAce(PACL Acl,
PACE Ace; PACE Ace;
PACE Current; PACE Current;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION) Acl->AclRevision > MAX_ACL_REVISION)
{ {
@ -535,6 +557,8 @@ RtlCreateAcl(PACL Acl,
ULONG AclSize, ULONG AclSize,
ULONG AclRevision) ULONG AclRevision)
{ {
PAGED_CODE_RTL();
if (AclSize < 8) if (AclSize < 8)
{ {
return(STATUS_BUFFER_TOO_SMALL); return(STATUS_BUFFER_TOO_SMALL);
@ -573,6 +597,8 @@ RtlQueryInformationAcl(PACL Acl,
{ {
PACE Ace; PACE Ace;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION) Acl->AclRevision > MAX_ACL_REVISION)
{ {
@ -638,6 +664,8 @@ RtlSetInformationAcl(PACL Acl,
ULONG InformationLength, ULONG InformationLength,
ACL_INFORMATION_CLASS InformationClass) ACL_INFORMATION_CLASS InformationClass)
{ {
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION) Acl->AclRevision > MAX_ACL_REVISION)
{ {
@ -681,6 +709,8 @@ RtlValidAcl (PACL Acl)
PACE Ace; PACE Ace;
USHORT Size; USHORT Size;
PAGED_CODE_RTL();
Size = ROUND_UP(Acl->AclSize, 4); Size = ROUND_UP(Acl->AclSize, 4);
if (Acl->AclRevision < MIN_ACL_REVISION || if (Acl->AclRevision < MIN_ACL_REVISION ||

View file

@ -12,6 +12,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -22,6 +23,8 @@ VOID STDCALL
RtlCopyLuid(PLUID LuidDest, RtlCopyLuid(PLUID LuidDest,
PLUID LuidSrc) PLUID LuidSrc)
{ {
PAGED_CODE_RTL();
LuidDest->LowPart = LuidSrc->LowPart; LuidDest->LowPart = LuidSrc->LowPart;
LuidDest->HighPart = LuidSrc->HighPart; LuidDest->HighPart = LuidSrc->HighPart;
} }
@ -37,6 +40,8 @@ RtlCopyLuidAndAttributesArray(ULONG Count,
{ {
ULONG i; ULONG i;
PAGED_CODE_RTL();
for (i = 0; i < Count; i++) for (i = 0; i < Count; i++)
{ {
RtlCopyMemory(&Dest[i], RtlCopyMemory(&Dest[i],
@ -53,6 +58,8 @@ BOOLEAN STDCALL
RtlEqualLuid(PLUID Luid1, RtlEqualLuid(PLUID Luid1,
PLUID Luid2) PLUID Luid2)
{ {
PAGED_CODE_RTL();
return (Luid1->LowPart == Luid2->LowPart && return (Luid1->LowPart == Luid2->LowPart &&
Luid1->HighPart == Luid2->HighPart); Luid1->HighPart == Luid2->HighPart);
} }

View file

@ -12,6 +12,10 @@ TARGET_CFLAGS = -Wall -Werror -ffreestanding
# require os code to explicitly request A/W version of structs/functions # require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS TARGET_CFLAGS += -D_DISABLE_TIDENTS
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
TARGET_OBJECTS = \ TARGET_OBJECTS = \
acl.o \ acl.o \
bit.o \ bit.o \

View file

@ -113,6 +113,8 @@ NTSTATUS STDCALL
RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor, RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
ULONG Revision) ULONG Revision)
{ {
PAGED_CODE_RTL();
if (Revision != SECURITY_DESCRIPTOR_REVISION1) if (Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -134,6 +136,8 @@ NTSTATUS STDCALL
RtlCreateSecurityDescriptorRelative (PSECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor, RtlCreateSecurityDescriptorRelative (PSECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
ULONG Revision) ULONG Revision)
{ {
PAGED_CODE_RTL();
if (Revision != SECURITY_DESCRIPTOR_REVISION1) if (Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -161,6 +165,8 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
PACL Sacl, Dacl; PACL Sacl, Dacl;
ULONG Length = sizeof(SECURITY_DESCRIPTOR); ULONG Length = sizeof(SECURITY_DESCRIPTOR);
PAGED_CODE_RTL();
RtlpQuerySecurityDescriptorPointers(SecurityDescriptor, RtlpQuerySecurityDescriptorPointers(SecurityDescriptor,
&Owner, &Owner,
&Group, &Group,
@ -200,6 +206,8 @@ RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL* Dacl, PACL* Dacl,
PBOOLEAN DaclDefaulted) PBOOLEAN DaclDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -233,6 +241,8 @@ RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL Dacl, PACL Dacl,
BOOLEAN DaclDefaulted) BOOLEAN DaclDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -271,6 +281,8 @@ RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
PSID Owner, Group; PSID Owner, Group;
PACL Sacl, Dacl; PACL Sacl, Dacl;
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return FALSE; return FALSE;
@ -302,6 +314,8 @@ RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID Owner, PSID Owner,
BOOLEAN OwnerDefaulted) BOOLEAN OwnerDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -332,6 +346,8 @@ RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID* Owner, PSID* Owner,
PBOOLEAN OwnerDefaulted) PBOOLEAN OwnerDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -357,6 +373,8 @@ RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID Group, PSID Group,
BOOLEAN GroupDefaulted) BOOLEAN GroupDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -386,6 +404,8 @@ RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID* Group, PSID* Group,
PBOOLEAN GroupDefaulted) PBOOLEAN GroupDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -422,6 +442,8 @@ RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
ULONG TotalLength; ULONG TotalLength;
ULONG_PTR Current; ULONG_PTR Current;
PAGED_CODE_RTL();
RtlpQuerySecurityDescriptor(AbsSD, RtlpQuerySecurityDescriptor(AbsSD,
&Owner, &Owner,
&OwnerLength, &OwnerLength,
@ -494,6 +516,8 @@ RtlAbsoluteToSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
PSECURITY_DESCRIPTOR_RELATIVE RelSD, PSECURITY_DESCRIPTOR_RELATIVE RelSD,
PULONG BufferLength) PULONG BufferLength)
{ {
PAGED_CODE_RTL();
if (AbsSD->Control & SE_SELF_RELATIVE) if (AbsSD->Control & SE_SELF_RELATIVE)
{ {
return STATUS_BAD_DESCRIPTOR_FORMAT; return STATUS_BAD_DESCRIPTOR_FORMAT;
@ -511,6 +535,8 @@ RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSECURITY_DESCRIPTOR_CONTROL Control, PSECURITY_DESCRIPTOR_CONTROL Control,
PULONG Revision) PULONG Revision)
{ {
PAGED_CODE_RTL();
*Revision = SecurityDescriptor->Revision; *Revision = SecurityDescriptor->Revision;
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
@ -532,6 +558,8 @@ RtlSetControlSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet) IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -556,6 +584,8 @@ RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL *Sacl, PACL *Sacl,
PBOOLEAN SaclDefaulted) PBOOLEAN SaclDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -589,6 +619,8 @@ RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL Sacl, PACL Sacl,
BOOLEAN SaclDefaulted) BOOLEAN SaclDefaulted)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -643,6 +675,8 @@ RtlSelfRelativeToAbsoluteSD(PSECURITY_DESCRIPTOR_RELATIVE RelSD,
PACL pDacl; PACL pDacl;
PACL pSacl; PACL pSacl;
PAGED_CODE_RTL();
if (RelSD->Revision != SECURITY_DESCRIPTOR_REVISION1) if (RelSD->Revision != SECURITY_DESCRIPTOR_REVISION1)
{ {
return STATUS_UNKNOWN_REVISION; return STATUS_UNKNOWN_REVISION;
@ -713,6 +747,8 @@ RtlValidRelativeSecurityDescriptor(IN PSECURITY_DESCRIPTOR_RELATIVE SecurityDesc
IN ULONG SecurityDescriptorLength, IN ULONG SecurityDescriptorLength,
IN SECURITY_INFORMATION RequiredInformation) IN SECURITY_INFORMATION RequiredInformation)
{ {
PAGED_CODE_RTL();
if (SecurityDescriptorLength < sizeof(SECURITY_DESCRIPTOR_RELATIVE) || if (SecurityDescriptorLength < sizeof(SECURITY_DESCRIPTOR_RELATIVE) ||
SecurityDescriptorInput->Revision != SECURITY_DESCRIPTOR_REVISION1 || SecurityDescriptorInput->Revision != SECURITY_DESCRIPTOR_REVISION1 ||
!(SecurityDescriptorInput->Control & SE_SELF_RELATIVE)) !(SecurityDescriptorInput->Control & SE_SELF_RELATIVE))
@ -783,6 +819,8 @@ BOOLEAN STDCALL
RtlGetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, RtlGetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
PUCHAR RMControl) PUCHAR RMControl)
{ {
PAGED_CODE_RTL();
if (!(SecurityDescriptor->Control & SE_RM_CONTROL_VALID)) if (!(SecurityDescriptor->Control & SE_RM_CONTROL_VALID))
{ {
*RMControl = 0; *RMControl = 0;
@ -802,6 +840,8 @@ VOID STDCALL
RtlSetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, RtlSetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
PUCHAR RMControl) PUCHAR RMControl)
{ {
PAGED_CODE_RTL();
if (RMControl == NULL) if (RMControl == NULL)
{ {
SecurityDescriptor->Control &= ~SE_RM_CONTROL_VALID; SecurityDescriptor->Control &= ~SE_RM_CONTROL_VALID;
@ -823,6 +863,8 @@ RtlSetAttributesSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL Control, IN SECURITY_DESCRIPTOR_CONTROL Control,
OUT PULONG Revision) OUT PULONG Revision)
{ {
PAGED_CODE_RTL();
*Revision = SecurityDescriptor->Revision; *Revision = SecurityDescriptor->Revision;
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1) if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)

View file

@ -30,6 +30,8 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
OBJECT_ATTRIBUTES ObjAttr; OBJECT_ATTRIBUTES ObjAttr;
SECURITY_QUALITY_OF_SERVICE Sqos; SECURITY_QUALITY_OF_SERVICE Sqos;
PAGED_CODE_RTL();
Status = NtOpenProcessToken(NtCurrentProcess(), Status = NtOpenProcessToken(NtCurrentProcess(),
TOKEN_DUPLICATE, TOKEN_DUPLICATE,
&ProcessToken); &ProcessToken);
@ -98,6 +100,8 @@ RtlAdjustPrivilege(IN ULONG Privilege,
HANDLE TokenHandle; HANDLE TokenHandle;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE_RTL();
DPRINT ("RtlAdjustPrivilege() called\n"); DPRINT ("RtlAdjustPrivilege() called\n");
if (CurrentThread) if (CurrentThread)

View file

@ -13,6 +13,7 @@
#define __NTDRIVER__ #define __NTDRIVER__
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#include <string.h> #include <string.h>
@ -26,6 +27,8 @@ RtlValidSid(IN PSID Sid_)
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
if ((Sid->Revision != SID_REVISION) || if ((Sid->Revision != SID_REVISION) ||
(Sid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)) (Sid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES))
{ {
@ -42,6 +45,8 @@ RtlValidSid(IN PSID Sid_)
ULONG STDCALL ULONG STDCALL
RtlLengthRequiredSid(IN UCHAR SubAuthorityCount) RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
{ {
PAGED_CODE_RTL();
return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG)); return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
} }
@ -56,6 +61,8 @@ RtlInitializeSid(IN PSID Sid_,
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
Sid->Revision = SID_REVISION; Sid->Revision = SID_REVISION;
Sid->SubAuthorityCount = SubAuthorityCount; Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority, memcpy(&Sid->IdentifierAuthority,
@ -75,6 +82,8 @@ RtlSubAuthoritySid(IN PSID Sid_,
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->SubAuthority[SubAuthority]; return &Sid->SubAuthority[SubAuthority];
} }
@ -87,6 +96,8 @@ RtlSubAuthorityCountSid(IN PSID Sid_)
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->SubAuthorityCount; return &Sid->SubAuthorityCount;
} }
@ -101,6 +112,8 @@ RtlEqualSid(IN PSID Sid1_,
PISID Sid1 = Sid1_; PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_; PISID Sid2 = Sid2_;
PAGED_CODE_RTL();
if (Sid1->Revision != Sid2->Revision) if (Sid1->Revision != Sid2->Revision)
{ {
return(FALSE); return(FALSE);
@ -125,6 +138,8 @@ RtlLengthSid(IN PSID Sid_)
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG)); return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG));
} }
@ -137,6 +152,8 @@ RtlCopySid(ULONG BufferLength,
PSID Dest, PSID Dest,
PSID Src) PSID Src)
{ {
PAGED_CODE_RTL();
if (BufferLength < RtlLengthSid(Src)) if (BufferLength < RtlLengthSid(Src))
{ {
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
@ -166,6 +183,8 @@ RtlCopySidAndAttributesArray(ULONG Count,
ULONG Length; ULONG Length;
ULONG i; ULONG i;
PAGED_CODE_RTL();
Length = SidAreaSize; Length = SidAreaSize;
for (i=0; i<Count; i++) for (i=0; i<Count; i++)
@ -197,6 +216,8 @@ RtlIdentifierAuthoritySid(IN PSID Sid_)
{ {
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->IdentifierAuthority; return &Sid->IdentifierAuthority;
} }
@ -219,6 +240,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
{ {
PISID pSid; PISID pSid;
PAGED_CODE_RTL();
if (SubAuthorityCount > 8) if (SubAuthorityCount > 8)
return STATUS_INVALID_SID; return STATUS_INVALID_SID;
@ -273,6 +296,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
PVOID STDCALL PVOID STDCALL
RtlFreeSid(IN PSID Sid) RtlFreeSid(IN PSID Sid)
{ {
PAGED_CODE_RTL();
ExFreePool(Sid); ExFreePool(Sid);
return NULL; return NULL;
} }
@ -288,6 +313,8 @@ RtlEqualPrefixSid(IN PSID Sid1_,
PISID Sid1 = Sid1_; PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_; PISID Sid2 = Sid2_;
PAGED_CODE_RTL();
return(Sid1->SubAuthorityCount == Sid2->SubAuthorityCount && return(Sid1->SubAuthorityCount == Sid2->SubAuthorityCount &&
!RtlCompareMemory(Sid1, Sid2, !RtlCompareMemory(Sid1, Sid2,
(Sid1->SubAuthorityCount - 1) * sizeof(DWORD) + 8)); (Sid1->SubAuthorityCount - 1) * sizeof(DWORD) + 8));
@ -308,6 +335,8 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
ULONG i; ULONG i;
PISID Sid = Sid_; PISID Sid = Sid_;
PAGED_CODE_RTL();
if (RtlValidSid (Sid) == FALSE) if (RtlValidSid (Sid) == FALSE)
return STATUS_INVALID_SID; return STATUS_INVALID_SID;

View file

@ -14,6 +14,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntos/registry.h> #include <ntos/registry.h>
#include <ntos/time.h> #include <ntos/time.h>
#include <ntdll/rtl.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -34,6 +35,8 @@ RtlQueryTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
DPRINT("RtlQueryTimeZoneInformation()\n"); DPRINT("RtlQueryTimeZoneInformation()\n");
PAGED_CODE_RTL();
RtlZeroMemory(QueryTable, RtlZeroMemory(QueryTable,
sizeof(QueryTable)); sizeof(QueryTable));
@ -94,6 +97,8 @@ RtlSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
DPRINT("RtlSetTimeZoneInformation()\n"); DPRINT("RtlSetTimeZoneInformation()\n");
PAGED_CODE_RTL();
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL, Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation", L"TimeZoneInformation",
L"Bias", L"Bias",

View file

@ -39,37 +39,6 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(RTL_OSVERSIONINFOW *Info)
{
WCHAR CSDString[] = L"Service Pack 6";
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
Info->dwMajorVersion = 4;
Info->dwMinorVersion = 0;
Info->dwBuildNumber = 1381;
Info->dwPlatformId = VER_PLATFORM_WIN32_NT;
RtlCopyMemory(Info->szCSDVersion, CSDString, sizeof(CSDString));
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
InfoEx->wServicePackMajor = 6;
InfoEx->wServicePackMinor = 0;
InfoEx->wSuiteMask = 0;
InfoEx->wProductType = VER_NT_WORKSTATION;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}
/* /*
* @unimplemented * @unimplemented
*/ */
@ -114,12 +83,10 @@ RtlVerifyVersionInfo(
/* /*
* @implemented * @implemented
*/ */
ULONGLONG NTAPI VerSetConditionMask ULONGLONG NTAPI
( VerSetConditionMask(IN ULONGLONG dwlConditionMask,
IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask, IN DWORD dwTypeBitMask,
IN BYTE dwConditionMask IN BYTE dwConditionMask)
)
{ {
if(dwTypeBitMask == 0) if(dwTypeBitMask == 0)
return dwlConditionMask; return dwlConditionMask;

View file

@ -54,6 +54,10 @@ else
TARGET_BASE = 0x80000000 TARGET_BASE = 0x80000000
endif endif
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
# enable thread event pair features (NT4 only!) # enable thread event pair features (NT4 only!)
# TARGET_CFLAGS += -D_ENABLE_THRDEVTPAIR # TARGET_CFLAGS += -D_ENABLE_THRDEVTPAIR

View file

@ -65,4 +65,23 @@
#include <pseh.h> #include <pseh.h>
#ifdef DBG
#ifndef PAGED_CODE
#define PAGED_CODE() \
do { \
if(KeGetCurrentIrql() > APC_LEVEL) { \
DbgPrint("%s:%i: Pagable code called at IRQL > APC_LEVEL (%d)\n", \
__FILE__, __LINE__, KeGetCurrentIrql()); \
KEBUGCHECK(0); \
} \
} while(0)
#endif
#define PAGED_CODE_RTL PAGED_CODE
#else
#ifndef PAGED_CODE
#define PAGED_CODE()
#endif
#define PAGED_CODE_RTL()
#endif
#endif /* INCLUDE_NTOSKRNL_H */ #endif /* INCLUDE_NTOSKRNL_H */

View file

@ -31,6 +31,10 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define BUILD_OSCSDVERSION(major, minor) (((major & 0xFF) << 8) | (minor & 0xFF))
ULONG NtMajorVersion = 4;
ULONG NtMinorVersion = 0;
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(6, 0);
#ifdef __GNUC__ #ifdef __GNUC__
ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD; ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG EXPORTED NtGlobalFlag = 0; ULONG EXPORTED NtGlobalFlag = 0;

View file

@ -28,13 +28,11 @@ typedef struct _SD_CACHE_ENTRY
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
PLIST_ENTRY ObpSdCache;
KSPIN_LOCK ObpSdCacheSpinLock;
KIRQL ObpSdCacheIrql;
#define SD_CACHE_ENTRIES 0x100 #define SD_CACHE_ENTRIES 0x100
LIST_ENTRY ObpSdCache[SD_CACHE_ENTRIES];
FAST_MUTEX ObpSdCacheMutex;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
NTSTATUS NTSTATUS
@ -42,37 +40,36 @@ ObpInitSdCache(VOID)
{ {
ULONG i; ULONG i;
ObpSdCache = ExAllocatePool(NonPagedPool, for (i = 0; i < (sizeof(ObpSdCache) / sizeof(ObpSdCache[0])); i++)
SD_CACHE_ENTRIES * sizeof(LIST_ENTRY));
if (ObpSdCache == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
for (i = 0; i < SD_CACHE_ENTRIES; i++)
{ {
InitializeListHead(&ObpSdCache[i]); InitializeListHead(&ObpSdCache[i]);
} }
KeInitializeSpinLock(&ObpSdCacheSpinLock); ExInitializeFastMutex(&ObpSdCacheMutex);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static VOID static inline VOID
ObpSdCacheLock(VOID) ObpSdCacheLock(VOID)
{ {
KeAcquireSpinLock(&ObpSdCacheSpinLock, /* can't acquire a fast mutex in the early boot process... */
&ObpSdCacheIrql); if(KeGetCurrentThread() != NULL)
{
ExAcquireFastMutex(&ObpSdCacheMutex);
}
} }
static VOID static inline VOID
ObpSdCacheUnlock(VOID) ObpSdCacheUnlock(VOID)
{ {
KeReleaseSpinLock(&ObpSdCacheSpinLock, /* can't acquire a fast mutex in the early boot process... */
ObpSdCacheIrql); if(KeGetCurrentThread() != NULL)
{
ExReleaseFastMutex(&ObpSdCacheMutex);
}
} }

View file

@ -1,4 +1,4 @@
/* $Id:$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -109,4 +109,17 @@ RtlInitializeCriticalSectionAndSpinCount(
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#ifdef DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
if(KeGetCurrentIrql() > APC_LEVEL)
{
DbgPrint("%s:%i: Pagable code called at IRQL > APC_LEVEL (%d)\n", file, line, KeGetCurrentIrql());
KEBUGCHECK(0);
}
}
#endif
/* EOF */ /* EOF */

View file

@ -17,6 +17,37 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
extern ULONG NtGlobalFlag; extern ULONG NtGlobalFlag;
extern ULONG NtMajorVersion;
extern ULONG NtMinorVersion;
extern ULONG NtOSCSDVersion;
/* header hell made me do this...sorry */
typedef struct _OSVERSIONINFOW {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
WCHAR szCSDVersion[ 128 ];
} OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
typedef struct _OSVERSIONINFOEXW {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
WCHAR szCSDVersion[ 128 ];
WORD wServicePackMajor;
WORD wServicePackMinor;
WORD wSuiteMask;
BYTE wProductType;
BYTE wReserved;
} OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
#ifndef VER_PLATFORM_WIN32_NT
#define VER_PLATFORM_WIN32_NT (2)
#endif
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -29,3 +60,45 @@ RtlGetNtGlobalFlags(VOID)
{ {
return(NtGlobalFlag); return(NtGlobalFlag);
} }
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
{
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
lpVersionInformation->dwMajorVersion = NtMajorVersion;
lpVersionInformation->dwMinorVersion = NtMinorVersion;
lpVersionInformation->dwBuildNumber = NtBuildNumber;
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
if(((NtOSCSDVersion >> 8) & 0xFF) != 0)
{
int i = _snwprintf(lpVersionInformation->szCSDVersion,
(sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1,
L"Service Pack %d",
((NtOSCSDVersion >> 8) & 0xFF));
lpVersionInformation->szCSDVersion[i] = L'\0';
}
else
{
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
}
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
InfoEx->wServicePackMajor = (NtOSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = NtOSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask;
InfoEx->wProductType = SharedUserData->NtProductType;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}

View file

@ -26,6 +26,8 @@ RtlAreAllAccessesGranted (
ACCESS_MASK DesiredAccess ACCESS_MASK DesiredAccess
) )
{ {
PAGED_CODE_RTL();
return ((GrantedAccess & DesiredAccess) == DesiredAccess); return ((GrantedAccess & DesiredAccess) == DesiredAccess);
} }
@ -40,6 +42,8 @@ RtlAreAnyAccessesGranted (
ACCESS_MASK DesiredAccess ACCESS_MASK DesiredAccess
) )
{ {
PAGED_CODE_RTL();
return ((GrantedAccess & DesiredAccess) != 0); return ((GrantedAccess & DesiredAccess) != 0);
} }
@ -54,6 +58,8 @@ RtlMapGenericMask (
PGENERIC_MAPPING GenericMapping PGENERIC_MAPPING GenericMapping
) )
{ {
PAGED_CODE_RTL();
if (*AccessMask & GENERIC_READ) if (*AccessMask & GENERIC_READ)
*AccessMask |= GenericMapping->GenericRead; *AccessMask |= GenericMapping->GenericRead;

View file

@ -226,6 +226,8 @@ SepCreateImpersonationTokenDacl(PTOKEN Token,
ULONG AclLength; ULONG AclLength;
PVOID TokenDacl; PVOID TokenDacl;
PAGED_CODE();
AclLength = sizeof(ACL) + AclLength = sizeof(ACL) +
(sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid)) + (sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid)) +
(sizeof(ACE) + RtlLengthSid(SeRestrictedCodeSid)) + (sizeof(ACE) + RtlLengthSid(SeRestrictedCodeSid)) +

View file

@ -63,6 +63,8 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
KPROCESSOR_MODE PreviousMode; KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode(); PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode) if(PreviousMode != KernelMode)
@ -108,6 +110,8 @@ VOID STDCALL
RtlCopyLuid(IN PLUID LuidDest, RtlCopyLuid(IN PLUID LuidDest,
IN PLUID LuidSrc) IN PLUID LuidSrc)
{ {
PAGED_CODE_RTL();
LuidDest->LowPart = LuidSrc->LowPart; LuidDest->LowPart = LuidSrc->LowPart;
LuidDest->HighPart = LuidSrc->HighPart; LuidDest->HighPart = LuidSrc->HighPart;
} }
@ -120,6 +124,8 @@ BOOLEAN STDCALL
RtlEqualLuid(IN PLUID Luid1, RtlEqualLuid(IN PLUID Luid1,
IN PLUID Luid2) IN PLUID Luid2)
{ {
PAGED_CODE_RTL();
return (Luid1->LowPart == Luid2->LowPart && return (Luid1->LowPart == Luid2->LowPart &&
Luid1->HighPart == Luid2->HighPart); Luid1->HighPart == Luid2->HighPart);
} }

View file

@ -109,6 +109,8 @@ SepPrivilegeCheck (PTOKEN Token,
DPRINT ("SepPrivilegeCheck() called\n"); DPRINT ("SepPrivilegeCheck() called\n");
PAGED_CODE();
if (PreviousMode == KernelMode) if (PreviousMode == KernelMode)
{ {
return TRUE; return TRUE;
@ -168,6 +170,8 @@ SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
PLUID_AND_ATTRIBUTES* NewMem; PLUID_AND_ATTRIBUTES* NewMem;
ULONG SrcLength; ULONG SrcLength;
PAGED_CODE();
if (PrivilegeCount == 0) if (PrivilegeCount == 0)
{ {
*Dest = 0; *Dest = 0;
@ -212,6 +216,8 @@ SeReleaseLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Privilege,
KPROCESSOR_MODE PreviousMode, KPROCESSOR_MODE PreviousMode,
ULONG a) ULONG a)
{ {
PAGED_CODE();
ExFreePool (Privilege); ExFreePool (Privilege);
} }
@ -228,6 +234,8 @@ NtPrivilegeCheck (IN HANDLE ClientToken,
ULONG Length; ULONG Length;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
Status = ObReferenceObjectByHandle (ClientToken, Status = ObReferenceObjectByHandle (ClientToken,
0, 0,
SepTokenObjectType, SepTokenObjectType,
@ -292,6 +300,8 @@ SePrivilegeCheck (PPRIVILEGE_SET Privileges,
{ {
PACCESS_TOKEN Token = NULL; PACCESS_TOKEN Token = NULL;
PAGED_CODE();
if (SubjectContext->ClientToken == NULL) if (SubjectContext->ClientToken == NULL)
{ {
Token = SubjectContext->PrimaryToken; Token = SubjectContext->PrimaryToken;
@ -324,6 +334,8 @@ SeSinglePrivilegeCheck (IN LUID PrivilegeValue,
PRIVILEGE_SET Priv; PRIVILEGE_SET Priv;
BOOLEAN Result; BOOLEAN Result;
PAGED_CODE();
SeCaptureSubjectContext (&SubjectContext); SeCaptureSubjectContext (&SubjectContext);
Priv.PrivilegeCount = 1; Priv.PrivilegeCount = 1;

View file

@ -199,6 +199,8 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
BOOLEAN CopyOnOpen; BOOLEAN CopyOnOpen;
BOOLEAN EffectiveOnly; BOOLEAN EffectiveOnly;
PAGED_CODE();
Thread = PsGetCurrentThread(); Thread = PsGetCurrentThread();
if (Thread == NULL) if (Thread == NULL)
{ {
@ -226,6 +228,8 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL VOID STDCALL
SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{ {
PAGED_CODE();
KeEnterCriticalRegion(); KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&SepSubjectContextLock, TRUE); ExAcquireResourceExclusiveLite(&SepSubjectContextLock, TRUE);
} }
@ -237,6 +241,8 @@ SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL VOID STDCALL
SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{ {
PAGED_CODE();
ExReleaseResourceLite(&SepSubjectContextLock); ExReleaseResourceLite(&SepSubjectContextLock);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
} }
@ -248,6 +254,8 @@ SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL VOID STDCALL
SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{ {
PAGED_CODE();
if (SubjectContext->PrimaryToken != NULL) if (SubjectContext->PrimaryToken != NULL)
{ {
ObDereferenceObject(SubjectContext->PrimaryToken); ObDereferenceObject(SubjectContext->PrimaryToken);
@ -266,6 +274,8 @@ SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
NTSTATUS STDCALL NTSTATUS STDCALL
SeDeassignSecurity(PSECURITY_DESCRIPTOR *SecurityDescriptor) SeDeassignSecurity(PSECURITY_DESCRIPTOR *SecurityDescriptor)
{ {
PAGED_CODE();
if (*SecurityDescriptor != NULL) if (*SecurityDescriptor != NULL)
{ {
ExFreePool(*SecurityDescriptor); ExFreePool(*SecurityDescriptor);
@ -332,6 +342,8 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
PACL Dacl = NULL; PACL Dacl = NULL;
PACL Sacl = NULL; PACL Sacl = NULL;
PAGED_CODE();
/* Lock subject context */ /* Lock subject context */
SeLockSubjectContext(SubjectContext); SeLockSubjectContext(SubjectContext);
@ -562,6 +574,8 @@ SepSidInToken(PACCESS_TOKEN _Token,
ULONG i; ULONG i;
PTOKEN Token = (PTOKEN)_Token; PTOKEN Token = (PTOKEN)_Token;
PAGED_CODE();
if (Token->UserAndGroupCount == 0) if (Token->UserAndGroupCount == 0)
{ {
return FALSE; return FALSE;
@ -625,6 +639,8 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID Sid; PSID Sid;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
CurrentAccess = PreviouslyGrantedAccess; CurrentAccess = PreviouslyGrantedAccess;
if (SubjectContextLocked == FALSE) if (SubjectContextLocked == FALSE)
@ -796,6 +812,8 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
PTOKEN Token; PTOKEN Token;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
DPRINT("NtAccessCheck() called\n"); DPRINT("NtAccessCheck() called\n");
PreviousMode = KeGetPreviousMode(); PreviousMode = KeGetPreviousMode();

View file

@ -108,7 +108,9 @@ main(int argc, char* argv[])
} }
else else
{ {
s = s + sprintf(s, "#ifndef %s\n", argv[i]);
s = s + sprintf(s, "#define %s\n", argv[i]); s = s + sprintf(s, "#define %s\n", argv[i]);
s = s + sprintf(s, "#endif /* %s */\n", argv[i]);
} }
strcat(config, argv[i]); strcat(config, argv[i]);
if (i != (argc - 1)) if (i != (argc - 1))