1
Fork 0

analyze: show begin/end

main
Motiejus Jakštys 2022-07-06 11:16:20 +03:00
parent 09de309b6e
commit 9f69a972ee
1 changed files with 17 additions and 17 deletions

View File

@ -126,19 +126,18 @@ fn execute(
}; };
const template = const template =
\\File: {[fname]s} \\File: {[fname]s}
\\Size: {[size_file]s} ({[bytes_file]d} bytes) \\Size: {[size_file]s} ({[bytes_file]d} bytes)
\\Version: {[version]d} \\Version: {[version]d}
\\Endian: {[endian]s} \\Endian: {[endian]s}
\\Pointer size: {[ptr_size]}d \\Pointer size: {[ptr_size]} bytes
\\Buffer size in bytes for getgr: {[getgr_bufsize]d} \\getgr buffer size: {[getgr_bufsize]d}B
\\Buffer size in bytes for getpw: {[getpw_bufsize]d} \\getpw buffer size: {[getpw_bufsize]d}B
\\ \\Users: {[users]d}
\\Users: {[users]d} \\Groups: {[groups]d}
\\Groups: {[groups]d} \\Shells: {[shells]d}
\\Shells: {[shells]d}
\\Sections: \\Sections:
\\ Name Blocks Size Offset \\ Name Begin End Size
\\ \\
; ;
stdout.print(template, info) catch {}; stdout.print(template, info) catch {};
@ -148,16 +147,17 @@ fn execute(
inline for (meta.fields(DB.DBNumbers)) |field| { inline for (meta.fields(DB.DBNumbers)) |field| {
const length = @field(lengths, field.name); const length = @field(lengths, field.name);
const size = fmt.bufPrint(scratch[0..], "{:.2}", .{ const size = fmt.bufPrint(scratch[0..], "{:.0}", .{
fmt.fmtIntSizeBin(@intCast(u64, length << section_length_bits)), fmt.fmtIntSizeBin(@intCast(u64, length << section_length_bits)),
}) catch unreachable; }) catch unreachable;
const offset = @field(offsets, field.name); const start = @field(offsets, field.name);
stdout.print(" {s:<19}{:8} {s:<12} {:8}\n", .{ const end = start + @field(lengths, field.name);
stdout.print("{s:>21} {x:0>8} {x:0>8} {s:>10}\n", .{
field.name, field.name,
length, start << section_length_bits,
end << section_length_bits,
size, size,
offset,
}) catch {}; }) catch {};
} }