DoxigAlpha

FileInformationIterator

Helper for iterating a byte buffer of FILE_*_INFORMATION structures (from things like NtQueryDirectoryFile calls).

Fields of this type

Fields

#
byte_offset:usize
= 0
buf:[]u8

Functions in this namespace

Functions

#

Source

Implementation

#
pub fn FileInformationIterator(comptime FileInformationType: type) type {
    return struct {
        byte_offset: usize = 0,
        buf: []u8 align(@alignOf(FileInformationType)),

        pub fn next(self: *@This()) ?*FileInformationType {
            if (self.byte_offset >= self.buf.len) return null;
            const cur: *FileInformationType = @ptrCast(@alignCast(&self.buf[self.byte_offset]));
            if (cur.NextEntryOffset == 0) {
                self.byte_offset = self.buf.len;
            } else {
                self.byte_offset += cur.NextEntryOffset;
            }
            return cur;
        }
    };
}