More formatting improvements

This commit is contained in:
gingerBill
2026-01-02 11:32:39 +00:00
parent 274e7e7e58
commit e154489f01
10 changed files with 198 additions and 170 deletions

View File

@@ -5,19 +5,22 @@ foreign import userenv "system:Userenv.lib"
@(default_calling_convention="system")
foreign userenv {
GetUserProfileDirectoryW :: proc(hToken: HANDLE,
lpProfileDir: LPWSTR,
lpcchSize: ^DWORD) -> BOOL ---
GetUserProfileDirectoryW :: proc(
hToken: HANDLE,
lpProfileDir: LPWSTR,
lpcchSize: ^DWORD,
) -> BOOL ---
LoadUserProfileW :: proc(
hToken: HANDLE,
hToken: HANDLE,
lpProfileInfo: ^PROFILEINFOW,
) -> BOOL ---
// https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-createprofile
// The caller must have administrator privileges to call this function.
CreateProfile :: proc(
pszUserSid: LPCWSTR,
pszUserName: LPCWSTR,
pszUserSid: LPCWSTR,
pszUserName: LPCWSTR,
pszProfilePath: wstring,
cchProfilePath: DWORD,
) -> u32 ---
@@ -25,15 +28,15 @@ foreign userenv {
// https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-deleteprofilew
// The caller must have administrative privileges to delete a user's profile.
DeleteProfileW :: proc(
lpSidString: LPCWSTR,
lpProfilePath: LPCWSTR,
lpSidString: LPCWSTR,
lpProfilePath: LPCWSTR,
lpComputerName: LPCWSTR,
) -> BOOL ---
// https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertsidtostringsida
// To turn a SID into a string SID to use with CreateProfile & DeleteProfileW.
ConvertSidToStringSidW :: proc(
Sid: ^SID,
Sid: ^SID,
StringSid: ^LPCWSTR,
) -> BOOL ---
}

View File

@@ -7,74 +7,89 @@ import "base:intrinsics"
L :: intrinsics.constant_utf16_cstring
// https://learn.microsoft.com/en-us/windows/win32/winmsg/makeword
@(require_results)
MAKEWORD :: #force_inline proc "contextless" (#any_int a, b: int) -> WORD {
return WORD(BYTE(DWORD_PTR(a) & 0xff)) | (WORD(BYTE(DWORD_PTR(b) & 0xff)) << 8)
}
// https://learn.microsoft.com/en-us/windows/win32/winmsg/makelong
@(require_results)
MAKELONG :: #force_inline proc "contextless" (#any_int a, b: int) -> LONG {
return LONG(WORD(DWORD_PTR(a) & 0xffff)) | (LONG(WORD(DWORD_PTR(b) & 0xffff)) << 16)
}
// https://learn.microsoft.com/en-us/windows/win32/winmsg/loword
@(require_results)
LOWORD :: #force_inline proc "contextless" (#any_int x: int) -> WORD {
return WORD(x & 0xffff)
}
// https://learn.microsoft.com/en-us/windows/win32/winmsg/hiword
@(require_results)
HIWORD :: #force_inline proc "contextless" (#any_int x: int) -> WORD {
return WORD(x >> 16)
}
// https://learn.microsoft.com/en-us/windows/win32/winmsg/lobyte
@(require_results)
LOBYTE :: #force_inline proc "contextless" (w: WORD) -> BYTE {
return BYTE((DWORD_PTR(w)) & 0xff)
}
// https://learn.microsoft.com/en-us/windows/win32/winmsg/hibyte
@(require_results)
HIBYTE :: #force_inline proc "contextless" (w: WORD) -> BYTE {
return BYTE(((DWORD_PTR(w)) >> 8) & 0xff)
}
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makewparam
@(require_results)
MAKEWPARAM :: #force_inline proc "contextless" (#any_int l, h: int) -> WPARAM {
return WPARAM(MAKELONG(l, h))
}
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makelparam
@(require_results)
MAKELPARAM :: #force_inline proc "contextless" (#any_int l, h: int) -> LPARAM {
return LPARAM(MAKELONG(l, h))
}
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makelresult
@(require_results)
MAKELRESULT :: #force_inline proc "contextless" (#any_int l, h: int) -> LRESULT {
return LRESULT(MAKELONG(l, h))
}
// https://learn.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_x_lparam
@(require_results)
GET_X_LPARAM :: #force_inline proc "contextless" (lp: LPARAM) -> c_int {
return cast(c_int)cast(c_short)LOWORD(cast(DWORD)lp)
}
// https://learn.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_y_lparam
@(require_results)
GET_Y_LPARAM :: #force_inline proc "contextless" (lp: LPARAM) -> c_int {
return cast(c_int)cast(c_short)HIWORD(cast(DWORD)lp)
}
// https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelcid
@(require_results)
MAKELCID :: #force_inline proc "contextless" (lgid, srtid: WORD) -> LCID {
return (DWORD(WORD(srtid)) << 16) | DWORD(WORD(lgid))
}
// https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelangid
@(require_results)
MAKELANGID :: #force_inline proc "contextless" (p, s: WORD) -> DWORD {
return DWORD(WORD(s)) << 10 | DWORD(WORD(p))
}
@(require_results)
LANGIDFROMLCID :: #force_inline proc "contextless" (lcid: LCID) -> LANGID {
return LANGID(lcid)
}
@(require_results)
utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
if len(s) < 1 {
return nil
@@ -102,6 +117,7 @@ utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> [
return text[:n]
}
@(require_results)
utf8_to_utf16_buf :: proc(buf: []u16, s: string) -> []u16 {
n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), c_int(len(s)), nil, 0)
if n1 == 0 {
@@ -120,6 +136,7 @@ utf8_to_utf16_buf :: proc(buf: []u16, s: string) -> []u16 {
}
utf8_to_utf16 :: proc{utf8_to_utf16_alloc, utf8_to_utf16_buf}
@(require_results)
utf8_to_wstring_alloc :: proc(s: string, allocator := context.temp_allocator) -> wstring {
if res := utf8_to_utf16(s, allocator); len(res) > 0 {
return wstring(raw_data(res))
@@ -127,6 +144,7 @@ utf8_to_wstring_alloc :: proc(s: string, allocator := context.temp_allocator) ->
return nil
}
@(require_results)
utf8_to_wstring_buf :: proc(buf: []u16, s: string) -> wstring {
if res := utf8_to_utf16(buf, s); len(res) > 0 {
return wstring(raw_data(res))
@@ -136,6 +154,7 @@ utf8_to_wstring_buf :: proc(buf: []u16, s: string) -> wstring {
utf8_to_wstring :: proc{utf8_to_wstring_alloc, utf8_to_wstring_buf}
@(require_results)
wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
context.allocator = allocator
@@ -170,6 +189,7 @@ wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allo
return string(text[:n]), nil
}
@(require_results)
wstring_to_utf8_buf :: proc(buf: []u8, s: wstring, N := -1) -> (res: string) {
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, c_int(N), nil, 0, nil, nil)
if n == 0 {
@@ -211,6 +231,7 @@ Returns:
- res: A cloned and converted string
- err: An optional allocator error if one occured, `nil` otherwise
*/
@(require_results)
utf16_to_utf8_alloc :: proc(s: []u16, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
if len(s) == 0 {
return "", nil
@@ -232,6 +253,7 @@ Inputs:
Returns:
- res: A converted string, backed byu `buf`
*/
@(require_results)
utf16_to_utf8_buf :: proc(buf: []u8, s: []u16) -> (res: string) {
if len(s) == 0 {
return
@@ -244,8 +266,9 @@ utf16_to_utf8 :: proc{utf16_to_utf8_alloc, utf16_to_utf8_buf}
// AdvAPI32, NetAPI32 and UserENV helpers.
allowed_username :: proc(username: string) -> bool {
contains_any :: proc(s, chars: string) -> bool {
@(require_results)
allowed_username :: proc "contextless" (username: string) -> bool {
contains_any :: proc "contextless" (s, chars: string) -> bool {
if chars == "" {
return false
}
@@ -287,8 +310,8 @@ allowed_username :: proc(username: string) -> bool {
}
// Returns .Success on success.
@(require_results)
_add_user :: proc(servername: string, username: string, password: string) -> (ok: NET_API_STATUS) {
servername_w: wstring
username_w: []u16
password_w: []u16
@@ -339,8 +362,8 @@ _add_user :: proc(servername: string, username: string, password: string) -> (ok
return
}
@(require_results)
get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: string, sid := SID{}, ok: bool) {
username_w := utf8_to_utf16(username, context.temp_allocator)
cbsid: DWORD
computer_name_size: DWORD
@@ -381,8 +404,8 @@ get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: s
return
}
@(require_results)
get_sid :: proc(username: string, sid: ^SID) -> (ok: bool) {
username_w := utf8_to_utf16(username, context.temp_allocator)
cbsid: DWORD
computer_name_size: DWORD
@@ -451,6 +474,7 @@ add_del_from_group :: proc(sid: ^SID, group: string) -> (ok: NET_API_STATUS) {
return
}
@(require_results)
add_user_profile :: proc(username: string) -> (ok: bool, profile_path: string) {
username_w := utf8_to_utf16(username, context.temp_allocator)

View File

@@ -13,6 +13,6 @@ PMARGINS :: ^MARGINS
@(default_calling_convention="system")
foreign uxtheme {
IsThemeActive :: proc() -> BOOL ---
IsThemeActive :: proc() -> BOOL ---
SetWindowTheme :: proc(hWnd: HWND, pszSubAppName, pszSubIdList: LPCWSTR) -> HRESULT ---
}

View File

@@ -91,7 +91,7 @@ gl_set_proc_address :: proc(p: rawptr, name: cstring) {
func := wglGetProcAddress(name)
switch uintptr(func) {
case 0, 1, 2, 3, ~uintptr(0):
module := LoadLibraryW(L("opengl32.dll"))
module := LoadLibraryW("opengl32.dll")
func = GetProcAddress(module, name)
}
(^rawptr)(p)^ = func

View File

@@ -12,28 +12,28 @@ foreign winmm {
timeEndPeriod :: proc(uPeriod: UINT) -> MMRESULT ---
timeGetTime :: proc() -> DWORD ---
waveOutGetNumDevs :: proc() -> UINT ---
waveOutGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwoc: LPWAVEOUTCAPSW, cbwoc: UINT) -> MMRESULT ---
waveOutGetVolume :: proc(hwo: HWAVEOUT, pdwVolume: LPDWORD) -> MMRESULT ---
waveOutSetVolume :: proc(hwo: HWAVEOUT, dwVolume: DWORD) -> MMRESULT ---
waveOutGetErrorTextW :: proc(mmrError: MMRESULT, pszText: LPWSTR, cchText: UINT) -> MMRESULT ---
waveOutOpen :: proc(phwo: LPHWAVEOUT, uDeviceID: UINT, pwfx: LPCWAVEFORMATEX, dwCallback: DWORD_PTR, dwInstance: DWORD_PTR, fdwOpen: DWORD) -> MMRESULT ---
waveOutClose :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutPrepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT ---
waveOutGetNumDevs :: proc() -> UINT ---
waveOutGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwoc: LPWAVEOUTCAPSW, cbwoc: UINT) -> MMRESULT ---
waveOutGetVolume :: proc(hwo: HWAVEOUT, pdwVolume: LPDWORD) -> MMRESULT ---
waveOutSetVolume :: proc(hwo: HWAVEOUT, dwVolume: DWORD) -> MMRESULT ---
waveOutGetErrorTextW :: proc(mmrError: MMRESULT, pszText: LPWSTR, cchText: UINT) -> MMRESULT ---
waveOutOpen :: proc(phwo: LPHWAVEOUT, uDeviceID: UINT, pwfx: LPCWAVEFORMATEX, dwCallback: DWORD_PTR, dwInstance: DWORD_PTR, fdwOpen: DWORD) -> MMRESULT ---
waveOutClose :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutPrepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT ---
waveOutUnprepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT ---
waveOutWrite :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT ---
waveOutPause :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutRestart :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutReset :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutBreakLoop :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutGetPosition :: proc(hwo: HWAVEOUT, pmmt: LPMMTIME, cbmmt: UINT) -> MMRESULT ---
waveOutGetPitch :: proc(hwo: HWAVEOUT, pdwPitch: LPDWORD) -> MMRESULT ---
waveOutSetPitch :: proc(hwo: HWAVEOUT, pdwPitch: DWORD) -> MMRESULT ---
waveOutWrite :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT ---
waveOutPause :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutRestart :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutReset :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutBreakLoop :: proc(hwo: HWAVEOUT) -> MMRESULT ---
waveOutGetPosition :: proc(hwo: HWAVEOUT, pmmt: LPMMTIME, cbmmt: UINT) -> MMRESULT ---
waveOutGetPitch :: proc(hwo: HWAVEOUT, pdwPitch: LPDWORD) -> MMRESULT ---
waveOutSetPitch :: proc(hwo: HWAVEOUT, pdwPitch: DWORD) -> MMRESULT ---
waveOutGetPlaybackRate :: proc(hwo: HWAVEOUT, pdwRate: LPDWORD) -> MMRESULT ---
waveOutSetPlaybackRate :: proc(hwo: HWAVEOUT, pdwRate: DWORD) -> MMRESULT ---
waveOutGetID :: proc(hwo: HWAVEOUT, puDeviceID: LPUINT) -> MMRESULT ---
waveOutGetID :: proc(hwo: HWAVEOUT, puDeviceID: LPUINT) -> MMRESULT ---
waveInGetNumDevs :: proc() -> UINT ---
waveInGetNumDevs :: proc() -> UINT ---
waveInGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwic: LPWAVEINCAPSW, cbwic: UINT) -> MMRESULT ---
PlaySoundW :: proc(pszSound: LPCWSTR, hmod: HMODULE, fdwSound: DWORD) -> BOOL ---
@@ -272,10 +272,10 @@ LPHWAVEOUT :: ^HWAVEOUT
MMTIME :: struct {
wType: MMTIME_TYPE,
u: struct #raw_union {
ms: DWORD,
sample: DWORD,
cb: DWORD,
ticks: DWORD,
ms: DWORD `raw_union_tag:"wType=TIME_MS"`,
sample: DWORD `raw_union_tag:"wType=TIME_SAMPLES"`,
cb: DWORD `raw_union_tag:"wType=TIME_BYTES"`,
ticks: DWORD `raw_union_tag:"wType=TIME_TICKS"`,
smpte: struct {
hour: BYTE,
min: BYTE,
@@ -284,10 +284,10 @@ MMTIME :: struct {
fps: BYTE,
dummy: BYTE,
pad: [2]BYTE,
},
} `raw_union_tag:"wType=TIME_SMPTE"`,
midi: struct {
songptrpos: DWORD,
},
} `raw_union_tag:"wType=TIME_MIDI"`,
},
}
LPMMTIME :: ^MMTIME
@@ -307,12 +307,13 @@ MMTIME_TYPE :: enum UINT {
TIME_TICKS = 0x0020,
}
MAXPNAMELEN :: 32
MAXPNAMELEN :: 32
MAXERRORLENGTH :: 256
MMVERSION :: UINT
MMVERSION :: UINT
// Input is four characters string
// Output is little-endian u32 representation
@(require_results)
MAKEFOURCC :: #force_inline proc "contextless" (s: [4]byte) -> DWORD {
return (DWORD(s[0])) | (DWORD(s[1]) << 8) | (DWORD(s[2]) << 16) | (DWORD(s[3]) << 24 )
}

View File

@@ -5,8 +5,8 @@ LCTYPE :: distinct DWORD
LOCALE_NAME_MAX_LENGTH :: 85
LOCALE_NAME_USER_DEFAULT :: 0
LOCALE_NAME_INVARIANT : wstring = L("")
LOCALE_NAME_SYSTEM_DEFAULT : wstring = L("!x-sys-default-locale")
LOCALE_NAME_INVARIANT : wstring = ""
LOCALE_NAME_SYSTEM_DEFAULT : wstring = "!x-sys-default-locale"
// String Length Maximums.
// 5 ranges, 2 bytes ea., 0 term.
@@ -16,16 +16,16 @@ MAX_DEFAULTCHAR :: 2
CPINFOEXW :: struct{
// Maximum length, in bytes, of a character in the code page.
MaxCharSize: UINT,
MaxCharSize: UINT,
// The default is usually the "?" character for the code page.
DefaultChar: [MAX_DEFAULTCHAR]BYTE,
DefaultChar: [MAX_DEFAULTCHAR]BYTE,
// A fixed-length array of lead byte ranges, for which the number of lead byte ranges is variable.
LeadByte: [MAX_LEADBYTES]BYTE,
LeadByte: [MAX_LEADBYTES]BYTE,
// The default is usually the "?" character or the katakana middle dot character.
UnicodeDefaultChar: WCHAR,
// Code page value. This value reflects the code page passed to the GetCPInfoEx function.
CodePage: CODEPAGE,
CodePage: CODEPAGE,
// Full name of the code page.
CodePageName: [MAX_PATH]WCHAR,
CodePageName: [MAX_PATH]WCHAR,
}
LPCPINFOEXW :: ^CPINFOEXW

View File

@@ -5,14 +5,14 @@ foreign import version "system:version.lib"
@(default_calling_convention = "system")
foreign version {
GetFileVersionInfoSizeW :: proc(lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD ---
GetFileVersionInfoW :: proc(lptstrFilename: LPCWSTR, dwHandle: DWORD, dwLen: DWORD, lpData: LPVOID) -> BOOL ---
GetFileVersionInfoSizeW :: proc(lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD ---
GetFileVersionInfoW :: proc(lptstrFilename: LPCWSTR, dwHandle: DWORD, dwLen: DWORD, lpData: LPVOID) -> BOOL ---
GetFileVersionInfoSizeExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD ---
GetFileVersionInfoExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, dwHandle, dwLen: DWORD, lpData: LPVOID) -> DWORD ---
GetFileVersionInfoExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, dwHandle, dwLen: DWORD, lpData: LPVOID) -> DWORD ---
VerLanguageNameW :: proc(wLang: DWORD, szLang: LPWSTR, cchLang: DWORD) -> DWORD ---
VerQueryValueW :: proc(pBlock: LPCVOID, lpSubBlock: LPCWSTR, lplpBuffer: ^LPVOID, puLen: PUINT) -> BOOL ---
VerLanguageNameW :: proc(wLang: DWORD, szLang: LPWSTR, cchLang: DWORD) -> DWORD ---
VerQueryValueW :: proc(pBlock: LPCVOID, lpSubBlock: LPCWSTR, lplpBuffer: ^LPVOID, puLen: PUINT) -> BOOL ---
}
FILE_VER_GET :: enum DWORD {LOCALISED, NEUTRAL, PREFETCHED}

View File

@@ -5,30 +5,30 @@ foreign import kernel32 "system:Kernel32.lib"
@(default_calling_convention="system")
foreign kernel32 {
GetSystemWow64Directory2W :: proc (lpBuffer: LPWSTR, uSize: UINT, ImageFileMachineTyp: WORD) -> UINT ---
GetSystemWow64DirectoryW :: proc (lpBuffer: LPWSTR, uSize: UINT) -> UINT ---
IsWow64GuestMachineSupported :: proc (WowGuestMachine: USHORT, MachineIsSupported: ^BOOL) -> HRESULT ---
IsWow64Process :: proc (hProcess: HANDLE, Wow64Process: PBOOL) -> BOOL ---
IsWow64Process2 :: proc (hProcess: HANDLE, pProcessMachine: ^USHORT, pNativeMachine: ^USHORT) -> BOOL ---
Wow64EnableWow64FsRedirection :: proc (Wow64FsEnableRedirection: BOOLEAN) -> BOOLEAN ---
Wow64DisableWow64FsRedirection :: proc (OldValue: ^PVOID) -> BOOL ---
Wow64RevertWow64FsRedirection :: proc (OlValue: PVOID) -> BOOL ---
Wow64GetThreadContext :: proc (hThread: HANDLE, lpContext: PWOW64_CONTEXT) -> BOOL ---
Wow64SetThreadContext :: proc(hThread: HANDLE, lpContext: ^WOW64_CONTEXT) -> BOOL ---
GetSystemWow64Directory2W :: proc(lpBuffer: LPWSTR, uSize: UINT, ImageFileMachineTyp: WORD) -> UINT ---
GetSystemWow64DirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT ---
IsWow64GuestMachineSupported :: proc(WowGuestMachine: USHORT, MachineIsSupported: ^BOOL) -> HRESULT ---
IsWow64Process :: proc(hProcess: HANDLE, Wow64Process: PBOOL) -> BOOL ---
IsWow64Process2 :: proc(hProcess: HANDLE, pProcessMachine: ^USHORT, pNativeMachine: ^USHORT) -> BOOL ---
Wow64EnableWow64FsRedirection :: proc(Wow64FsEnableRedirection: BOOLEAN) -> BOOLEAN ---
Wow64DisableWow64FsRedirection :: proc(OldValue: ^PVOID) -> BOOL ---
Wow64RevertWow64FsRedirection :: proc(OlValue: PVOID) -> BOOL ---
Wow64GetThreadContext :: proc(hThread: HANDLE, lpContext: PWOW64_CONTEXT) -> BOOL ---
Wow64SetThreadContext :: proc(hThread: HANDLE, lpContext: ^WOW64_CONTEXT) -> BOOL ---
Wow64SetThreadDefaultGuestMachine :: proc(Machine: USHORT) -> USHORT ---
Wow64SuspendThread :: proc (hThread: HANDLE) -> DWORD ---
Wow64SuspendThread :: proc(hThread: HANDLE) -> DWORD ---
}
WOW64_CONTEXT_i386 :: 0x00010000
WOW64_CONTEXT_CONTROL :: (WOW64_CONTEXT_i386 | 0x00000001)
WOW64_CONTEXT_INTEGER :: (WOW64_CONTEXT_i386 | 0x00000002)
WOW64_CONTEXT_CONTROL :: (WOW64_CONTEXT_i386 | 0x00000001)
WOW64_CONTEXT_INTEGER :: (WOW64_CONTEXT_i386 | 0x00000002)
WOW64_CONTEXT_SEGMENTS :: (WOW64_CONTEXT_i386 | 0x00000004)
WOW64_CONTEXT_FLOATING_POINT :: (WOW64_CONTEXT_i386 | 0x00000008)
WOW64_CONTEXT_DEBUG_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000010)
WOW64_CONTEXT_FLOATING_POINT :: (WOW64_CONTEXT_i386 | 0x00000008)
WOW64_CONTEXT_DEBUG_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000010)
WOW64_CONTEXT_EXTENDED_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000020)
WOW64_CONTEXT_FULL :: (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
WOW64_CONTEXT_FULL :: (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
WOW64_CONTEXT_ALL :: (
WOW64_CONTEXT_CONTROL |
WOW64_CONTEXT_INTEGER |
@@ -41,45 +41,45 @@ WOW64_SIZE_OF_80387_REGISTERS :: 80
WOW64_MAXIMUM_SUPPORTED_EXTENSION :: 512
WOW64_CONTEXT :: struct {
ContextFlags: DWORD,
Dr0: DWORD,
Dr1: DWORD,
Dr2: DWORD,
Dr3: DWORD,
Dr6: DWORD,
Dr7: DWORD,
FloatSave: WOW64_FLOATING_SAVE_AREA,
SegGs: DWORD,
SegFs: DWORD,
SegEs: DWORD,
SegDs: DWORD,
Edi: DWORD,
Esi: DWORD,
Ebx: DWORD,
Edx: DWORD,
Ecx: DWORD,
Eax: DWORD,
Ebp: DWORD,
Eip: DWORD,
SegCs: DWORD,
EFlags: DWORD,
Esp: DWORD,
SegSs: DWORD,
ContextFlags: DWORD,
Dr0: DWORD,
Dr1: DWORD,
Dr2: DWORD,
Dr3: DWORD,
Dr6: DWORD,
Dr7: DWORD,
FloatSave: WOW64_FLOATING_SAVE_AREA,
SegGs: DWORD,
SegFs: DWORD,
SegEs: DWORD,
SegDs: DWORD,
Edi: DWORD,
Esi: DWORD,
Ebx: DWORD,
Edx: DWORD,
Ecx: DWORD,
Eax: DWORD,
Ebp: DWORD,
Eip: DWORD,
SegCs: DWORD,
EFlags: DWORD,
Esp: DWORD,
SegSs: DWORD,
ExtendedRegisters: [WOW64_MAXIMUM_SUPPORTED_EXTENSION]BYTE,
}
PWOW64_CONTEXT :: ^WOW64_CONTEXT
WOW64_FLOATING_SAVE_AREA :: struct {
ControlWord: DWORD,
StatusWord: DWORD,
TagWord: DWORD,
ErrorOffset: DWORD,
ControlWord: DWORD,
StatusWord: DWORD,
TagWord: DWORD,
ErrorOffset: DWORD,
ErrorSelector: DWORD,
DataOffset: DWORD,
DataSelector: DWORD,
RegisterArea: [WOW64_SIZE_OF_80387_REGISTERS]BYTE,
Cr0NpxState: DWORD,
DataOffset: DWORD,
DataSelector: DWORD,
RegisterArea: [WOW64_SIZE_OF_80387_REGISTERS]BYTE,
Cr0NpxState: DWORD,
}
PWOW64_FLOATING_SAVE_AREA :: ^WOW64_FLOATING_SAVE_AREA

View File

@@ -109,62 +109,62 @@ foreign ws2_32 {
WSAPoll :: proc(fdArray: ^WSA_POLLFD, fds: c_ulong, timeout: c_int) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw)
WSADuplicateSocketW :: proc(
s: SOCKET,
dwProcessId: DWORD,
s: SOCKET,
dwProcessId: DWORD,
lpProtocolInfo: LPWSAPROTOCOL_INFO,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend)
WSASend :: proc(
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
lpNumberOfBytesSent: LPDWORD,
dwFlags: DWORD,
lpOverlapped: LPWSAOVERLAPPED,
dwFlags: DWORD,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendto)
WSASendTo :: proc(
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
lpNumberOfBytesSent: LPDWORD,
dwFlags: DWORD,
lpTo: ^SOCKADDR_STORAGE_LH,
iToLen: c_int,
lpOverlapped: LPWSAOVERLAPPED,
dwFlags: DWORD,
lpTo: ^SOCKADDR_STORAGE_LH,
iToLen: c_int,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecv)
WSARecv :: proc(
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
lpNumberOfBytesRecvd: LPDWORD,
lpFlags: LPDWORD,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
lpFlags: LPDWORD,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecvfrom)
WSARecvFrom :: proc(
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
s: SOCKET,
lpBuffers: LPWSABUF,
dwBufferCount: DWORD,
lpNumberOfBytesRecvd: LPDWORD,
lpFlags: LPDWORD,
lpFrom: ^SOCKADDR_STORAGE_LH,
lpFromlen: ^c_int,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
lpFlags: LPDWORD,
lpFrom: ^SOCKADDR_STORAGE_LH,
lpFromlen: ^c_int,
lpOverlapped: LPWSAOVERLAPPED,
lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw)
WSASocketW :: proc(
af: c_int,
kind: c_int,
protocol: c_int,
af: c_int,
kind: c_int,
protocol: c_int,
lpProtocolInfo: LPWSAPROTOCOL_INFO,
g: GROUP,
dwFlags: DWORD,
g: GROUP,
dwFlags: DWORD,
) -> SOCKET ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaioctl)
WSAIoctl :: proc(s: SOCKET, dwIoControlCode: DWORD, lpvInBuffer: rawptr, cbInBuffer: DWORD, lpvOutBuffer: rawptr, cbOutBuffer: DWORD, lpcbBytesReturned: ^DWORD, lpOverlapped: ^OVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> c_int ---
@@ -182,8 +182,8 @@ foreign ws2_32 {
WSAGetOverlappedResult :: proc(s: SOCKET, lpOverlapped: ^OVERLAPPED, lpcbTransfer: ^DWORD, fWait: BOOL, lpdwFlags: ^DWORD) -> BOOL ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket)
socket :: proc(
af: c_int,
type: c_int,
af: c_int,
type: c_int,
protocol: c_int,
) -> SOCKET ---
@@ -197,20 +197,20 @@ foreign ws2_32 {
send :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom)
recvfrom :: proc(
socket: SOCKET,
buf: rawptr,
len: c_int,
flags: c_int,
addr: ^SOCKADDR_STORAGE_LH,
socket: SOCKET,
buf: rawptr,
len: c_int,
flags: c_int,
addr: ^SOCKADDR_STORAGE_LH,
addrlen: ^c_int,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto)
sendto :: proc(
socket: SOCKET,
buf: rawptr,
len: c_int,
flags: c_int,
addr: ^SOCKADDR_STORAGE_LH,
socket: SOCKET,
buf: rawptr,
len: c_int,
flags: c_int,
addr: ^SOCKADDR_STORAGE_LH,
addrlen: c_int,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown)
@@ -220,11 +220,11 @@ foreign ws2_32 {
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt)
setsockopt :: proc(
s: SOCKET,
level: c_int,
s: SOCKET,
level: c_int,
optname: c_int,
optval: rawptr,
optlen: c_int,
optval: rawptr,
optlen: c_int,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname)
getsockname :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int ---
@@ -238,10 +238,10 @@ foreign ws2_32 {
connect :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, len: c_int) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo)
getaddrinfo :: proc(
node: cstring,
node: cstring,
service: cstring,
hints: ^ADDRINFOA,
res: ^^ADDRINFOA,
hints: ^ADDRINFOA,
res: ^^ADDRINFOA,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfo)
freeaddrinfo :: proc(res: ^ADDRINFOA) ---
@@ -261,19 +261,19 @@ foreign ws2_32 {
lpHandle: LPHANDLE) -> INT ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select)
select :: proc(
nfds: c_int,
readfds: ^fd_set,
writefds: ^fd_set,
exceptfds: ^fd_set,
timeout: ^timeval,
nfds: c_int,
readfds: [^]fd_set,
writefds: [^]fd_set,
exceptfds: [^]fd_set,
timeout: ^timeval,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt)
getsockopt :: proc(
s: SOCKET,
level: c_int,
s: SOCKET,
level: c_int,
optname: c_int,
optval: ^c_char,
optlen: ^c_int,
optval: [^]c_char,
optlen: ^c_int,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ntohl)
ntohl :: proc(netlong: c_ulong) -> c_ulong ---

View File

@@ -199,12 +199,12 @@ XINPUT_KEYSTROKE :: struct {
// XInput APIs
@(default_calling_convention = "system")
foreign xinput {
XInputGetState :: proc(user: XUSER, pState: ^XINPUT_STATE) -> System_Error ---
XInputSetState :: proc(user: XUSER, pVibration: ^XINPUT_VIBRATION) -> System_Error ---
XInputGetCapabilities :: proc(user: XUSER, dwFlags: XINPUT_FLAG, pCapabilities: ^XINPUT_CAPABILITIES) -> System_Error ---
XInputEnable :: proc(enable: BOOL) ---
XInputGetAudioDeviceIds :: proc(user: XUSER, pRenderDeviceId: LPWSTR, pRenderCount: ^UINT, pCaptureDeviceId: LPWSTR, pCaptureCount: ^UINT) -> System_Error ---
XInputGetBatteryInformation :: proc(user: XUSER, devType: BATTERY_DEVTYPE, pBatteryInformation: ^XINPUT_BATTERY_INFORMATION) -> System_Error ---
XInputGetKeystroke :: proc(user: XUSER, dwReserved: DWORD, pKeystroke: ^XINPUT_KEYSTROKE) -> System_Error ---
XInputGetState :: proc(user: XUSER, pState: ^XINPUT_STATE) -> System_Error ---
XInputSetState :: proc(user: XUSER, pVibration: ^XINPUT_VIBRATION) -> System_Error ---
XInputGetCapabilities :: proc(user: XUSER, dwFlags: XINPUT_FLAG, pCapabilities: ^XINPUT_CAPABILITIES) -> System_Error ---
XInputEnable :: proc(enable: BOOL) ---
XInputGetAudioDeviceIds :: proc(user: XUSER, pRenderDeviceId: LPWSTR, pRenderCount: ^UINT, pCaptureDeviceId: LPWSTR, pCaptureCount: ^UINT) -> System_Error ---
XInputGetBatteryInformation :: proc(user: XUSER, devType: BATTERY_DEVTYPE, pBatteryInformation: ^XINPUT_BATTERY_INFORMATION) -> System_Error ---
XInputGetKeystroke :: proc(user: XUSER, dwReserved: DWORD, pKeystroke: ^XINPUT_KEYSTROKE) -> System_Error ---
XInputGetDSoundAudioDeviceGuids :: proc(user: XUSER, pDSoundRenderGuid: ^GUID, pDSoundCaptureGuid: ^GUID) -> System_Error ---
}