platform/windows
skip to the library navigationTarget scope is enforced by the module assertion below.
compiler.assert(compiler.os == linux or compiler.os == darwin
or compiler.os == freebsd or compiler.os == windows)
Windows' own interface under the Windows x64 C convention, raw: a call that fails returns the system's failure value and leaves the reason for last_error. It is what the hosted providers are written over on Windows, as they are over platform/posix elsewhere.
The module holds the process entry every Windows executable starts at, which refine links into each one whether or not the program imports the module. No C runtime is linked. Every hosted system may import the module, and off Windows it declares nothing.
Each facility has a file of its own, which names the library it links with linker.library:
| File | What it holds | Links |
|---|---|---|
windows.ldn | The entry, the argument and environment root, handles, the error codes, VirtualAlloc and VirtualFree. | kernel32 |
wide.ldn | The conversion between a host string and the system's 16-bit units, and terminate, which makes the terminated wide string a call takes. | |
files.ldn | Files, directories and the console. | |
processes.ldn | Child processes, pipes, events and waiting on them. | |
time.ldn | The wall clock, the performance counter, sleeping and BCryptGenRandom. | bcrypt |
threads.ldn | Threads, and WaitOnAddress with its wakes. | synchronization |
memory.ldn | What VirtualQuery says of a region, the page and the 64 KiB unit of reservation. | |
completion.ldn | I/O completion ports, the job a child's end is learned through, and the console's control events. |
Windows Sockets is the module platform/windows/sockets, below.
A Windows host string, a text.os_string, is WTF-8: UTF-8 for every well-formed name, with a lone surrogate as the three bytes UTF-8 would give its value. So every name the system gives survives the trip to bytes and back.
| Name | What it is |
|---|---|
_landin_start | The process entry. It reads GetCommandLineW and the environment block, splits the command line as Microsoft's C runtime does, calls the program's main and ends the process with ExitProcess, main's result the exit code's 32 bits. |
_landin_host_initialize_arguments | Keeps C vectors as the process's argument root, as platform/posix's does. The entry calls it. |
arguments, environment | What the entry found, read as platform/posix's are. |
Every program of the Windows corpus starts at the entry, the first example among them, which imports nothing and ends with its status. The second starts the command processor ComSpec names, with pipes for its three streams.
Items
Types 20
Atoms 2
Values 88
allocation_granularityappend_dataattribute_directoryattribute_handle_listattribute_normalattribute_read_onlyattribute_reparse_pointcontrol_breakcontrol_ccontrol_closecontrol_logoffcontrol_shutdowncreate_alwayscreate_newduplicate_same_accessepoch_differenceerror_access_deniederror_already_existserror_bad_netpatherror_broken_pipeerror_directoryerror_file_existserror_file_not_founderror_filename_exceeds_rangeerror_handle_eoferror_invalid_driveerror_invalid_nameerror_invalid_parametererror_io_pendingerror_lock_violationerror_more_dataerror_no_more_fileserror_not_enough_memoryerror_not_supportederror_operation_abortederror_path_not_founderror_pipe_not_connectederror_sharing_violationerror_write_protectextended_startupfile_beginfile_currentfile_end_of_file_infofile_read_attributesfile_write_attributesflag_backup_semanticsflag_open_reparse_pointflag_overlappedgeneric_readgeneric_writehandle_flag_inheritinfiniteinvalid_attributesinvalid_handlejob_abnormal_exit_processjob_basic_limitsjob_completion_portjob_exit_processjob_silent_breakawaylist_directorymem_commitmem_decommitmem_releasemem_reservemove_replace_existingno_handleopen_alwaysopen_existingpage_bytespage_readwritepipe_access_inboundpipe_access_outboundpipe_byte_wait_localpipe_first_instancereparse_tag_symlinkshare_allstack_size_is_a_reservationstate_reservedstd_errorstd_inputstd_outputsynchronize_accesssystem_preferred_generatortruncate_existingunicode_environmentuse_std_handleswait_failedwait_object_0
Functions 73
_landin_startallocate_consoleargumentargumentsassign_to_jobcancel_ioclose_handlecode_ofcompletion_portconsole_screen_infocreate_directorycreate_eventcreate_filecreate_jobcreate_named_pipecreate_processcreate_threadcurrent_directorycurrent_processcurrent_process_iddelete_attributesdelete_fileduplicate_handleenvironmentexit_code_ofexit_processfinal_pathfind_closefind_first_filefind_next_fileflush_file_buffersfree_consoleget_completionsget_console_modeget_file_attributesget_file_attributes_exget_file_informationget_std_handlehost_lengthinitialize_attributeslast_errormove_fileoverlapped_resultpeek_named_pipeperformance_counterperformance_frequencypost_completionprocess_id_ofrandomread_fileremove_directorysend_control_eventset_control_handlerset_file_attributesset_file_informationset_file_pointerset_handle_informationset_jobsleepsystem_timeterminateto_hostto_unitsupdate_attributevariablevirtual_allocvirtual_freevirtual_querywait_forwait_for_anywait_on_addresswake_by_address_singlewrite_file
Also on this page
When compiler.os == windows
public argument_table: type = struct
values: ptr ptr u8
count: usize
end argument_table
The process's arguments: the vector after the program's name and their count. argument reads it.
When compiler.os == windows
What get_file_attributes_ex fills: WIN32_FILE_ATTRIBUTE_DATA.
When compiler.os == windows
public completion_entry: type = struct
key: usize
record: usize
internal: usize
moved: u32
reserved: u32
end completion_entry
What get_completions takes off a port for each packet, OVERLAPPED_ENTRY: the key the packet's handle was associated with, the address of the call's overlapped record, the call's status, and the bytes it moved. A packet a job or post_completion sent carries its own word in record and its own count in moved.
When compiler.os == windows
public console_screen: type = struct
size_x: i16
size_y: i16
cursor_x: i16
cursor_y: i16
attributes: u16
left: i16
top: i16
right: i16
bottom: i16
largest_x: i16
largest_y: i16
end console_screen
A console's screen buffer, CONSOLE_SCREEN_BUFFER_INFO: its size, the cursor, the attributes, the window's corners and its largest size, each coordinate 16 bits.
When compiler.os == windows
public control_handler: type = extern(c) (event: u32) -> (handled: i32)
A routine the system calls on a thread of its own for each control event, PHANDLER_ROUTINE: nonzero when it handled the event, zero to hand it to the next routine, the last of which ends the process.
When compiler.os == windows
public environment_table: type = struct
values: ptr ptr u8
count: usize
end environment_table
The process's environment as the entry read it, and the count of its entries. variable reads it.
When compiler.os == windows
What get_file_information fills: BY_HANDLE_FILE_INFORMATION.
When compiler.os == windows
public file_time: type = struct
low: u32
high: u32
end file_time
A time as Windows keeps it: hundreds of nanoseconds since 1601, FILETIME's two halves.
When compiler.os == windows
What find_first_file fills for each entry: WIN32_FIND_DATAW.
When compiler.os == windows
public handle: type = usize
A kernel object's handle, HANDLE: one word, which names an open file, pipe, console, process, thread or event until it is closed.
When compiler.os == windows
public job_limits: type = struct
process_time: i64
job_time: i64
flags: u32
pad_0: u32
least_working_set: usize
most_working_set: usize
process_count: u32
pad_1: u32
affinity: usize
priority: u32
scheduling: u32
end job_limits
JOBOBJECT_BASIC_LIMIT_INFORMATION, its padding named.
When compiler.os == windows
public job_port: type = struct
key: usize
port: handle
end job_port
JOBOBJECT_ASSOCIATE_COMPLETION_PORT: the port the job sends its messages to, under key.
When compiler.os == windows
public memory_information: type = struct
base: usize
allocation_base: usize
allocation_protection: u32
partition: u16
reserved_1: u16
size: usize
state: u32
protection: u32
kind: u32
reserved_2: u32
end memory_information
MEMORY_BASIC_INFORMATION: the run of pages from base alike in state and protection, size bytes long, and the reservation allocation_base that holds them.
When compiler.os == windows
public name_failure: type = bad_name | name_too_long
Why a host string could not be given to the system.
When compiler.os == windows
public overlapped: type = struct
internal: usize
internal_high: usize
offset_low: u32
offset_high: u32
event: handle
end overlapped
The record an overlapped call takes: its offset, and the event that is set when it ends, or zero. OVERLAPPED.
When compiler.os == windows
public path_room: type = [1024]u16
Room for a path and its NUL, in units: Windows' long-path limit is 32,767, but a path beyond MAX_PATH, 260, needs the \\?\ form and a manifest the image does not carry, so this room keeps a frame small and still takes every path the system gives an ordinary program.
When compiler.os == windows
What create_process fills: PROCESS_INFORMATION.
When compiler.os == windows
public security_attributes: type = struct
length: u32
descriptor: usize
inherit: i32
end security_attributes
SECURITY_ATTRIBUTES, given only to make a handle a child may inherit: its size, no descriptor, and inherit nonzero.
When compiler.os == windows
public startup_information: type = struct
size: u32
reserved: usize
desktop: usize
title: usize
x: u32
y: u32
x_size: u32
y_size: u32
x_count: u32
y_count: u32
fill: u32
flags: u32
show: u16
reserved_count: u16
reserved_data: usize
input: handle
output: handle
errors: handle
attributes: usize
end startup_information
STARTUPINFOEXW: what create_process gives the child's first thread, its standard handles among them when flags holds use_std_handles, and the attribute list that names the handles it inherits.
When compiler.os == windows
public thread_routine: type = extern(c) (argument: usize) -> (result: usize)
The routine a thread runs, LPTHREAD_START_ROUTINE: called with the argument create_thread was given, on the thread's own stack. Its result's low 32 bits are the thread's exit code.
When compiler.os == windows
public bad_name: atom
A host string this module cannot give the system: one holding a NUL or bytes WTF-8 does not encode, ERROR_INVALID_NAME to the system.
When compiler.os == windows
public name_too_long: atom
A host string whose units and NUL do not fit the buffer given, ERROR_FILENAME_EXCED_RANGE to the system.
When compiler.os == windows
public allocation_granularity: usize = 65536
The unit virtual_alloc reserves address space in.
When compiler.os == windows
public append_data: u32 = 4
FILE_APPEND_DATA and SYNCHRONIZE: an open to append, whose every write goes to the file's end.
When compiler.os == windows
public attribute_directory: u32 = 0x10
FILE_ATTRIBUTE_DIRECTORY: the file is a directory.
When compiler.os == windows
public attribute_handle_list: usize = 0x20002
PROC_THREAD_ATTRIBUTE_HANDLE_LIST: the handles a child inherits, no other.
When compiler.os == windows
public attribute_normal: u32 = 0x80
CreateFileW's attributes and flags: a plain file, FILE_FLAG_BACKUP_SEMANTICS, which a directory is opened with, FILE_FLAG_OVERLAPPED, FILE_FLAG_WRITE_THROUGH, and FILE_FLAG_OPEN_REPARSE_POINT, which opens a link rather than what it names.
When compiler.os == windows
public attribute_read_only: u32 = 0x1
A file's attribute bits: read-only, a directory and a reparse point, which a symbolic link is; and what get_file_attributes gives when it fails, all ones.
When compiler.os == windows
public attribute_reparse_point: u32 = 0x400
FILE_ATTRIBUTE_REPARSE_POINT: the file is a link or another reparse point.
When compiler.os == windows
public control_break: u32 = 1
Ctrl+Break, CTRL_BREAK_EVENT.
When compiler.os == windows
public control_c: u32 = 0
The console's control event Ctrl+C, CTRL_C_EVENT.
When compiler.os == windows
public control_close: u32 = 2
The console closed, CTRL_CLOSE_EVENT.
When compiler.os == windows
public control_logoff: u32 = 5
The user logging off, CTRL_LOGOFF_EVENT.
When compiler.os == windows
public control_shutdown: u32 = 6
The system shutting down, CTRL_SHUTDOWN_EVENT.
When compiler.os == windows
public create_always: u32 = 2
CREATE_ALWAYS: make the file, or empty one that is there.
When compiler.os == windows
public create_new: u32 = 1
CreateFileW's dispositions.
When compiler.os == windows
public duplicate_same_access: u32 = 2
DUPLICATE_SAME_ACCESS.
When compiler.os == windows
public epoch_difference: u64 = 116444736000000000
Hundreds of nanoseconds from 1601 to 1970, the Unix epoch.
When compiler.os == windows
public error_access_denied: u32 = 5
ERROR_ACCESS_DENIED.
When compiler.os == windows
public error_already_exists: u32 = 183
ERROR_ALREADY_EXISTS.
When compiler.os == windows
public error_bad_netpath: u32 = 53
ERROR_BAD_NETPATH.
When compiler.os == windows
public error_broken_pipe: u32 = 109
ERROR_BROKEN_PIPE.
When compiler.os == windows
public error_directory: u32 = 267
ERROR_DIRECTORY.
When compiler.os == windows
public error_file_exists: u32 = 80
ERROR_FILE_EXISTS.
When compiler.os == windows
public error_file_not_found: u32 = 2
The Win32 error codes the providers tell apart: ERROR_*.
When compiler.os == windows
public error_filename_exceeds_range: u32 = 206
ERROR_FILENAME_EXCED_RANGE.
When compiler.os == windows
public error_handle_eof: u32 = 38
ERROR_HANDLE_EOF.
When compiler.os == windows
public error_invalid_drive: u32 = 15
ERROR_INVALID_DRIVE.
When compiler.os == windows
public error_invalid_name: u32 = 123
ERROR_INVALID_NAME.
When compiler.os == windows
public error_invalid_parameter: u32 = 87
ERROR_INVALID_PARAMETER.
When compiler.os == windows
public error_io_pending: u32 = 997
ERROR_IO_PENDING.
When compiler.os == windows
public error_lock_violation: u32 = 33
ERROR_LOCK_VIOLATION.
When compiler.os == windows
public error_more_data: u32 = 234
ERROR_MORE_DATA.
When compiler.os == windows
public error_no_more_files: u32 = 18
ERROR_NO_MORE_FILES.
When compiler.os == windows
public error_not_enough_memory: u32 = 8
ERROR_NOT_ENOUGH_MEMORY.
When compiler.os == windows
public error_not_supported: u32 = 50
ERROR_NOT_SUPPORTED.
When compiler.os == windows
public error_operation_aborted: u32 = 995
ERROR_OPERATION_ABORTED.
When compiler.os == windows
public error_path_not_found: u32 = 3
ERROR_PATH_NOT_FOUND.
When compiler.os == windows
public error_pipe_not_connected: u32 = 233
ERROR_PIPE_NOT_CONNECTED.
When compiler.os == windows
public error_sharing_violation: u32 = 32
ERROR_SHARING_VIOLATION.
When compiler.os == windows
public error_write_protect: u32 = 19
ERROR_WRITE_PROTECT.
When compiler.os == windows
public extended_startup: u32 = 0x80000
EXTENDED_STARTUP_INFO_PRESENT: the information has an attribute list.
When compiler.os == windows
public file_begin: u32 = 0
Move opened's position, SetFilePointerEx, from the start, the current position or the end, by distance; the new position goes to moved when it is not zero.
When compiler.os == windows
public file_current: u32 = 1
FILE_CURRENT: set_file_pointer moves from the current position.
When compiler.os == windows
public file_end_of_file_info: u32 = 6
FileEndOfFileInfo, the class set_file_information takes to give a file a size without moving its position.
When compiler.os == windows
public file_read_attributes: u32 = 0x80
FILE_READ_ATTRIBUTES: the right to ask about a file, alone.
When compiler.os == windows
public file_write_attributes: u32 = 0x100
FILE_WRITE_ATTRIBUTES: the right to change what is kept of a file.
When compiler.os == windows
public flag_backup_semantics: u32 = 0x02000000
FILE_FLAG_BACKUP_SEMANTICS: needed to open a directory.
When compiler.os == windows
public flag_open_reparse_point: u32 = 0x00200000
FILE_FLAG_OPEN_REPARSE_POINT: open a link, not what it names.
When compiler.os == windows
public flag_overlapped: u32 = 0x40000000
FILE_FLAG_OVERLAPPED: calls on the handle may end later.
When compiler.os == windows
public generic_read: u32 = 0x80000000
CreateFileW's access rights, GENERIC_READ and GENERIC_WRITE, and FILE_READ_ATTRIBUTES, which opens a file only to ask about it.
When compiler.os == windows
public generic_write: u32 = 0x40000000
GENERIC_WRITE: the right to write.
When compiler.os == windows
public handle_flag_inherit: u32 = 1
HANDLE_FLAG_INHERIT.
When compiler.os == windows
public infinite: u32 = 0xFFFFFFFF
INFINITE: wait for as long as it takes.
When compiler.os == windows
public invalid_attributes: u32 = 0xFFFFFFFF
INVALID_FILE_ATTRIBUTES: what get_file_attributes gives when it fails.
When compiler.os == windows
public invalid_handle: handle = 0xFFFFFFFFFFFFFFFF
INVALID_HANDLE_VALUE, what create_file and get_std_handle give when they fail: all ones.
When compiler.os == windows
public job_abnormal_exit_process: u32 = 8
The message when a process ended with an exception's code, JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS.
When compiler.os == windows
public job_basic_limits: u32 = 2
SetInformationJobObject's class of the basic limits.
When compiler.os == windows
public job_completion_port: u32 = 7
SetInformationJobObject's class of the port the job reports to.
When compiler.os == windows
public job_exit_process: u32 = 7
The message a job's packet carries in its moved, with the process's ID in its record, when a process ended, JOB_OBJECT_MSG_EXIT_PROCESS.
When compiler.os == windows
public job_silent_breakaway: u32 = 0x1000
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK: a process the job's processes start is not in the job.
When compiler.os == windows
public list_directory: u32 = 1
FILE_LIST_DIRECTORY, the access a directory is opened to list with.
When compiler.os == windows
public mem_commit: u32 = 0x1000
virtual_alloc's and virtual_free's kinds and protections.
When compiler.os == windows
public mem_decommit: u32 = 0x4000
MEM_DECOMMIT: give the memory back and keep the addresses.
When compiler.os == windows
public mem_release: u32 = 0x8000
MEM_RELEASE: give the memory and the addresses back.
When compiler.os == windows
public mem_reserve: u32 = 0x2000
MEM_RESERVE: reserve addresses.
When compiler.os == windows
public move_replace_existing: u32 = 1
MoveFileExW's flags: replace a file the new name holds, and do not return before the move is on the disk.
When compiler.os == windows
public no_handle: handle = 0
No handle: the null a call gives when it fails, and what a parent that gave a process no standard stream leaves in its place.
When compiler.os == windows
public open_always: u32 = 4
OPEN_ALWAYS: open the file, making it when it is not there.
When compiler.os == windows
public open_existing: u32 = 3
OPEN_EXISTING: open the file only if it is there.
When compiler.os == windows
public page_bytes: usize = 4096
The page virtual_alloc commits in.
When compiler.os == windows
public page_readwrite: u32 = 0x04
PAGE_READWRITE: the pages may be read and written.
When compiler.os == windows
public pipe_access_inbound: u32 = 1
CreateNamedPipeW's open mode: inbound, outbound or duplex, each with FILE_FLAG_OVERLAPPED and FILE_FLAG_FIRST_PIPE_INSTANCE.
When compiler.os == windows
public pipe_access_outbound: u32 = 2
PIPE_ACCESS_OUTBOUND: the server end writes.
When compiler.os == windows
public pipe_byte_wait_local: u32 = 0x8
CreateNamedPipeW's pipe mode: bytes, waiting, remote clients refused.
When compiler.os == windows
public pipe_first_instance: u32 = 0x00080000
FILE_FLAG_FIRST_PIPE_INSTANCE: fail if the name is taken.
When compiler.os == windows
public reparse_tag_symlink: u32 = 0xA000000C
IO_REPARSE_TAG_SYMLINK, the tag find_data's reserved_0 holds for a symbolic link.
When compiler.os == windows
public stack_size_is_a_reservation: u32 = 0x10000
STACK_SIZE_PARAM_IS_A_RESERVATION: create_thread's size is what the stack reserves, of which a page is committed, rather than what it commits.
When compiler.os == windows
public state_reserved: u32 = 0x2000
MEM_RESERVE, the state of pages reserved and not committed.
When compiler.os == windows
public std_error: u32 = 0xFFFFFFF4
STD_ERROR_HANDLE.
When compiler.os == windows
public std_input: u32 = 0xFFFFFFF6
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE and STD_ERROR_HANDLE, what get_std_handle takes.
When compiler.os == windows
public std_output: u32 = 0xFFFFFFF5
STD_OUTPUT_HANDLE.
When compiler.os == windows
public synchronize_access: u32 = 0x100000
SYNCHRONIZE: the right to wait for the handle.
When compiler.os == windows
public system_preferred_generator: u32 = 2
BCRYPT_USE_SYSTEM_PREFERRED_RNG: random asks the system's own generator, with no algorithm handle.
When compiler.os == windows
public truncate_existing: u32 = 5
TRUNCATE_EXISTING: empty the file, which must be there.
When compiler.os == windows
public unicode_environment: u32 = 0x400
create_process's flags: CREATE_UNICODE_ENVIRONMENT, the block is 16-bit units; EXTENDED_STARTUPINFO_PRESENT, the information has an attribute list.
When compiler.os == windows
public use_std_handles: u32 = 0x100
STARTF_USESTDHANDLES.
When compiler.os == windows
public wait_failed: u32 = 0xFFFFFFFF
WAIT_FAILED: the wait failed, with the reason in last_error.
When compiler.os == windows
public wait_object_0: u32 = 0
WaitForSingleObject's and WaitForMultipleObjects' answers: the object, or the first of several, is signalled; the time ran out; the wait failed with the reason in last_error.
When compiler.os == windows
public extern(c) _landin_start: () -> noreturn
The process entry. Windows starts a process at the image's entry with the stack aligned as after a call, which a routine's prologue expects, so the entry is an ordinary routine: it reads the command line and the environment, calls the program's main with them as C's runtime would, and ends the process with main's result as the exit code.
When compiler.os == windows
public extern(c) link(symbol: "AllocConsole") allocate_console:
() -> (done: i32)
Make the process a console of its own, AllocConsole.
When compiler.os == windows
public argument: (table: argument_table, index: usize)
-> (value: text.os_string from table)
The argument index, from zero, as a host string lending the process's own storage. An index at or past the table's count traps.
When compiler.os == windows
public arguments: () -> (table: argument_table)
The process's arguments, the program's name not among them. It traps when no argument root has been established.
When compiler.os == windows
Put process in job, AssignProcessToJobObject.
When compiler.os == windows
public extern(c) link(symbol: "CancelIoEx") cancel_io:
(opened: handle, record: usize) -> (done: i32)
Cancel the overlapped call record names on opened, or every one the process has on it when record is zero, CancelIoEx.
When compiler.os == windows
public extern(c) link(symbol: "CloseHandle") close_handle:
(object: handle) -> (done: i32)
Close object, CloseHandle: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public code_of: (problem: name_failure) -> (code: u32)
The Win32 error code that says the same as problem.
When compiler.os == windows
Make a port with existing zero and opened invalid_handle, or associate opened with the port existing under key, CreateIoCompletionPort: the port, or zero with the reason in last_error. A handle is associated once, with one port, for as long as it is open; asking again fails error_invalid_parameter. threads zero lets as many threads run as there are processors.
When compiler.os == windows
public extern(c) link(symbol: "GetConsoleScreenBufferInfo") console_screen_info:
(console: handle, found: ptr mut console_screen) -> (done: i32)
Fill found for the console screen buffer console, GetConsoleScreenBufferInfo.
When compiler.os == windows
public extern(c) link(symbol: "CreateDirectoryW") create_directory:
(name: ptr u16, security: usize) -> (done: i32)
Make the directory name names, CreateDirectoryW, with the default security: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "CreateEventW") create_event:
(security: usize, manual: i32, initial: i32, name: usize)
-> (result: handle)
Make an event, CreateEventW: reset by hand when manual is nonzero, signalled at first when initial is; its handle or zero.
When compiler.os == windows
public extern(c) link(symbol: "CreateFileW") create_file:
(name: ptr u16, access: u32, share: u32, security: usize,
disposition: u32, flags: u32, template: usize) -> (result: handle)
Open or make the file name names, CreateFileW: its handle, or invalid_handle with the reason in last_error. security is zero, so the handle is not inherited by a child, and template is zero.
When compiler.os == windows
public extern(c) link(symbol: "CreateJobObjectW") create_job:
(security: usize, name: usize) -> (job: handle)
Make a job without a name, CreateJobObjectW: its handle, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "CreateNamedPipeW") create_named_pipe:
(name: ptr u16, open_mode: u32, pipe_mode: u32, instances: u32,
out_size: u32, in_size: u32, timeout: u32, security: usize)
-> (result: handle)
Make the first instance of the named pipe name, CreateNamedPipeW: its server end, or invalid_handle with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "CreateProcessW") create_process:
(application: ptr u16, line: ptr mut u16, process_security: usize,
thread_security: usize, inherit: i32, flags: u32,
environment: usize, directory: usize,
startup: ptr startup_information,
started: ptr mut process_information) -> (done: i32)
Start the program application with the command line line, CreateProcessW: nonzero with the child's handles in started, or zero with the reason in last_error. application is not looked up on a search path and gets no extension; line is changed in place.
When compiler.os == windows
public extern(c) link(symbol: "CreateThread") create_thread:
(attributes: usize, stack_size: usize, routine: thread_routine,
argument: usize, flags: u32, id: ptr mut u32) -> (thread: handle)
Start a thread running routine with argument, CreateThread, with no security attributes, stack_size the stack's size, zero for the image's default, and flags zero or stack_size_is_a_reservation: the thread's handle, with its identifier in id when that is not zero, or no_handle with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetCurrentDirectoryW") current_directory:
(size: u32, into: ptr mut u16) -> (count: u32)
The working directory into into's size units with a NUL, GetCurrentDirectoryW: the units written, the NUL not counted; the units it needs, the NUL counted, when they do not fit; or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetCurrentProcess") current_process:
() -> (result: handle)
The calling process as a handle, GetCurrentProcess: the pseudo handle all ones less one, which needs no closing.
When compiler.os == windows
public extern(c) link(symbol: "GetCurrentProcessId") current_process_id:
() -> (id: u32)
The calling process's ID, GetCurrentProcessId.
When compiler.os == windows
public extern(c) link(symbol: "DeleteProcThreadAttributeList") delete_attributes: (list: usize) -> none
Release what an attribute list holds, DeleteProcThreadAttributeList.
When compiler.os == windows
public extern(c) link(symbol: "DeleteFileW") delete_file:
(name: ptr u16) -> (done: i32)
Remove the file name names, DeleteFileW. A file another handle holds open with share_all is removed when the last is closed.
When compiler.os == windows
Duplicate source of source_process into target_process as target, DuplicateHandle, inheritable when inherit is nonzero.
When compiler.os == windows
public environment: () -> (table: environment_table)
The process's environment, as the system gave it when the process started, in its order: NAME=value entries, the hidden =C: entries that keep each drive's working directory among them. It traps before the argument root exists, as arguments does.
When compiler.os == windows
public extern(c) link(symbol: "GetExitCodeProcess") exit_code_of:
(process: handle, code: ptr mut u32) -> (done: i32)
The exit code of process, GetExitCodeProcess, or STILL_ACTIVE, 259, while it runs.
When compiler.os == windows
public extern(c) link(symbol: "ExitProcess") exit_process: (status: i32)
-> noreturn
End the process with status as its exit code, after every DLL's detach routine has run. Windows reads the code as a DWORD: a negative status is the same 32 bits, so -1 is 4294967295.
When compiler.os == windows
public extern(c) link(symbol: "GetFinalPathNameByHandleW") final_path:
(opened: handle, into: ptr mut u16, size: u32, flags: u32)
-> (count: u32)
The path opened was reached by after every link, into into's size units with a NUL, GetFinalPathNameByHandleW: the units written, the NUL not counted, in the \\?\ form; the units it needs when they do not fit; or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "FindClose") find_close:
(search: handle) -> (done: i32)
End a search, FindClose.
When compiler.os == windows
Begin a directory's listing, FindFirstFileW, with pattern such as dir\*: the search's handle, its first entry in found, or invalid_handle with the reason in last_error, error_file_not_found for an empty match.
When compiler.os == windows
The search's next entry, FindNextFileW: nonzero, or zero with error_no_more_files at the end.
When compiler.os == windows
public extern(c) link(symbol: "FlushFileBuffers") flush_file_buffers:
(opened: handle) -> (done: i32)
Write what the system holds of opened to its disk, FlushFileBuffers.
When compiler.os == windows
public extern(c) link(symbol: "FreeConsole") free_console: () -> (done: i32)
Leave the process's console, FreeConsole.
When compiler.os == windows
public extern(c) link(symbol: "GetQueuedCompletionStatusEx") get_completions:
(port: handle, into: ptr mut completion_entry, count: u32,
taken: ptr mut u32, milliseconds: u32, alertable: i32)
-> (done: i32)
Take up to count packets off port into into, waiting up to milliseconds, or infinite, for the first, GetQueuedCompletionStatusEx: nonzero with how many in taken, or zero with the reason in last_error, WAIT_TIMEOUT when none came. alertable zero.
When compiler.os == windows
public extern(c) link(symbol: "GetConsoleMode") get_console_mode:
(console: handle, mode: ptr mut u32) -> (done: i32)
The mode of a console handle, GetConsoleMode: nonzero for a console, zero with the reason in last_error for anything else.
When compiler.os == windows
public extern(c) link(symbol: "GetFileAttributesW") get_file_attributes:
(name: ptr u16) -> (attributes: u32)
A path's attribute bits, GetFileAttributesW, or invalid_attributes with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetFileAttributesExW") get_file_attributes_ex:
(name: ptr u16, level: u32, found: ptr mut attribute_data)
-> (done: i32)
Fill found with a path's attributes, times and size, not following a link it ends in, GetFileAttributesExW with GetFileExInfoStandard: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetFileInformationByHandle") get_file_information:
(opened: handle, found: ptr mut file_information) -> (done: i32)
Fill found with what the system keeps of opened, GetFileInformationByHandle: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetStdHandle") get_std_handle:
(which: u32) -> (result: handle)
One of the process's standard handles, GetStdHandle: the handle, no_handle when the process has none, or invalid_handle with the reason in last_error.
When compiler.os == windows
public host_length: (units: []u16) -> (length: usize)
How many bytes to_host writes for units.
When compiler.os == windows
public extern(c) link(symbol: "InitializeProcThreadAttributeList") initialize_attributes:
(list: usize, count: u32, flags: u32, size: ptr mut usize)
-> (done: i32)
Make an attribute list for count attributes in list's size bytes, InitializeProcThreadAttributeList; with list zero it puts the size it needs in size and fails.
When compiler.os == windows
public extern(c) link(symbol: "GetLastError") last_error: () -> (code: u32)
The reason the calling thread's last failing call gave, GetLastError: a Win32 error code, zero for none. Read it at once after the call that failed, before any other.
When compiler.os == windows
public extern(c) link(symbol: "MoveFileExW") move_file:
(old: ptr u16, new: ptr u16, flags: u32) -> (done: i32)
Rename old to new, MoveFileExW: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "GetOverlappedResult") overlapped_result:
(opened: handle, record: ptr mut overlapped, moved: ptr mut u32,
wait: i32) -> (done: i32)
How an overlapped call on opened ended, GetOverlappedResult: the bytes it moved in moved, waiting for it when wait is nonzero.
When compiler.os == windows
public extern(c) link(symbol: "PeekNamedPipe") peek_named_pipe:
(pipe: handle, into: usize, size: u32, read: usize,
available: ptr mut u32, left: usize) -> (done: i32)
What is waiting in the pipe pipe, without reading it, PeekNamedPipe: the bytes available in available.
When compiler.os == windows
public extern(c) link(symbol: "QueryPerformanceCounter") performance_counter: (into: ptr mut i64) -> (done: i32)
The performance counter, QueryPerformanceCounter: ticks since the system started, which never go back, at performance_frequency a second. It never fails on a system that runs Windows 10 or later.
When compiler.os == windows
public extern(c) link(symbol: "QueryPerformanceFrequency") performance_frequency: (into: ptr mut i64) -> (done: i32)
The performance counter's ticks a second, QueryPerformanceFrequency, fixed while the system runs.
When compiler.os == windows
public extern(c) link(symbol: "PostQueuedCompletionStatus") post_completion:
(port: handle, moved: u32, key: usize, record: usize) -> (done: i32)
Put a packet of the caller's on port, PostQueuedCompletionStatus.
When compiler.os == windows
public extern(c) link(symbol: "GetProcessId") process_id_of:
(process: handle) -> (id: u32)
The process process's ID, GetProcessId.
When compiler.os == windows
public extern(c) link(symbol: "BCryptGenRandom") random:
(algorithm: usize, into: ptr mut u8, count: u32, flags: u32)
-> (status: i32)
Fill count bytes at into from the system's random generator, which is fit for keys, BCryptGenRandom: zero, or an NTSTATUS that says why it did not.
When compiler.os == windows
public extern(c) link(symbol: "ReadFile") read_file:
(source: handle, into: ptr mut u8, count: u32, got: ptr mut u32,
overlapped: usize) -> (done: i32)
Read up to count bytes from source into into, ReadFile, without overlapping: nonzero with the count read in got, zero at the end of a file, or zero with the reason in last_error. overlapped is zero or an overlapped record's address for a handle opened to overlap.
When compiler.os == windows
public extern(c) link(symbol: "RemoveDirectoryW") remove_directory:
(name: ptr u16) -> (done: i32)
Remove the empty directory name names, RemoveDirectoryW.
When compiler.os == windows
public extern(c) link(symbol: "GenerateConsoleCtrlEvent") send_control_event:
(event: u32, group: u32) -> (done: i32)
Send event to the processes of the console's process group group, every process on the console when zero, GenerateConsoleCtrlEvent.
When compiler.os == windows
public extern(c) link(symbol: "SetConsoleCtrlHandler") set_control_handler:
(routine: usize, add: i32) -> (done: i32)
Add the routine at routine, a control_handler, to the process's control handlers when add is nonzero, or remove it, SetConsoleCtrlHandler. With routine zero it sets whether the process ignores Ctrl+C, which it does when add is nonzero: a process a parent started in a new process group begins ignoring it, and a child inherits the setting.
When compiler.os == windows
public extern(c) link(symbol: "SetFileAttributesW") set_file_attributes:
(name: ptr u16, attributes: u32) -> (done: i32)
Set a path's attribute bits, SetFileAttributesW: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "SetFileInformationByHandle") set_file_information:
(opened: handle, class: u32, information: usize, size: u32)
-> (done: i32)
Set what the information class class says of opened from the size bytes at information, SetFileInformationByHandle.
When compiler.os == windows
public extern(c) link(symbol: "SetFilePointerEx") set_file_pointer:
(opened: handle, distance: i64, moved: usize, method: u32)
-> (done: i32)
Move opened's position by distance from where method says, SetFilePointerEx; the new position goes to the i64 at moved unless it is zero.
When compiler.os == windows
public extern(c) link(symbol: "SetHandleInformation") set_handle_information:
(object: handle, mask: u32, flags: u32) -> (done: i32)
Set the flags mask selects of object to flags, SetHandleInformation.
When compiler.os == windows
public extern(c) link(symbol: "SetInformationJobObject") set_job:
(job: handle, class: u32, information: usize, size: u32)
-> (done: i32)
Set what the class class says of job from the size bytes at information, SetInformationJobObject.
When compiler.os == windows
public extern(c) link(symbol: "Sleep") sleep: (milliseconds: u32) -> none
Give up the processor for at least milliseconds, Sleep; zero gives up the rest of the thread's turn.
When compiler.os == windows
public extern(c) link(symbol: "GetSystemTimePreciseAsFileTime") system_time: (into: ptr mut file_time) -> none
The wall clock, GetSystemTimePreciseAsFileTime: hundreds of nanoseconds since 1601 in UTC, as precise as the system keeps it.
When compiler.os == windows
public terminate: (name: text.os_string, room: []mut u16)
-> (terminated: ptr u16 from room) ! name_failure
Copy name into room as units with a NUL after them, for a call that takes a terminated wide string, and return the first unit's address: bad_name for a name holding a NUL or bytes WTF-8 does not encode, name_too_long when it and its NUL do not fit.
When compiler.os == windows
public to_host: (units: []u16, into: []mut u8) -> (count: usize)
Write units as WTF-8 into into, which has room for host_length bytes of them, and return how many it wrote.
When compiler.os == windows
public to_units: (bytes: []u8, into: []mut u16) -> (count: usize)
! name_failure
Write the units of the WTF-8 bytes into into and return how many: bad_name for bytes WTF-8 does not encode or a NUL, name_too_long when they do not fit.
When compiler.os == windows
public extern(c) link(symbol: "UpdateProcThreadAttribute") update_attribute:
(list: usize, flags: u32, attribute: usize, value: usize, size: usize,
previous: usize, returned: usize) -> (done: i32)
Set the attribute attribute of list to the size bytes at value, UpdateProcThreadAttribute, which value must outlive.
When compiler.os == windows
public variable: (table: environment_table, index: usize)
-> (item: text.os_variable from table)
The variable at index, from zero: the units of its entry before the first = after its first unit as its name and those after it as its value, so that a hidden =C: entry is named =C:. An index at or past the table's count traps.
When compiler.os == windows
public extern(c) link(symbol: "VirtualAlloc") virtual_alloc:
(wanted: usize, size: usize, kind: u32, protection: u32)
-> (address: usize)
Reserve and commit size bytes of the address space, readable and writable and zeroed, VirtualAlloc with MEM_RESERVE | MEM_COMMIT and PAGE_READWRITE: their address, or zero with the reason in last_error. wanted is zero or the address to place them at.
When compiler.os == windows
public extern(c) link(symbol: "VirtualFree") virtual_free:
(address: usize, size: usize, kind: u32) -> (done: i32)
Release, MEM_RELEASE with a size of zero, or decommit what virtual_alloc gave, VirtualFree: nonzero, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "VirtualQuery") virtual_query:
(address: usize, into: ptr mut memory_information, bytes: usize)
-> (written: usize)
Describe the pages at address, VirtualQuery, into into: the bytes written, or zero with the reason in last_error.
When compiler.os == windows
public extern(c) link(symbol: "WaitForSingleObject") wait_for:
(object: handle, milliseconds: u32) -> (result: u32)
Wait up to milliseconds, or infinite, for object to be signalled, WaitForSingleObject.
When compiler.os == windows
public extern(c) link(symbol: "WaitForMultipleObjects") wait_for_any:
(count: u32, objects: ptr handle, all: i32, milliseconds: u32)
-> (result: u32)
Wait up to milliseconds for any of the count objects at objects, or all of them when all is nonzero, WaitForMultipleObjects: the answer is wait_object_0 plus the first signalled one's index.
When compiler.os == windows
public extern(c) link(symbol: "WaitOnAddress") wait_on_address:
(address: usize, compare: usize, size: usize, milliseconds: u32)
-> (woken: i32)
Sleep while the size bytes at address equal those at compare, WaitOnAddress, for at most milliseconds: nonzero when woken or when they already differ, zero with ERROR_TIMEOUT in last_error. The system compares and sleeps in one step, so a wake after a change is never lost; it may also return with nobody having woken it. size is 1, 2, 4 or 8.
When compiler.os == windows
public extern(c) link(symbol: "WakeByAddressSingle") wake_by_address_single:
(address: usize) -> none
Wake one thread wait_on_address sleeps in on address, if any, WakeByAddressSingle.
When compiler.os == windows
public extern(c) link(symbol: "WriteFile") write_file:
(to: handle, bytes: ptr u8, count: u32, put: ptr mut u32,
overlapped: usize) -> (done: i32)
Write count bytes from bytes to to, WriteFile: nonzero with the count written in put, or zero with the reason in last_error.
Example program
This complete program is one of the compiler's runtime tests. View source.
public main: () -> (code: i32) = mut small: u8 = 254 + 1 small = small - 1 code = 40 + 2 code = code - 0 end main