I am not sure if this will ever work.
Here is why (or maybe I did not look at it properly at all?):
- You have kept a copy of the Unicode string buffer pointer that was
initialized using RtlInitUnicodeString- which effectively means that it is
pointing to somewhere on the stack and is bound to change after the function
finishes. You are storing the file table structure in generic table with a
pointer to string which has almost 0 chance of remaining valid.
- This is not C++ that you just overload the ==, <, > operator and they
will do the string comparison for you. Try string comparison functions.
- Oh and btw, in extension to point 1, I hope that you do know that
UNICODE_STRINGS are NOT NULL terminated. So, you know what will happen if
you just store that buffer without a trailing NULL and don’t have length of
that buffer?
Regards,
Ayush Gupta
Software Consultant & Owner,
AI Consulting
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Friday, June 17, 2011 4:29 PM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Optimized LIST
Hi Mark,
I implemented Generic table as following :
//structure that mainting into Table
typedef struct _FL_TABLE
{
BYTE m_bytStatus;
BYTE m_bytType;
BYTE m_bytDel;
PVOID m_DataPath;
}FLTABLE, *PFLTABLE;
//Inserting into table as following
FLTABLE tbObj;
BOOLEAN ret;
tbObj.m_DataPath = (PVOID)r_strDataPath.Buffer; / r_strDataPath is
UNICODE_STRING filled with
/
RtlInitUnicodeString
RtlInsertElementGenericTable(&gLockTable,&tbObj,sizeof(FLTABLE), &ret);
// Comparing element as following :
BOOLEAN bSuccess = FALSE;
FLTABLE tbObj;
BOOLEAN ret;
tbObj.m_DataPath = (PVOID)uPath.Buffer; //uPath is UNICODE_STRING data type
is allocated buffer
if(RtlLookupElementGenericTable(&gLockTable,&tbObj) != NULL)
bSuccess = TRUE;
// Compare function
RTL_GENERIC_COMPARE_RESULTS CompareElement ( struct _RTL_GENERIC_TABLE
*Table, PVOID FirstStruct, PVOID SecondStruct ) {
if(((FLTABLE*)FirstStruct)->m_DataPath ==
((FLTABLE*)SecondStruct)->m_DataPath)
return GenericEqual;
if(((FLTABLE*)FirstStruct)->m_DataPath <
((FLTABLE*)SecondStruct)->m_DataPath)
return GenericLessThan;
return GenericGreaterThan;
}
//Allocate
PVOID AllocElement ( struct _RTL_GENERIC_TABLE *Table, CLONG ByteSize ) {
return ExAllocatePoolWithTag(PagedPool,ByteSize,‘gtb1’);
}
VOID FreeElement ( struct _RTL_GENERIC_TABLE *Table, PVOID Buffer ) {
ExFreePoolWithTag(Buffer,‘gtb1’);
return;
}
Note : Problem is that not comparing successfully.
Thanks
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer