#zig compiler segfaulting

1 messages · Page 1 of 1 (latest)

fleet jolt
#
const nt = @import("nt.zig");

export fn _start(inData: [*c]u64) callconv(.Win64) void {
    const PsInitialSystemProcess: u64 = inData[8];
    
    while(true) {
        var currentEntry = PsInitialSystemProcess;

        while(true) {
            const list: nt.PLIST_ENTRY = @ptrFromInt(currentEntry + 0x2F0);
            currentEntry = @intFromPtr(list.*.Flink) - 0x2F0;    
            if (currentEntry == PsInitialSystemProcess) break;
        }
    }
}

Compiling this code with
zig build-exe main.zig -O ReleaseSmall -fstrip -fomit-frame-pointer -fsingle-threaded -fno-stack-check -fno-unwind-tables -fPIC -target x86_64-freestanding crashes the zig compiler. its only output is the
Segmentation fault (core dumped)

#

currentEntry and PsInitialSystemProcess point to EPROCESS structures

0x2F0 is the offset to the next eprocess list entry

Im compiling on debian bookworm on master

fleet jolt
#
const nt = @import("nt.zig");

export fn _start(inData: [*c]u64) callconv(.Win64) void {
    const PsInitialSystemProcess: u64 = inData[8];
    
    while(true) {
        var currentEntry = PsInitialSystemProcess;

        while(true) {
            const forwardLink: *u64 = @ptrFromInt(currentEntry + 0x2F0);
            currentEntry = forwardLink.* - 0x2F0;    
            if (currentEntry == PsInitialSystemProcess) break;
        }
    }
}

but this seems to work?