mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
sys/windows: fixed calling conventions, added several bindings
This commit is contained in:
@@ -341,6 +341,7 @@ MEM_TOP_DOWN :: 0x100000
|
|||||||
MEM_LARGE_PAGES :: 0x20000000
|
MEM_LARGE_PAGES :: 0x20000000
|
||||||
MEM_4MB_PAGES :: 0x80000000
|
MEM_4MB_PAGES :: 0x80000000
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
VirtualAlloc :: proc(
|
VirtualAlloc :: proc(
|
||||||
lpAddress: LPVOID,
|
lpAddress: LPVOID,
|
||||||
@@ -483,6 +484,7 @@ LowMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.LowMemoryRes
|
|||||||
HighMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.HighMemoryResourceNotification
|
HighMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.HighMemoryResourceNotification
|
||||||
|
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
CreateMemoryResourceNotification :: proc(
|
CreateMemoryResourceNotification :: proc(
|
||||||
NotificationType: MEMORY_RESOURCE_NOTIFICATION_TYPE,
|
NotificationType: MEMORY_RESOURCE_NOTIFICATION_TYPE,
|
||||||
@@ -498,6 +500,7 @@ FILE_CACHE_MAX_HARD_DISABLE :: DWORD(0x00000002)
|
|||||||
FILE_CACHE_MIN_HARD_ENABLE :: DWORD(0x00000004)
|
FILE_CACHE_MIN_HARD_ENABLE :: DWORD(0x00000004)
|
||||||
FILE_CACHE_MIN_HARD_DISABLE :: DWORD(0x00000008)
|
FILE_CACHE_MIN_HARD_DISABLE :: DWORD(0x00000008)
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
GetSystemFileCacheSize :: proc(
|
GetSystemFileCacheSize :: proc(
|
||||||
lpMinimumFileCacheSize: PSIZE_T,
|
lpMinimumFileCacheSize: PSIZE_T,
|
||||||
@@ -527,6 +530,7 @@ WIN32_MEMORY_RANGE_ENTRY :: struct {
|
|||||||
|
|
||||||
PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY
|
PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
PrefetchVirtualMemory :: proc(
|
PrefetchVirtualMemory :: proc(
|
||||||
hProcess: HANDLE,
|
hProcess: HANDLE,
|
||||||
@@ -584,6 +588,7 @@ foreign kernel32 {
|
|||||||
|
|
||||||
MEHC_PATROL_SCRUBBER_PRESENT :: ULONG(0x1)
|
MEHC_PATROL_SCRUBBER_PRESENT :: ULONG(0x1)
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
GetMemoryErrorHandlingCapabilities :: proc(
|
GetMemoryErrorHandlingCapabilities :: proc(
|
||||||
Capabilities: PULONG,
|
Capabilities: PULONG,
|
||||||
@@ -592,6 +597,7 @@ foreign kernel32 {
|
|||||||
|
|
||||||
PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "stdcall" ()
|
PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "stdcall" ()
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
RegisterBadMemoryNotification :: proc(
|
RegisterBadMemoryNotification :: proc(
|
||||||
Callback: PBAD_MEMORY_CALLBACK_ROUTINE,
|
Callback: PBAD_MEMORY_CALLBACK_ROUTINE,
|
||||||
@@ -612,6 +618,7 @@ VmOfferPriorityLow :: OFFER_PRIORITY.VmOfferPriorityLow
|
|||||||
VmOfferPriorityBelowNormal :: OFFER_PRIORITY.VmOfferPriorityBelowNormal
|
VmOfferPriorityBelowNormal :: OFFER_PRIORITY.VmOfferPriorityBelowNormal
|
||||||
VmOfferPriorityNormal :: OFFER_PRIORITY.VmOfferPriorityNormal
|
VmOfferPriorityNormal :: OFFER_PRIORITY.VmOfferPriorityNormal
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
OfferVirtualMemory :: proc(
|
OfferVirtualMemory :: proc(
|
||||||
VirtualAddress: PVOID,
|
VirtualAddress: PVOID,
|
||||||
@@ -676,6 +683,7 @@ WIN32_MEMORY_REGION_INFORMATION_u_s_Bitfield :: distinct ULONG
|
|||||||
Reserved : 32-6,
|
Reserved : 32-6,
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
QueryVirtualMemoryInformation :: proc(
|
QueryVirtualMemoryInformation :: proc(
|
||||||
Process: HANDLE,
|
Process: HANDLE,
|
||||||
@@ -700,7 +708,7 @@ foreign kernel32 {
|
|||||||
|
|
||||||
NUMA_NO_PREFERRED_NODE :: 0xffffffff
|
NUMA_NO_PREFERRED_NODE :: 0xffffffff
|
||||||
|
|
||||||
MapViewOfFile2 :: #force_inline proc(
|
MapViewOfFile2 :: #force_inline proc "stdcall" (
|
||||||
FileMappingHandle: HANDLE,
|
FileMappingHandle: HANDLE,
|
||||||
ProcessHandle: HANDLE,
|
ProcessHandle: HANDLE,
|
||||||
Offset: ULONG64,
|
Offset: ULONG64,
|
||||||
@@ -721,6 +729,7 @@ MapViewOfFile2 :: #force_inline proc(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
foreign kernel32 {
|
foreign kernel32 {
|
||||||
UnmapViewOfFile2 :: proc(
|
UnmapViewOfFile2 :: proc(
|
||||||
ProcessHandle: HANDLE,
|
ProcessHandle: HANDLE,
|
||||||
|
|||||||
+12
-15
@@ -54,6 +54,7 @@ NTSTATUS :: c.long
|
|||||||
LPARAM :: LONG_PTR
|
LPARAM :: LONG_PTR
|
||||||
WPARAM :: UINT_PTR
|
WPARAM :: UINT_PTR
|
||||||
LRESULT :: LONG_PTR
|
LRESULT :: LONG_PTR
|
||||||
|
LPRECT :: ^RECT
|
||||||
|
|
||||||
UINT8 :: u8
|
UINT8 :: u8
|
||||||
UINT16 :: u16
|
UINT16 :: u16
|
||||||
@@ -80,6 +81,7 @@ PBOOL :: ^BOOL
|
|||||||
LPBOOL :: ^BOOL
|
LPBOOL :: ^BOOL
|
||||||
LPCSTR :: cstring
|
LPCSTR :: cstring
|
||||||
LPCWSTR :: wstring
|
LPCWSTR :: wstring
|
||||||
|
LPCTSTR :: wstring
|
||||||
LPDWORD :: ^DWORD
|
LPDWORD :: ^DWORD
|
||||||
PCSTR :: cstring
|
PCSTR :: cstring
|
||||||
PCWSTR :: wstring
|
PCWSTR :: wstring
|
||||||
@@ -438,21 +440,16 @@ _IDI_EXCLAMATION := rawptr(uintptr(32515))
|
|||||||
_IDI_ASTERISK := rawptr(uintptr(32516))
|
_IDI_ASTERISK := rawptr(uintptr(32516))
|
||||||
_IDI_WINLOGO := rawptr(uintptr(32517))
|
_IDI_WINLOGO := rawptr(uintptr(32517))
|
||||||
_IDI_SHIELD := rawptr(uintptr(32518))
|
_IDI_SHIELD := rawptr(uintptr(32518))
|
||||||
|
IDI_APPLICATION := cstring(_IDI_APPLICATION)
|
||||||
IDI_APPLICATION := cstring(_IDI_APPLICATION)
|
IDI_HAND := cstring(_IDI_HAND)
|
||||||
IDI_HAND := cstring(_IDI_HAND)
|
IDI_QUESTION := cstring(_IDI_QUESTION)
|
||||||
IDI_QUESTION := cstring(_IDI_QUESTION)
|
IDI_EXCLAMATION := cstring(_IDI_EXCLAMATION)
|
||||||
IDI_EXCLAMATION := cstring(_IDI_EXCLAMATION)
|
IDI_ASTERISK := cstring(_IDI_ASTERISK)
|
||||||
IDI_ASTERISK := cstring(_IDI_ASTERISK)
|
IDI_WINLOGO := cstring(_IDI_WINLOGO)
|
||||||
|
IDI_SHIELD := cstring(_IDI_SHIELD)
|
||||||
// if WINVER >= _WIN32_WINNT_NT4
|
IDI_WARNING := IDI_EXCLAMATION
|
||||||
IDI_WINLOGO := cstring(_IDI_WINLOGO)
|
IDI_ERROR := IDI_HAND
|
||||||
IDI_WARNING := IDI_EXCLAMATION
|
IDI_INFORMATION := IDI_ASTERISK
|
||||||
IDI_ERROR := IDI_HAND
|
|
||||||
IDI_INFORMATION := IDI_ASTERISK
|
|
||||||
|
|
||||||
// if WINVER >= _WIN32_WINNT_VISTA
|
|
||||||
IDI_SHIELD := cstring(_IDI_SHIELD)
|
|
||||||
|
|
||||||
|
|
||||||
WSA_FLAG_OVERLAPPED: DWORD : 0x01
|
WSA_FLAG_OVERLAPPED: DWORD : 0x01
|
||||||
|
|||||||
@@ -28,30 +28,6 @@ foreign user32 {
|
|||||||
RegisterClassExA :: proc(^WNDCLASSEXA) -> ATOM ---
|
RegisterClassExA :: proc(^WNDCLASSEXA) -> ATOM ---
|
||||||
RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
|
RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
|
||||||
|
|
||||||
CreateWindowA :: proc(
|
|
||||||
lpClassName: LPCSTR,
|
|
||||||
lpWindowName: LPCSTR,
|
|
||||||
dwStyle: DWORD,
|
|
||||||
X: c_int,
|
|
||||||
Y: c_int,
|
|
||||||
nWidth: c_int,
|
|
||||||
nHeight: c_int,
|
|
||||||
hWndParent: HWND,
|
|
||||||
hMenu: HMENU,
|
|
||||||
hInstance: HINSTANCE,
|
|
||||||
lpParam: LPARAM) -> HWND ---
|
|
||||||
CreateWindowW :: proc(
|
|
||||||
lpClassName: LPCWSTR,
|
|
||||||
lpWindowName: LPCWSTR,
|
|
||||||
dwStyle: DWORD,
|
|
||||||
X: c_int,
|
|
||||||
Y: c_int,
|
|
||||||
nWidth: c_int,
|
|
||||||
nHeight: c_int,
|
|
||||||
hWndParent: HWND,
|
|
||||||
hMenu: HMENU,
|
|
||||||
hInstance: HINSTANCE,
|
|
||||||
lpParam: LPARAM) -> HWND ---
|
|
||||||
CreateWindowExA :: proc(
|
CreateWindowExA :: proc(
|
||||||
dwExStyle: DWORD,
|
dwExStyle: DWORD,
|
||||||
lpClassName: LPCSTR,
|
lpClassName: LPCSTR,
|
||||||
@@ -110,6 +86,8 @@ foreign user32 {
|
|||||||
DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
|
DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
|
||||||
DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
|
DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
|
||||||
|
|
||||||
|
FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND ---
|
||||||
|
FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND ---
|
||||||
FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
|
FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
|
||||||
FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
|
FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
|
||||||
|
|
||||||
@@ -124,6 +102,68 @@ foreign user32 {
|
|||||||
GetDC :: proc(hWnd: HWND) -> HDC ---
|
GetDC :: proc(hWnd: HWND) -> HDC ---
|
||||||
ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
|
ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
|
||||||
|
|
||||||
|
GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
|
||||||
|
ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
|
||||||
|
InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
|
||||||
|
|
||||||
BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
|
BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
|
||||||
EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
|
EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateWindowA :: #force_inline proc "stdcall" (
|
||||||
|
lpClassName: LPCSTR,
|
||||||
|
lpWindowName: LPCSTR,
|
||||||
|
dwStyle: DWORD,
|
||||||
|
X: c_int,
|
||||||
|
Y: c_int,
|
||||||
|
nWidth: c_int,
|
||||||
|
nHeight: c_int,
|
||||||
|
hWndParent: HWND,
|
||||||
|
hMenu: HMENU,
|
||||||
|
hInstance: HINSTANCE,
|
||||||
|
lpParam: LPVOID,
|
||||||
|
) -> HWND {
|
||||||
|
return CreateWindowExA(
|
||||||
|
0,
|
||||||
|
lpClassName,
|
||||||
|
lpWindowName,
|
||||||
|
dwStyle,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
nWidth,
|
||||||
|
nHeight,
|
||||||
|
hWndParent,
|
||||||
|
hMenu,
|
||||||
|
hInstance,
|
||||||
|
lpParam,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateWindowW :: #force_inline proc "stdcall" (
|
||||||
|
lpClassName: LPCTSTR,
|
||||||
|
lpWindowName: LPCTSTR,
|
||||||
|
dwStyle: DWORD,
|
||||||
|
X: c_int,
|
||||||
|
Y: c_int,
|
||||||
|
nWidth: c_int,
|
||||||
|
nHeight: c_int,
|
||||||
|
hWndParent: HWND,
|
||||||
|
hMenu: HMENU,
|
||||||
|
hInstance: HINSTANCE,
|
||||||
|
lpParam: LPVOID,
|
||||||
|
) -> HWND {
|
||||||
|
return CreateWindowExW(
|
||||||
|
0,
|
||||||
|
lpClassName,
|
||||||
|
lpWindowName,
|
||||||
|
dwStyle,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
nWidth,
|
||||||
|
nHeight,
|
||||||
|
hWndParent,
|
||||||
|
hMenu,
|
||||||
|
hInstance,
|
||||||
|
lpParam,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user