- Sync with trunk head (r50270)
- This also reverts r49298.

svn path=/branches/cmake-bringup/; revision=50271
This commit is contained in:
Amine Khaldi 2011-01-03 00:33:31 +00:00
commit 6c0c23cb53
482 changed files with 40346 additions and 24711 deletions

View file

@ -239,7 +239,7 @@ static UNICODE_STRING xmlstr2unicode(const xmlstr_t *xmlstr)
UNICODE_STRING res;
res.Buffer = (PWSTR)xmlstr->ptr;
res.Length = res.MaximumLength = xmlstr->len;
res.Length = res.MaximumLength = xmlstr->len * sizeof(WCHAR);
return res;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -210,70 +210,124 @@ ByteZero:
_RtlMoveMemory@12:
push ebp
mov ebp, esp
/* Save volatiles */
/* Save non-volatiles */
push esi
push edi
/* Get pointers and size */
mov esi, [esp+16]
mov edi, [esp+12]
mov ecx, [esp+20]
cld
mov edi, [ebp + 8]
mov esi, [ebp + 12]
mov ecx, [ebp + 16]
/* Check if the destination is higher (or equal) */
cmp esi, edi
jbe Overlap
/* Use downward copy if source < dest and overlapping */
cmp edi, esi
jbe .CopyUp
mov eax, ecx
add eax, esi
cmp edi, eax
jb .CopyDown
/* Set ULONG size and UCHAR remainder */
DoMove:
mov edx, ecx
and edx, 3
shr ecx, 2
.CopyUp:
cld
/* Do the move */
rep movsd
or ecx, edx
jnz ByteMove
/* Check for small moves */
cmp ecx, 16
jb .CopyUpBytes
/* Return */
pop edi
pop esi
ret 12
/* Check if its already aligned */
mov edx, ecx
test edi, 3
je .CopyUpDwords
ByteMove:
/* Move what's left */
rep movsb
/* Make the destination dword aligned */
mov ecx, edi
and ecx, 3
sub ecx, 5
not ecx
sub edx, ecx
rep movsb
mov ecx, edx
DoneMove:
/* Restore volatiles */
pop edi
pop esi
ret 12
.CopyUpDwords:
shr ecx, 2
rep movsd
mov ecx, edx
and ecx, 3
Overlap:
/* Don't copy if they're equal */
jz DoneMove
.CopyUpBytes:
test ecx, ecx
je .CopyUpEnd
rep movsb
/* Compare pointer distance with given length and check for overlap */
mov eax, edi
sub eax, esi
cmp ecx, eax
jbe DoMove
.CopyUpEnd:
mov eax, [ebp + 8]
pop edi
pop esi
pop ebp
ret 12
/* Set direction flag for backward move */
std
.CopyDown:
std
/* Copy byte-by-byte the non-overlapping distance */
add esi, ecx
add edi, ecx
dec esi
dec edi
/* Go to the end of the region */
add edi, ecx
add esi, ecx
/* Check for small moves */
cmp ecx, 16
jb .CopyDownSmall
/* Check if its already aligned */
mov edx, ecx
test edi, 3
je .CopyDownAligned
/* Make the destination dword aligned */
mov ecx, edi
and ecx, 3
sub edx, ecx
dec esi
dec edi
rep movsb
mov ecx, edx
sub esi, 3
sub edi, 3
.CopyDownDwords:
shr ecx, 2
rep movsd
mov ecx, edx
and ecx, 3
je .CopyDownEnd
add esi, 3
add edi, 3
.CopyDownBytes:
rep movsb
.CopyDownEnd:
cld
mov eax, [ebp + 8]
pop edi
pop esi
pop ebp
ret 12
.CopyDownAligned:
sub edi, 4
sub esi, 4
jmp .CopyDownDwords
.CopyDownSmall:
test ecx, ecx
je .CopyDownEnd
dec esi
dec edi
jmp .CopyDownBytes
/* Do the move, reset flag and return */
rep movsb
cld
jmp DoneMove
@RtlPrefetchMemoryNonTemporal@8:

View file

@ -22,9 +22,10 @@
BOOLEAN
NTAPI
LdrVerifyMappedImageMatchesChecksum(IN PVOID BaseAddress,
IN ULONG NumberOfBytes,
IN ULONG FileLength)
LdrVerifyMappedImageMatchesChecksum(
IN PVOID BaseAddress,
IN ULONG NumberOfBytes,
IN ULONG FileLength)
{
/* FIXME: TODO */
return TRUE;
@ -33,26 +34,26 @@ LdrVerifyMappedImageMatchesChecksum(IN PVOID BaseAddress,
/*
* @implemented
*/
PIMAGE_NT_HEADERS NTAPI
RtlImageNtHeader (IN PVOID BaseAddress)
PIMAGE_NT_HEADERS
NTAPI
RtlImageNtHeader(IN PVOID BaseAddress)
{
PIMAGE_NT_HEADERS NtHeader;
PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
PIMAGE_NT_HEADERS NtHeader;
PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE)
if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE)
{
DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic));
DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)));
DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic));
DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)));
}
else
{
NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew));
if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE)
return NtHeader;
}
if (DosHeader && SWAPW(DosHeader->e_magic) == IMAGE_DOS_SIGNATURE)
{
NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew));
if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE)
return NtHeader;
}
return NULL;
return NULL;
}
@ -61,40 +62,41 @@ RtlImageNtHeader (IN PVOID BaseAddress)
*/
PVOID
NTAPI
RtlImageDirectoryEntryToData(PVOID BaseAddress,
BOOLEAN MappedAsImage,
USHORT Directory,
PULONG Size)
RtlImageDirectoryEntryToData(
PVOID BaseAddress,
BOOLEAN MappedAsImage,
USHORT Directory,
PULONG Size)
{
PIMAGE_NT_HEADERS NtHeader;
ULONG Va;
PIMAGE_NT_HEADERS NtHeader;
ULONG Va;
/* Magic flag for non-mapped images. */
if ((ULONG_PTR)BaseAddress & 1)
{
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1);
MappedAsImage = FALSE;
}
/* Magic flag for non-mapped images. */
if ((ULONG_PTR)BaseAddress & 1)
{
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1);
MappedAsImage = FALSE;
}
NtHeader = RtlImageNtHeader (BaseAddress);
if (NtHeader == NULL)
return NULL;
NtHeader = RtlImageNtHeader (BaseAddress);
if (NtHeader == NULL)
return NULL;
if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes))
return NULL;
if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes))
return NULL;
Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress);
if (Va == 0)
return NULL;
Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress);
if (Va == 0)
return NULL;
*Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size);
*Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size);
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
return (PVOID)((ULONG_PTR)BaseAddress + Va);
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
return (PVOID)((ULONG_PTR)BaseAddress + Va);
/* image mapped as ordinary file, we must find raw pointer */
return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL);
/* image mapped as ordinary file, we must find raw pointer */
return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL);
}
@ -103,28 +105,27 @@ RtlImageDirectoryEntryToData(PVOID BaseAddress,
*/
PIMAGE_SECTION_HEADER
NTAPI
RtlImageRvaToSection (
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva
)
RtlImageRvaToSection(
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva)
{
PIMAGE_SECTION_HEADER Section;
ULONG Va;
ULONG Count;
PIMAGE_SECTION_HEADER Section;
ULONG Va;
ULONG Count;
Count = SWAPW(NtHeader->FileHeader.NumberOfSections);
Section = IMAGE_FIRST_SECTION(NtHeader);
Count = SWAPW(NtHeader->FileHeader.NumberOfSections);
Section = IMAGE_FIRST_SECTION(NtHeader);
while (Count--)
{
Va = SWAPD(Section->VirtualAddress);
if ((Va <= Rva) &&
(Rva < Va + SWAPD(Section->Misc.VirtualSize)))
return Section;
Section++;
}
return NULL;
while (Count--)
{
Va = SWAPD(Section->VirtualAddress);
if ((Va <= Rva) &&
(Rva < Va + SWAPD(Section->Misc.VirtualSize)))
return Section;
Section++;
}
return NULL;
}
@ -133,34 +134,33 @@ RtlImageRvaToSection (
*/
PVOID
NTAPI
RtlImageRvaToVa (
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva,
PIMAGE_SECTION_HEADER *SectionHeader
)
RtlImageRvaToVa(
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva,
PIMAGE_SECTION_HEADER *SectionHeader)
{
PIMAGE_SECTION_HEADER Section = NULL;
PIMAGE_SECTION_HEADER Section = NULL;
if (SectionHeader)
Section = *SectionHeader;
if (SectionHeader)
Section = *SectionHeader;
if (Section == NULL ||
Rva < SWAPD(Section->VirtualAddress) ||
Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))
{
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva);
if (Section == NULL)
return 0;
if (Section == NULL ||
Rva < SWAPD(Section->VirtualAddress) ||
Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))
{
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva);
if (Section == NULL)
return 0;
if (SectionHeader)
*SectionHeader = Section;
}
if (SectionHeader)
*SectionHeader = Section;
}
return (PVOID)((ULONG_PTR)BaseAddress +
Rva +
SWAPD(Section->PointerToRawData) -
(ULONG_PTR)SWAPD(Section->VirtualAddress));
return (PVOID)((ULONG_PTR)BaseAddress +
Rva +
SWAPD(Section->PointerToRawData) -
(ULONG_PTR)SWAPD(Section->VirtualAddress));
}
PIMAGE_BASE_RELOCATION
@ -169,8 +169,7 @@ LdrProcessRelocationBlockLongLong(
IN ULONG_PTR Address,
IN ULONG Count,
IN PUSHORT TypeOffset,
IN LONGLONG Delta
)
IN LONGLONG Delta)
{
SHORT Offset;
USHORT Type;
@ -197,8 +196,8 @@ LdrProcessRelocationBlockLongLong(
{*/
switch (Type)
{
/* case IMAGE_REL_BASED_SECTION : */
/* case IMAGE_REL_BASED_REL32 : */
/* case IMAGE_REL_BASED_SECTION : */
/* case IMAGE_REL_BASED_REL32 : */
case IMAGE_REL_BASED_ABSOLUTE:
break;
@ -242,8 +241,7 @@ LdrRelocateImageWithBias(
IN PCCH LoaderName,
IN ULONG Success,
IN ULONG Conflict,
IN ULONG Invalid
)
IN ULONG Invalid)
{
PIMAGE_NT_HEADERS NtHeaders;
PIMAGE_DATA_DIRECTORY RelocationDDir;
@ -275,16 +273,16 @@ LdrRelocateImageWithBias(
RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + SWAPD(RelocationDDir->Size));
while (RelocationDir < RelocationEnd &&
SWAPW(RelocationDir->SizeOfBlock) > 0)
SWAPW(RelocationDir->SizeOfBlock) > 0)
{
Count = (SWAPW(RelocationDir->SizeOfBlock) - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT);
Address = (ULONG_PTR)RVA(BaseAddress, SWAPD(RelocationDir->VirtualAddress));
TypeOffset = (PUSHORT)(RelocationDir + 1);
RelocationDir = LdrProcessRelocationBlockLongLong(Address,
Count,
TypeOffset,
Delta);
Count,
TypeOffset,
Delta);
if (RelocationDir == NULL)
{
@ -295,4 +293,5 @@ LdrRelocateImageWithBias(
return Success;
}
/* EOF */