master
 1const std = @import("std");
 2const uefi = std.os.uefi;
 3const Guid = uefi.Guid;
 4const Handle = uefi.Handle;
 5const Status = uefi.Status;
 6const SystemTable = uefi.tables.SystemTable;
 7const MemoryType = uefi.tables.MemoryType;
 8const DevicePath = uefi.protocol.DevicePath;
 9const cc = uefi.cc;
10const Error = Status.Error;
11
12pub const LoadedImage = extern struct {
13    revision: u32,
14    parent_handle: Handle,
15    system_table: *SystemTable,
16    device_handle: ?Handle,
17    file_path: *DevicePath,
18    reserved: *anyopaque,
19    load_options_size: u32,
20    load_options: ?*anyopaque,
21    image_base: [*]u8,
22    image_size: u64,
23    image_code_type: MemoryType,
24    image_data_type: MemoryType,
25    _unload: *const fn (*LoadedImage, Handle) callconv(cc) Status,
26
27    pub const UnloadError = uefi.UnexpectedError || error{InvalidParameter};
28
29    /// Unloads an image from memory.
30    pub fn unload(self: *LoadedImage, handle: Handle) UnloadError!void {
31        switch (self._unload(self, handle)) {
32            .success => {},
33            .invalid_parameter => return Error.InvalidParameter,
34            else => |status| return uefi.unexpectedStatus(status),
35        }
36    }
37
38    pub const guid align(8) = Guid{
39        .time_low = 0x5b1b31a1,
40        .time_mid = 0x9562,
41        .time_high_and_version = 0x11d2,
42        .clock_seq_high_and_reserved = 0x8e,
43        .clock_seq_low = 0x3f,
44        .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
45    };
46
47    pub const device_path_guid align(8) = Guid{
48        .time_low = 0xbc62157e,
49        .time_mid = 0x3e33,
50        .time_high_and_version = 0x4fec,
51        .clock_seq_high_and_reserved = 0x99,
52        .clock_seq_low = 0x20,
53        .node = [_]u8{ 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf },
54    };
55};