zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

blob 9286b7d0 (11589B) - Raw


      1 const std = @import("../../index.zig");
      2 const assert = std.debug.assert;
      3 
      4 pub use @import("advapi32.zig");
      5 pub use @import("kernel32.zig");
      6 pub use @import("ntdll.zig");
      7 pub use @import("ole32.zig");
      8 pub use @import("shell32.zig");
      9 pub use @import("shlwapi.zig");
     10 pub use @import("user32.zig");
     11 
     12 test "import" {
     13     _ = @import("util.zig");
     14 }
     15 
     16 pub const ERROR = @import("error.zig");
     17 
     18 pub const SHORT = c_short;
     19 pub const BOOL = c_int;
     20 pub const BOOLEAN = BYTE;
     21 pub const BYTE = u8;
     22 pub const CHAR = u8;
     23 pub const DWORD = u32;
     24 pub const FLOAT = f32;
     25 pub const HANDLE = *c_void;
     26 pub const HCRYPTPROV = ULONG_PTR;
     27 pub const HINSTANCE = *@OpaqueType();
     28 pub const HMODULE = *@OpaqueType();
     29 pub const INT = c_int;
     30 pub const LPBYTE = *BYTE;
     31 pub const LPCH = *CHAR;
     32 pub const LPCSTR = [*]const CHAR;
     33 pub const LPCTSTR = [*]const TCHAR;
     34 pub const LPCVOID = *const c_void;
     35 pub const LPDWORD = *DWORD;
     36 pub const LPSTR = [*]CHAR;
     37 pub const LPTSTR = if (UNICODE) LPWSTR else LPSTR;
     38 pub const LPVOID = *c_void;
     39 pub const LPWSTR = [*]WCHAR;
     40 pub const LPCWSTR = [*]const WCHAR;
     41 pub const PVOID = *c_void;
     42 pub const PWSTR = [*]WCHAR;
     43 pub const SIZE_T = usize;
     44 pub const TCHAR = if (UNICODE) WCHAR else u8;
     45 pub const UINT = c_uint;
     46 pub const ULONG_PTR = usize;
     47 pub const DWORD_PTR = ULONG_PTR;
     48 pub const UNICODE = false;
     49 pub const WCHAR = u16;
     50 pub const WORD = u16;
     51 pub const LARGE_INTEGER = i64;
     52 
     53 pub const TRUE = 1;
     54 pub const FALSE = 0;
     55 
     56 /// The standard input device. Initially, this is the console input buffer, CONIN$.
     57 pub const STD_INPUT_HANDLE = @maxValue(DWORD) - 10 + 1;
     58 
     59 /// The standard output device. Initially, this is the active console screen buffer, CONOUT$.
     60 pub const STD_OUTPUT_HANDLE = @maxValue(DWORD) - 11 + 1;
     61 
     62 /// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
     63 pub const STD_ERROR_HANDLE = @maxValue(DWORD) - 12 + 1;
     64 
     65 pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, @maxValue(usize));
     66 
     67 pub const INVALID_FILE_ATTRIBUTES = DWORD(@maxValue(DWORD));
     68 
     69 pub const OVERLAPPED = extern struct {
     70     Internal: ULONG_PTR,
     71     InternalHigh: ULONG_PTR,
     72     Offset: DWORD,
     73     OffsetHigh: DWORD,
     74     hEvent: ?HANDLE,
     75 };
     76 pub const LPOVERLAPPED = *OVERLAPPED;
     77 
     78 pub const MAX_PATH = 260;
     79 
     80 // TODO issue #305
     81 pub const FILE_INFO_BY_HANDLE_CLASS = u32;
     82 pub const FileBasicInfo = 0;
     83 pub const FileStandardInfo = 1;
     84 pub const FileNameInfo = 2;
     85 pub const FileRenameInfo = 3;
     86 pub const FileDispositionInfo = 4;
     87 pub const FileAllocationInfo = 5;
     88 pub const FileEndOfFileInfo = 6;
     89 pub const FileStreamInfo = 7;
     90 pub const FileCompressionInfo = 8;
     91 pub const FileAttributeTagInfo = 9;
     92 pub const FileIdBothDirectoryInfo = 10;
     93 pub const FileIdBothDirectoryRestartInfo = 11;
     94 pub const FileIoPriorityHintInfo = 12;
     95 pub const FileRemoteProtocolInfo = 13;
     96 pub const FileFullDirectoryInfo = 14;
     97 pub const FileFullDirectoryRestartInfo = 15;
     98 pub const FileStorageInfo = 16;
     99 pub const FileAlignmentInfo = 17;
    100 pub const FileIdInfo = 18;
    101 pub const FileIdExtdDirectoryInfo = 19;
    102 pub const FileIdExtdDirectoryRestartInfo = 20;
    103 
    104 pub const FILE_NAME_INFO = extern struct {
    105     FileNameLength: DWORD,
    106     FileName: [1]WCHAR,
    107 };
    108 
    109 /// Return the normalized drive name. This is the default.
    110 pub const FILE_NAME_NORMALIZED = 0x0;
    111 
    112 /// Return the opened file name (not normalized).
    113 pub const FILE_NAME_OPENED = 0x8;
    114 
    115 /// Return the path with the drive letter. This is the default.
    116 pub const VOLUME_NAME_DOS = 0x0;
    117 
    118 /// Return the path with a volume GUID path instead of the drive name.
    119 pub const VOLUME_NAME_GUID = 0x1;
    120 
    121 /// Return the path with no drive information.
    122 pub const VOLUME_NAME_NONE = 0x4;
    123 
    124 /// Return the path with the volume device path.
    125 pub const VOLUME_NAME_NT = 0x2;
    126 
    127 pub const SECURITY_ATTRIBUTES = extern struct {
    128     nLength: DWORD,
    129     lpSecurityDescriptor: ?*c_void,
    130     bInheritHandle: BOOL,
    131 };
    132 pub const PSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
    133 pub const LPSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
    134 
    135 pub const GENERIC_READ = 0x80000000;
    136 pub const GENERIC_WRITE = 0x40000000;
    137 pub const GENERIC_EXECUTE = 0x20000000;
    138 pub const GENERIC_ALL = 0x10000000;
    139 
    140 pub const FILE_SHARE_DELETE = 0x00000004;
    141 pub const FILE_SHARE_READ = 0x00000001;
    142 pub const FILE_SHARE_WRITE = 0x00000002;
    143 
    144 pub const CREATE_ALWAYS = 2;
    145 pub const CREATE_NEW = 1;
    146 pub const OPEN_ALWAYS = 4;
    147 pub const OPEN_EXISTING = 3;
    148 pub const TRUNCATE_EXISTING = 5;
    149 
    150 pub const FILE_ATTRIBUTE_ARCHIVE = 0x20;
    151 pub const FILE_ATTRIBUTE_COMPRESSED = 0x800;
    152 pub const FILE_ATTRIBUTE_DEVICE = 0x40;
    153 pub const FILE_ATTRIBUTE_DIRECTORY = 0x10;
    154 pub const FILE_ATTRIBUTE_ENCRYPTED = 0x4000;
    155 pub const FILE_ATTRIBUTE_HIDDEN = 0x2;
    156 pub const FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x8000;
    157 pub const FILE_ATTRIBUTE_NORMAL = 0x80;
    158 pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000;
    159 pub const FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x20000;
    160 pub const FILE_ATTRIBUTE_OFFLINE = 0x1000;
    161 pub const FILE_ATTRIBUTE_READONLY = 0x1;
    162 pub const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x400000;
    163 pub const FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x40000;
    164 pub const FILE_ATTRIBUTE_REPARSE_POINT = 0x400;
    165 pub const FILE_ATTRIBUTE_SPARSE_FILE = 0x200;
    166 pub const FILE_ATTRIBUTE_SYSTEM = 0x4;
    167 pub const FILE_ATTRIBUTE_TEMPORARY = 0x100;
    168 pub const FILE_ATTRIBUTE_VIRTUAL = 0x10000;
    169 
    170 pub const PROCESS_INFORMATION = extern struct {
    171     hProcess: HANDLE,
    172     hThread: HANDLE,
    173     dwProcessId: DWORD,
    174     dwThreadId: DWORD,
    175 };
    176 
    177 pub const STARTUPINFOA = extern struct {
    178     cb: DWORD,
    179     lpReserved: ?LPSTR,
    180     lpDesktop: ?LPSTR,
    181     lpTitle: ?LPSTR,
    182     dwX: DWORD,
    183     dwY: DWORD,
    184     dwXSize: DWORD,
    185     dwYSize: DWORD,
    186     dwXCountChars: DWORD,
    187     dwYCountChars: DWORD,
    188     dwFillAttribute: DWORD,
    189     dwFlags: DWORD,
    190     wShowWindow: WORD,
    191     cbReserved2: WORD,
    192     lpReserved2: ?LPBYTE,
    193     hStdInput: ?HANDLE,
    194     hStdOutput: ?HANDLE,
    195     hStdError: ?HANDLE,
    196 };
    197 
    198 pub const STARTF_FORCEONFEEDBACK = 0x00000040;
    199 pub const STARTF_FORCEOFFFEEDBACK = 0x00000080;
    200 pub const STARTF_PREVENTPINNING = 0x00002000;
    201 pub const STARTF_RUNFULLSCREEN = 0x00000020;
    202 pub const STARTF_TITLEISAPPID = 0x00001000;
    203 pub const STARTF_TITLEISLINKNAME = 0x00000800;
    204 pub const STARTF_UNTRUSTEDSOURCE = 0x00008000;
    205 pub const STARTF_USECOUNTCHARS = 0x00000008;
    206 pub const STARTF_USEFILLATTRIBUTE = 0x00000010;
    207 pub const STARTF_USEHOTKEY = 0x00000200;
    208 pub const STARTF_USEPOSITION = 0x00000004;
    209 pub const STARTF_USESHOWWINDOW = 0x00000001;
    210 pub const STARTF_USESIZE = 0x00000002;
    211 pub const STARTF_USESTDHANDLES = 0x00000100;
    212 
    213 pub const INFINITE = 4294967295;
    214 
    215 pub const WAIT_ABANDONED = 0x00000080;
    216 pub const WAIT_OBJECT_0 = 0x00000000;
    217 pub const WAIT_TIMEOUT = 0x00000102;
    218 pub const WAIT_FAILED = 0xFFFFFFFF;
    219 
    220 pub const HANDLE_FLAG_INHERIT = 0x00000001;
    221 pub const HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002;
    222 
    223 pub const MOVEFILE_COPY_ALLOWED = 2;
    224 pub const MOVEFILE_CREATE_HARDLINK = 16;
    225 pub const MOVEFILE_DELAY_UNTIL_REBOOT = 4;
    226 pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32;
    227 pub const MOVEFILE_REPLACE_EXISTING = 1;
    228 pub const MOVEFILE_WRITE_THROUGH = 8;
    229 
    230 pub const FILE_BEGIN = 0;
    231 pub const FILE_CURRENT = 1;
    232 pub const FILE_END = 2;
    233 
    234 pub const HEAP_CREATE_ENABLE_EXECUTE = 0x00040000;
    235 pub const HEAP_GENERATE_EXCEPTIONS = 0x00000004;
    236 pub const HEAP_NO_SERIALIZE = 0x00000001;
    237 
    238 pub const PTHREAD_START_ROUTINE = extern fn (LPVOID) DWORD;
    239 pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
    240 
    241 pub const WIN32_FIND_DATAA = extern struct {
    242     dwFileAttributes: DWORD,
    243     ftCreationTime: FILETIME,
    244     ftLastAccessTime: FILETIME,
    245     ftLastWriteTime: FILETIME,
    246     nFileSizeHigh: DWORD,
    247     nFileSizeLow: DWORD,
    248     dwReserved0: DWORD,
    249     dwReserved1: DWORD,
    250     cFileName: [260]CHAR,
    251     cAlternateFileName: [14]CHAR,
    252 };
    253 
    254 pub const FILETIME = extern struct {
    255     dwLowDateTime: DWORD,
    256     dwHighDateTime: DWORD,
    257 };
    258 
    259 pub const SYSTEM_INFO = extern struct {
    260     anon1: extern union {
    261         dwOemId: DWORD,
    262         anon2: extern struct {
    263             wProcessorArchitecture: WORD,
    264             wReserved: WORD,
    265         },
    266     },
    267     dwPageSize: DWORD,
    268     lpMinimumApplicationAddress: LPVOID,
    269     lpMaximumApplicationAddress: LPVOID,
    270     dwActiveProcessorMask: DWORD_PTR,
    271     dwNumberOfProcessors: DWORD,
    272     dwProcessorType: DWORD,
    273     dwAllocationGranularity: DWORD,
    274     wProcessorLevel: WORD,
    275     wProcessorRevision: WORD,
    276 };
    277 
    278 pub const HRESULT = c_long;
    279 
    280 pub const KNOWNFOLDERID = GUID;
    281 pub const GUID = extern struct {
    282     Data1: c_ulong,
    283     Data2: c_ushort,
    284     Data3: c_ushort,
    285     Data4: [8]u8,
    286 
    287     pub fn parse(str: []const u8) GUID {
    288         var guid: GUID = undefined;
    289         var index: usize = 0;
    290         assert(str[index] == '{');
    291         index += 1;
    292 
    293         guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index .. index + 8], 16) catch unreachable;
    294         index += 8;
    295 
    296         assert(str[index] == '-');
    297         index += 1;
    298 
    299         guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
    300         index += 4;
    301 
    302         assert(str[index] == '-');
    303         index += 1;
    304 
    305         guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
    306         index += 4;
    307 
    308         assert(str[index] == '-');
    309         index += 1;
    310 
    311         guid.Data4[0] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
    312         index += 2;
    313         guid.Data4[1] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
    314         index += 2;
    315 
    316         assert(str[index] == '-');
    317         index += 1;
    318 
    319         var i: usize = 2;
    320         while (i < guid.Data4.len) : (i += 1) {
    321             guid.Data4[i] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
    322             index += 2;
    323         }
    324 
    325         assert(str[index] == '}');
    326         index += 1;
    327         return guid;
    328     }
    329 };
    330 
    331 pub const FOLDERID_LocalAppData = GUID.parse("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}");
    332 
    333 pub const KF_FLAG_DEFAULT = 0;
    334 pub const KF_FLAG_NO_APPCONTAINER_REDIRECTION = 65536;
    335 pub const KF_FLAG_CREATE = 32768;
    336 pub const KF_FLAG_DONT_VERIFY = 16384;
    337 pub const KF_FLAG_DONT_UNEXPAND = 8192;
    338 pub const KF_FLAG_NO_ALIAS = 4096;
    339 pub const KF_FLAG_INIT = 2048;
    340 pub const KF_FLAG_DEFAULT_PATH = 1024;
    341 pub const KF_FLAG_NOT_PARENT_RELATIVE = 512;
    342 pub const KF_FLAG_SIMPLE_IDLIST = 256;
    343 pub const KF_FLAG_ALIAS_ONLY = -2147483648;
    344 
    345 pub const S_OK = 0;
    346 pub const E_NOTIMPL = @bitCast(c_long, c_ulong(0x80004001));
    347 pub const E_NOINTERFACE = @bitCast(c_long, c_ulong(0x80004002));
    348 pub const E_POINTER = @bitCast(c_long, c_ulong(0x80004003));
    349 pub const E_ABORT = @bitCast(c_long, c_ulong(0x80004004));
    350 pub const E_FAIL = @bitCast(c_long, c_ulong(0x80004005));
    351 pub const E_UNEXPECTED = @bitCast(c_long, c_ulong(0x8000FFFF));
    352 pub const E_ACCESSDENIED = @bitCast(c_long, c_ulong(0x80070005));
    353 pub const E_HANDLE = @bitCast(c_long, c_ulong(0x80070006));
    354 pub const E_OUTOFMEMORY = @bitCast(c_long, c_ulong(0x8007000E));
    355 pub const E_INVALIDARG = @bitCast(c_long, c_ulong(0x80070057));
    356 
    357 pub const FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
    358 pub const FILE_FLAG_DELETE_ON_CLOSE = 0x04000000;
    359 pub const FILE_FLAG_NO_BUFFERING = 0x20000000;
    360 pub const FILE_FLAG_OPEN_NO_RECALL = 0x00100000;
    361 pub const FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000;
    362 pub const FILE_FLAG_OVERLAPPED = 0x40000000;
    363 pub const FILE_FLAG_POSIX_SEMANTICS = 0x0100000;
    364 pub const FILE_FLAG_RANDOM_ACCESS = 0x10000000;
    365 pub const FILE_FLAG_SESSION_AWARE = 0x00800000;
    366 pub const FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000;
    367 pub const FILE_FLAG_WRITE_THROUGH = 0x80000000;
    368 
    369 pub const SMALL_RECT = extern struct {
    370     Left: SHORT,
    371     Top: SHORT,
    372     Right: SHORT,
    373     Bottom: SHORT,
    374 };
    375 
    376 pub const COORD = extern struct {
    377     X: SHORT,
    378     Y: SHORT,
    379 };