00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
#include <nt.h>
00031
#include <ntrtl.h>
00032
#include <stdio.h>
00033
#include "localrtl.h"
00034
00035 #define BUFFER_SIZE (MAX_OFFSET + MAX_LENGTH)
00036
00037 UCHAR
String1[
BUFFER_SIZE];
00038 UCHAR
String2[
BUFFER_SIZE];
00039
00040
void
00041 __cdecl
00042 main()
00043 {
00044 ULONG ErrorCount;
00045 ULONG Expected;
00046 ULONG Length;
00047 ULONG Offset1;
00048 ULONG Offset2;
00049 ULONG Result;
00050 ULONG TestCases;
00051
00052 fprintf(stderr,
"Testing RtlCompareMemory\n");
00053 ErrorCount = 0;
00054 TestCases = 0;
00055
00056
for (Offset1 = 0; Offset1 <=
MAX_OFFSET; Offset1 += 1) {
00057
00058
00059
00060
00061
00062
00063
00064
00065
FillPattern(&
String1[Offset1],
MAX_LENGTH);
00066
for (Offset2 = 0; Offset2 <=
MAX_OFFSET; Offset2 += 1) {
00067
for (Length = 0; Length <=
MAX_LENGTH; Length += 1) {
00068
for (Expected = 0; Expected <= Length; Expected += 1) {
00069
00070
00071
00072
00073
00074
00075
00076
00077
FillPattern(&
String2[Offset2],
MAX_LENGTH);
00078
String2[Offset2 + Expected] =
' ';
00079 Result = RtlCompareMemory(&
String1[Offset1],
00080 &
String2[Offset2],
00081 Length);
00082 TestCases += 1;
00083
if (Result != Expected) {
00084 ErrorCount += 1;
00085
00086
00087
00088
00089
00090 printf(
"ERROR: Offset1 = %d, Offset2 = %d, Length = %d, Expected = %d, Result = %d\n",
00091 Offset1, Offset2, Length, Expected, Result);
00092 printf(
" String1[Offset1] = %lx: <%.*s>\n",
00093 &
String1[Offset1], Length, &
String1[Offset1]);
00094 printf(
" String2[Offset2] = %lx: <%.*s>\n",
00095 &
String2[Offset2], Length, &
String2[Offset2]);
00096 printf(
"\n");
00097 }
00098 }
00099 }
00100 }
00101 }
00102
00103 fprintf(stderr,
"Test of RtlCompareMemory completed: ");
00104 fprintf(stderr,
"%d test cases, %d errors found.\n", TestCases, ErrorCount);
00105 }