| ... | @@ -608,6 +608,27 @@ pub fn GetFileAttributesW(lpFileName: [*]const u16) GetFileAttributesError!DWORD | ... | @@ -608,6 +608,27 @@ pub fn GetFileAttributesW(lpFileName: [*]const u16) GetFileAttributesError!DWORD |
| 608 | return rc; | 608 | return rc; |
| 609 | } | 609 | } |
| 610 | | 610 | |
| | 611 | pub fn WSASocketW( |
| | 612 | af: i32, |
| | 613 | socket_type: i32, |
| | 614 | protocol: i32, |
| | 615 | protocolInfo: ?*ws2_32.WSAPROTOCOL_INFOW, |
| | 616 | g: ws2_32.GROUP, |
| | 617 | dwFlags: DWORD, |
| | 618 | ) !ws2_32.SOCKET { |
| | 619 | const rc = ws2_32.WSASocketW(af, socket_type, protocol, protocolInfo, g, dwFlags); |
| | 620 | if (rc == ws2_32.INVALID_SOCKET) { |
| | 621 | switch (ws2_32.WSAGetLastError()) { |
| | 622 | ws2_32.WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, |
| | 623 | ws2_32.WSAEMFILE => return error.ProcessFdQuotaExceeded, |
| | 624 | ws2_32.WSAENOBUFS => return error.SystemResources, |
| | 625 | ws2_32.WSAEPROTONOSUPPORT => return error.ProtocolNotSupported, |
| | 626 | else => |err| return unexpectedWSAError(err), |
| | 627 | } |
| | 628 | } |
| | 629 | return rc; |
| | 630 | } |
| | 631 | |
| 611 | const GetModuleFileNameError = error{Unexpected}; | 632 | const GetModuleFileNameError = error{Unexpected}; |
| 612 | | 633 | |
| 613 | pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) GetModuleFileNameError![]u16 { | 634 | pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) GetModuleFileNameError![]u16 { |
| ... | @@ -905,6 +926,10 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError { | ... | @@ -905,6 +926,10 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError { |
| 905 | return error.Unexpected; | 926 | return error.Unexpected; |
| 906 | } | 927 | } |
| 907 | | 928 | |
| | 929 | pub fn unexpectedWSAError(err: c_int) std.os.UnexpectedError { |
| | 930 | return unexpectedError(@intCast(DWORD, err)); |
| | 931 | } |
| | 932 | |
| 908 | /// Call this when you made a windows NtDll call | 933 | /// Call this when you made a windows NtDll call |
| 909 | /// and you get an unexpected status. | 934 | /// and you get an unexpected status. |
| 910 | pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { | 935 | pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { |