include stdio include stdlib include ntddk define SIZE_OF_ELEMENT RTL_

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
#include <stdio.h>
#include <stdlib.h>
#include <ntddk.h>
#define SIZE_OF_ELEMENT 4
RTL_GENERIC_COMPARE_RESULTS
CompareRoutine(
__in struct _RTL_AVL_TABLE *Table,
__in PVOID FirstStruct,
__in PVOID SecondStruct
)
{
int i;
char *p1 = FirstStruct;
char *p2 = SecondStruct;
for(i = SIZE_OF_ELEMENT - 1; i >= 0; i--){
if(p1[i] - p2[i] < 0){
return GenericLessThan;
}
if(p1[i] - p2[i] > 0){
return GenericGreaterThan;
}
}
return GenericEqual;
}
PVOID
Allocate_Routine(
__in struct _RTL_AVL_TABLE *Table,
__in CLONG ByteSize
)
{
void *temp;
temp = malloc(ByteSize);
return temp;
}
VOID
FreeRoutine(
__in struct _RTL_AVL_TABLE *Table,
__in PVOID Buffer
)
{
free(Buffer);
}
void main()
{
//Start vars
BOOLEAN ok;
int A[10], B[10], i, j, sA, sB;
void *temp, *restart;
char *p1, *p2;
PRTL_AVL_TABLE Table = malloc(sizeof(RTL_AVL_TABLE));
RtlInitializeGenericTableAvl(Table, CompareRoutine, Allocate_Routine, FreeRoutine, NULL);
//Some array A
A[0] = 534;
A[1] = 345;
A[2] = 3563;
A[3] = 453;
A[4] = 43;
A[5] = 65;
A[6] = 23443;
A[7] = 23546;
A[8] = 2;
A[9] = 6456;
//Some array B
for(i = 0; i < 10; i++){
B[i] = A[i] + 1000000;
}
//Adding pairs A->B to the Table
sA = sizeof(A[0]);
sB = sizeof(B[0]);
for(i = 0; i < 10; i++){
temp = malloc(sA + sB);
p1 = (PVOID)&A[i];
p2 = (PVOID)&B[i];
for(j = 0; j < sA; j++){
((char*)temp)[j] = p1[j];
}
for(j = 0; j < sB; j++){
((char*)temp)[j + sA] = p2[j];
}
RtlInsertElementGenericTableAvl(Table, &A[i], sizeof(A[i]), &ok);
if (ok == 1) printf("ok\n");
free(temp);
}
printf("\n");
//Lookup
for(i = 0; i < 10; i++){
RtlLookupFirstMatchingElementGenericTableAvl(Table, &A[i], restart);
}
printf("\n");
//Printing info
printf("%lu\n", Table->NumberGenericTableElements);
printf("%lu\n", Table->DepthOfTree);
printf("%lu\n", Table->DeleteCount);
free(Table);
}
//error LNK2001: unresolved external symbol __imp_RtlLookupFirstMatchingElementGenericTableAvl