2017-06-04 22:08:55 +08:00
|
|
|
pub const ERROR = @import("error.zig");
|
|
|
|
|
2017-10-12 11:14:48 +08:00
|
|
|
pub extern "advapi32" stdcallcc fn CryptAcquireContextA(phProv: &HCRYPTPROV, pszContainer: ?LPCSTR,
|
|
|
|
pszProvider: ?LPCSTR, dwProvType: DWORD, dwFlags: DWORD) -> bool;
|
|
|
|
|
|
|
|
pub extern "advapi32" stdcallcc fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> bool;
|
|
|
|
|
|
|
|
pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: &BYTE) -> bool;
|
|
|
|
|
|
|
|
|
2017-10-10 02:21:35 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn CloseHandle(hObject: HANDLE) -> BOOL;
|
|
|
|
|
|
|
|
pub extern "kernel32" stdcallcc fn CreateFileA(lpFileName: LPCSTR, dwDesiredAccess: DWORD,
|
|
|
|
dwShareMode: DWORD, lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD,
|
|
|
|
dwFlagsAndAttributes: DWORD, hTemplateFile: ?HANDLE) -> HANDLE;
|
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn CreatePipe(hReadPipe: &HANDLE, hWritePipe: &HANDLE,
|
|
|
|
lpPipeAttributes: &SECURITY_ATTRIBUTES, nSize: DWORD) -> BOOL;
|
|
|
|
|
|
|
|
pub extern "kernel32" stdcallcc fn CreateProcessA(lpApplicationName: ?LPCSTR, lpCommandLine: LPSTR,
|
|
|
|
lpProcessAttributes: ?&SECURITY_ATTRIBUTES, lpThreadAttributes: ?&SECURITY_ATTRIBUTES, bInheritHandles: BOOL,
|
|
|
|
dwCreationFlags: DWORD, lpEnvironment: ?LPVOID, lpCurrentDirectory: ?LPCSTR, lpStartupInfo: &STARTUPINFOA,
|
|
|
|
lpProcessInformation: &PROCESS_INFORMATION) -> BOOL;
|
|
|
|
|
2017-10-09 11:06:56 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn DeleteFileA(lpFileName: LPCSTR) -> bool;
|
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) -> noreturn;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-10-11 22:16:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetCommandLineA() -> LPSTR;
|
2017-06-14 12:04:34 +08:00
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: &DWORD) -> bool;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-10-09 11:06:56 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetCurrentDirectoryA(nBufferLength: WORD, lpBuffer: ?LPSTR) -> DWORD;
|
2017-10-09 09:40:33 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: &DWORD) -> BOOL;
|
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetLastError() -> DWORD;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(in_hFile: HANDLE,
|
2017-06-14 12:04:34 +08:00
|
|
|
in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, out_lpFileInformation: &c_void,
|
|
|
|
in_dwBufferSize: DWORD) -> bool;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-10-10 02:21:35 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleA(hFile: HANDLE, lpszFilePath: LPSTR,
|
|
|
|
cchFilePath: DWORD, dwFlags: DWORD) -> DWORD;
|
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetProcessHeap() -> HANDLE;
|
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn GetStdHandle(in_nStdHandle: DWORD) -> ?HANDLE;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
|
|
|
|
|
|
|
|
pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
|
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn ReadFile(in_hFile: HANDLE, out_lpBuffer: LPVOID,
|
2017-06-14 12:04:34 +08:00
|
|
|
in_nNumberOfBytesToRead: DWORD, out_lpNumberOfBytesRead: &DWORD,
|
|
|
|
in_out_lpOverlapped: ?&OVERLAPPED) -> BOOL;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) -> BOOL;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn Sleep(dwMilliseconds: DWORD);
|
2017-09-19 21:46:41 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
|
2017-09-28 10:59:58 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
|
2017-09-28 10:59:58 +08:00
|
|
|
|
2017-10-13 21:31:03 +08:00
|
|
|
pub extern "kernel32" stdcallcc fn WriteFile(in_hFile: HANDLE, in_lpBuffer: &const c_void,
|
|
|
|
in_nNumberOfBytesToWrite: DWORD, out_lpNumberOfBytesWritten: ?&DWORD,
|
|
|
|
in_out_lpOverlapped: ?&OVERLAPPED) -> BOOL;
|
2017-09-24 15:54:59 +08:00
|
|
|
|
2017-09-24 16:18:13 +08:00
|
|
|
pub extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) -> c_int;
|
2017-09-24 15:54:59 +08:00
|
|
|
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const PROV_RSA_FULL = 1;
|
|
|
|
|
2017-06-14 12:04:34 +08:00
|
|
|
pub const UNICODE = false;
|
2017-10-09 09:40:33 +08:00
|
|
|
pub const LPTSTR = if (UNICODE) LPWSTR else LPSTR;
|
2017-06-14 12:04:34 +08:00
|
|
|
pub const LPWSTR = &WCHAR;
|
|
|
|
pub const LPSTR = &CHAR;
|
|
|
|
pub const CHAR = u8;
|
2017-09-24 15:54:59 +08:00
|
|
|
pub const PWSTR = &WCHAR;
|
2017-09-28 10:59:58 +08:00
|
|
|
pub const SIZE_T = usize;
|
2017-06-04 22:08:55 +08:00
|
|
|
|
|
|
|
pub const BOOL = bool;
|
|
|
|
pub const BYTE = u8;
|
2017-10-09 09:40:33 +08:00
|
|
|
pub const WORD = u16;
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const DWORD = u32;
|
|
|
|
pub const FLOAT = f32;
|
|
|
|
pub const HANDLE = &c_void;
|
2017-09-24 15:54:59 +08:00
|
|
|
pub const HINSTANCE = &@OpaqueType();
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const HCRYPTPROV = ULONG_PTR;
|
|
|
|
pub const LPCTSTR = &const TCHAR;
|
2017-10-09 11:06:56 +08:00
|
|
|
pub const LPCSTR = &const CHAR;
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const LPDWORD = &DWORD;
|
|
|
|
pub const LPVOID = &c_void;
|
|
|
|
pub const PVOID = &c_void;
|
2017-06-14 12:04:34 +08:00
|
|
|
pub const TCHAR = if (UNICODE) WCHAR else u8;
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const UINT = c_uint;
|
2017-09-24 15:54:59 +08:00
|
|
|
pub const INT = c_int;
|
2017-06-04 22:08:55 +08:00
|
|
|
pub const ULONG_PTR = usize;
|
|
|
|
pub const WCHAR = u16;
|
|
|
|
pub const LPCVOID = &const c_void;
|
2017-10-13 21:31:03 +08:00
|
|
|
pub const LPBYTE = &BYTE;
|
2017-06-14 12:04:34 +08:00
|
|
|
|
2017-06-04 22:08:55 +08:00
|
|
|
/// The standard input device. Initially, this is the console input buffer, CONIN$.
|
|
|
|
pub const STD_INPUT_HANDLE = @maxValue(DWORD) - 10 + 1;
|
|
|
|
|
|
|
|
/// The standard output device. Initially, this is the active console screen buffer, CONOUT$.
|
|
|
|
pub const STD_OUTPUT_HANDLE = @maxValue(DWORD) - 11 + 1;
|
|
|
|
|
|
|
|
/// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
|
|
|
|
pub const STD_ERROR_HANDLE = @maxValue(DWORD) - 12 + 1;
|
|
|
|
|
2017-09-10 23:16:27 +08:00
|
|
|
pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, @maxValue(usize));
|
2017-06-04 22:08:55 +08:00
|
|
|
|
|
|
|
pub const OVERLAPPED = extern struct {
|
|
|
|
Internal: ULONG_PTR,
|
|
|
|
InternalHigh: ULONG_PTR,
|
|
|
|
Pointer: PVOID,
|
|
|
|
hEvent: HANDLE,
|
|
|
|
};
|
|
|
|
pub const LPOVERLAPPED = &OVERLAPPED;
|
|
|
|
|
|
|
|
pub const MAX_PATH = 260;
|
|
|
|
|
|
|
|
// TODO issue #305
|
|
|
|
pub const FILE_INFO_BY_HANDLE_CLASS = u32;
|
|
|
|
pub const FileBasicInfo = 0;
|
|
|
|
pub const FileStandardInfo = 1;
|
|
|
|
pub const FileNameInfo = 2;
|
|
|
|
pub const FileRenameInfo = 3;
|
|
|
|
pub const FileDispositionInfo = 4;
|
|
|
|
pub const FileAllocationInfo = 5;
|
|
|
|
pub const FileEndOfFileInfo = 6;
|
|
|
|
pub const FileStreamInfo = 7;
|
|
|
|
pub const FileCompressionInfo = 8;
|
|
|
|
pub const FileAttributeTagInfo = 9;
|
|
|
|
pub const FileIdBothDirectoryInfo = 10;
|
|
|
|
pub const FileIdBothDirectoryRestartInfo = 11;
|
|
|
|
pub const FileIoPriorityHintInfo = 12;
|
|
|
|
pub const FileRemoteProtocolInfo = 13;
|
|
|
|
pub const FileFullDirectoryInfo = 14;
|
|
|
|
pub const FileFullDirectoryRestartInfo = 15;
|
|
|
|
pub const FileStorageInfo = 16;
|
|
|
|
pub const FileAlignmentInfo = 17;
|
|
|
|
pub const FileIdInfo = 18;
|
|
|
|
pub const FileIdExtdDirectoryInfo = 19;
|
|
|
|
pub const FileIdExtdDirectoryRestartInfo = 20;
|
|
|
|
|
|
|
|
pub const FILE_NAME_INFO = extern struct {
|
|
|
|
FileNameLength: DWORD,
|
|
|
|
FileName: [1]WCHAR,
|
|
|
|
};
|
2017-10-10 02:21:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
/// Return the normalized drive name. This is the default.
|
|
|
|
pub const FILE_NAME_NORMALIZED = 0x0;
|
|
|
|
/// Return the opened file name (not normalized).
|
|
|
|
pub const FILE_NAME_OPENED = 0x8;
|
|
|
|
|
|
|
|
/// Return the path with the drive letter. This is the default.
|
|
|
|
pub const VOLUME_NAME_DOS = 0x0;
|
|
|
|
/// Return the path with a volume GUID path instead of the drive name.
|
|
|
|
pub const VOLUME_NAME_GUID = 0x1;
|
|
|
|
/// Return the path with no drive information.
|
|
|
|
pub const VOLUME_NAME_NONE = 0x4;
|
|
|
|
/// Return the path with the volume device path.
|
|
|
|
pub const VOLUME_NAME_NT = 0x2;
|
|
|
|
|
|
|
|
|
|
|
|
pub const SECURITY_ATTRIBUTES = extern struct {
|
|
|
|
nLength: DWORD,
|
2017-10-13 21:31:03 +08:00
|
|
|
lpSecurityDescriptor: ?LPVOID,
|
2017-10-10 02:21:35 +08:00
|
|
|
bInheritHandle: BOOL,
|
|
|
|
};
|
|
|
|
pub const PSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
|
|
|
|
pub const LPSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
|
|
|
|
|
|
|
|
|
|
|
|
pub const GENERIC_READ = 0x80000000;
|
|
|
|
pub const GENERIC_WRITE = 0x40000000;
|
|
|
|
pub const GENERIC_EXECUTE = 0x20000000;
|
|
|
|
pub const GENERIC_ALL = 0x10000000;
|
|
|
|
|
|
|
|
pub const FILE_SHARE_DELETE = 0x00000004;
|
|
|
|
pub const FILE_SHARE_READ = 0x00000001;
|
|
|
|
pub const FILE_SHARE_WRITE = 0x00000002;
|
|
|
|
|
|
|
|
pub const CREATE_ALWAYS = 2;
|
|
|
|
pub const CREATE_NEW = 1;
|
|
|
|
pub const OPEN_ALWAYS = 4;
|
|
|
|
pub const OPEN_EXISTING = 3;
|
|
|
|
pub const TRUNCATE_EXISTING = 5;
|
|
|
|
|
|
|
|
|
|
|
|
pub const FILE_ATTRIBUTE_ARCHIVE = 0x20;
|
|
|
|
pub const FILE_ATTRIBUTE_ENCRYPTED = 0x4000;
|
|
|
|
pub const FILE_ATTRIBUTE_HIDDEN = 0x2;
|
|
|
|
pub const FILE_ATTRIBUTE_NORMAL = 0x80;
|
|
|
|
pub const FILE_ATTRIBUTE_OFFLINE = 0x1000;
|
|
|
|
pub const FILE_ATTRIBUTE_READONLY = 0x1;
|
|
|
|
pub const FILE_ATTRIBUTE_SYSTEM = 0x4;
|
|
|
|
pub const FILE_ATTRIBUTE_TEMPORARY = 0x100;
|
2017-10-13 21:31:03 +08:00
|
|
|
|
|
|
|
pub const PROCESS_INFORMATION = extern struct {
|
|
|
|
hProcess: HANDLE,
|
|
|
|
hThread: HANDLE,
|
|
|
|
dwProcessId: DWORD,
|
|
|
|
dwThreadId: DWORD,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const STARTUPINFOA = extern struct {
|
|
|
|
cb: DWORD,
|
|
|
|
lpReserved: ?LPSTR,
|
|
|
|
lpDesktop: ?LPSTR,
|
|
|
|
lpTitle: ?LPSTR,
|
|
|
|
dwX: DWORD,
|
|
|
|
dwY: DWORD,
|
|
|
|
dwXSize: DWORD,
|
|
|
|
dwYSize: DWORD,
|
|
|
|
dwXCountChars: DWORD,
|
|
|
|
dwYCountChars: DWORD,
|
|
|
|
dwFillAttribute: DWORD,
|
|
|
|
dwFlags: DWORD,
|
|
|
|
wShowWindow: WORD,
|
|
|
|
cbReserved2: WORD,
|
|
|
|
lpReserved2: ?LPBYTE,
|
|
|
|
hStdInput: ?HANDLE,
|
|
|
|
hStdOutput: ?HANDLE,
|
|
|
|
hStdError: ?HANDLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const STARTF_FORCEONFEEDBACK = 0x00000040;
|
|
|
|
pub const STARTF_FORCEOFFFEEDBACK = 0x00000080;
|
|
|
|
pub const STARTF_PREVENTPINNING = 0x00002000;
|
|
|
|
pub const STARTF_RUNFULLSCREEN = 0x00000020;
|
|
|
|
pub const STARTF_TITLEISAPPID = 0x00001000;
|
|
|
|
pub const STARTF_TITLEISLINKNAME = 0x00000800;
|
|
|
|
pub const STARTF_UNTRUSTEDSOURCE = 0x00008000;
|
|
|
|
pub const STARTF_USECOUNTCHARS = 0x00000008;
|
|
|
|
pub const STARTF_USEFILLATTRIBUTE = 0x00000010;
|
|
|
|
pub const STARTF_USEHOTKEY = 0x00000200;
|
|
|
|
pub const STARTF_USEPOSITION = 0x00000004;
|
|
|
|
pub const STARTF_USESHOWWINDOW = 0x00000001;
|
|
|
|
pub const STARTF_USESIZE = 0x00000002;
|
|
|
|
pub const STARTF_USESTDHANDLES = 0x00000100;
|
|
|
|
|
|
|
|
pub const INFINITE = 4294967295;
|
|
|
|
|
|
|
|
pub const WAIT_ABANDONED = 0x00000080;
|
|
|
|
pub const WAIT_OBJECT_0 = 0x00000000;
|
|
|
|
pub const WAIT_TIMEOUT = 0x00000102;
|
|
|
|
pub const WAIT_FAILED = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
pub const HANDLE_FLAG_INHERIT = 0x00000001;
|
|
|
|
pub const HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002;
|