Difference between revisions of "TNTFSDiskIndex"

From Ultibo.org
Jump to: navigation, search
(Created page with "Return to Unit NTFSClass __TOC__ === Description === ---- ''To be documented'' === Class definitions === ---- <div class="toccolours mw-collapsible m...")
(No difference)

Revision as of 05:48, 24 May 2018

Return to Unit NTFSClass


Description


To be documented

Class definitions



TNTFSDiskIndex = class(TLinkedObjBtree)

Note: Index of INDX records.
 
constructor Create(AKeyLocal:TMutexHandle; ALock:TSynchronizerHandle; AVolumeVersion,ASectorSize:Word; AIndexType,ACollateRule:LongWord; AAttribute:TNTFSDiskAttribute);  
destructor Destroy; override;  
private
FLock:TSynchronizerHandle;  
FKeyLocal:TMutexHandle;  
 
FStatus:LongWord;  
 
FSectorSize:Word;  
FVolumeVersion:Word;  
 
FIndexType:LongWord; Attribute Type (Or None if Data Index)
FCollateRule:LongWord; Collation Rule
FIndexRecordSize:LongWord; Size of Index Allocation Entry (bytes)
FIndexCounterOffset:LongWord; Index Record Number increment
 
FClustersPerIndex:LongWord; Clusters per INDX Record or 0 if less than cluster size
FIndexsPerCluster:LongWord; INDX Records per Cluster or 0 if more than cluster size
 
FIndexCounterShift:Word; Shift count for Record -> Counter
FIndexRecordShiftCount:Word; Shift count for Record -> VCN
FIndexRecordOffsetMask:Int64; Mask for Record offset calculation
 
FTotalIndexRecordCount:Int64; Total number of index records in index
 
FLastFreeIndexRecord:Int64; Or ntfsUnknownRecordNumber if not known
FFreeIndexRecordCount:Int64; Or ntfsUnknownRecordNumber if not known
 
FCompareSecurityDescriptor:TNTFSCompareSecurityDescriptor;  
 
FUpCase:TNTFSUpCase; Uppercase Conversion Table
 
FNodes:TNTFSDiskNodes; List of index nodes
FAttribute:TNTFSDiskAttribute; Attribute owning this index
 
function GetNodesLock:TSynchronizerHandle;  
 
function GetKeyLocal:TMutexHandle;  
function GetNodeLocal:TMutexHandle;  
 
function GetLoaded:Boolean;  
procedure SetLoaded(AValue:Boolean);  
function GetChanged:Boolean;  
 
function GetUpCase:PNTFSUpCaseData;  
function GetRootNode:TNTFSDiskNode;  
 
function CreateNodes(ANew:Boolean):TNTFSDiskNodes;  
 
function CompareKey(AEntry1,AEntry2:Pointer; ASize1,ASize2:Word):Integer;  
 
function CompareBinary(AEntry1,AEntry2:Pointer; ASize1,ASize2:Word):Integer;  
function CompareFileName(AEntry1,AEntry2:PWideChar; ASize1,ASize2:Word):Integer;  
function CompareUnicode(AEntry1,AEntry2:PWideChar; ASize1,ASize2:Word):Integer;  
function CompareLongWord(AEntry1,AEntry2:LongWord; ASize1,ASize2:Word):Integer;  
function CompareSID(AEntry1,AEntry2:PSID; ASize1,ASize2:Word):Integer;  
function CompareSecurityHash(AEntry1,AEntry2:PNTFSSecurityHashKeyData; ASize1,ASize2:Word):Integer;  
function CompareGUID(AEntry1,AEntry2:PGUID; ASize1,ASize2:Word):Integer;  
protected
function GetEnd(AEntry:TBtreeObject):TBtreeObject; override;  
function GetStart(AEntry:TBtreeObject):TBtreeObject; override;  
function GetBlank(AEntry:TBtreeObject):TBtreeObject; override;  
function GetMedian(AEntry:TBtreeObject):TBtreeObject; override;  
 
function GetDropTest(AEntry:TBtreeObject; var ALeft:Boolean):TBtreeObject;  
function GetDrop(AEntry:TBtreeObject; var ALeft:Boolean):TBtreeObject; override;  
function GetMerge(AEntry:TBtreeObject):TBtreeObject; override;  
function GetBorrow(AEntry:TBtreeObject):TBtreeObject; override;  
function GetTarget(ADrop:TBtreeObject; ALeft:Boolean):TBtreeObject; override;  
 
function PushNode(AEntry:TBtreeObject):Boolean; override;  
function SplitNode(AEntry:TBtreeObject):Boolean; override;  
function DropNode(AEntry,ADrop,ATarget:TBtreeObject; ALeft:Boolean):Boolean; override;  
function DropNodeOld(AEntry,ADrop:TBtreeObject; ALeft:Boolean):Boolean; override;  
function MergeNode(AEntry,AMerge:TBtreeObject):Boolean; override;  
function BorrowEntry(AEntry,ABorrow:TBtreeObject):Boolean; override;  
 
function SwapEntry(AEntry,ASwap:TBtreeObject;ALeft:Boolean):Boolean; override;  
function SetParentEntry(AEntry,AParent:TBtreeObject):Boolean; override;  
 
function DeleteBlank(ABlank:TBtreeObject):Boolean; override;  
 
function AttachBlank(ABlank:TBtreeObject):Boolean; override;  
function DetachBlank(ABlank:TBtreeObject):Boolean; override;  
 
function AttachEntry(AEntry:TBtreeObject):Boolean; override;  
function DetachEntry(AEntry:TBtreeObject):Boolean; override;  
 
function RequirePush(AEntry:TBtreeObject):Boolean; override;  
function RequireSplit(AEntry:TBtreeObject):Boolean; override;  
function RequireDrop(AEntry:TBtreeObject):Boolean; override;  
function RequireMerge(AEntry:TBtreeObject):Boolean; override;  
function RequireBorrow(AEntry:TBtreeObject):Boolean; override;  
public
property Loaded:Boolean read GetLoaded write SetLoaded;  
property Changed:Boolean read GetChanged;  
 
property SectorSize:Word read FSectorSize write FSectorSize;  
property VolumeVersion:Word read FVolumeVersion;  
 
property IndexType:LongWord read FIndexType write FIndexType;  
property CollateRule:LongWord read FCollateRule write FCollateRule;  
property IndexRecordSize:LongWord read FIndexRecordSize write FIndexRecordSize;  
property IndexCounterOffset:LongWord read FIndexCounterOffset write FIndexCounterOffset;  
 
property ClustersPerIndex:LongWord read FClustersPerIndex write FClustersPerIndex;  
property IndexsPerCluster:LongWord read FIndexsPerCluster write FIndexsPerCluster;  
 
property IndexCounterShift:Word read FIndexCounterShift write FIndexCounterShift;  
property IndexRecordShiftCount:Word read FIndexRecordShiftCount write FIndexRecordShiftCount;  
property IndexRecordOffsetMask:Int64 read FIndexRecordOffsetMask write FIndexRecordOffsetMask;  
 
property TotalIndexRecordCount:Int64 read FTotalIndexRecordCount write FTotalIndexRecordCount;  
 
property LastFreeIndexRecord:Int64 read FLastFreeIndexRecord write FLastFreeIndexRecord;  
property FreeIndexRecordCount:Int64 read FFreeIndexRecordCount write FFreeIndexRecordCount;  
 
property CompareSecurityDescriptor:TNTFSCompareSecurityDescriptor read FCompareSecurityDescriptor write FCompareSecurityDescriptor;  
 
property UpCase:TNTFSUpCase read FUpCase write FUpCase;  
 
property Nodes:TNTFSDiskNodes read FNodes;  
property Attribute:TNTFSDiskAttribute read FAttribute;  
 
property RootNode:TNTFSDiskNode read GetRootNode;  
 
function NodeCount:Integer;  
 
function CreateKey(ANode:TNTFSDiskNode; ABlank:Boolean):TNTFSDiskKey; virtual;  
function DestroyKey(AKey:TNTFSDiskKey):Boolean;  
function NewKey(AKey,AData:Pointer; AKeySize,ADataSize:Word):TNTFSDiskKey; virtual;  
function NewKeyEx(AKey,AData,APadding:Pointer; AKeySize,ADataSize,APaddingSize:Word):TNTFSDiskKey; virtual;  
function AddKey(AParent,AKey:TNTFSDiskKey):Boolean;  
function InsertKey(AKey:TNTFSDiskKey):Boolean;  
function RemoveKey(AKey:TNTFSDiskKey):Boolean;  
 
function CreateNode(ANew:Boolean):TNTFSDiskNode;  
function DestroyNode(ANode:TNTFSDiskNode):Boolean;  
function NewNode(const ARecordNumber:Int64):TNTFSDiskNode;  
function GetNode(const ARecordNumber:Int64):TNTFSDiskNode;  
function DeleteNode(ANode:TNTFSDiskNode):Boolean;  
function RemoveNode(ANode:TNTFSDiskNode):Boolean;  
 
function UpdateNodes(AVersion:Word):Boolean; virtual;  
 
function FindKey(AValue:Pointer; ASize:Word):TNTFSDiskKey; virtual;  
 
function ReadRoot(ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;  
function WriteRoot(ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;  
 
function ReadKeys(AParent:TNTFSDiskKey; ANode:TNTFSDiskNode; ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;  
function WriteKeys(AParent:TNTFSDiskKey; ANode:TNTFSDiskNode; ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;  
 
function ReaderLock:Boolean;  
function ReaderUnlock:Boolean;  
function WriterLock:Boolean;  
function WriterUnlock:Boolean;  


Function declarations



constructor TNTFSDiskIndex.Create(AKeyLocal:TMutexHandle; ALock:TSynchronizerHandle; AVolumeVersion,ASectorSize:Word; AIndexType,ACollateRule:LongWord; AAttribute:TNTFSDiskAttribute);
Description: To be documented
Note None documented


destructor TNTFSDiskIndex.Destroy;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetNodesLock:TSynchronizerHandle;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetKeyLocal:TMutexHandle;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetNodeLocal:TMutexHandle;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetLoaded:Boolean;
Description: To be documented
Note None documented


procedure TNTFSDiskIndex.SetLoaded(AValue:Boolean);
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetChanged:Boolean;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetUpCase:PNTFSUpCaseData;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetRootNode:TNTFSDiskNode;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CreateNodes(ANew:Boolean):TNTFSDiskNodes;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareKey(AEntry1,AEntry2:Pointer; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareBinary(AEntry1,AEntry2:Pointer; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareFileName(AEntry1,AEntry2:PWideChar; ASize1,ASize2:Word):Integer;
Description: To be documented
Note Current implementation is a simple ordinal value compare

May need to use CompareString/CompareStringEx in future


function TNTFSDiskIndex.CompareUnicode(AEntry1,AEntry2:PWideChar; ASize1,ASize2:Word):Integer;
Description: To be documented
Note Current implementation is a simple ordinal value compare

May need to use CompareString/CompareStringEx in future
Documentation says Uppercase characters come first, no special accomodation is made for this
The above is assumed at this point to be a case sensitive compare which is as implemented


function TNTFSDiskIndex.CompareLongWord(AEntry1,AEntry2:LongWord; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareSID(AEntry1,AEntry2:PSID; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareSecurityHash(AEntry1,AEntry2:PNTFSSecurityHashKeyData; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CompareGUID(AEntry1,AEntry2:PGUID; ASize1,ASize2:Word):Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetEnd(AEntry:TBtreeObject):TBtreeObject;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetStart(AEntry:TBtreeObject):TBtreeObject;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetBlank(AEntry:TBtreeObject):TBtreeObject;
Description: To be documented
Note None documented


function TNTFSDiskIndex.GetMedian(AEntry:TBtreeObject):TBtreeObject;
Description: Get the median entry in the node of the supplied entry
Note Does not include the blank key

The minimum key count is 3 including the blank


function TNTFSDiskIndex.GetDropTest(AEntry:TBtreeObject; var ALeft:Boolean):TBtreeObject;
Description: Get the neighbour with appropriate number of keys to drop
Note Always drop with the Righthand neighbour if available

If both lefthand and righthand nodes are nil then GetDrop will return the entry itself to indicate success, the node should then be dropped without demoting the parent. No account is made of whether the lefthand or righthand nodes have room for the demoted parent, the caller must check for require push or split on the neighbour after drop.


function TNTFSDiskIndex.GetDrop(AEntry:TBtreeObject; var ALeft:Boolean):TBtreeObject;
Description: Get the neighbour with appropriate number of keys to drop
Note Always drop with the Righthand neighbour if available

If both lefthand and righthand nodes are nil then GetDrop will return the entry itself to indicate success, the node should then be dropped without demoting the parent.
No account is made of whether the lefthand or righthand nodes have room for the demoted parent, the caller must check for require push or split on the neighbour after drop.


function TNTFSDiskIndex.GetMerge(AEntry:TBtreeObject):TBtreeObject;
Description: Get the neighbour with appropriate number of keys to merge
Note Always merge with the Righthand neighbour if available


function TNTFSDiskIndex.GetBorrow(AEntry:TBtreeObject):TBtreeObject;
Description: Get the neighbour with sufficient keys to borrow one
Note Always borrow from the Righthand neighbour if available


function TNTFSDiskIndex.GetTarget(ADrop:TBtreeObject; ALeft:Boolean):TBtreeObject;
Description: Get the actual target within the neighbour that is appropriate to drop
Note If drop has no child then GetTarget will return the neighbour itself

No account is made of whether the leftmost or rightmost nodes have room for the demoted parent, the caller must check for require push or split on the target after drop.


function TNTFSDiskIndex.PushNode(AEntry:TBtreeObject):Boolean;
Description: Called before a node is pushed following insert of an entry
Note None documented


function TNTFSDiskIndex.SplitNode(AEntry:TBtreeObject):Boolean;
Description: Called before a node is split following insert of an entry
Note None documented


function TNTFSDiskIndex.DropNode(AEntry,ADrop,ATarget:TBtreeObject; ALeft:Boolean):Boolean;
Description: Called before a node is dropped following removal of an entry
Note None documented


function TNTFSDiskIndex.DropNodeOld(AEntry,ADrop:TBtreeObject; ALeft:Boolean):Boolean;
Description: Called before a node is dropped following removal of an entry
Note Changed to account for Target


function TNTFSDiskIndex.MergeNode(AEntry,AMerge:TBtreeObject):Boolean;
Description: Called before a node is merged following removal of an entry
Note None documented


function TNTFSDiskIndex.BorrowEntry(AEntry,ABorrow:TBtreeObject):Boolean;
Description: Called before an entry is borrowed following removal of an entry
Note None documented


function TNTFSDiskIndex.SwapEntry(AEntry,ASwap:TBtreeObject; ALeft:Boolean):Boolean;
Description: Called before an entry is swapped during a remove or borrow
Note None documented


function TNTFSDiskIndex.SetParentEntry(AEntry,AParent:TBtreeObject):Boolean;
Description: Called after an entry is reparented during a push, split, drop, merge, borrow or swap
Note None documented


function TNTFSDiskIndex.DeleteBlank(ABlank:TBtreeObject):Boolean;
Description: Delete a blank key when a node is removed (Merge/Drop)
Note None documented


function TNTFSDiskIndex.AttachBlank(ABlank:TBtreeObject):Boolean;
Description: Occurs immediately after a new Blank is Created and Attached
Note None documented


function TNTFSDiskIndex.DetachBlank(ABlank:TBtreeObject):Boolean;
Description: Occurs immediately before a Blank is Detached and Deleted
Note None documented


function TNTFSDiskIndex.AttachEntry(AEntry:TBtreeObject):Boolean;
Description: Occurs immediately after an Entry is Attached
Note None documented


function TNTFSDiskIndex.DetachEntry(AEntry:TBtreeObject):Boolean;
Description: Occurs immediately before an Entry is Detached
Note None documented


function TNTFSDiskIndex.RequirePush(AEntry:TBtreeObject):Boolean;
Description: Called after an entry is inserted to determine if a push is required
Note Entry is the key that was inserted

Or a key in a parent node of the node where the entry was inserted
Push requires a minimum of 2 keys including the blank
Push can only occur on the Root Node


function TNTFSDiskIndex.RequireSplit(AEntry:TBtreeObject):Boolean;
Description: Called after an entry is inserted to determine if a split is required
Note Entry is the key that was inserted

Or a key in a parent node of the node where the entry was inserted
Split requires a minimum of 3 keys including the blank


function TNTFSDiskIndex.RequireDrop(AEntry:TBtreeObject):Boolean;
Description: Called after an entry is removed to determine if a drop is required
Note Entry is the start key of the node where the entry was removed

Or a key in a parent node of the node where the entry was removed
Drop requires a maximum of 1 key including the blank
Drop can only occur on a Sub Node


function TNTFSDiskIndex.RequireMerge(AEntry:TBtreeObject):Boolean;
Description: Called after an entry is removed to determine if a merge is required
Note Entry is the start key of the node where the entry was removed

Or a key in a parent node of the node where the entry was removed
Merge is never used in NTFS indexes


function TNTFSDiskIndex.RequireBorrow(AEntry:TBtreeObject):Boolean;
Description: Called after an entry is removed to determine if a borrow is required
Note Entry is the start key of the node where the entry was removed

Or a key in a parent node of the node where the entry was removed
Borrow is never used in NTFS indexes


function TNTFSDiskIndex.NodeCount:Integer;
Description: To be documented
Note None documented


function TNTFSDiskIndex.CreateKey(ANode:TNTFSDiskNode; ABlank:Boolean):TNTFSDiskKey;
Description: Create a key in the supplied node do not insert in index or mark as added
Note None documented


function TNTFSDiskIndex.DestroyKey(AKey:TNTFSDiskKey):Boolean;
Description: Free the key, do not remove from the index
Note None documented


function TNTFSDiskIndex.NewKey(AKey,AData:Pointer; AKeySize,ADataSize:Word):TNTFSDiskKey;
Description: Create a key with the supplied data do not insert in index or mark as added
Note None documented


function TNTFSDiskIndex.NewKeyEx(AKey,AData,APadding:Pointer; AKeySize,ADataSize,APaddingSize:Word):TNTFSDiskKey;
Description: Create a key with the supplied data do not insert in index or mark as added
Note None documented


function TNTFSDiskIndex.AddKey(AParent,AKey:TNTFSDiskKey):Boolean;
Description: Add the key to the index (Blank allowed)
Note None documented


function TNTFSDiskIndex.InsertKey(AKey:TNTFSDiskKey):Boolean;
Description: Insert the key in the index (Blank not allowed)
Note None documented


function TNTFSDiskIndex.RemoveKey(AKey:TNTFSDiskKey):Boolean;
Description: Remove the key from the index and free (Blank not allowed)
Note None documented


function TNTFSDiskIndex.CreateNode(ANew:Boolean):TNTFSDiskNode;
Description: Create a node, add to list do not mark as added
Note None documented


function TNTFSDiskIndex.DestroyNode(ANode:TNTFSDiskNode):Boolean;
Description: Remove the node from the list and free
Note None documented


function TNTFSDiskIndex.NewNode(const ARecordNumber:Int64):TNTFSDiskNode;
Description: Create a node, add to list and mark as added
Note None documented


function TNTFSDiskIndex.GetNode(const ARecordNumber:Int64):TNTFSDiskNode;
Description: To be documented
Note None documented


function TNTFSDiskIndex.DeleteNode(ANode:TNTFSDiskNode):Boolean;
Description: Mark the node as deleted but do not free or remove
Note None documented


function TNTFSDiskIndex.RemoveNode(ANode:TNTFSDiskNode):Boolean;
Description: Remove the node from the list and free
Note None documented


function TNTFSDiskIndex.UpdateNodes(AVersion:Word):Boolean;
Description: To be documented
Note None documented


function TNTFSDiskIndex.FindKey(AValue:Pointer; ASize:Word):TNTFSDiskKey;
Description: To be documented
Note None documented


function TNTFSDiskIndex.ReadRoot(ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;
Description: Read the resident index header and entries from the supplied buffer at the supplied offset
Note None documented


function TNTFSDiskIndex.WriteRoot(ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;
Description: Write the resident index header and entries to the supplied buffer at the supplied offset
Note None documented


function TNTFSDiskIndex.ReadKeys(AParent:TNTFSDiskKey; ANode:TNTFSDiskNode; ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;
Description: Read the index entries from the supplied buffer at the supplied offset
Note None documented


function TNTFSDiskIndex.WriteKeys(AParent:TNTFSDiskKey; ANode:TNTFSDiskNode; ABuffer:Pointer; var AOffset,ASize:LongWord; AVersion:Word):Boolean;
Description: Write the index entries to the supplied buffer at the supplied offset
Note None documented


function TNTFSDiskIndex.ReaderLock:Boolean;
Description: To be documented
Note None documented


function TNTFSDiskIndex.ReaderUnlock:Boolean;
Description: To be documented
Note None documented


function TNTFSDiskIndex.WriterLock:Boolean;
Description: To be documented
Note None documented


function TNTFSDiskIndex.WriterUnlock:Boolean;
Description: To be documented
Note None documented


Return to Unit Reference