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
00031
#include <nt.h>
00032
#include <ntrtl.h>
00033
#include <stdio.h>
00034
#include "localrtl.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define MIN_OVERLAP (-(MAX_LENGTH + MAX_MARGIN))
00046 #define MAX_OVERLAP (MAX_LENGTH + MAX_MARGIN - 1)
00047
00048 #define BUFFER_SIZE (MAX_MARGIN + MAX_LENGTH + MAX_MARGIN + MAX_OFFSET + MAX_LENGTH + MAX_MARGIN + MAX_LENGTH + MAX_MARGIN)
00049
00050 UCHAR
Buffer0[
BUFFER_SIZE];
00051 UCHAR
Buffer1[
BUFFER_SIZE];
00052 UCHAR
Buffer2[
BUFFER_SIZE];
00053
00054
void
00055 __cdecl
00056 main()
00057 {
00058 ULONG ErrorCount;
00059 ULONG Length;
00060 ULONG
Offset;
00061 LONG Overlap;
00062 ULONG Result;
00063 ULONG Source;
00064 ULONG Target;
00065 ULONG TestCases;
00066
00067 fprintf(stderr,
"Testing RtlMoveMemory\n");
00068 ErrorCount = 0;
00069 TestCases = 0;
00070
00071
00072
00073
00074
00075
00076
00077
00078
for (
Offset = 0;
Offset <=
MAX_OFFSET;
Offset += 1) {
00079
for (Length = 0; Length <=
MAX_LENGTH; Length += 1) {
00080
for (Overlap =
MIN_OVERLAP; Overlap <=
MAX_OVERLAP; Overlap += 1) {
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
FillPattern(
Buffer1,
BUFFER_SIZE);
00091
FillPattern(
Buffer2,
BUFFER_SIZE);
00092
00093 Source =
MAX_MARGIN +
MAX_LENGTH +
MAX_MARGIN +
Offset;
00094 Target = Source + Overlap;
00095
00096
LocalMoveMemory(&
Buffer1[Target], &
Buffer1[Source], Length);
00097 RtlMoveMemory(&
Buffer2[Target], &
Buffer2[Source], Length);
00098
00099 Result =
LocalCompareMemory(
Buffer1,
Buffer2,
BUFFER_SIZE);
00100
00101 TestCases += 1;
00102
if (Result !=
BUFFER_SIZE) {
00103 ErrorCount += 1;
00104
00105 printf(
"ERROR: Offset = %d, Length = %d, Overlap = %d\n",
00106
Offset, Length, Overlap);
00107 printf(
"RtlMoveMemory( &Buffer[ %d ], &Buffer[ %d ], %d )\n",
00108 Target, Source, Length);
00109
00110
FillPattern(
Buffer0,
BUFFER_SIZE);
00111 printf(
" Original Source = %lx: <%.*s>\n",
00112 &
Buffer0[Source], Length, &
Buffer0[Source]);
00113 printf(
" Expected Target = %lx: <%.*s>\n",
00114 &
Buffer1[Target], Length, &
Buffer1[Target]);
00115 printf(
" Actual Target = %lx: <%.*s>\n",
00116 &
Buffer2[Target], Length, &
Buffer2[Target]);
00117 printf(
"\n");
00118 printf(
"Buffers differ starting at byte %d:\n", Result);
00119 printf(
"Buffer1 = <%*s>\n",
BUFFER_SIZE,
Buffer1);
00120 printf(
"Buffer2 = <%*s>\n",
BUFFER_SIZE,
Buffer2);
00121 printf(
"\n");
00122 }
00123 }
00124 }
00125 }
00126
00127 fprintf(stderr,
"Test of RtlMoveMemory completed: ");
00128 fprintf(stderr,
"%d test cases, %d errors found.\n", TestCases, ErrorCount);
00129 }