mirror of
https://github.com/reactos/reactos.git
synced 2024-10-19 23:50:05 +00:00
moved into rtl
svn path=/trunk/; revision=9780
This commit is contained in:
parent
13e51e12a9
commit
d26418fb30
|
@ -1,80 +0,0 @@
|
|||
/* $Id: encode.c,v 1.3 2004/02/01 20:48:06 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Security descriptor functions
|
||||
* FILE: lib/ntdll/rtl/encode.c
|
||||
* PROGRAMMER: KJK::Hyperion <noog@libero.it>
|
||||
* REVISION HISTORY:
|
||||
* 02/04/2003: created (code contributed by crazylord
|
||||
* <crazyl0rd@minithins.net>)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <ntdll/ntdll.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID STDCALL
|
||||
RtlRunDecodeUnicodeString (IN UCHAR Hash,
|
||||
IN OUT PUNICODE_STRING String)
|
||||
{
|
||||
PUCHAR ptr;
|
||||
USHORT i;
|
||||
|
||||
ptr = (PUCHAR)String->Buffer;
|
||||
if (String->Length > 1)
|
||||
{
|
||||
for (i = String->Length; i > 1; i--)
|
||||
{
|
||||
ptr[i - 1] ^= ptr[i - 2] ^ Hash;
|
||||
}
|
||||
}
|
||||
|
||||
if (String->Length >= 1)
|
||||
{
|
||||
ptr[0] ^= Hash | (UCHAR)0x43;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
RtlRunEncodeUnicodeString (IN OUT PUCHAR Hash,
|
||||
IN OUT PUNICODE_STRING String)
|
||||
{
|
||||
LARGE_INTEGER CurrentTime;
|
||||
PUCHAR ptr;
|
||||
USHORT i;
|
||||
NTSTATUS Status;
|
||||
|
||||
ptr = (PUCHAR) String->Buffer;
|
||||
if (*Hash == 0)
|
||||
{
|
||||
Status = NtQuerySystemTime (&CurrentTime);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
for (i = 1; i < sizeof(LARGE_INTEGER) && (*Hash == 0); i++)
|
||||
*Hash |= *(PUCHAR)(((PUCHAR)&CurrentTime) + i);
|
||||
}
|
||||
|
||||
if (*Hash == 0)
|
||||
*Hash = 1;
|
||||
}
|
||||
|
||||
if (String->Length >= 1)
|
||||
{
|
||||
ptr[0] ^= (*Hash) | (UCHAR)0x43;
|
||||
if (String->Length > 1)
|
||||
{
|
||||
for (i = 1; i < String->Length; i++)
|
||||
{
|
||||
ptr[i] ^= ptr[i - 1] ^ (*Hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,148 +0,0 @@
|
|||
/* $Id: image.c,v 1.7 2004/01/17 10:30:53 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: lib/ntdll/rtl/image.c
|
||||
* PURPOSE: Image handling functions
|
||||
* PROGRAMMER: Eric Kohl
|
||||
* UPDATE HISTORY:
|
||||
* 17/03/2000 Created
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <ntdll/ntdll.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
PIMAGE_NT_HEADERS STDCALL
|
||||
RtlImageNtHeader (IN PVOID BaseAddress)
|
||||
{
|
||||
PIMAGE_NT_HEADERS NtHeader;
|
||||
PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
|
||||
|
||||
if (DosHeader && DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
{
|
||||
DPRINT1("DosHeader->e_magic %x\n", DosHeader->e_magic);
|
||||
DPRINT1("NtHeader %x\n", (BaseAddress + DosHeader->e_lfanew));
|
||||
}
|
||||
|
||||
if (DosHeader && DosHeader->e_magic == IMAGE_DOS_SIGNATURE)
|
||||
{
|
||||
NtHeader = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
|
||||
if (NtHeader->Signature == IMAGE_NT_SIGNATURE)
|
||||
return NtHeader;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
RtlImageDirectoryEntryToData (
|
||||
PVOID BaseAddress,
|
||||
BOOLEAN bFlag,
|
||||
ULONG Directory,
|
||||
PULONG Size
|
||||
)
|
||||
{
|
||||
PIMAGE_NT_HEADERS NtHeader;
|
||||
ULONG Va;
|
||||
|
||||
NtHeader = RtlImageNtHeader (BaseAddress);
|
||||
if (NtHeader == NULL)
|
||||
return NULL;
|
||||
|
||||
if (Directory >= NtHeader->OptionalHeader.NumberOfRvaAndSizes)
|
||||
return NULL;
|
||||
|
||||
Va = NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress;
|
||||
if (Va == 0)
|
||||
return NULL;
|
||||
|
||||
if (Size)
|
||||
*Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size;
|
||||
|
||||
if (bFlag)
|
||||
return (PVOID)(BaseAddress + Va);
|
||||
|
||||
/* image mapped as ordinary file, we must find raw pointer */
|
||||
return (PVOID)RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
PIMAGE_SECTION_HEADER
|
||||
STDCALL
|
||||
RtlImageRvaToSection (
|
||||
PIMAGE_NT_HEADERS NtHeader,
|
||||
PVOID BaseAddress,
|
||||
ULONG Rva
|
||||
)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER Section;
|
||||
ULONG Va;
|
||||
ULONG Count;
|
||||
|
||||
Count = NtHeader->FileHeader.NumberOfSections;
|
||||
Section = (PIMAGE_SECTION_HEADER)((ULONG)&NtHeader->OptionalHeader +
|
||||
NtHeader->FileHeader.SizeOfOptionalHeader);
|
||||
while (Count)
|
||||
{
|
||||
Va = Section->VirtualAddress;
|
||||
if ((Va <= Rva) &&
|
||||
(Rva < Va + Section->SizeOfRawData))
|
||||
return Section;
|
||||
Section++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
ULONG
|
||||
STDCALL
|
||||
RtlImageRvaToVa (
|
||||
PIMAGE_NT_HEADERS NtHeader,
|
||||
PVOID BaseAddress,
|
||||
ULONG Rva,
|
||||
PIMAGE_SECTION_HEADER *SectionHeader
|
||||
)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER Section = NULL;
|
||||
|
||||
if (SectionHeader)
|
||||
Section = *SectionHeader;
|
||||
|
||||
if (Section == NULL ||
|
||||
Rva < Section->VirtualAddress ||
|
||||
Rva >= Section->VirtualAddress + Section->SizeOfRawData)
|
||||
{
|
||||
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva);
|
||||
if (Section == NULL)
|
||||
return 0;
|
||||
|
||||
if (SectionHeader)
|
||||
*SectionHeader = Section;
|
||||
}
|
||||
|
||||
return (ULONG)(BaseAddress +
|
||||
Rva +
|
||||
Section->PointerToRawData -
|
||||
Section->VirtualAddress);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2003 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: splaytree.c,v 1.1 2003/09/02 11:19:29 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Splay-Tree implementation
|
||||
* FILE: lib/ntdll/rtl/splaytree.c
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PRTL_SPLAY_LINKS STDCALL
|
||||
RtlSubtreePredecessor (IN PRTL_SPLAY_LINKS Links)
|
||||
{
|
||||
PRTL_SPLAY_LINKS Child;
|
||||
|
||||
Child = Links->RightChild;
|
||||
if (Child == NULL)
|
||||
return NULL;
|
||||
|
||||
if (Child->LeftChild == NULL)
|
||||
return Child;
|
||||
|
||||
/* Get left-most child */
|
||||
while (Child->LeftChild != NULL)
|
||||
Child = Child->LeftChild;
|
||||
|
||||
return Child;
|
||||
}
|
||||
|
||||
|
||||
PRTL_SPLAY_LINKS STDCALL
|
||||
RtlSubtreeSuccessor (IN PRTL_SPLAY_LINKS Links)
|
||||
{
|
||||
PRTL_SPLAY_LINKS Child;
|
||||
|
||||
Child = Links->LeftChild;
|
||||
if (Child == NULL)
|
||||
return NULL;
|
||||
|
||||
if (Child->RightChild == NULL)
|
||||
return Child;
|
||||
|
||||
/* Get right-most child */
|
||||
while (Child->RightChild != NULL)
|
||||
Child = Child->RightChild;
|
||||
|
||||
return Child;
|
||||
}
|
||||
|
||||
/* EOF */
|
Loading…
Reference in a new issue