# std/winlean

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:
Source Edit

This module implements a small wrapper for some needed Win API procedures, so that the Nim compiler does not depend on the huge Windows module.

# Imports

dynlib, syncio, widestrs

# Types

    AddrInfo {.importc: "ADDRINFOA", header: "ws2tcpip.h".} = object
      ai_flags*: cint            ## Input flags.
      ai_family*: cint           ## Address family of socket.
      ai_socktype*: cint         ## Socket type.
      ai_protocol*: cint         ## Protocol of socket.
      ai_addrlen*: csize_t       ## Length of socket address.
      ai_canonname*: cstring     ## Canonical name of service location.
      ai_addr*: ptr SockAddr     ## Socket address of socket.
      ai_next*: ptr AddrInfo     ## Pointer to next in list.

  Source Edit

    BY_HANDLE_FILE_INFORMATION = object
      dwFileAttributes*: DWORD
      ftCreationTime*: FILETIME
      ftLastAccessTime*: FILETIME
      ftLastWriteTime*: FILETIME
      dwVolumeSerialNumber*: DWORD
      nFileSizeHigh*: DWORD
      nFileSizeLow*: DWORD
      nNumberOfLinks*: DWORD
      nFileIndexHigh*: DWORD
      nFileIndexLow*: DWORD

  Source Edit

    BYTE = uint8

  Source Edit

    DWORD = int32

  Source Edit

    FILETIME = object
      dwLowDateTime*: DWORD
      dwHighDateTime*: DWORD

  CANNOT BE int64 BECAUSE OF ALIGNMENT Source Edit

    GUID = object
      D1*: int32
      D2*: int16
      D3*: int16
      D4*: array[0 .. 7, int8]

  Source Edit

    Handle = int

  Source Edit

    HDC = Handle

  Source Edit

    HGLRC = Handle

  Source Edit

    Hostent = object
      h_name*: cstring
      h_aliases*: cstringArray
      h_addrtype*: int16
      h_length*: int16
      h_addr_list*: cstringArray

  Source Edit

    In6_addr {.importc: "IN6_ADDR", header: "winsock2.h".} = object
      bytes* {.importc: "u.Byte".}: array[0 .. 15, char]

  Source Edit

    InAddr {.importc: "IN_ADDR", header: "winsock2.h", union.} = object
      s_addr*: uint32

  Source Edit

    KEY_EVENT_RECORD = object
      eventType*: int16
      bKeyDown*: WINBOOL
      wRepeatCount*: int16
      wVirtualKeyCode*: int16
      wVirtualScanCode*: int16
      uChar*: int16
      dwControlKeyState*: DWORD

  Source Edit

    LONG = int32

  Source Edit

    LPFIBER_START_ROUTINE = proc (param: pointer) {.stdcall.}

  Source Edit

    LPFILETIME = ptr FILETIME

  Source Edit

    LPINT = ptr int32

  Source Edit

    OSVERSIONINFO = object
      dwOSVersionInfoSize*: DWORD
      dwMajorVersion*: DWORD
      dwMinorVersion*: DWORD
      dwBuildNumber*: DWORD
      dwPlatformId*: DWORD
      szCSDVersion*: array[0 .. 127, WinChar]

  Source Edit

    OVERLAPPED {.pure, inheritable.} = object
      internal*: PULONG
      internalHigh*: PULONG
      offset*: DWORD
      offsetHigh*: DWORD
      hEvent*: Handle

  Source Edit

    PBOOL = ptr WINBOOL

  Source Edit

    PDWORD = ptr DWORD

  Source Edit

    POVERLAPPED = ptr OVERLAPPED

  Source Edit

    POVERLAPPED_COMPLETION_ROUTINE = proc (para1: DWORD; para2: DWORD;
                                           para3: POVERLAPPED) {.stdcall.}

  Source Edit

    PROCESS_INFORMATION = object
      hProcess*: Handle
      hThread*: Handle
      dwProcessId*: int32
      dwThreadId*: int32

  Source Edit

    Protoent = object
      p_name*: cstring
      p_aliases*: cstringArray
      p_proto*: cshort

  Source Edit

    PSID = ptr SID

  Source Edit

    PULONG = ptr int

  Source Edit

    PULONG_PTR = ptr uint

  Source Edit

    PWOHandleArray = ptr WOHandleArray

  Source Edit

    SECURITY_ATTRIBUTES = object
      nLength*: int32
      lpSecurityDescriptor*: pointer
      bInheritHandle*: WINBOOL

  Source Edit

    Servent = object
      s_name*: cstring
      s_aliases*: cstringArray
      when defined(cpu64):
        s_proto*: cstring
        s_port*: int16
      else:
        s_port*: int16
        s_proto*: cstring

  Source Edit

    SID {.importc, header: "<windows.h>".} = object

  Source Edit

    SID_IDENTIFIER_AUTHORITY {.importc, header: "<windows.h>".} = object
      value* {.importc: "Value".}: array[6, BYTE]

  Source Edit

    SockAddr {.importc: "SOCKADDR", header: "winsock2.h".} = object
      sa_family*: uint16
      sa_data*: array[0 .. 13, char]

  Source Edit

    Sockaddr_in {.importc: "SOCKADDR_IN", header: "winsock2.h".} = object
      sin_family*: uint16
      sin_port*: uint16
      sin_addr*: InAddr
      sin_zero*: array[0 .. 7, char]

  Source Edit

    Sockaddr_in6 {.importc: "SOCKADDR_IN6", header: "ws2tcpip.h".} = object
      sin6_family*: uint16
      sin6_port*: uint16
      sin6_flowinfo*: int32
      sin6_addr*: In6_addr
      sin6_scope_id*: int32

  Source Edit

    Sockaddr_storage {.importc: "SOCKADDR_STORAGE", header: "winsock2.h".} = object
      ss_family*: uint16

  Source Edit

    SocketHandle = distinct int

  Source Edit

    SockLen = cuint

  Source Edit

    STARTUPINFO = object
      cb*: int32
      lpReserved*: cstring
      lpDesktop*: cstring
      lpTitle*: cstring
      dwX*: int32
      dwY*: int32
      dwXSize*: int32
      dwYSize*: int32
      dwXCountChars*: int32
      dwYCountChars*: int32
      dwFillAttribute*: int32
      dwFlags*: int32
      wShowWindow*: int16
      cbReserved2*: int16
      lpReserved2*: pointer
      hStdInput*: Handle
      hStdOutput*: Handle
      hStdError*: Handle

  Source Edit

    TFdSet = object
      fd_count*: cint
      fd_array*: array[0 .. 64 - 1, SocketHandle]

  Source Edit

    Timeval {.importc: "struct timeval", header: "<time.h>".} = object
      tv_sec*, tv_usec*: int32

  Source Edit

    TWSABuf {.importc: "WSABUF", header: "winsock2.h".} = object
      len*: ULONG
      buf*: cstring

  Source Edit

    ULONG = int32

  Source Edit

    ULONG_PTR = uint

  Source Edit

    WAITORTIMERCALLBACK = proc (para1: pointer; para2: int32) {.stdcall.}

  Source Edit

    WIN32_FIND_DATA {.pure.} = object
      dwFileAttributes*: int32
      ftCreationTime*: FILETIME
      ftLastAccessTime*: FILETIME
      ftLastWriteTime*: FILETIME
      nFileSizeHigh*: int32
      nFileSizeLow*: int32
      cFileName*: array[0 .. 260 - 1, WinChar]
      cAlternateFileName*: array[0 .. 13, WinChar]

  Source Edit

    WINBOOL = int32

  `WINBOOL` uses opposite convention as posix, !=0 meaning success. Source Edit

    WinChar = Utf16Char

  Source Edit

    WinSizeT = uint64

  Source Edit

    WOHandleArray = array[0 .. 0x00000040 - 1, Handle]

  Source Edit

    WSAData {.importc: "WSADATA", header: "winsock2.h".} = object

  Source Edit

    WSAPROC_ACCEPTEX = proc (sListenSocket: SocketHandle;
                             sAcceptSocket: SocketHandle; lpOutputBuffer: pointer;
                             dwReceiveDataLength: DWORD;
                             dwLocalAddressLength: DWORD;
                             dwRemoteAddressLength: DWORD;
                             lpdwBytesReceived: ptr DWORD; lpOverlapped: POVERLAPPED): bool {.
        stdcall, ...gcsafe, raises: [].}

  Source Edit

    WSAPROC_CONNECTEX = proc (s: SocketHandle; name: ptr SockAddr; namelen: cint;
                              lpSendBuffer: pointer; dwSendDataLength: DWORD;
                              lpdwBytesSent: ptr DWORD; lpOverlapped: POVERLAPPED): bool {.
        stdcall, ...gcsafe, raises: [].}

  Source Edit

    WSAPROC_GETACCEPTEXSOCKADDRS = proc (lpOutputBuffer: pointer;
                                         dwReceiveDataLength: DWORD;
                                         dwLocalAddressLength: DWORD;
                                         dwRemoteAddressLength: DWORD;
                                         LocalSockaddr: ptr PSockAddr;
                                         LocalSockaddrLength: ptr cint;
                                         RemoteSockaddr: ptr PSockAddr;
                                         RemoteSockaddrLength: ptr cint) {.stdcall,
        ...gcsafe, raises: [].}

  Source Edit

# Vars

    INVALID_SOCKET {.importc, header: "winsock2.h".}: SocketHandle

  Source Edit

    SO_ACCEPTCONN {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_BROADCAST {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_DEBUG {.importc, header: "winsock2.h".}: cint

  turn on debugging info recording Source Edit

    SO_DONTLINGER {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_DONTROUTE {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_ERROR {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_EXCLUSIVEADDRUSE {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_KEEPALIVE {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_LINGER {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_OOBINLINE {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_REUSEADDR {.importc, header: "winsock2.h".}: cint

  Source Edit

    SO_REUSEPORT {.importc: "SO_REUSEADDR", header: "winsock2.h".}: cint

  Source Edit

    SO_USELOOPBACK {.importc, header: "winsock2.h".}: cint

  Source Edit

    SOL_SOCKET {.importc, header: "winsock2.h".}: cint

  Source Edit

    SOMAXCONN {.importc, header: "winsock2.h".}: cint

  Source Edit

    TCP_NODELAY {.importc, header: "winsock2.h".}: cint

  Source Edit

    WSAID_ACCEPTEX: GUID = GUID(D1: 0xB5367DF1'i32, D2: 0xCBAC'i16, D3: 0x000011CF, D4: [
        0x95'i8, 0xCA'i8, 0x00'i8, 0x80'i8, 0x5F'i8, 0x48'i8, 0xA1'i8, 0x92'i8])

  Source Edit

    WSAID_CONNECTEX: GUID = GUID(D1: 0x25A207B9, D2: 0xDDF3'i16, D3: 0x00004660, D4: [
        0x8E'i8, 0xE9'i8, 0x76'i8, 0xE5'i8, 0x8C'i8, 0x74'i8, 0x06'i8, 0x3E'i8])

  Source Edit

    WSAID_GETACCEPTEXSOCKADDRS: GUID = GUID(D1: 0xB5367DF2'i32, D2: 0xCBAC'i16,
                                            D3: 0x000011CF, D4: [0x95'i8, 0xCA'i8,
        0x00'i8, 0x80'i8, 0x5F'i8, 0x48'i8, 0xA1'i8, 0x92'i8])

  Source Edit

# Consts

    AF_INET = 2

  Source Edit

    AF_INET6 = 23

  Source Edit

    AF_UNSPEC = 0

  Source Edit

    AI_V4MAPPED = 0x00000008

  Source Edit

    CREATE_ALWAYS = 2'i32

  Source Edit

    CREATE_NEW = 1'i32

  Source Edit

    CREATE_NO_WINDOW = 0x08000000'i32

  Source Edit

    CREATE_UNICODE_ENVIRONMENT = 1024'i32

  Source Edit

    DETACHED_PROCESS = 8'i32

  Source Edit

    DOMAIN_ALIAS_RID_ADMINS = 544

  Source Edit

    DUPLICATE_SAME_ACCESS = 2

  Source Edit

    ERROR_ACCESS_DENIED = 5

  Source Edit

    ERROR_BAD_ARGUMENTS = 165

  Source Edit

    ERROR_FILE_EXISTS = 80

  Source Edit

    ERROR_FILE_NOT_FOUND = 2

  https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- Source Edit

    ERROR_HANDLE_EOF = 38

  Source Edit

    ERROR_IO_PENDING = 997

  Source Edit

    ERROR_LOCK_VIOLATION = 33

  Source Edit

    ERROR_NETNAME_DELETED = 64

  Source Edit

    ERROR_NO_MORE_FILES = 18

  Source Edit

    ERROR_PATH_NOT_FOUND = 3

  Source Edit

    FD_ACCEPT = 0x00000008'i32

  Source Edit

    FD_ADDRESS_LIST_CHANGE = 0x00000200'i32

  Source Edit

    FD_ALL_EVENTS = 0x000003FF'i32

  Source Edit

    FD_CLOSE = 0x00000020'i32

  Source Edit

    FD_CONNECT = 0x00000010'i32

  Source Edit

    FD_GROUP_QQS = 0x00000080'i32

  Source Edit

    FD_OOB = 0x00000004'i32

  Source Edit

    FD_QQS = 0x00000040'i32

  Source Edit

    FD_READ = 0x00000001'i32

  Source Edit

    FD_ROUTING_INTERFACE_CHANGE = 0x00000100'i32

  Source Edit

    FD_SETSIZE = 64

  Source Edit

    FD_WRITE = 0x00000002'i32

  Source Edit

    FIBER_FLAG_FLOAT_SWITCH = 0x00000001

  Source Edit

    FILE_ATTRIBUTE_ARCHIVE = 0x00000020'i32

  Source Edit

    FILE_ATTRIBUTE_COMPRESSED = 0x00000800'i32

  Source Edit

    FILE_ATTRIBUTE_DEVICE = 0x00000040'i32

  Source Edit

    FILE_ATTRIBUTE_DIRECTORY = 0x00000010'i32

  Source Edit

    FILE_ATTRIBUTE_HIDDEN = 0x00000002'i32

  Source Edit

    FILE_ATTRIBUTE_NORMAL = 0x00000080'i32

  Source Edit

    FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000'i32

  Source Edit

    FILE_ATTRIBUTE_OFFLINE = 0x00001000'i32

  Source Edit

    FILE_ATTRIBUTE_READONLY = 0x00000001'i32

  Source Edit

    FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400'i32

  Source Edit

    FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200'i32

  Source Edit

    FILE_ATTRIBUTE_SYSTEM = 0x00000004'i32

  Source Edit

    FILE_ATTRIBUTE_TEMPORARY = 0x00000100'i32

  Source Edit

    FILE_BEGIN = 0'i32

  Source Edit

    FILE_FLAG_BACKUP_SEMANTICS = 0x02000000'i32

  Source Edit

    FILE_FLAG_DELETE_ON_CLOSE = 0x04000000'i32

  Source Edit

    FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000'i32

  Source Edit

    FILE_FLAG_NO_BUFFERING = 0x20000000'i32

  Source Edit

    FILE_FLAG_OPEN_NO_RECALL = 0x00100000'i32

  Source Edit

    FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000'i32

  Source Edit

    FILE_FLAG_OVERLAPPED = 0x40000000'i32

  Source Edit

    FILE_FLAG_POSIX_SEMANTICS = 0x01000000'i32

  Source Edit

    FILE_FLAG_RANDOM_ACCESS = 0x10000000'i32

  Source Edit

    FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000'i32

  Source Edit

    FILE_FLAG_WRITE_THROUGH = 0x80000000'i32

  Source Edit

    FILE_MAP_READ = 4'i32

  Source Edit

    FILE_MAP_WRITE = 2'i32

  Source Edit

    FILE_READ_DATA = 0x00000001

  Source Edit

    FILE_SHARE_DELETE = 4'i32

  Source Edit

    FILE_SHARE_READ = 1'i32

  Source Edit

    FILE_SHARE_WRITE = 2'i32

  Source Edit

    FILE_WRITE_DATA = 0x00000002

  Source Edit

    GENERIC_ALL = 0x10000000'i32

  Source Edit

    GENERIC_READ = 0x80000000'i32

  Source Edit

    GENERIC_WRITE = 0x40000000'i32

  Source Edit

    HANDLE_FLAG_INHERIT = 0x00000001'i32

  Source Edit

    HIGH_PRIORITY_CLASS = 128'i32

  Source Edit

    IDLE_PRIORITY_CLASS = 64'i32

  Source Edit

    INADDR_ANY = 0'u32

  Source Edit

    INADDR_BROADCAST = -1

  Source Edit

    INADDR_LOOPBACK = 0x7F000001

  Source Edit

    INADDR_NONE = -1

  Source Edit

    INFINITE = -1'i32

  Source Edit

    INVALID_FILE_SIZE = -1'i32

  Source Edit

    INVALID_HANDLE_VALUE = -1

  Source Edit

    INVALID_SET_FILE_POINTER = -1'i32

  Source Edit

    IOC_IN = 0x80000000'i32

  Source Edit

    IOC_INOUT = -1073741824'i32

  Source Edit

    IOC_OUT = 0x40000000'i32

  Source Edit

    IOC_WS2 = 0x08000000'i32

  Source Edit

    MAX_PATH = 260

  Source Edit

    MAXIMUM_WAIT_OBJECTS = 0x00000040

  Source Edit

    MOVEFILE_COPY_ALLOWED = 0x00000002'i32

  Source Edit

    MOVEFILE_CREATE_HARDLINK = 0x00000010'i32

  Source Edit

    MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004'i32

  Source Edit

    MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020'i32

  Source Edit

    MOVEFILE_REPLACE_EXISTING = 0x00000001'i32

  Source Edit

    MOVEFILE_WRITE_THROUGH = 0x00000008'i32

  Source Edit

    MSG_PEEK = 2

  Source Edit

    NO_ERROR = 0'i32

  Source Edit

    NORMAL_PRIORITY_CLASS = 32'i32

  Source Edit

    OPEN_ALWAYS = 4'i32

  Source Edit

    OPEN_EXISTING = 3'i32

  Source Edit

    PAGE_EXECUTE = 0x00000010'i32

  Source Edit

    PAGE_EXECUTE_READ = 0x00000020'i32

  Source Edit

    PAGE_EXECUTE_READWRITE = 0x00000040'i32

  Source Edit

    PAGE_NOACCESS = 0x00000001'i32

  Source Edit

    PAGE_READONLY = 2'i32

  Source Edit

    PAGE_READWRITE = 4'i32

  Source Edit

    PIPE_ACCESS_DUPLEX = 0x00000003'i32

  Source Edit

    PIPE_ACCESS_INBOUND = 1'i32

  Source Edit

    PIPE_ACCESS_OUTBOUND = 2'i32

  Source Edit

    PIPE_NOWAIT = 0x00000001'i32

  Source Edit

    PROCESS_CREATE_PROCESS = 0x00000080'i32

  Source Edit

    PROCESS_CREATE_THREAD = 0x00000002'i32

  Source Edit

    PROCESS_DUP_HANDLE = 0x00000040'i32

  Source Edit

    PROCESS_QUERY_INFORMATION = 0x00000400'i32

  Source Edit

    PROCESS_QUERY_LIMITED_INFORMATION = 0x00001000'i32

  Source Edit

    PROCESS_SET_INFORMATION = 0x00000200'i32

  Source Edit

    PROCESS_SET_LIMITED_INFORMATION = 0x00002000'i32

  Source Edit

    PROCESS_SET_QUOTA = 0x00000100'i32

  Source Edit

    PROCESS_SET_SESSIONID = 0x00000004'i32

  Source Edit

    PROCESS_SUSPEND_RESUME = 0x00000800'i32

  Source Edit

    PROCESS_TERMINATE = 0x00000001'i32

  Source Edit

    PROCESS_VM_OPERATION = 0x00000008'i32

  Source Edit

    PROCESS_VM_READ = 0x00000010'i32

  Source Edit

    PROCESS_VM_WRITE = 0x00000020'i32

  Source Edit

    REALTIME_PRIORITY_CLASS = 256'i32

  Source Edit

    SECURITY_BUILTIN_DOMAIN_RID = 32

  Source Edit

    SECURITY_NT_AUTHORITY = [0'u, 0'u, 0'u, 0'u, 0'u, 5'u]

  Source Edit

    SIO_GET_EXTENSION_FUNCTION_POINTER = -939524090'i32

  Source Edit

    SO_UPDATE_ACCEPT_CONTEXT = 0x0000700B

  Source Edit

    STARTF_USESHOWWINDOW = 1'i32

  Source Edit

    STARTF_USESTDHANDLES = 256'i32

  Source Edit

    STATUS_PENDING = 0x00000103

  Source Edit

    STD_ERROR_HANDLE = -12'i32

  Source Edit

    STD_INPUT_HANDLE = -10'i32

  Source Edit

    STD_OUTPUT_HANDLE = -11'i32

  Source Edit

    STILL_ACTIVE = 0x00000103'i32

  Source Edit

    SW_SHOWNORMAL = 1'i32

  Source Edit

    SYNCHRONIZE = 0x00100000'i32

  Source Edit

    WAIT_FAILED = 0xFFFFFFFF'i32

  Source Edit

    WAIT_OBJECT_0 = 0'i32

  Source Edit

    WAIT_TIMEOUT = 0x00000102'i32

  Source Edit

    WSADESCRIPTION_LEN = 256

  Source Edit

    WSAEADDRINUSE = 10048

  Source Edit

    WSAECONNABORTED = 10053

  Source Edit

    WSAECONNRESET = 10054

  Source Edit

    WSAEDISCON = 10101

  Source Edit

    WSAEINPROGRESS = 10036

  Source Edit

    WSAEINTR = 10004

  Source Edit

    WSAENETRESET = 10052

  Source Edit

    WSAENOTSOCK = 10038

  Source Edit

    WSAESHUTDOWN = 10058

  Source Edit

    WSAETIMEDOUT = 10060

  Source Edit

    WSAEWOULDBLOCK = 10035

  Source Edit

    WSANOTINITIALISED = 10093

  Source Edit

    WSASYS_STATUS_LEN = 128

  Source Edit

    WT_EXECUTEDEFAULT = 0x00000000'i32

  Source Edit

    WT_EXECUTEINIOTHREAD = 0x00000001'i32

  Source Edit

    WT_EXECUTEINPERSISTENTIOTHREAD = 0x00000040'i32

  Source Edit

    WT_EXECUTEINPERSISTENTTHREAD = 0x00000080'i32

  Source Edit

    WT_EXECUTEINTIMERTHREAD = 0x00000020'i32

  Source Edit

    WT_EXECUTEINUITHREAD = 0x00000002'i32

  Source Edit

    WT_EXECUTEINWAITTHREAD = 0x00000004'i32

  Source Edit

    WT_EXECUTELONGFUNCTION = 0x00000010'i32

  Source Edit

    WT_EXECUTEONLYONCE = 0x00000008'i32

  Source Edit

    WT_TRANSFER_IMPERSONATION = 0x00000100'i32

  Source Edit

# Procs

    proc `==`(x, y: SocketHandle): bool {.borrow, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc accept(s: SocketHandle; a: ptr SockAddr; addrlen: ptr SockLen): SocketHandle {.
        stdcall, importc: "accept", dynlib: ws2dll, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc allocateAndInitializeSid(pIdentifierAuthority: ptr SID_IDENTIFIER_AUTHORITY;
                                  nSubAuthorityCount: BYTE; nSubAuthority0: DWORD;
                                  nSubAuthority1: DWORD; nSubAuthority2: DWORD;
                                  nSubAuthority3: DWORD; nSubAuthority4: DWORD;
                                  nSubAuthority5: DWORD; nSubAuthority6: DWORD;
                                  nSubAuthority7: DWORD; pSid: ptr PSID): WINBOOL {.
        stdcall, dynlib: "Advapi32", importc: "AllocateAndInitializeSid",
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc bindSocket(s: SocketHandle; name: ptr SockAddr; namelen: SockLen): cint {.
        stdcall, importc: "bind", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc checkTokenMembership(tokenHandle: Handle; sidToCheck: PSID; isMember: PBOOL): WINBOOL {.
        stdcall, dynlib: "Advapi32", importc: "CheckTokenMembership", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc closeHandle(hObject: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
        importc: "CloseHandle", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc closesocket(s: SocketHandle): cint {.stdcall, importc: "closesocket",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc connect(s: SocketHandle; name: ptr SockAddr; namelen: SockLen): cint {.
        stdcall, importc: "connect", dynlib: ws2dll, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc ConvertThreadToFiber(param: pointer): pointer {.stdcall, discardable,
        dynlib: "kernel32", importc, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc ConvertThreadToFiberEx(param: pointer; flags: int32): pointer {.stdcall,
        discardable, dynlib: "kernel32", importc, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc copyFileW(lpExistingFileName, lpNewFileName: WideCString;
                   bFailIfExists: WINBOOL): WINBOOL {.importc: "CopyFileW", stdcall,
        dynlib: "kernel32", sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createDirectoryW(pathName: WideCString; security: pointer = nil): int32 {.
        importc: "CreateDirectoryW", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createEvent(lpEventAttributes: ptr SECURITY_ATTRIBUTES;
                     bManualReset: DWORD; bInitialState: DWORD;
                     lpName: ptr Utf16Char): Handle {.stdcall, dynlib: "kernel32",
        importc: "CreateEventW", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc CreateFiber(stackSize: int; fn: LPFIBER_START_ROUTINE; param: pointer): pointer {.
        stdcall, discardable, dynlib: "kernel32", importc, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc CreateFiberEx(stkCommit: int; stkReserve: int; flags: int32;
                       fn: LPFIBER_START_ROUTINE; param: pointer): pointer {.
        stdcall, discardable, dynlib: "kernel32", importc, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc createFileA(lpFileName: cstring; dwDesiredAccess, dwShareMode: DWORD;
                     lpSecurityAttributes: pointer;
                     dwCreationDisposition, dwFlagsAndAttributes: DWORD;
                     hTemplateFile: Handle): Handle {.stdcall, dynlib: "kernel32",
        importc: "CreateFileA", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createFileMappingW(hFile: Handle; lpFileMappingAttributes: pointer;
                            flProtect, dwMaximumSizeHigh: DWORD;
                            dwMaximumSizeLow: DWORD; lpName: pointer): Handle {.
        stdcall, dynlib: "kernel32", importc: "CreateFileMappingW", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc createFileW(lpFileName: WideCString; dwDesiredAccess, dwShareMode: DWORD;
                     lpSecurityAttributes: pointer;
                     dwCreationDisposition, dwFlagsAndAttributes: DWORD;
                     hTemplateFile: Handle): Handle {.stdcall, dynlib: "kernel32",
        importc: "CreateFileW", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createHardLinkW(lpFileName, lpExistingFileName: WideCString;
                         security: pointer = nil): int32 {.
        importc: "CreateHardLinkW", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createIoCompletionPort(FileHandle: Handle; ExistingCompletionPort: Handle;
                                CompletionKey: ULONG_PTR;
                                NumberOfConcurrentThreads: DWORD): Handle {.stdcall,
        dynlib: "kernel32", importc: "CreateIoCompletionPort", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc createNamedPipe(lpName: WideCString; dwOpenMode, dwPipeMode, nMaxInstances,
        nOutBufferSize, nInBufferSize, nDefaultTimeOut: int32;
                         lpSecurityAttributes: ptr SECURITY_ATTRIBUTES): Handle {.
        stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createPipe(hReadPipe, hWritePipe: var Handle;
                    lpPipeAttributes: var SECURITY_ATTRIBUTES; nSize: int32): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "CreatePipe", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc createProcessW(lpApplicationName, lpCommandLine: WideCString;
                        lpProcessAttributes: ptr SECURITY_ATTRIBUTES;
                        lpThreadAttributes: ptr SECURITY_ATTRIBUTES;
                        bInheritHandles: WINBOOL; dwCreationFlags: int32;
                        lpEnvironment, lpCurrentDirectory: WideCString;
                        lpStartupInfo: var STARTUPINFO;
                        lpProcessInformation: var PROCESS_INFORMATION): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "CreateProcessW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc createSymbolicLinkW(lpSymlinkFileName, lpTargetFileName: WideCString;
                             flags: DWORD): int32 {.importc: "CreateSymbolicLinkW",
        dynlib: "kernel32", stdcall, sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc DeleteFiber(fiber: pointer) {.stdcall, discardable, dynlib: "kernel32",
                                       importc, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc deleteFileA(pathName: cstring): int32 {.importc: "DeleteFileA",
        dynlib: "kernel32", stdcall, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc deleteFileW(pathName: WideCString): int32 {.importc: "DeleteFileW",
        dynlib: "kernel32", stdcall, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc duplicateHandle(hSourceProcessHandle: Handle; hSourceHandle: Handle;
                         hTargetProcessHandle: Handle; lpTargetHandle: ptr Handle;
                         dwDesiredAccess: DWORD; bInheritHandle: WINBOOL;
                         dwOptions: DWORD): WINBOOL {.stdcall, dynlib: "kernel32",
        importc: "DuplicateHandle", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc FD_ISSET(socket: SocketHandle; set: var TFdSet): cint {....raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc FD_SET(socket: SocketHandle; s: var TFdSet) {....raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc FD_ZERO(s: var TFdSet) {....raises: [], tags: [], forbids: [].}

  Source Edit

    proc findClose(hFindFile: Handle) {.stdcall, dynlib: "kernel32",
                                        importc: "FindClose", ...raises: [], tags: [],
                                        forbids: [].}

  Source Edit

    proc findFirstFileW(lpFileName: WideCString; lpFindFileData: var WIN32_FIND_DATA): Handle {.
        stdcall, dynlib: "kernel32", importc: "FindFirstFileW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc findNextFileW(hFindFile: Handle; lpFindFileData: var WIN32_FIND_DATA): int32 {.
        stdcall, dynlib: "kernel32", importc: "FindNextFileW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc flushFileBuffers(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
        importc: "FlushFileBuffers", sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc flushViewOfFile(lpBaseAddress: pointer; dwNumberOfBytesToFlush: DWORD): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "FlushViewOfFile", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc formatMessageW(dwFlags: int32; lpSource: pointer;
                        dwMessageId, dwLanguageId: int32; lpBuffer: pointer;
                        nSize: int32; arguments: pointer): int32 {.
        importc: "FormatMessageW", stdcall, dynlib: "kernel32", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc freeAddrInfo(ai: ptr AddrInfo) {.stdcall, importc: "freeaddrinfo",
                                          dynlib: ws2dll, ...raises: [], tags: [],
                                          forbids: [].}

  Source Edit

    proc freeEnvironmentStringsW(para1: WideCString): int32 {.stdcall,
        dynlib: "kernel32", importc: "FreeEnvironmentStringsW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc freeSid(pSid: PSID): PSID {.stdcall, dynlib: "Advapi32",
                                     importc: "FreeSid", ...raises: [], tags: [],
                                     forbids: [].}

  Source Edit

    proc get_osfhandle(fd: cint): Handle {.importc: "_get_osfhandle",
                                           header: "<io.h>", ...raises: [], tags: [],
                                           forbids: [].}

  Source Edit

    proc getaddrinfo(nodename, servname: cstring; hints: ptr AddrInfo;
                     res: var ptr AddrInfo): cint {.stdcall, importc: "getaddrinfo",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getCommandLineW(): WideCString {.importc: "GetCommandLineW", stdcall,
                                          dynlib: "kernel32", sideEffect,
                                          ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getCurrentDirectoryW(nBufferLength: int32; lpBuffer: WideCString): int32 {.
        importc: "GetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc GetCurrentFiber(): pointer {.stdcall, importc, header: "windows.h",
                                      ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getCurrentProcess(): Handle {.stdcall, dynlib: "kernel32",
                                       importc: "GetCurrentProcess", ...raises: [],
                                       tags: [], forbids: [].}

  Source Edit

    proc getEnvironmentStringsW(): WideCString {.stdcall, dynlib: "kernel32",
        importc: "GetEnvironmentStringsW", sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getExitCodeProcess(hProcess: Handle; lpExitCode: var int32): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getFileAttributesW(lpFileName: WideCString): int32 {.stdcall,
        dynlib: "kernel32", importc: "GetFileAttributesW", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getFileInformationByHandle(hFile: Handle; lpFileInformation: ptr BY_HANDLE_FILE_INFORMATION): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle",
        sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getFileSize(hFile: Handle; lpFileSizeHigh: ptr DWORD): DWORD {.stdcall,
        dynlib: "kernel32", importc: "GetFileSize", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getFullPathNameW(lpFileName: WideCString; nBufferLength: int32;
                          lpBuffer: WideCString; lpFilePart: var WideCString): int32 {.
        stdcall, dynlib: "kernel32", importc: "GetFullPathNameW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getHandleInformation(hObject: Handle; lpdwFlags: ptr DWORD): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetHandleInformation", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc gethostbyaddr(ip: ptr InAddr; len: cuint; theType: cint): ptr Hostent {.
        stdcall, importc: "gethostbyaddr", dynlib: ws2dll, sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc gethostbyname(name: cstring): ptr Hostent {.stdcall,
        importc: "gethostbyname", dynlib: ws2dll, sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc gethostname(hostname: cstring; len: cint): cint {.stdcall,
        importc: "gethostname", dynlib: ws2dll, sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getLastError(): int32 {.importc: "GetLastError", stdcall,
                                 dynlib: "kernel32", sideEffect, ...raises: [],
                                 tags: [], forbids: [].}

  Source Edit

    proc getModuleFileNameW(handle: Handle; buf: WideCString; size: int32): int32 {.
        importc: "GetModuleFileNameW", dynlib: "kernel32", stdcall, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getnameinfo(a1: ptr SockAddr; a2: SockLen; a3: cstring; a4: SockLen;
                     a5: cstring; a6: SockLen; a7: cint): cint {.stdcall,
        importc: "getnameinfo", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getOverlappedResult(hFile: Handle; lpOverlapped: POVERLAPPED;
                             lpNumberOfBytesTransferred: var DWORD; bWait: WINBOOL): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetOverlappedResult", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getpeername(s: SocketHandle; name: ptr SockAddr; namelen: ptr SockLen): cint {.
        stdcall, importc, dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getProcessTimes(hProcess: Handle; lpCreationTime, lpExitTime, lpKernelTime,
                                           lpUserTime: var FILETIME): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetProcessTimes", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getprotobyname(name: cstring): ptr Protoent {.stdcall,
        importc: "getprotobyname", dynlib: ws2dll, sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getprotobynumber(proto: cint): ptr Protoent {.stdcall,
        importc: "getprotobynumber", dynlib: ws2dll, sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getQueuedCompletionStatus(CompletionPort: Handle;
                                   lpNumberOfBytesTransferred: PDWORD;
                                   lpCompletionKey: PULONG_PTR;
                                   lpOverlapped: ptr POVERLAPPED;
                                   dwMilliseconds: DWORD): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "GetQueuedCompletionStatus", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getservbyname(name, proto: cstring): ptr Servent {.stdcall,
        importc: "getservbyname", dynlib: ws2dll, sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getservbyport(port: cint; proto: cstring): ptr Servent {.stdcall,
        importc: "getservbyport", dynlib: ws2dll, sideEffect, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getsockname(s: SocketHandle; name: ptr SockAddr; namelen: ptr SockLen): cint {.
        stdcall, importc: "getsockname", dynlib: ws2dll, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc getsockopt(s: SocketHandle; level, optname: cint; optval: pointer;
                    optlen: ptr SockLen): cint {.stdcall, importc: "getsockopt",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getStdHandle(nStdHandle: int32): Handle {.stdcall, dynlib: "kernel32",
        importc: "GetStdHandle", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getSystemTimeAsFileTime(lpSystemTimeAsFileTime: var FILETIME) {.
        importc: "GetSystemTimeAsFileTime", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime: var FILETIME) {.
        importc: "GetSystemTimePreciseAsFileTime", dynlib: "kernel32", stdcall,
        sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getSystemTimes(lpIdleTime, lpKernelTime, lpUserTime: var FILETIME): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "GetSystemTimes", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getVersion(): DWORD {.stdcall, dynlib: "kernel32", importc: "GetVersion",
                               sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc getVersionExA(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "GetVersionExA", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc getVersionExW(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "GetVersionExW", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc inet_addr(cp: cstring): uint32 {.stdcall, importc: "inet_addr",
                                          dynlib: ws2dll, ...raises: [], tags: [],
                                          forbids: [].}

  Source Edit

    proc inet_ntoa(i: InAddr): cstring {.stdcall, importc, dynlib: ws2dll,
                                         ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc inet_ntop(family: cint; paddr: pointer; pStringBuffer: cstring;
                   stringBufSize: int32): cstring {.stdcall, ...raises: [Exception],
        tags: [], forbids: [].}

  Source Edit

    proc isSuccess(a: WINBOOL): bool {.inline, ...raises: [], tags: [], forbids: [].}

  Returns true if `a != 0`. Windows uses a different convention than POSIX, where `a == 0` is commonly used on success. Source Edit

    proc listen(s: SocketHandle; backlog: cint): cint {.stdcall, importc: "listen",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc localFree(p: pointer) {.importc: "LocalFree", stdcall, dynlib: "kernel32",
                                 ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc mapViewOfFileEx(hFileMappingObject: Handle; dwDesiredAccess: DWORD;
                         dwFileOffsetHigh, dwFileOffsetLow: DWORD;
                         dwNumberOfBytesToMap: WinSizeT; lpBaseAddress: pointer): pointer {.
        stdcall, dynlib: "kernel32", importc: "MapViewOfFileEx", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc moveFileExW(lpExistingFileName, lpNewFileName: WideCString; flags: DWORD): WINBOOL {.
        importc: "MoveFileExW", stdcall, dynlib: "kernel32", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc moveFileW(lpExistingFileName, lpNewFileName: WideCString): WINBOOL {.
        importc: "MoveFileW", stdcall, dynlib: "kernel32", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc openProcess(dwDesiredAccess: DWORD; bInheritHandle: WINBOOL;
                     dwProcessId: DWORD): Handle {.stdcall, dynlib: "kernel32",
        importc: "OpenProcess", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc peekNamedPipe(hNamedPipe: Handle; lpBuffer: pointer = nil;
                       nBufferSize: int32 = 0; lpBytesRead: ptr int32 = nil;
                       lpTotalBytesAvail: ptr int32 = nil;
                       lpBytesLeftThisMessage: ptr int32 = nil): bool {.stdcall,
        dynlib: "kernel32", importc: "PeekNamedPipe", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc postQueuedCompletionStatus(CompletionPort: Handle;
                                    dwNumberOfBytesTransferred: DWORD;
                                    dwCompletionKey: ULONG_PTR;
                                    lpOverlapped: pointer): bool {.stdcall,
        dynlib: "kernel32", importc: "PostQueuedCompletionStatus", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc rdFileSize(f: WIN32_FIND_DATA): int64 {....raises: [], tags: [], forbids: [].}

  Source Edit

    proc rdFileTime(f: FILETIME): int64 {....raises: [], tags: [], forbids: [].}

  Source Edit

    proc readConsoleInput(hConsoleInput: Handle; lpBuffer: pointer; nLength: cint;
                          lpNumberOfEventsRead: ptr cint): cint {.stdcall,
        dynlib: "kernel32", importc: "ReadConsoleInputW", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc readFile(hFile: Handle; buffer: pointer; nNumberOfBytesToRead: int32;
                  lpNumberOfBytesRead: ptr int32; lpOverlapped: pointer): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "ReadFile", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc recv(s: SocketHandle; buf: pointer; len, flags: cint): cint {.stdcall,
        importc: "recv", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc recvfrom(s: SocketHandle; buf: cstring; len, flags: cint;
                  fromm: ptr SockAddr; fromlen: ptr SockLen): cint {.stdcall,
        importc: "recvfrom", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc registerWaitForSingleObject(phNewWaitObject: ptr Handle; hObject: Handle;
                                     Callback: WAITORTIMERCALLBACK;
                                     Context: pointer; dwMilliseconds: ULONG;
                                     dwFlags: ULONG): bool {.stdcall,
        dynlib: "kernel32", importc: "RegisterWaitForSingleObject", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc removeDirectoryW(lpPathName: WideCString): int32 {.
        importc: "RemoveDirectoryW", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc resumeThread(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
        importc: "ResumeThread", sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc select(nfds: cint; readfds, writefds, exceptfds: ptr TFdSet;
                timeout: ptr Timeval): cint {.stdcall, importc: "select",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc send(s: SocketHandle; buf: pointer; len, flags: cint): cint {.stdcall,
        importc: "send", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc sendto(s: SocketHandle; buf: pointer; len, flags: cint; to: ptr SockAddr;
                tolen: SockLen): cint {.stdcall, importc: "sendto", dynlib: ws2dll,
                                        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setCurrentDirectoryW(lpPathName: WideCString): int32 {.
        importc: "SetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setEndOfFile(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
        importc: "SetEndOfFile", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setEnvironmentVariableW(lpName, lpValue: WideCString): int32 {.stdcall,
        dynlib: "kernel32", importc: "SetEnvironmentVariableW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setEvent(hEvent: Handle): cint {.stdcall, dynlib: "kernel32",
                                          importc: "SetEvent", ...raises: [], tags: [],
                                          forbids: [].}

  Source Edit

    proc setFileAttributesW(lpFileName: WideCString; dwFileAttributes: int32): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "SetFileAttributesW", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setFilePointer(hFile: Handle; lDistanceToMove: LONG;
                        lpDistanceToMoveHigh: ptr LONG; dwMoveMethod: DWORD): DWORD {.
        stdcall, dynlib: "kernel32", importc: "SetFilePointer", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc setFileTime(hFile: Handle; lpCreationTime: LPFILETIME;
                     lpLastAccessTime: LPFILETIME; lpLastWriteTime: LPFILETIME): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "SetFileTime", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc setHandleInformation(hObject: Handle; dwMask: DWORD; dwFlags: DWORD): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "SetHandleInformation", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc setLastError(error: int32) {.importc: "SetLastError", stdcall,
                                      dynlib: "kernel32", sideEffect, ...raises: [],
                                      tags: [], forbids: [].}

  Source Edit

    proc setsockopt(s: SocketHandle; level, optname: cint; optval: pointer;
                    optlen: SockLen): cint {.stdcall, importc: "setsockopt",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc setStdHandle(nStdHandle: int32; hHandle: Handle): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "SetStdHandle", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc shellExecuteW(hwnd: Handle;
                       lpOperation, lpFile, lpParameters, lpDirectory: WideCString;
                       nShowCmd: int32): Handle {.stdcall, dynlib: "shell32.dll",
        importc: "ShellExecuteW", sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc shutdown(s: SocketHandle; how: cint): cint {.stdcall, importc: "shutdown",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc sleep(dwMilliseconds: int32) {.stdcall, dynlib: "kernel32",
                                        importc: "Sleep", sideEffect, ...raises: [],
                                        tags: [], forbids: [].}

  Source Edit

    proc socket(af, typ, protocol: cint): SocketHandle {.stdcall, importc: "socket",
        dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc suspendThread(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
        importc: "SuspendThread", sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc SwitchToFiber(fiber: pointer) {.stdcall, discardable, dynlib: "kernel32",
                                         importc, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc terminateProcess(hProcess: Handle; uExitCode: int): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "TerminateProcess", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc toFILETIME(t: int64): FILETIME {....raises: [], tags: [], forbids: [].}

  Convert the Windows file time timestamp `t` to `FILETIME`. Source Edit

    proc unmapViewOfFile(lpBaseAddress: pointer): WINBOOL {.stdcall,
        dynlib: "kernel32", importc: "UnmapViewOfFile", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc unregisterWait(WaitHandle: Handle): DWORD {.stdcall, dynlib: "kernel32",
        importc: "UnregisterWait", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc waitForMultipleObjects(nCount: DWORD; lpHandles: PWOHandleArray;
                                bWaitAll: WINBOOL; dwMilliseconds: DWORD): DWORD {.
        stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc waitForSingleObject(hHandle: Handle; dwMilliseconds: int32): int32 {.
        stdcall, dynlib: "kernel32", importc: "WaitForSingleObject", sideEffect,
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc writeFile(hFile: Handle; buffer: pointer; nNumberOfBytesToWrite: int32;
                   lpNumberOfBytesWritten: ptr int32; lpOverlapped: pointer): WINBOOL {.
        stdcall, dynlib: "kernel32", importc: "WriteFile", sideEffect, ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc wsaCloseEvent(hEvent: Handle): bool {.stdcall, importc: "WSACloseEvent",
        dynlib: "ws2_32.dll", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc wsaCreateEvent(): Handle {.stdcall, importc: "WSACreateEvent",
                                    dynlib: "ws2_32.dll", ...raises: [], tags: [],
                                    forbids: [].}

  Source Edit

    proc wsaEventSelect(s: SocketHandle; hEventObject: Handle; lNetworkEvents: clong): cint {.
        stdcall, importc: "WSAEventSelect", dynlib: "ws2_32.dll", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc wsaGetLastError(): cint {.importc: "WSAGetLastError", dynlib: ws2dll,
                                   sideEffect, ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc WSAIoctl(s: SocketHandle; dwIoControlCode: DWORD; lpvInBuffer: pointer;
                  cbInBuffer: DWORD; lpvOutBuffer: pointer; cbOutBuffer: DWORD;
                  lpcbBytesReturned: PDWORD; lpOverlapped: POVERLAPPED;
                  lpCompletionRoutine: POVERLAPPED_COMPLETION_ROUTINE): cint {.
        stdcall, importc: "WSAIoctl", dynlib: "Ws2_32.dll", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc WSARecv(s: SocketHandle; buf: ptr TWSABuf; bufCount: DWORD;
                 bytesReceived, flags: PDWORD; lpOverlapped: POVERLAPPED;
                 completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.stdcall,
        importc: "WSARecv", dynlib: "Ws2_32.dll", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc WSARecvFrom(s: SocketHandle; buf: ptr TWSABuf; bufCount: DWORD;
                     bytesReceived: PDWORD; flags: PDWORD; name: ptr SockAddr;
                     namelen: ptr cint; lpOverlapped: POVERLAPPED;
                     completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.
        stdcall, importc: "WSARecvFrom", dynlib: "Ws2_32.dll", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc wsaResetEvent(hEvent: Handle): bool {.stdcall, importc: "WSAResetEvent",
        dynlib: "ws2_32.dll", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc WSASend(s: SocketHandle; buf: ptr TWSABuf; bufCount: DWORD;
                 bytesSent: PDWORD; flags: DWORD; lpOverlapped: POVERLAPPED;
                 completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.stdcall,
        importc: "WSASend", dynlib: "Ws2_32.dll", ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc WSASendTo(s: SocketHandle; buf: ptr TWSABuf; bufCount: DWORD;
                   bytesSent: PDWORD; flags: DWORD; name: ptr SockAddr;
                   namelen: cint; lpOverlapped: POVERLAPPED;
                   completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.stdcall,
        importc: "WSASendTo", dynlib: "Ws2_32.dll", ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc wsaStartup(wVersionRequired: int16; WSData: ptr WSAData): cint {.stdcall,
        importc: "WSAStartup", dynlib: ws2dll, ...raises: [], tags: [], forbids: [].}

  Source Edit

# Templates

    template hasOverlappedIoCompleted(lpOverlapped): bool

  Source Edit

    template WSAIORW(x, y): untyped

  Source Edit