From 8f7c38cd4477370a9ecbf77d95ebec3c720cf123 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 16 Mar 2011 11:58:12 +0000 Subject: [PATCH] [RTL] - Hack away LdrVerifyMappedImageMatchesChecksum() invocations with zero ImageSize until MM is fixed. - Implement a helper ChkSum() routine to be used later by LdrVerifyMappedImageMatchesChecksum(). svn path=/trunk/; revision=51061 --- reactos/lib/rtl/image.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/reactos/lib/rtl/image.c b/reactos/lib/rtl/image.c index 479319f5fef..03c402fc20c 100644 --- a/reactos/lib/rtl/image.c +++ b/reactos/lib/rtl/image.c @@ -20,6 +20,25 @@ /* FUNCTIONS *****************************************************************/ +USHORT +FORCEINLINE +ChkSum(ULONG Sum, PUSHORT Src, ULONG Len) +{ + ULONG i; + + for (i=0; i> 16); + } + + /* Apply carry one more time and clamp to the USHORT */ + return (Sum + (Sum >> 16)) & 0xFFFF; +} + BOOLEAN NTAPI LdrVerifyMappedImageMatchesChecksum( @@ -34,8 +53,11 @@ LdrVerifyMappedImageMatchesChecksum( ULONG HeaderSum; ULONG i; + // HACK: Ignore calls with ImageSize=0. Should be fixed by new MM. + if (ImageSize == 0) return TRUE; + /* Get NT header to check if it's an image at all */ - Header = RtlImageNtHeader (BaseAddress); + Header = RtlImageNtHeader(BaseAddress); if (!Header) return FALSE; /* Get checksum to match */ @@ -93,7 +115,7 @@ LdrVerifyMappedImageMatchesChecksum( CalcSum += ImageSize; if (CalcSum != HeaderSum) - DPRINT1("Image %p checksum mismatches! 0x%x != 0x%x\n", BaseAddress, CalcSum, HeaderSum); + DPRINT1("Image %p checksum mismatches! 0x%x != 0x%x, ImageSize %x, FileLen %x\n", BaseAddress, CalcSum, HeaderSum, ImageSize, FileLength); return (BOOLEAN)(CalcSum == HeaderSum); }