[FORMATTING]

Fix indentation and coding style. No code changes!

svn path=/trunk/; revision=57334
This commit is contained in:
Eric Kohl 2012-09-19 12:20:39 +00:00
parent c31b441d5c
commit c2ab3689b3
8 changed files with 1381 additions and 1349 deletions

View file

@ -31,28 +31,20 @@
*
* @implemented
*/
SIZE_T NTAPI
SIZE_T
NTAPI
RtlCompareMemory(IN const VOID *Source1,
IN const VOID *Source2,
IN SIZE_T Length)
{
SIZE_T i;
for(i=0; (i<Length) && (((PUCHAR)Source1)[i]==((PUCHAR)Source2)[i]); i++)
;
return i;
SIZE_T i;
for (i = 0; (i < Length) && (((PUCHAR)Source1)[i] == ((PUCHAR)Source2)[i]); i++)
;
return i;
}
/*
* @implemented
*/
SIZE_T
NTAPI
RtlCompareMemoryUlong (
PVOID Source,
SIZE_T Length,
ULONG Value
)
/*
* FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes
* ARGUMENTS:
@ -60,20 +52,28 @@ RtlCompareMemoryUlong (
* Length = Number of bytes to compare
* Value = Value to compare
* RETURNS: Number of equal bytes
*
* @implemented
*/
SIZE_T
NTAPI
RtlCompareMemoryUlong(IN PVOID Source,
IN SIZE_T Length,
IN ULONG Value)
{
PULONG ptr = (PULONG)Source;
ULONG_PTR len = Length / sizeof(ULONG);
ULONG_PTR i;
PULONG ptr = (PULONG)Source;
ULONG_PTR len = Length / sizeof(ULONG);
ULONG_PTR i;
for (i = 0; i < len; i++)
{
if (*ptr != Value)
break;
ptr++;
}
for (i = 0; i < len; i++)
{
if (*ptr != Value)
break;
return (SIZE_T)((PCHAR)ptr - (PCHAR)Source);
ptr++;
}
return (SIZE_T)((PCHAR)ptr - (PCHAR)Source);
}
@ -83,13 +83,11 @@ RtlCompareMemoryUlong (
*/
VOID
NTAPI
RtlFillMemory (
PVOID Destination,
SIZE_T Length,
UCHAR Fill
)
RtlFillMemory(PVOID Destination,
SIZE_T Length,
UCHAR Fill)
{
memset(Destination, Fill, Length);
memset(Destination, Fill, Length);
}
@ -99,21 +97,19 @@ RtlFillMemory (
*/
VOID
NTAPI
RtlFillMemoryUlong (
PVOID Destination,
SIZE_T Length,
ULONG Fill
)
RtlFillMemoryUlong(PVOID Destination,
SIZE_T Length,
ULONG Fill)
{
PULONG Dest = Destination;
SIZE_T Count = Length / sizeof(ULONG);
PULONG Dest = Destination;
SIZE_T Count = Length / sizeof(ULONG);
while (Count > 0)
{
*Dest = Fill;
Dest++;
Count--;
}
while (Count > 0)
{
*Dest = Fill;
Dest++;
Count--;
}
}
@ -123,32 +119,25 @@ RtlFillMemoryUlong (
*/
VOID
NTAPI
RtlMoveMemory (
PVOID Destination,
CONST VOID * Source,
SIZE_T Length
)
RtlMoveMemory(PVOID Destination,
CONST VOID *Source,
SIZE_T Length)
{
memmove (
Destination,
Source,
Length
);
memmove(Destination, Source, Length);
}
/*
* @implemented
*/
VOID
FASTCALL
RtlPrefetchMemoryNonTemporal(
IN PVOID Source,
IN SIZE_T Length
)
RtlPrefetchMemoryNonTemporal(IN PVOID Source,
IN SIZE_T Length)
{
/* By nature of prefetch, this is non-portable. */
(void)Source;
(void)Length;
/* By nature of prefetch, this is non-portable. */
(void)Source;
(void)Length;
}
@ -158,16 +147,10 @@ RtlPrefetchMemoryNonTemporal(
*/
VOID
NTAPI
RtlZeroMemory (
PVOID Destination,
SIZE_T Length
)
RtlZeroMemory(PVOID Destination,
SIZE_T Length)
{
RtlFillMemory (
Destination,
Length,
0
);
RtlFillMemory(Destination, Length, 0);
}
/* EOF */

File diff suppressed because it is too large Load diff

View file

@ -18,67 +18,66 @@
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
{
HANDLE ProcessToken;
HANDLE ImpersonationToken;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjAttr;
SECURITY_QUALITY_OF_SERVICE Sqos;
HANDLE ProcessToken;
HANDLE ImpersonationToken;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjAttr;
SECURITY_QUALITY_OF_SERVICE Sqos;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
Status = ZwOpenProcessToken(NtCurrentProcess(),
TOKEN_DUPLICATE,
&ProcessToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtOpenProcessToken() failed (Status %lx)\n", Status);
return(Status);
}
Status = ZwOpenProcessToken(NtCurrentProcess(),
TOKEN_DUPLICATE,
&ProcessToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtOpenProcessToken() failed (Status %lx)\n", Status);
return Status;
}
Sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
Sqos.ImpersonationLevel = ImpersonationLevel;
Sqos.ContextTrackingMode = 0;
Sqos.EffectiveOnly = FALSE;
Sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
Sqos.ImpersonationLevel = ImpersonationLevel;
Sqos.ContextTrackingMode = 0;
Sqos.EffectiveOnly = FALSE;
InitializeObjectAttributes(
&ObjAttr,
NULL,
0,
NULL,
NULL
);
InitializeObjectAttributes(&ObjAttr,
NULL,
0,
NULL,
NULL);
ObjAttr.SecurityQualityOfService = &Sqos;
ObjAttr.SecurityQualityOfService = &Sqos;
Status = ZwDuplicateToken(ProcessToken,
TOKEN_IMPERSONATE,
&ObjAttr,
Sqos.EffectiveOnly, /* why both here _and_ in Sqos? */
TokenImpersonation,
&ImpersonationToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtDuplicateToken() failed (Status %lx)\n", Status);
NtClose(ProcessToken);
return(Status);
}
Status = ZwDuplicateToken(ProcessToken,
TOKEN_IMPERSONATE,
&ObjAttr,
Sqos.EffectiveOnly, /* why both here _and_ in Sqos? */
TokenImpersonation,
&ImpersonationToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtDuplicateToken() failed (Status %lx)\n", Status);
NtClose(ProcessToken);
return Status;
}
Status = ZwSetInformationThread(NtCurrentThread(),
ThreadImpersonationToken,
&ImpersonationToken,
sizeof(HANDLE));
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetInformationThread() failed (Status %lx)\n", Status);
}
Status = ZwSetInformationThread(NtCurrentThread(),
ThreadImpersonationToken,
&ImpersonationToken,
sizeof(HANDLE));
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetInformationThread() failed (Status %lx)\n", Status);
}
ZwClose(ImpersonationToken);
ZwClose(ProcessToken);
ZwClose(ImpersonationToken);
ZwClose(ProcessToken);
return(Status);
return Status;
}
/*
@ -108,79 +107,81 @@ RtlReleasePrivilege(IN PVOID ReturnedState)
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlAdjustPrivilege(IN ULONG Privilege,
IN BOOLEAN Enable,
IN BOOLEAN CurrentThread,
OUT PBOOLEAN Enabled)
{
TOKEN_PRIVILEGES NewState;
TOKEN_PRIVILEGES OldState;
ULONG ReturnLength;
HANDLE TokenHandle;
NTSTATUS Status;
TOKEN_PRIVILEGES NewState;
TOKEN_PRIVILEGES OldState;
ULONG ReturnLength;
HANDLE TokenHandle;
NTSTATUS Status;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
DPRINT ("RtlAdjustPrivilege() called\n");
DPRINT("RtlAdjustPrivilege() called\n");
if (CurrentThread)
{
Status = ZwOpenThreadToken (NtCurrentThread (),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
FALSE,
&TokenHandle);
}
else
{
Status = ZwOpenProcessToken (NtCurrentProcess (),
if (CurrentThread)
{
Status = ZwOpenThreadToken(NtCurrentThread(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
FALSE,
&TokenHandle);
}
}
else
{
Status = ZwOpenProcessToken(NtCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&TokenHandle);
}
if (!NT_SUCCESS (Status))
{
DPRINT1 ("Retrieving token handle failed (Status %lx)\n", Status);
return Status;
}
if (!NT_SUCCESS (Status))
{
DPRINT1("Retrieving token handle failed (Status %lx)\n", Status);
return Status;
}
OldState.PrivilegeCount = 1;
OldState.PrivilegeCount = 1;
NewState.PrivilegeCount = 1;
NewState.Privileges[0].Luid.LowPart = Privilege;
NewState.Privileges[0].Luid.HighPart = 0;
NewState.Privileges[0].Attributes = (Enable) ? SE_PRIVILEGE_ENABLED : 0;
NewState.PrivilegeCount = 1;
NewState.Privileges[0].Luid.LowPart = Privilege;
NewState.Privileges[0].Luid.HighPart = 0;
NewState.Privileges[0].Attributes = (Enable) ? SE_PRIVILEGE_ENABLED : 0;
Status = ZwAdjustPrivilegesToken (TokenHandle,
Status = ZwAdjustPrivilegesToken(TokenHandle,
FALSE,
&NewState,
sizeof(TOKEN_PRIVILEGES),
&OldState,
&ReturnLength);
ZwClose (TokenHandle);
if (Status == STATUS_NOT_ALL_ASSIGNED)
{
DPRINT1 ("Failed to assign all privileges\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
if (!NT_SUCCESS(Status))
{
DPRINT1 ("NtAdjustPrivilegesToken() failed (Status %lx)\n", Status);
return Status;
}
ZwClose (TokenHandle);
if (Status == STATUS_NOT_ALL_ASSIGNED)
{
DPRINT1("Failed to assign all privileges\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
if (OldState.PrivilegeCount == 0)
{
*Enabled = Enable;
}
else
{
*Enabled = (OldState.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED);
}
if (!NT_SUCCESS(Status))
{
DPRINT1("NtAdjustPrivilegesToken() failed (Status %lx)\n", Status);
return Status;
}
DPRINT ("RtlAdjustPrivilege() done\n");
if (OldState.PrivilegeCount == 0)
{
*Enabled = Enable;
}
else
{
*Enabled = (OldState.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED);
}
return STATUS_SUCCESS;
DPRINT("RtlAdjustPrivilege() done\n");
return STATUS_SUCCESS;
}
/*

View file

@ -17,153 +17,162 @@
/* FUNCTIONS ***************************************************************/
BOOLEAN NTAPI
BOOLEAN
NTAPI
RtlValidSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
if ((Sid->Revision != SID_REVISION) ||
(Sid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES))
if ((Sid->Revision != SID_REVISION) ||
(Sid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES))
{
return FALSE;
return FALSE;
}
return TRUE;
return TRUE;
}
/*
* @implemented
*/
ULONG NTAPI
ULONG
NTAPI
RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
{
PAGED_CODE_RTL();
PAGED_CODE_RTL();
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[SubAuthorityCount]);
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[SubAuthorityCount]);
}
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlInitializeSid(IN PSID Sid_,
IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
IN UCHAR SubAuthorityCount)
{
PISID Sid = Sid_;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
Sid->Revision = SID_REVISION;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
Sid->Revision = SID_REVISION;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
/*
* @implemented
*/
PULONG NTAPI
PULONG
NTAPI
RtlSubAuthoritySid(IN PSID Sid_,
IN ULONG SubAuthority)
{
PISID Sid = Sid_;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
return (PULONG)&Sid->SubAuthority[SubAuthority];
return (PULONG)&Sid->SubAuthority[SubAuthority];
}
/*
* @implemented
*/
PUCHAR NTAPI
PUCHAR
NTAPI
RtlSubAuthorityCountSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
return &Sid->SubAuthorityCount;
return &Sid->SubAuthorityCount;
}
/*
* @implemented
*/
BOOLEAN NTAPI
BOOLEAN
NTAPI
RtlEqualSid(IN PSID Sid1_,
IN PSID Sid2_)
{
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
SIZE_T SidLen;
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
SIZE_T SidLen;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
if (Sid1->Revision != Sid2->Revision ||
(*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2)))
{
return(FALSE);
}
if (Sid1->Revision != Sid2->Revision ||
(*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2)))
{
return FALSE;
}
SidLen = RtlLengthSid(Sid1);
return RtlCompareMemory(Sid1, Sid2, SidLen) == SidLen;
SidLen = RtlLengthSid(Sid1);
return RtlCompareMemory(Sid1, Sid2, SidLen) == SidLen;
}
/*
* @implemented
*/
ULONG NTAPI
ULONG
NTAPI
RtlLengthSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[Sid->SubAuthorityCount]);
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[Sid->SubAuthorityCount]);
}
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlCopySid(ULONG BufferLength,
PSID Dest,
PSID Src)
{
PAGED_CODE_RTL();
PAGED_CODE_RTL();
if (BufferLength < RtlLengthSid(Src))
if (BufferLength < RtlLengthSid(Src))
{
return STATUS_UNSUCCESSFUL;
return STATUS_UNSUCCESSFUL;
}
memmove(Dest,
Src,
RtlLengthSid(Src));
memmove(Dest,
Src,
RtlLengthSid(Src));
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlCopySidAndAttributesArray(ULONG Count,
PSID_AND_ATTRIBUTES Src,
ULONG SidAreaSize,
@ -172,110 +181,115 @@ RtlCopySidAndAttributesArray(ULONG Count,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize)
{
ULONG SidLength;
ULONG Length;
ULONG i;
ULONG SidLength;
ULONG Length;
ULONG i;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
Length = SidAreaSize;
Length = SidAreaSize;
for (i=0; i<Count; i++)
{
if (RtlLengthSid(Src[i].Sid) > Length)
{
return(STATUS_BUFFER_TOO_SMALL);
}
SidLength = RtlLengthSid(Src[i].Sid);
Length = Length - SidLength;
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(SidLength,
SidArea,
Src[i].Sid);
SidArea = (PVOID)((ULONG_PTR)SidArea + SidLength);
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return(STATUS_SUCCESS);
}
/*
* @implemented
*/
PSID_IDENTIFIER_AUTHORITY NTAPI
RtlIdentifierAuthoritySid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->IdentifierAuthority;
}
/*
* @implemented
*/
NTSTATUS NTAPI
RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
ULONG SubAuthority2,
ULONG SubAuthority3,
ULONG SubAuthority4,
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid)
{
PISID pSid;
PAGED_CODE_RTL();
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
pSid = RtlpAllocateMemory(RtlLengthRequiredSid(SubAuthorityCount),
TAG_SID);
if (pSid == NULL)
return STATUS_NO_MEMORY;
pSid->Revision = SID_REVISION;
pSid->SubAuthorityCount = SubAuthorityCount;
memcpy(&pSid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
switch (SubAuthorityCount)
for (i = 0; i < Count; i++)
{
case 8:
pSid->SubAuthority[7] = SubAuthority7;
case 7:
pSid->SubAuthority[6] = SubAuthority6;
case 6:
pSid->SubAuthority[5] = SubAuthority5;
case 5:
pSid->SubAuthority[4] = SubAuthority4;
case 4:
pSid->SubAuthority[3] = SubAuthority3;
case 3:
pSid->SubAuthority[2] = SubAuthority2;
case 2:
pSid->SubAuthority[1] = SubAuthority1;
case 1:
pSid->SubAuthority[0] = SubAuthority0;
break;
if (RtlLengthSid(Src[i].Sid) > Length)
{
return STATUS_BUFFER_TOO_SMALL;
}
SidLength = RtlLengthSid(Src[i].Sid);
Length = Length - SidLength;
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(SidLength,
SidArea,
Src[i].Sid);
SidArea = (PVOID)((ULONG_PTR)SidArea + SidLength);
}
*Sid = pSid;
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
/*
* @implemented
*/
PSID_IDENTIFIER_AUTHORITY
NTAPI
RtlIdentifierAuthoritySid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->IdentifierAuthority;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
ULONG SubAuthority2,
ULONG SubAuthority3,
ULONG SubAuthority4,
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid)
{
PISID pSid;
PAGED_CODE_RTL();
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
pSid = RtlpAllocateMemory(RtlLengthRequiredSid(SubAuthorityCount),
TAG_SID);
if (pSid == NULL)
return STATUS_NO_MEMORY;
pSid->Revision = SID_REVISION;
pSid->SubAuthorityCount = SubAuthorityCount;
memcpy(&pSid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
switch (SubAuthorityCount)
{
case 8:
pSid->SubAuthority[7] = SubAuthority7;
case 7:
pSid->SubAuthority[6] = SubAuthority6;
case 6:
pSid->SubAuthority[5] = SubAuthority5;
case 5:
pSid->SubAuthority[4] = SubAuthority4;
case 4:
pSid->SubAuthority[3] = SubAuthority3;
case 3:
pSid->SubAuthority[2] = SubAuthority2;
case 2:
pSid->SubAuthority[1] = SubAuthority1;
case 1:
pSid->SubAuthority[0] = SubAuthority0;
break;
}
*Sid = pSid;
return STATUS_SUCCESS;
}
@ -286,116 +300,120 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
* Docs says FreeSid does NOT return a value
* even thou it's defined to return a PVOID...
*/
PVOID NTAPI
PVOID
NTAPI
RtlFreeSid(IN PSID Sid)
{
PAGED_CODE_RTL();
PAGED_CODE_RTL();
RtlpFreeMemory(Sid, TAG_SID);
return NULL;
RtlpFreeMemory(Sid, TAG_SID);
return NULL;
}
/*
* @implemented
*/
BOOLEAN NTAPI
BOOLEAN
NTAPI
RtlEqualPrefixSid(IN PSID Sid1_,
IN PSID Sid2_)
{
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
SIZE_T SidLen;
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
SIZE_T SidLen;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
if (Sid1->SubAuthorityCount == Sid2->SubAuthorityCount)
{
SidLen = FIELD_OFFSET(SID,
SubAuthority[Sid1->SubAuthorityCount]);
return RtlCompareMemory(Sid1,
Sid2,
SidLen) == SidLen;
}
if (Sid1->SubAuthorityCount == Sid2->SubAuthorityCount)
{
SidLen = FIELD_OFFSET(SID,
SubAuthority[Sid1->SubAuthorityCount]);
return RtlCompareMemory(Sid1,
Sid2,
SidLen) == SidLen;
}
return FALSE;
return FALSE;
}
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlConvertSidToUnicodeString(PUNICODE_STRING String,
PSID Sid_,
BOOLEAN AllocateBuffer)
{
WCHAR Buffer[256];
PWSTR wcs;
SIZE_T Length;
ULONG i;
PISID Sid = Sid_;
WCHAR Buffer[256];
PWSTR wcs;
SIZE_T Length;
ULONG i;
PISID Sid = Sid_;
PAGED_CODE_RTL();
PAGED_CODE_RTL();
if (RtlValidSid (Sid) == FALSE)
return STATUS_INVALID_SID;
if (RtlValidSid (Sid) == FALSE)
return STATUS_INVALID_SID;
wcs = Buffer;
wcs += swprintf (wcs, L"S-%u-", Sid->Revision);
if (Sid->IdentifierAuthority.Value[0] == 0 &&
Sid->IdentifierAuthority.Value[1] == 0)
{
wcs += swprintf (wcs,
L"%lu",
(ULONG)Sid->IdentifierAuthority.Value[2] << 24 |
(ULONG)Sid->IdentifierAuthority.Value[3] << 16 |
(ULONG)Sid->IdentifierAuthority.Value[4] << 8 |
(ULONG)Sid->IdentifierAuthority.Value[5]);
}
else
{
wcs += swprintf (wcs,
L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
Sid->IdentifierAuthority.Value[0],
Sid->IdentifierAuthority.Value[1],
Sid->IdentifierAuthority.Value[2],
Sid->IdentifierAuthority.Value[3],
Sid->IdentifierAuthority.Value[4],
Sid->IdentifierAuthority.Value[5]);
}
wcs = Buffer;
wcs += swprintf(wcs, L"S-%u-", Sid->Revision);
for (i = 0; i < Sid->SubAuthorityCount; i++)
{
wcs += swprintf (wcs,
L"-%u",
Sid->SubAuthority[i]);
}
if (Sid->IdentifierAuthority.Value[0] == 0 &&
Sid->IdentifierAuthority.Value[1] == 0)
{
wcs += swprintf(wcs,
L"%lu",
(ULONG)Sid->IdentifierAuthority.Value[2] << 24 |
(ULONG)Sid->IdentifierAuthority.Value[3] << 16 |
(ULONG)Sid->IdentifierAuthority.Value[4] << 8 |
(ULONG)Sid->IdentifierAuthority.Value[5]);
}
else
{
wcs += swprintf(wcs,
L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
Sid->IdentifierAuthority.Value[0],
Sid->IdentifierAuthority.Value[1],
Sid->IdentifierAuthority.Value[2],
Sid->IdentifierAuthority.Value[3],
Sid->IdentifierAuthority.Value[4],
Sid->IdentifierAuthority.Value[5]);
}
if (AllocateBuffer)
{
if (!RtlCreateUnicodeString(String,
Buffer))
{
return STATUS_NO_MEMORY;
}
}
else
{
Length = (wcs - Buffer) * sizeof(WCHAR);
for (i = 0; i < Sid->SubAuthorityCount; i++)
{
wcs += swprintf(wcs,
L"-%u",
Sid->SubAuthority[i]);
}
if (Length > String->MaximumLength)
return STATUS_BUFFER_TOO_SMALL;
if (AllocateBuffer)
{
if (!RtlCreateUnicodeString(String,
Buffer))
{
return STATUS_NO_MEMORY;
}
}
else
{
Length = (wcs - Buffer) * sizeof(WCHAR);
String->Length = (USHORT)Length;
RtlCopyMemory (String->Buffer,
Buffer,
Length);
if (Length < String->MaximumLength)
String->Buffer[Length / sizeof(WCHAR)] = 0;
}
if (Length > String->MaximumLength)
return STATUS_BUFFER_TOO_SMALL;
return STATUS_SUCCESS;
String->Length = (USHORT)Length;
RtlCopyMemory(String->Buffer,
Buffer,
Length);
if (Length < String->MaximumLength)
String->Buffer[Length / sizeof(WCHAR)] = 0;
}
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -49,16 +49,16 @@ static const UCHAR MonthLengths[2][MONSPERYEAR] =
static __inline int IsLeapYear(int Year)
{
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0;
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0;
}
static int DaysSinceEpoch(int Year)
{
int Days;
Year--; /* Don't include a leap day from the current year */
Days = Year * DAYSPERNORMALYEAR + Year / 4 - Year / 100 + Year / 400;
Days -= (EPOCHYEAR - 1) * DAYSPERNORMALYEAR + (EPOCHYEAR - 1) / 4 - (EPOCHYEAR - 1) / 100 + (EPOCHYEAR - 1) / 400;
return Days;
int Days;
Year--; /* Don't include a leap day from the current year */
Days = Year * DAYSPERNORMALYEAR + Year / 4 - Year / 100 + Year / 400;
Days -= (EPOCHYEAR - 1) * DAYSPERNORMALYEAR + (EPOCHYEAR - 1) / 4 - (EPOCHYEAR - 1) / 100 + (EPOCHYEAR - 1) / 400;
return Days;
}
/* FUNCTIONS *****************************************************************/
@ -72,93 +72,93 @@ RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
IN PLARGE_INTEGER CurrentTime,
IN BOOLEAN ThisYearsCutoverOnly)
{
TIME_FIELDS AdjustedTimeFields;
TIME_FIELDS CurrentTimeFields;
TIME_FIELDS CutoverSystemTimeFields;
LARGE_INTEGER CutoverSystemTime;
UCHAR MonthLength;
CSHORT Days;
BOOLEAN NextYearsCutover = FALSE;
TIME_FIELDS AdjustedTimeFields;
TIME_FIELDS CurrentTimeFields;
TIME_FIELDS CutoverSystemTimeFields;
LARGE_INTEGER CutoverSystemTime;
UCHAR MonthLength;
CSHORT Days;
BOOLEAN NextYearsCutover = FALSE;
/* Check fixed cutover time */
if (CutoverTimeFields->Year != 0)
{
if (!RtlTimeFieldsToTime(CutoverTimeFields, SystemTime))
return FALSE;
/* Check fixed cutover time */
if (CutoverTimeFields->Year != 0)
{
if (!RtlTimeFieldsToTime(CutoverTimeFields, SystemTime))
return FALSE;
if (SystemTime->QuadPart < CurrentTime->QuadPart)
return FALSE;
if (SystemTime->QuadPart < CurrentTime->QuadPart)
return FALSE;
return TRUE;
}
/*
* Compute recurring cutover time
*/
/* Day must be between 1(first) and 5(last) */
if (CutoverTimeFields->Day == 0 || CutoverTimeFields->Day > 5)
return FALSE;
RtlTimeToTimeFields(CurrentTime, &CurrentTimeFields);
while (TRUE)
{
/* Compute the cutover time of the first day of the current month */
AdjustedTimeFields.Year = CurrentTimeFields.Year;
if (NextYearsCutover == TRUE)
AdjustedTimeFields.Year++;
AdjustedTimeFields.Month = CutoverTimeFields->Month;
AdjustedTimeFields.Day = 1;
AdjustedTimeFields.Hour = CutoverTimeFields->Hour;
AdjustedTimeFields.Minute = CutoverTimeFields->Minute;
AdjustedTimeFields.Second = CutoverTimeFields->Second;
AdjustedTimeFields.Milliseconds = CutoverTimeFields->Milliseconds;
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
return FALSE;
RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
/* Adjust day to first matching weekday */
if (CutoverSystemTimeFields.Weekday != CutoverTimeFields->Weekday)
{
if (CutoverSystemTimeFields.Weekday < CutoverTimeFields->Weekday)
Days = CutoverTimeFields->Weekday - CutoverSystemTimeFields.Weekday;
else
Days = DAYSPERWEEK - (CutoverSystemTimeFields.Weekday - CutoverTimeFields->Weekday);
AdjustedTimeFields.Day += Days;
}
/* Adjust the number of weeks */
if (CutoverTimeFields->Day > 1)
{
Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
MonthLength = MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Month - 1];
if ((AdjustedTimeFields.Day + Days) > MonthLength)
Days -= DAYSPERWEEK;
AdjustedTimeFields.Day += Days;
}
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
return FALSE;
if (ThisYearsCutoverOnly == TRUE ||
NextYearsCutover == TRUE ||
CutoverSystemTime.QuadPart >= CurrentTime->QuadPart)
{
break;
}
NextYearsCutover = TRUE;
}
SystemTime->QuadPart = CutoverSystemTime.QuadPart;
return TRUE;
}
/*
* Compute recurring cutover time
*/
/* Day must be between 1(first) and 5(last) */
if (CutoverTimeFields->Day == 0 || CutoverTimeFields->Day > 5)
return FALSE;
RtlTimeToTimeFields(CurrentTime, &CurrentTimeFields);
while (TRUE)
{
/* Compute the cutover time of the first day of the current month */
AdjustedTimeFields.Year = CurrentTimeFields.Year;
if (NextYearsCutover == TRUE)
AdjustedTimeFields.Year++;
AdjustedTimeFields.Month = CutoverTimeFields->Month;
AdjustedTimeFields.Day = 1;
AdjustedTimeFields.Hour = CutoverTimeFields->Hour;
AdjustedTimeFields.Minute = CutoverTimeFields->Minute;
AdjustedTimeFields.Second = CutoverTimeFields->Second;
AdjustedTimeFields.Milliseconds = CutoverTimeFields->Milliseconds;
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
return FALSE;
RtlTimeToTimeFields(&CutoverSystemTime, &CutoverSystemTimeFields);
/* Adjust day to first matching weekday */
if (CutoverSystemTimeFields.Weekday != CutoverTimeFields->Weekday)
{
if (CutoverSystemTimeFields.Weekday < CutoverTimeFields->Weekday)
Days = CutoverTimeFields->Weekday - CutoverSystemTimeFields.Weekday;
else
Days = DAYSPERWEEK - (CutoverSystemTimeFields.Weekday - CutoverTimeFields->Weekday);
AdjustedTimeFields.Day += Days;
}
/* Adjust the number of weeks */
if (CutoverTimeFields->Day > 1)
{
Days = DAYSPERWEEK * (CutoverTimeFields->Day - 1);
MonthLength = MonthLengths[IsLeapYear(AdjustedTimeFields.Year)][AdjustedTimeFields.Month - 1];
if ((AdjustedTimeFields.Day + Days) > MonthLength)
Days -= DAYSPERWEEK;
AdjustedTimeFields.Day += Days;
}
if (!RtlTimeFieldsToTime(&AdjustedTimeFields, &CutoverSystemTime))
return FALSE;
if (ThisYearsCutoverOnly == TRUE ||
NextYearsCutover == TRUE ||
CutoverSystemTime.QuadPart >= CurrentTime->QuadPart)
{
break;
}
NextYearsCutover = TRUE;
}
SystemTime->QuadPart = CutoverSystemTime.QuadPart;
return TRUE;
}
@ -167,44 +167,43 @@ RtlCutoverTimeToSystemTime(IN PTIME_FIELDS CutoverTimeFields,
*/
BOOLEAN
NTAPI
RtlTimeFieldsToTime(
IN PTIME_FIELDS TimeFields,
OUT PLARGE_INTEGER Time)
RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields,
OUT PLARGE_INTEGER Time)
{
int CurMonth;
TIME_FIELDS IntTimeFields;
int CurMonth;
TIME_FIELDS IntTimeFields;
memcpy(&IntTimeFields,
TimeFields,
sizeof(TIME_FIELDS));
memcpy(&IntTimeFields,
TimeFields,
sizeof(TIME_FIELDS));
if (TimeFields->Milliseconds < 0 || TimeFields->Milliseconds > 999 ||
TimeFields->Second < 0 || TimeFields->Second > 59 ||
TimeFields->Minute < 0 || TimeFields->Minute > 59 ||
TimeFields->Hour < 0 || TimeFields->Hour > 23 ||
TimeFields->Month < 1 || TimeFields->Month > 12 ||
TimeFields->Day < 1 ||
TimeFields->Day >
MonthLengths[IsLeapYear(TimeFields->Year)][TimeFields->Month - 1] ||
TimeFields->Year < 1601)
{
return FALSE;
}
if (TimeFields->Milliseconds < 0 || TimeFields->Milliseconds > 999 ||
TimeFields->Second < 0 || TimeFields->Second > 59 ||
TimeFields->Minute < 0 || TimeFields->Minute > 59 ||
TimeFields->Hour < 0 || TimeFields->Hour > 23 ||
TimeFields->Month < 1 || TimeFields->Month > 12 ||
TimeFields->Day < 1 ||
TimeFields->Day >
MonthLengths[IsLeapYear(TimeFields->Year)][TimeFields->Month - 1] ||
TimeFields->Year < 1601)
{
return FALSE;
}
/* Compute the time */
Time->QuadPart = DaysSinceEpoch(IntTimeFields.Year);
for (CurMonth = 1; CurMonth < IntTimeFields.Month; CurMonth++)
{
Time->QuadPart += MonthLengths[IsLeapYear(IntTimeFields.Year)][CurMonth - 1];
}
Time->QuadPart += IntTimeFields.Day - 1;
Time->QuadPart *= SECSPERDAY;
Time->QuadPart += IntTimeFields.Hour * SECSPERHOUR + IntTimeFields.Minute * SECSPERMIN +
IntTimeFields.Second;
Time->QuadPart *= TICKSPERSEC;
Time->QuadPart += IntTimeFields.Milliseconds * TICKSPERMSEC;
/* Compute the time */
Time->QuadPart = DaysSinceEpoch(IntTimeFields.Year);
for (CurMonth = 1; CurMonth < IntTimeFields.Month; CurMonth++)
{
Time->QuadPart += MonthLengths[IsLeapYear(IntTimeFields.Year)][CurMonth - 1];
}
Time->QuadPart += IntTimeFields.Day - 1;
Time->QuadPart *= SECSPERDAY;
Time->QuadPart += IntTimeFields.Hour * SECSPERHOUR + IntTimeFields.Minute * SECSPERMIN +
IntTimeFields.Second;
Time->QuadPart *= TICKSPERSEC;
Time->QuadPart += IntTimeFields.Milliseconds * TICKSPERMSEC;
return TRUE;
return TRUE;
}
@ -216,33 +215,33 @@ NTAPI
RtlTimeToElapsedTimeFields(IN PLARGE_INTEGER Time,
OUT PTIME_FIELDS TimeFields)
{
ULONGLONG ElapsedSeconds;
ULONG SecondsInDay;
ULONG SecondsInMinute;
ULONGLONG ElapsedSeconds;
ULONG SecondsInDay;
ULONG SecondsInMinute;
/* Extract millisecond from time */
TimeFields->Milliseconds = (CSHORT)((Time->QuadPart % TICKSPERSEC) / TICKSPERMSEC);
/* Extract millisecond from time */
TimeFields->Milliseconds = (CSHORT)((Time->QuadPart % TICKSPERSEC) / TICKSPERMSEC);
/* Compute elapsed seconds */
ElapsedSeconds = (ULONGLONG)Time->QuadPart / TICKSPERSEC;
/* Compute elapsed seconds */
ElapsedSeconds = (ULONGLONG)Time->QuadPart / TICKSPERSEC;
/* Compute seconds within the day */
SecondsInDay = ElapsedSeconds % SECSPERDAY;
/* Compute seconds within the day */
SecondsInDay = ElapsedSeconds % SECSPERDAY;
/* Compute elapsed minutes within the day */
SecondsInMinute = SecondsInDay % SECSPERHOUR;
/* Compute elapsed minutes within the day */
SecondsInMinute = SecondsInDay % SECSPERHOUR;
/* Compute elapsed time of day */
TimeFields->Hour = (CSHORT)(SecondsInDay / SECSPERHOUR);
TimeFields->Minute = (CSHORT)(SecondsInMinute / SECSPERMIN);
TimeFields->Second = (CSHORT)(SecondsInMinute % SECSPERMIN);
/* Compute elapsed time of day */
TimeFields->Hour = (CSHORT)(SecondsInDay / SECSPERHOUR);
TimeFields->Minute = (CSHORT)(SecondsInMinute / SECSPERMIN);
TimeFields->Second = (CSHORT)(SecondsInMinute % SECSPERMIN);
/* Compute elapsed days */
TimeFields->Day = (CSHORT)(ElapsedSeconds / SECSPERDAY);
/* Compute elapsed days */
TimeFields->Day = (CSHORT)(ElapsedSeconds / SECSPERDAY);
/* The elapsed number of months and days cannot be calculated */
TimeFields->Month = 0;
TimeFields->Year = 0;
/* The elapsed number of months and days cannot be calculated */
TimeFields->Month = 0;
TimeFields->Year = 0;
}
@ -251,56 +250,55 @@ RtlTimeToElapsedTimeFields(IN PLARGE_INTEGER Time,
*/
VOID
NTAPI
RtlTimeToTimeFields(
IN PLARGE_INTEGER Time,
OUT PTIME_FIELDS TimeFields)
RtlTimeToTimeFields(IN PLARGE_INTEGER Time,
OUT PTIME_FIELDS TimeFields)
{
const UCHAR *Months;
ULONG SecondsInDay, CurYear;
ULONG LeapYear, CurMonth;
ULONG Days;
ULONGLONG IntTime = Time->QuadPart;
const UCHAR *Months;
ULONG SecondsInDay, CurYear;
ULONG LeapYear, CurMonth;
ULONG Days;
ULONGLONG IntTime = Time->QuadPart;
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((IntTime % TICKSPERSEC) / TICKSPERMSEC);
IntTime = IntTime / TICKSPERSEC;
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((IntTime % TICKSPERSEC) / TICKSPERMSEC);
IntTime = IntTime / TICKSPERSEC;
/* Split the time into days and seconds within the day */
Days = (ULONG)(IntTime / SECSPERDAY);
SecondsInDay = IntTime % SECSPERDAY;
/* Split the time into days and seconds within the day */
Days = (ULONG)(IntTime / SECSPERDAY);
SecondsInDay = IntTime % SECSPERDAY;
/* compute time of day */
TimeFields->Hour = (CSHORT) (SecondsInDay / SECSPERHOUR);
SecondsInDay = SecondsInDay % SECSPERHOUR;
TimeFields->Minute = (CSHORT) (SecondsInDay / SECSPERMIN);
TimeFields->Second = (CSHORT) (SecondsInDay % SECSPERMIN);
/* compute time of day */
TimeFields->Hour = (CSHORT) (SecondsInDay / SECSPERHOUR);
SecondsInDay = SecondsInDay % SECSPERHOUR;
TimeFields->Minute = (CSHORT) (SecondsInDay / SECSPERMIN);
TimeFields->Second = (CSHORT) (SecondsInDay % SECSPERMIN);
/* compute day of week */
TimeFields->Weekday = (CSHORT) ((EPOCHWEEKDAY + Days) % DAYSPERWEEK);
/* compute day of week */
TimeFields->Weekday = (CSHORT) ((EPOCHWEEKDAY + Days) % DAYSPERWEEK);
/* compute year */
CurYear = EPOCHYEAR;
CurYear += Days / DAYSPERLEAPYEAR;
Days -= DaysSinceEpoch(CurYear);
while (1)
{
LeapYear = IsLeapYear(CurYear);
if (Days < YearLengths[LeapYear])
{
break;
}
CurYear++;
Days = Days - YearLengths[LeapYear];
}
TimeFields->Year = (CSHORT) CurYear;
/* compute year */
CurYear = EPOCHYEAR;
CurYear += Days / DAYSPERLEAPYEAR;
Days -= DaysSinceEpoch(CurYear);
while (1)
{
LeapYear = IsLeapYear(CurYear);
if (Days < YearLengths[LeapYear])
{
break;
}
CurYear++;
Days = Days - YearLengths[LeapYear];
}
TimeFields->Year = (CSHORT) CurYear;
/* Compute month of year */
LeapYear = IsLeapYear(CurYear);
Months = MonthLengths[LeapYear];
for (CurMonth = 0; Days >= Months[CurMonth]; CurMonth++)
Days = Days - Months[CurMonth];
TimeFields->Month = (CSHORT) (CurMonth + 1);
TimeFields->Day = (CSHORT) (Days + 1);
/* Compute month of year */
LeapYear = IsLeapYear(CurYear);
Months = MonthLengths[LeapYear];
for (CurMonth = 0; Days >= Months[CurMonth]; CurMonth++)
Days = Days - Months[CurMonth];
TimeFields->Month = (CSHORT) (CurMonth + 1);
TimeFields->Day = (CSHORT) (Days + 1);
}
@ -309,21 +307,20 @@ RtlTimeToTimeFields(
*/
BOOLEAN
NTAPI
RtlTimeToSecondsSince1970(
IN PLARGE_INTEGER Time,
OUT PULONG SecondsSince1970)
RtlTimeToSecondsSince1970(IN PLARGE_INTEGER Time,
OUT PULONG SecondsSince1970)
{
LARGE_INTEGER IntTime;
LARGE_INTEGER IntTime;
IntTime.QuadPart = Time->QuadPart - TICKSTO1970;
IntTime.QuadPart = IntTime.QuadPart / TICKSPERSEC;
IntTime.QuadPart = Time->QuadPart - TICKSTO1970;
IntTime.QuadPart = IntTime.QuadPart / TICKSPERSEC;
if (IntTime.u.HighPart != 0)
return FALSE;
if (IntTime.u.HighPart != 0)
return FALSE;
*SecondsSince1970 = IntTime.u.LowPart;
*SecondsSince1970 = IntTime.u.LowPart;
return TRUE;
return TRUE;
}
@ -332,21 +329,20 @@ RtlTimeToSecondsSince1970(
*/
BOOLEAN
NTAPI
RtlTimeToSecondsSince1980(
IN PLARGE_INTEGER Time,
OUT PULONG SecondsSince1980)
RtlTimeToSecondsSince1980(IN PLARGE_INTEGER Time,
OUT PULONG SecondsSince1980)
{
LARGE_INTEGER IntTime;
LARGE_INTEGER IntTime;
IntTime.QuadPart = Time->QuadPart - TICKSTO1980;
IntTime.QuadPart = IntTime.QuadPart / TICKSPERSEC;
IntTime.QuadPart = Time->QuadPart - TICKSTO1980;
IntTime.QuadPart = IntTime.QuadPart / TICKSPERSEC;
if (IntTime.u.HighPart != 0)
return FALSE;
if (IntTime.u.HighPart != 0)
return FALSE;
*SecondsSince1980 = IntTime.u.LowPart;
*SecondsSince1980 = IntTime.u.LowPart;
return TRUE;
return TRUE;
}
@ -358,20 +354,20 @@ NTAPI
RtlLocalTimeToSystemTime(IN PLARGE_INTEGER LocalTime,
OUT PLARGE_INTEGER SystemTime)
{
SYSTEM_TIMEOFDAY_INFORMATION TimeInformation;
NTSTATUS Status;
SYSTEM_TIMEOFDAY_INFORMATION TimeInformation;
NTSTATUS Status;
Status = ZwQuerySystemInformation(SystemTimeOfDayInformation,
&TimeInformation,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL);
if (!NT_SUCCESS(Status))
return Status;
Status = ZwQuerySystemInformation(SystemTimeOfDayInformation,
&TimeInformation,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL);
if (!NT_SUCCESS(Status))
return Status;
SystemTime->QuadPart = LocalTime->QuadPart +
TimeInformation.TimeZoneBias.QuadPart;
SystemTime->QuadPart = LocalTime->QuadPart +
TimeInformation.TimeZoneBias.QuadPart;
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
@ -383,20 +379,32 @@ NTAPI
RtlSystemTimeToLocalTime(IN PLARGE_INTEGER SystemTime,
OUT PLARGE_INTEGER LocalTime)
{
SYSTEM_TIMEOFDAY_INFORMATION TimeInformation;
NTSTATUS Status;
SYSTEM_TIMEOFDAY_INFORMATION TimeInformation;
NTSTATUS Status;
Status = ZwQuerySystemInformation(SystemTimeOfDayInformation,
&TimeInformation,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL);
if (!NT_SUCCESS(Status))
return Status;
Status = ZwQuerySystemInformation(SystemTimeOfDayInformation,
&TimeInformation,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL);
if (!NT_SUCCESS(Status))
return Status;
LocalTime->QuadPart = SystemTime->QuadPart -
TimeInformation.TimeZoneBias.QuadPart;
LocalTime->QuadPart = SystemTime->QuadPart -
TimeInformation.TimeZoneBias.QuadPart;
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
/*
* @implemented
*/
VOID
NTAPI
RtlSecondsSince1970ToTime(IN ULONG SecondsSince1970,
OUT PLARGE_INTEGER Time)
{
Time->QuadPart = ((LONGLONG)SecondsSince1970 * TICKSPERSEC) + TICKSTO1970;
}
@ -404,23 +412,10 @@ RtlSystemTimeToLocalTime(IN PLARGE_INTEGER SystemTime,
* @implemented
*/
VOID NTAPI
RtlSecondsSince1970ToTime(
IN ULONG SecondsSince1970,
OUT PLARGE_INTEGER Time)
RtlSecondsSince1980ToTime(IN ULONG SecondsSince1980,
OUT PLARGE_INTEGER Time)
{
Time->QuadPart = ((LONGLONG)SecondsSince1970 * TICKSPERSEC) + TICKSTO1970;
}
/*
* @implemented
*/
VOID NTAPI
RtlSecondsSince1980ToTime(
IN ULONG SecondsSince1980,
OUT PLARGE_INTEGER Time)
{
Time->QuadPart = ((LONGLONG)SecondsSince1980 * TICKSPERSEC) + TICKSTO1980;
Time->QuadPart = ((LONGLONG)SecondsSince1980 * TICKSPERSEC) + TICKSTO1980;
}
/* EOF */

View file

@ -18,156 +18,158 @@
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlQueryTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
{
RTL_QUERY_REGISTRY_TABLE QueryTable[8];
UNICODE_STRING StandardName;
UNICODE_STRING DaylightName;
NTSTATUS Status;
RTL_QUERY_REGISTRY_TABLE QueryTable[8];
UNICODE_STRING StandardName;
UNICODE_STRING DaylightName;
NTSTATUS Status;
DPRINT("RtlQueryTimeZoneInformation()\n");
DPRINT("RtlQueryTimeZoneInformation()\n");
PAGED_CODE_RTL();
PAGED_CODE_RTL();
RtlZeroMemory(QueryTable,
sizeof(QueryTable));
RtlZeroMemory(QueryTable,
sizeof(QueryTable));
StandardName.Length = 0;
StandardName.MaximumLength = 32 * sizeof(WCHAR);
StandardName.Buffer = TimeZoneInformation->StandardName;
StandardName.Length = 0;
StandardName.MaximumLength = 32 * sizeof(WCHAR);
StandardName.Buffer = TimeZoneInformation->StandardName;
DaylightName.Length = 0;
DaylightName.MaximumLength = 32 * sizeof(WCHAR);
DaylightName.Buffer = TimeZoneInformation->DaylightName;
DaylightName.Length = 0;
DaylightName.MaximumLength = 32 * sizeof(WCHAR);
DaylightName.Buffer = TimeZoneInformation->DaylightName;
QueryTable[0].Name = L"Bias";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &TimeZoneInformation->Bias;
QueryTable[0].Name = L"Bias";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &TimeZoneInformation->Bias;
QueryTable[1].Name = L"Standard Name";
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[1].EntryContext = &StandardName;
QueryTable[1].Name = L"Standard Name";
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[1].EntryContext = &StandardName;
QueryTable[2].Name = L"Standard Bias";
QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[2].EntryContext = &TimeZoneInformation->StandardBias;
QueryTable[2].Name = L"Standard Bias";
QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[2].EntryContext = &TimeZoneInformation->StandardBias;
QueryTable[3].Name = L"Standard Start";
QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[3].EntryContext = &TimeZoneInformation->StandardDate;
QueryTable[3].Name = L"Standard Start";
QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[3].EntryContext = &TimeZoneInformation->StandardDate;
QueryTable[4].Name = L"Daylight Name";
QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[4].EntryContext = &DaylightName;
QueryTable[4].Name = L"Daylight Name";
QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[4].EntryContext = &DaylightName;
QueryTable[5].Name = L"Daylight Bias";
QueryTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[5].EntryContext = &TimeZoneInformation->DaylightBias;
QueryTable[5].Name = L"Daylight Bias";
QueryTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[5].EntryContext = &TimeZoneInformation->DaylightBias;
QueryTable[6].Name = L"Daylight Start";
QueryTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[6].EntryContext = &TimeZoneInformation->DaylightDate;
QueryTable[6].Name = L"Daylight Start";
QueryTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[6].EntryContext = &TimeZoneInformation->DaylightDate;
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
QueryTable,
NULL,
NULL);
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
QueryTable,
NULL,
NULL);
return Status;
return Status;
}
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
{
SIZE_T Length;
NTSTATUS Status;
SIZE_T Length;
NTSTATUS Status;
DPRINT("RtlSetTimeZoneInformation()\n");
DPRINT("RtlSetTimeZoneInformation()\n");
PAGED_CODE_RTL();
PAGED_CODE_RTL();
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Bias",
REG_DWORD,
&TimeZoneInformation->Bias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Bias",
REG_DWORD,
&TimeZoneInformation->Bias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Length = (wcslen(TimeZoneInformation->StandardName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Name",
REG_SZ,
TimeZoneInformation->StandardName,
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
}
Length = (wcslen(TimeZoneInformation->StandardName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Name",
REG_SZ,
TimeZoneInformation->StandardName,
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Bias",
REG_DWORD,
&TimeZoneInformation->StandardBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Bias",
REG_DWORD,
&TimeZoneInformation->StandardBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Start",
REG_BINARY,
&TimeZoneInformation->StandardDate,
sizeof(SYSTEMTIME));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Standard Start",
REG_BINARY,
&TimeZoneInformation->StandardDate,
sizeof(SYSTEMTIME));
if (!NT_SUCCESS(Status))
{
return Status;
}
Length = (wcslen(TimeZoneInformation->DaylightName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Name",
REG_SZ,
TimeZoneInformation->DaylightName,
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
}
Length = (wcslen(TimeZoneInformation->DaylightName) + 1) * sizeof(WCHAR);
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Name",
REG_SZ,
TimeZoneInformation->DaylightName,
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Bias",
REG_DWORD,
&TimeZoneInformation->DaylightBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Bias",
REG_DWORD,
&TimeZoneInformation->DaylightBias,
sizeof(LONG));
if (!NT_SUCCESS(Status))
{
return Status;
}
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Start",
REG_BINARY,
&TimeZoneInformation->DaylightDate,
sizeof(SYSTEMTIME));
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",
L"Daylight Start",
REG_BINARY,
&TimeZoneInformation->DaylightDate,
sizeof(SYSTEMTIME));
return Status;
return Status;
}
/* EOF */

View file

@ -154,37 +154,38 @@ RtlVerifyVersionInfo(
/*
* @implemented
*/
ULONGLONG NTAPI
ULONGLONG
NTAPI
VerSetConditionMask(IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask,
IN BYTE dwConditionMask)
{
if(dwTypeBitMask == 0)
if (dwTypeBitMask == 0)
return dwlConditionMask;
dwConditionMask &= VER_CONDITION_MASK;
if (dwConditionMask == 0)
return dwlConditionMask;
if (dwTypeBitMask & VER_PRODUCT_TYPE)
dwlConditionMask |= dwConditionMask << 7 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_SUITENAME)
dwlConditionMask |= dwConditionMask << 6 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
dwlConditionMask |= dwConditionMask << 5 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
dwlConditionMask |= dwConditionMask << 4 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_PLATFORMID)
dwlConditionMask |= dwConditionMask << 3 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_BUILDNUMBER)
dwlConditionMask |= dwConditionMask << 2 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_MAJORVERSION)
dwlConditionMask |= dwConditionMask << 1 * VER_NUM_BITS_PER_CONDITION_MASK;
else if (dwTypeBitMask & VER_MINORVERSION)
dwlConditionMask |= dwConditionMask << 0 * VER_NUM_BITS_PER_CONDITION_MASK;
return dwlConditionMask;
dwConditionMask &= VER_CONDITION_MASK;
if(dwConditionMask == 0)
return dwlConditionMask;
if(dwTypeBitMask & VER_PRODUCT_TYPE)
dwlConditionMask |= dwConditionMask << 7 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_SUITENAME)
dwlConditionMask |= dwConditionMask << 6 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_SERVICEPACKMAJOR)
dwlConditionMask |= dwConditionMask << 5 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_SERVICEPACKMINOR)
dwlConditionMask |= dwConditionMask << 4 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_PLATFORMID)
dwlConditionMask |= dwConditionMask << 3 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_BUILDNUMBER)
dwlConditionMask |= dwConditionMask << 2 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_MAJORVERSION)
dwlConditionMask |= dwConditionMask << 1 * VER_NUM_BITS_PER_CONDITION_MASK;
else if(dwTypeBitMask & VER_MINORVERSION)
dwlConditionMask |= dwConditionMask << 0 * VER_NUM_BITS_PER_CONDITION_MASK;
return dwlConditionMask;
}
/* EOF */

View file

@ -127,7 +127,7 @@ Wait_thread_proc(LPVOID Arg)
*|WT_EXECUTELONGFUNCTION - Hints that the execution can take a long time.
*|WT_TRANSFER_IMPERSONATION - Executes the function with the current access token.
*/
NTSTATUS
NTSTATUS
NTAPI
RtlRegisterWait(PHANDLE NewWaitObject,
HANDLE Object,
@ -194,8 +194,8 @@ RtlRegisterWait(PHANDLE NewWaitObject,
* Success: STATUS_SUCCESS.
* Failure: Any NTSTATUS code.
*/
NTSTATUS
NTAPI
NTSTATUS
NTAPI
RtlDeregisterWaitEx(HANDLE WaitHandle,
HANDLE CompletionEvent)
{