Remove unneeded semicolons from the core library

This commit is contained in:
gingerBill
2021-08-31 22:21:13 +01:00
parent b176af2742
commit 251da264ed
187 changed files with 27227 additions and 27227 deletions
+66 -66
View File
@@ -4,7 +4,7 @@ package win32
foreign import "system:comdlg32.lib"
import "core:strings"
OFN_Hook_Proc :: #type proc "stdcall" (hdlg: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Uint_Ptr;
OFN_Hook_Proc :: #type proc "stdcall" (hdlg: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Uint_Ptr
Open_File_Name_A :: struct {
struct_size: u32,
@@ -67,13 +67,13 @@ foreign comdlg32 {
@(link_name="CommDlgExtendedError") comm_dlg_extended_error :: proc() -> u32 ---
}
OPEN_TITLE :: "Select file to open";
OPEN_FLAGS :: u32(OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST);
OPEN_FLAGS_MULTI :: OPEN_FLAGS | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
OPEN_TITLE :: "Select file to open"
OPEN_FLAGS :: u32(OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST)
OPEN_FLAGS_MULTI :: OPEN_FLAGS | OFN_ALLOWMULTISELECT | OFN_EXPLORER
SAVE_TITLE :: "Select file to save";
SAVE_FLAGS :: u32(OFN_OVERWRITEPROMPT | OFN_EXPLORER);
SAVE_EXT :: "txt";
SAVE_TITLE :: "Select file to save"
SAVE_FLAGS :: u32(OFN_OVERWRITEPROMPT | OFN_EXPLORER)
SAVE_EXT :: "txt"
Open_Save_Mode :: enum {
Open = 0,
@@ -84,15 +84,15 @@ _open_file_dialog :: proc(title: string, dir: string,
filters: []string, default_filter: u32,
flags: u32, default_ext: string,
mode: Open_Save_Mode, allocator := context.temp_allocator) -> (path: string, ok: bool = true) {
file_buf := make([]u16, MAX_PATH_WIDE, allocator);
file_buf := make([]u16, MAX_PATH_WIDE, allocator)
// Filters need to be passed as a pair of strings (title, filter)
filter_len := u32(len(filters));
if filter_len % 2 != 0 do return "", false;
filter_len := u32(len(filters))
if filter_len % 2 != 0 do return "", false
filter: string;
filter = strings.join(filters, "\u0000", context.temp_allocator);
filter = strings.concatenate({filter, "\u0000"}, context.temp_allocator);
filter: string
filter = strings.join(filters, "\u0000", context.temp_allocator)
filter = strings.concatenate({filter, "\u0000"}, context.temp_allocator)
ofn := Open_File_Name_W{
struct_size = size_of(Open_File_Name_W),
@@ -104,33 +104,33 @@ _open_file_dialog :: proc(title: string, dir: string,
filter_index = u32(clamp(default_filter, 1, filter_len / 2)),
def_ext = utf8_to_wstring(default_ext, context.temp_allocator),
flags = u32(flags),
};
}
switch mode {
case .Open:
ok = bool(get_open_file_name_w(&ofn));
ok = bool(get_open_file_name_w(&ofn))
case .Save:
ok = bool(get_save_file_name_w(&ofn));
ok = bool(get_save_file_name_w(&ofn))
case:
ok = false;
ok = false
}
if !ok {
delete(file_buf);
return "", false;
delete(file_buf)
return "", false
}
file_name := utf16_to_utf8(file_buf[:], allocator);
path = strings.trim_right_null(file_name);
return;
file_name := utf16_to_utf8(file_buf[:], allocator)
path = strings.trim_right_null(file_name)
return
}
select_file_to_open :: proc(title := OPEN_TITLE, dir := ".",
filters := []string{"All Files", "*.*"}, default_filter := u32(1),
flags := OPEN_FLAGS, allocator := context.temp_allocator) -> (path: string, ok: bool) {
path, ok = _open_file_dialog(title, dir, filters, default_filter, flags, "", Open_Save_Mode.Open, allocator);
return;
path, ok = _open_file_dialog(title, dir, filters, default_filter, flags, "", Open_Save_Mode.Open, allocator)
return
}
select_file_to_save :: proc(title := SAVE_TITLE, dir := ".",
@@ -138,51 +138,51 @@ select_file_to_save :: proc(title := SAVE_TITLE, dir := ".",
flags := SAVE_FLAGS, default_ext := SAVE_EXT,
allocator := context.temp_allocator) -> (path: string, ok: bool) {
path, ok = _open_file_dialog(title, dir, filters, default_filter, flags, default_ext, Open_Save_Mode.Save, allocator);
return;
path, ok = _open_file_dialog(title, dir, filters, default_filter, flags, default_ext, Open_Save_Mode.Save, allocator)
return
}
// TODO: Implement convenience function for select_file_to_open with ALLOW_MULTI_SELECT that takes
// it output of the form "path\u0000\file1u\0000file2" and turns it into []string with the path + file pre-concatenated for you.
OFN_ALLOWMULTISELECT :: 0x00000200; // NOTE(Jeroen): Without OFN_EXPLORER it uses the Win3 dialog.
OFN_CREATEPROMPT :: 0x00002000;
OFN_DONTADDTORECENT :: 0x02000000;
OFN_ENABLEHOOK :: 0x00000020;
OFN_ENABLEINCLUDENOTIFY :: 0x00400000;
OFN_ENABLESIZING :: 0x00800000;
OFN_ENABLETEMPLATE :: 0x00000040;
OFN_ENABLETEMPLATEHANDLE :: 0x00000080;
OFN_EXPLORER :: 0x00080000;
OFN_EXTENSIONDIFFERENT :: 0x00000400;
OFN_FILEMUSTEXIST :: 0x00001000;
OFN_FORCESHOWHIDDEN :: 0x10000000;
OFN_HIDEREADONLY :: 0x00000004;
OFN_LONGNAMES :: 0x00200000;
OFN_NOCHANGEDIR :: 0x00000008;
OFN_NODEREFERENCELINKS :: 0x00100000;
OFN_NOLONGNAMES :: 0x00040000;
OFN_NONETWORKBUTTON :: 0x00020000;
OFN_NOREADONLYRETURN :: 0x00008000;
OFN_NOTESTFILECREATE :: 0x00010000;
OFN_NOVALIDATE :: 0x00000100;
OFN_OVERWRITEPROMPT :: 0x00000002;
OFN_PATHMUSTEXIST :: 0x00000800;
OFN_READONLY :: 0x00000001;
OFN_SHAREAWARE :: 0x00004000;
OFN_SHOWHELP :: 0x00000010;
OFN_ALLOWMULTISELECT :: 0x00000200 // NOTE(Jeroen): Without OFN_EXPLORER it uses the Win3 dialog.
OFN_CREATEPROMPT :: 0x00002000
OFN_DONTADDTORECENT :: 0x02000000
OFN_ENABLEHOOK :: 0x00000020
OFN_ENABLEINCLUDENOTIFY :: 0x00400000
OFN_ENABLESIZING :: 0x00800000
OFN_ENABLETEMPLATE :: 0x00000040
OFN_ENABLETEMPLATEHANDLE :: 0x00000080
OFN_EXPLORER :: 0x00080000
OFN_EXTENSIONDIFFERENT :: 0x00000400
OFN_FILEMUSTEXIST :: 0x00001000
OFN_FORCESHOWHIDDEN :: 0x10000000
OFN_HIDEREADONLY :: 0x00000004
OFN_LONGNAMES :: 0x00200000
OFN_NOCHANGEDIR :: 0x00000008
OFN_NODEREFERENCELINKS :: 0x00100000
OFN_NOLONGNAMES :: 0x00040000
OFN_NONETWORKBUTTON :: 0x00020000
OFN_NOREADONLYRETURN :: 0x00008000
OFN_NOTESTFILECREATE :: 0x00010000
OFN_NOVALIDATE :: 0x00000100
OFN_OVERWRITEPROMPT :: 0x00000002
OFN_PATHMUSTEXIST :: 0x00000800
OFN_READONLY :: 0x00000001
OFN_SHAREAWARE :: 0x00004000
OFN_SHOWHELP :: 0x00000010
CDERR_DIALOGFAILURE :: 0x0000FFFF;
CDERR_GENERALCODES :: 0x00000000;
CDERR_STRUCTSIZE :: 0x00000001;
CDERR_INITIALIZATION :: 0x00000002;
CDERR_NOTEMPLATE :: 0x00000003;
CDERR_NOHINSTANCE :: 0x00000004;
CDERR_LOADSTRFAILURE :: 0x00000005;
CDERR_FINDRESFAILURE :: 0x00000006;
CDERR_LOADRESFAILURE :: 0x00000007;
CDERR_LOCKRESFAILURE :: 0x00000008;
CDERR_MEMALLOCFAILURE :: 0x00000009;
CDERR_MEMLOCKFAILURE :: 0x0000000A;
CDERR_NOHOOK :: 0x0000000B;
CDERR_REGISTERMSGFAIL :: 0x0000000C;
CDERR_DIALOGFAILURE :: 0x0000FFFF
CDERR_GENERALCODES :: 0x00000000
CDERR_STRUCTSIZE :: 0x00000001
CDERR_INITIALIZATION :: 0x00000002
CDERR_NOTEMPLATE :: 0x00000003
CDERR_NOHINSTANCE :: 0x00000004
CDERR_LOADSTRFAILURE :: 0x00000005
CDERR_FINDRESFAILURE :: 0x00000006
CDERR_LOADRESFAILURE :: 0x00000007
CDERR_LOCKRESFAILURE :: 0x00000008
CDERR_MEMALLOCFAILURE :: 0x00000009
CDERR_MEMLOCKFAILURE :: 0x0000000A
CDERR_NOHOOK :: 0x0000000B
CDERR_REGISTERMSGFAIL :: 0x0000000C
+5 -5
View File
@@ -1,15 +1,15 @@
// +build windows
package win32
import "core:strings";
import "core:strings"
foreign {
@(link_name="_wgetcwd") _get_cwd_wide :: proc(buffer: Wstring, buf_len: int) -> ^Wstring ---
}
get_cwd :: proc(allocator := context.temp_allocator) -> string {
buffer := make([]u16, MAX_PATH_WIDE, allocator);
_get_cwd_wide(Wstring(&buffer[0]), MAX_PATH_WIDE);
file := utf16_to_utf8(buffer[:], allocator);
return strings.trim_right_null(file);
buffer := make([]u16, MAX_PATH_WIDE, allocator)
_get_cwd_wide(Wstring(&buffer[0]), MAX_PATH_WIDE)
file := utf16_to_utf8(buffer[:], allocator)
return strings.trim_right_null(file)
}
+8 -8
View File
@@ -3,12 +3,12 @@ package win32
foreign import "system:gdi32.lib"
WHITENESS :: 0x00FF0062;
BLACKNESS :: 0x00000042;
WHITENESS :: 0x00FF0062
BLACKNESS :: 0x00000042
@(default_calling_convention = "std")
foreign gdi32 {
@(link_name="GetStockObject") get_stock_object :: proc(fn_object: i32) -> Hgdiobj ---;
@(link_name="GetStockObject") get_stock_object :: proc(fn_object: i32) -> Hgdiobj ---
@(link_name="StretchDIBits")
stretch_dibits :: proc(hdc: Hdc,
@@ -16,11 +16,11 @@ foreign gdi32 {
x_src, y_src, width_src, header_src: i32,
bits: rawptr, bits_info: ^Bitmap_Info,
usage: u32,
rop: u32) -> i32 ---;
rop: u32) -> i32 ---
@(link_name="SetPixelFormat") set_pixel_format :: proc(hdc: Hdc, pixel_format: i32, pfd: ^Pixel_Format_Descriptor) -> Bool ---;
@(link_name="ChoosePixelFormat") choose_pixel_format :: proc(hdc: Hdc, pfd: ^Pixel_Format_Descriptor) -> i32 ---;
@(link_name="SwapBuffers") swap_buffers :: proc(hdc: Hdc) -> Bool ---;
@(link_name="SetPixelFormat") set_pixel_format :: proc(hdc: Hdc, pixel_format: i32, pfd: ^Pixel_Format_Descriptor) -> Bool ---
@(link_name="ChoosePixelFormat") choose_pixel_format :: proc(hdc: Hdc, pfd: ^Pixel_Format_Descriptor) -> i32 ---
@(link_name="SwapBuffers") swap_buffers :: proc(hdc: Hdc) -> Bool ---
@(link_name="PatBlt") pat_blt :: proc(hdc: Hdc, x, y, w, h: i32, rop: u32) -> Bool ---;
@(link_name="PatBlt") pat_blt :: proc(hdc: Hdc, x, y, w, h: i32, rop: u32) -> Bool ---
}
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -1,11 +1,11 @@
// +build windows
package win32
import "core:strings";
import "core:strings"
call_external_process :: proc(program, command_line: string) -> bool {
si := Startup_Info{ cb=size_of(Startup_Info) };
pi := Process_Information{};
si := Startup_Info{ cb=size_of(Startup_Info) }
pi := Process_Information{}
return cast(bool)create_process_w(
utf8_to_wstring(program),
@@ -18,12 +18,12 @@ call_external_process :: proc(program, command_line: string) -> bool {
nil,
&si,
&pi,
);
)
}
open_website :: proc(url: string) -> bool {
p :: "C:\\Windows\\System32\\cmd.exe";
arg := []string{"/C", "start", url};
args := strings.join(arg, " ", context.temp_allocator);
return call_external_process(p, args);
p :: "C:\\Windows\\System32\\cmd.exe"
arg := []string{"/C", "start", url}
args := strings.join(arg, " ", context.temp_allocator)
return call_external_process(p, args)
}
+132 -132
View File
@@ -9,188 +9,188 @@ foreign kernel32 {
process_attributes, thread_attributes: ^Security_Attributes,
inherit_handle: Bool, creation_flags: u32, environment: rawptr,
current_directory: cstring, startup_info: ^Startup_Info,
process_information: ^Process_Information) -> Bool ---;
process_information: ^Process_Information) -> Bool ---
@(link_name="CreateProcessW") create_process_w :: proc(application_name, command_line: Wstring,
process_attributes, thread_attributes: ^Security_Attributes,
inherit_handle: Bool, creation_flags: u32, environment: rawptr,
current_directory: Wstring, startup_info: ^Startup_Info,
process_information: ^Process_Information) -> Bool ---;
@(link_name="GetExitCodeProcess") get_exit_code_process :: proc(process: Handle, exit: ^u32) -> Bool ---;
@(link_name="ExitProcess") exit_process :: proc(exit_code: u32) ---;
@(link_name="GetModuleHandleA") get_module_handle_a :: proc(module_name: cstring) -> Hmodule ---;
@(link_name="GetModuleHandleW") get_module_handle_w :: proc(module_name: Wstring) -> Hmodule ---;
process_information: ^Process_Information) -> Bool ---
@(link_name="GetExitCodeProcess") get_exit_code_process :: proc(process: Handle, exit: ^u32) -> Bool ---
@(link_name="ExitProcess") exit_process :: proc(exit_code: u32) ---
@(link_name="GetModuleHandleA") get_module_handle_a :: proc(module_name: cstring) -> Hmodule ---
@(link_name="GetModuleHandleW") get_module_handle_w :: proc(module_name: Wstring) -> Hmodule ---
@(link_name="GetModuleFileNameA") get_module_file_name_a :: proc(module: Hmodule, filename: cstring, size: u32) -> u32 ---;
@(link_name="GetModuleFileNameW") get_module_file_name_w :: proc(module: Hmodule, filename: Wstring, size: u32) -> u32 ---;
@(link_name="GetModuleFileNameA") get_module_file_name_a :: proc(module: Hmodule, filename: cstring, size: u32) -> u32 ---
@(link_name="GetModuleFileNameW") get_module_file_name_w :: proc(module: Hmodule, filename: Wstring, size: u32) -> u32 ---
@(link_name="Sleep") sleep :: proc(ms: u32) ---;
@(link_name="QueryPerformanceFrequency") query_performance_frequency :: proc(result: ^i64) -> i32 ---;
@(link_name="QueryPerformanceCounter") query_performance_counter :: proc(result: ^i64) -> i32 ---;
@(link_name="OutputDebugStringA") output_debug_string_a :: proc(c_str: cstring) ---;
@(link_name="Sleep") sleep :: proc(ms: u32) ---
@(link_name="QueryPerformanceFrequency") query_performance_frequency :: proc(result: ^i64) -> i32 ---
@(link_name="QueryPerformanceCounter") query_performance_counter :: proc(result: ^i64) -> i32 ---
@(link_name="OutputDebugStringA") output_debug_string_a :: proc(c_str: cstring) ---
@(link_name="GetCommandLineA") get_command_line_a :: proc() -> cstring ---;
@(link_name="GetCommandLineW") get_command_line_w :: proc() -> Wstring ---;
@(link_name="GetSystemMetrics") get_system_metrics :: proc(index: i32) -> i32 ---;
@(link_name="GetSystemInfo") get_system_info :: proc(info: ^System_Info) ---;
@(link_name="GetVersionExA") get_version :: proc(osvi: ^OS_Version_Info_Ex_A) ---;
@(link_name="GetCurrentThreadId") get_current_thread_id :: proc() -> u32 ---;
@(link_name="GetCommandLineA") get_command_line_a :: proc() -> cstring ---
@(link_name="GetCommandLineW") get_command_line_w :: proc() -> Wstring ---
@(link_name="GetSystemMetrics") get_system_metrics :: proc(index: i32) -> i32 ---
@(link_name="GetSystemInfo") get_system_info :: proc(info: ^System_Info) ---
@(link_name="GetVersionExA") get_version :: proc(osvi: ^OS_Version_Info_Ex_A) ---
@(link_name="GetCurrentThreadId") get_current_thread_id :: proc() -> u32 ---
// NOTE(tetra): Not thread safe with SetCurrentDirectory and GetFullPathName;
// The current directory is stored as a global variable in the process.
@(link_name="GetCurrentDirectoryW") get_current_directory_w :: proc(len: u32, buf: Wstring) -> u32 ---;
@(link_name="SetCurrentDirectoryW") set_current_directory_w :: proc(buf: Wstring) -> u32 ---;
@(link_name="GetCurrentDirectoryW") get_current_directory_w :: proc(len: u32, buf: Wstring) -> u32 ---
@(link_name="SetCurrentDirectoryW") set_current_directory_w :: proc(buf: Wstring) -> u32 ---
@(link_name="GetSystemTimeAsFileTime") get_system_time_as_file_time :: proc(system_time_as_file_time: ^Filetime) ---;
@(link_name="FileTimeToLocalFileTime") file_time_to_local_file_time :: proc(file_time: ^Filetime, local_file_time: ^Filetime) -> Bool ---;
@(link_name="FileTimeToSystemTime") file_time_to_system_time :: proc(file_time: ^Filetime, system_time: ^Systemtime) -> Bool ---;
@(link_name="SystemTimeToFileTime") system_time_to_file_time :: proc(system_time: ^Systemtime, file_time: ^Filetime) -> Bool ---;
@(link_name="GetSystemTimeAsFileTime") get_system_time_as_file_time :: proc(system_time_as_file_time: ^Filetime) ---
@(link_name="FileTimeToLocalFileTime") file_time_to_local_file_time :: proc(file_time: ^Filetime, local_file_time: ^Filetime) -> Bool ---
@(link_name="FileTimeToSystemTime") file_time_to_system_time :: proc(file_time: ^Filetime, system_time: ^Systemtime) -> Bool ---
@(link_name="SystemTimeToFileTime") system_time_to_file_time :: proc(system_time: ^Systemtime, file_time: ^Filetime) -> Bool ---
@(link_name="GetStdHandle") get_std_handle :: proc(h: i32) -> Handle ---;
@(link_name="GetStdHandle") get_std_handle :: proc(h: i32) -> Handle ---
@(link_name="CreateFileA")
create_file_a :: proc(filename: cstring, desired_access, share_module: u32,
security: rawptr,
creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---;
creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---
@(link_name="CreateFileW")
create_file_w :: proc(filename: Wstring, desired_access, share_module: u32,
security: rawptr,
creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---;
creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---
@(link_name="ReadFile") read_file :: proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool ---;
@(link_name="WriteFile") write_file :: proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool ---;
@(link_name="ReadFile") read_file :: proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool ---
@(link_name="WriteFile") write_file :: proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool ---
@(link_name="GetFileSizeEx") get_file_size_ex :: proc(file_handle: Handle, file_size: ^i64) -> Bool ---;
@(link_name="GetFileInformationByHandle") get_file_information_by_handle :: proc(file_handle: Handle, file_info: ^By_Handle_File_Information) -> Bool ---;
@(link_name="GetFileSizeEx") get_file_size_ex :: proc(file_handle: Handle, file_size: ^i64) -> Bool ---
@(link_name="GetFileInformationByHandle") get_file_information_by_handle :: proc(file_handle: Handle, file_info: ^By_Handle_File_Information) -> Bool ---
@(link_name="CreateDirectoryA") create_directory_a :: proc(path: cstring, security_attributes: ^Security_Attributes) -> Bool ---;
@(link_name="CreateDirectoryW") create_directory_w :: proc(path: Wstring, security_attributes: ^Security_Attributes) -> Bool ---;
@(link_name="CreateDirectoryA") create_directory_a :: proc(path: cstring, security_attributes: ^Security_Attributes) -> Bool ---
@(link_name="CreateDirectoryW") create_directory_w :: proc(path: Wstring, security_attributes: ^Security_Attributes) -> Bool ---
@(link_name="GetFileType") get_file_type :: proc(file_handle: Handle) -> u32 ---;
@(link_name="SetFilePointer") set_file_pointer :: proc(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 ---;
@(link_name="GetFileType") get_file_type :: proc(file_handle: Handle) -> u32 ---
@(link_name="SetFilePointer") set_file_pointer :: proc(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 ---
@(link_name="SetHandleInformation") set_handle_information :: proc(obj: Handle, mask, flags: u32) -> Bool ---;
@(link_name="SetHandleInformation") set_handle_information :: proc(obj: Handle, mask, flags: u32) -> Bool ---
@(link_name="FindFirstFileA") find_first_file_a :: proc(file_name: cstring, data: ^Find_Data_A) -> Handle ---;
@(link_name="FindNextFileA") find_next_file_a :: proc(file: Handle, data: ^Find_Data_A) -> Bool ---;
@(link_name="FindFirstFileA") find_first_file_a :: proc(file_name: cstring, data: ^Find_Data_A) -> Handle ---
@(link_name="FindNextFileA") find_next_file_a :: proc(file: Handle, data: ^Find_Data_A) -> Bool ---
@(link_name="FindFirstFileW") find_first_file_w :: proc(file_name: Wstring, data: ^Find_Data_W) -> Handle ---;
@(link_name="FindNextFileW") find_next_file_w :: proc(file: Handle, data: ^Find_Data_W) -> Bool ---;
@(link_name="FindFirstFileW") find_first_file_w :: proc(file_name: Wstring, data: ^Find_Data_W) -> Handle ---
@(link_name="FindNextFileW") find_next_file_w :: proc(file: Handle, data: ^Find_Data_W) -> Bool ---
@(link_name="FindClose") find_close :: proc(file: Handle) -> Bool ---;
@(link_name="FindClose") find_close :: proc(file: Handle) -> Bool ---
@(link_name="MoveFileExA") move_file_ex_a :: proc(existing, new: cstring, flags: u32) -> Bool ---;
@(link_name="DeleteFileA") delete_file_a :: proc(file_name: cstring) -> Bool ---;
@(link_name="CopyFileA") copy_file_a :: proc(existing, new: cstring, fail_if_exists: Bool) -> Bool ---;
@(link_name="MoveFileExA") move_file_ex_a :: proc(existing, new: cstring, flags: u32) -> Bool ---
@(link_name="DeleteFileA") delete_file_a :: proc(file_name: cstring) -> Bool ---
@(link_name="CopyFileA") copy_file_a :: proc(existing, new: cstring, fail_if_exists: Bool) -> Bool ---
@(link_name="MoveFileExW") move_file_ex_w :: proc(existing, new: Wstring, flags: u32) -> Bool ---;
@(link_name="DeleteFileW") delete_file_w :: proc(file_name: Wstring) -> Bool ---;
@(link_name="CopyFileW") copy_file_w :: proc(existing, new: Wstring, fail_if_exists: Bool) -> Bool ---;
@(link_name="MoveFileExW") move_file_ex_w :: proc(existing, new: Wstring, flags: u32) -> Bool ---
@(link_name="DeleteFileW") delete_file_w :: proc(file_name: Wstring) -> Bool ---
@(link_name="CopyFileW") copy_file_w :: proc(existing, new: Wstring, fail_if_exists: Bool) -> Bool ---
@(link_name="HeapAlloc") heap_alloc :: proc(h: Handle, flags: u32, bytes: int) -> rawptr ---;
@(link_name="HeapReAlloc") heap_realloc :: proc(h: Handle, flags: u32, memory: rawptr, bytes: int) -> rawptr ---;
@(link_name="HeapFree") heap_free :: proc(h: Handle, flags: u32, memory: rawptr) -> Bool ---;
@(link_name="GetProcessHeap") get_process_heap :: proc() -> Handle ---;
@(link_name="HeapAlloc") heap_alloc :: proc(h: Handle, flags: u32, bytes: int) -> rawptr ---
@(link_name="HeapReAlloc") heap_realloc :: proc(h: Handle, flags: u32, memory: rawptr, bytes: int) -> rawptr ---
@(link_name="HeapFree") heap_free :: proc(h: Handle, flags: u32, memory: rawptr) -> Bool ---
@(link_name="GetProcessHeap") get_process_heap :: proc() -> Handle ---
@(link_name="LocalAlloc") local_alloc :: proc(flags: u32, bytes: int) -> rawptr ---;
@(link_name="LocalReAlloc") local_realloc :: proc(mem: rawptr, bytes: int, flags: uint) -> rawptr ---;
@(link_name="LocalFree") local_free :: proc(mem: rawptr) -> rawptr ---;
@(link_name="LocalAlloc") local_alloc :: proc(flags: u32, bytes: int) -> rawptr ---
@(link_name="LocalReAlloc") local_realloc :: proc(mem: rawptr, bytes: int, flags: uint) -> rawptr ---
@(link_name="LocalFree") local_free :: proc(mem: rawptr) -> rawptr ---
@(link_name="FindFirstChangeNotificationA") find_first_change_notification_a :: proc(path: cstring, watch_subtree: Bool, filter: u32) -> Handle ---;
@(link_name="FindNextChangeNotification") find_next_change_notification :: proc(h: Handle) -> Bool ---;
@(link_name="FindCloseChangeNotification") find_close_change_notification :: proc(h: Handle) -> Bool ---;
@(link_name="FindFirstChangeNotificationA") find_first_change_notification_a :: proc(path: cstring, watch_subtree: Bool, filter: u32) -> Handle ---
@(link_name="FindNextChangeNotification") find_next_change_notification :: proc(h: Handle) -> Bool ---
@(link_name="FindCloseChangeNotification") find_close_change_notification :: proc(h: Handle) -> Bool ---
@(link_name="ReadDirectoryChangesW") read_directory_changes_w :: proc(dir: Handle, buf: rawptr, buf_length: u32,
watch_subtree: Bool, notify_filter: u32,
bytes_returned: ^u32, overlapped: ^Overlapped,
completion: rawptr) -> Bool ---;
completion: rawptr) -> Bool ---
@(link_name="WideCharToMultiByte") wide_char_to_multi_byte :: proc(code_page: u32, flags: u32,
wchar_str: Wstring, wchar: i32,
multi_str: cstring, multi: i32,
default_char: cstring, used_default_char: ^Bool) -> i32 ---;
default_char: cstring, used_default_char: ^Bool) -> i32 ---
@(link_name="MultiByteToWideChar") multi_byte_to_wide_char :: proc(code_page: u32, flags: u32,
mb_str: cstring, mb: i32,
wc_str: Wstring, wc: i32) -> i32 ---;
wc_str: Wstring, wc: i32) -> i32 ---
@(link_name="CreateSemaphoreA") create_semaphore_a :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: cstring) -> Handle ---;
@(link_name="CreateSemaphoreW") create_semaphore_w :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: cstring) -> Handle ---;
@(link_name="ReleaseSemaphore") release_semaphore :: proc(semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool ---;
@(link_name="WaitForSingleObject") wait_for_single_object :: proc(handle: Handle, milliseconds: u32) -> u32 ---;
@(link_name="CreateSemaphoreA") create_semaphore_a :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: cstring) -> Handle ---
@(link_name="CreateSemaphoreW") create_semaphore_w :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: cstring) -> Handle ---
@(link_name="ReleaseSemaphore") release_semaphore :: proc(semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool ---
@(link_name="WaitForSingleObject") wait_for_single_object :: proc(handle: Handle, milliseconds: u32) -> u32 ---
}
// @(default_calling_convention = "c")
foreign kernel32 {
@(link_name="GetLastError") get_last_error :: proc() -> i32 ---;
@(link_name="CloseHandle") close_handle :: proc(h: Handle) -> i32 ---;
@(link_name="GetLastError") get_last_error :: proc() -> i32 ---
@(link_name="CloseHandle") close_handle :: proc(h: Handle) -> i32 ---
@(link_name="GetFileAttributesA") get_file_attributes_a :: proc(filename: cstring) -> u32 ---;
@(link_name="GetFileAttributesW") get_file_attributes_w :: proc(filename: Wstring) -> u32 ---;
@(link_name="GetFileAttributesExA") get_file_attributes_ex_a :: proc(filename: cstring, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: ^File_Attribute_Data) -> Bool ---;
@(link_name="GetFileAttributesExW") get_file_attributes_ex_w :: proc(filename: Wstring, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: ^File_Attribute_Data) -> Bool ---;
@(link_name="CompareFileTime") compare_file_time :: proc(a, b: ^Filetime) -> i32 ---;
@(link_name="GetFileAttributesA") get_file_attributes_a :: proc(filename: cstring) -> u32 ---
@(link_name="GetFileAttributesW") get_file_attributes_w :: proc(filename: Wstring) -> u32 ---
@(link_name="GetFileAttributesExA") get_file_attributes_ex_a :: proc(filename: cstring, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: ^File_Attribute_Data) -> Bool ---
@(link_name="GetFileAttributesExW") get_file_attributes_ex_w :: proc(filename: Wstring, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: ^File_Attribute_Data) -> Bool ---
@(link_name="CompareFileTime") compare_file_time :: proc(a, b: ^Filetime) -> i32 ---
}
@(default_calling_convention = "c")
foreign kernel32 {
@(link_name="InterlockedCompareExchange") interlocked_compare_exchange :: proc(dst: ^i32, exchange, comparand: i32) -> i32 ---;
@(link_name="InterlockedExchange") interlocked_exchange :: proc(dst: ^i32, desired: i32) -> i32 ---;
@(link_name="InterlockedExchangeAdd") interlocked_exchange_add :: proc(dst: ^i32, desired: i32) -> i32 ---;
@(link_name="InterlockedAnd") interlocked_and :: proc(dst: ^i32, desired: i32) -> i32 ---;
@(link_name="InterlockedOr") interlocked_or :: proc(dst: ^i32, desired: i32) -> i32 ---;
@(link_name="InterlockedCompareExchange") interlocked_compare_exchange :: proc(dst: ^i32, exchange, comparand: i32) -> i32 ---
@(link_name="InterlockedExchange") interlocked_exchange :: proc(dst: ^i32, desired: i32) -> i32 ---
@(link_name="InterlockedExchangeAdd") interlocked_exchange_add :: proc(dst: ^i32, desired: i32) -> i32 ---
@(link_name="InterlockedAnd") interlocked_and :: proc(dst: ^i32, desired: i32) -> i32 ---
@(link_name="InterlockedOr") interlocked_or :: proc(dst: ^i32, desired: i32) -> i32 ---
@(link_name="InterlockedCompareExchange64") interlocked_compare_exchange64 :: proc(dst: ^i64, exchange, comparand: i64) -> i64 ---;
@(link_name="InterlockedExchange64") interlocked_exchange64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
@(link_name="InterlockedExchangeAdd64") interlocked_exchange_add64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
@(link_name="InterlockedAnd64") interlocked_and64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
@(link_name="InterlockedOr64") interlocked_or64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
@(link_name="InterlockedCompareExchange64") interlocked_compare_exchange64 :: proc(dst: ^i64, exchange, comparand: i64) -> i64 ---
@(link_name="InterlockedExchange64") interlocked_exchange64 :: proc(dst: ^i64, desired: i64) -> i64 ---
@(link_name="InterlockedExchangeAdd64") interlocked_exchange_add64 :: proc(dst: ^i64, desired: i64) -> i64 ---
@(link_name="InterlockedAnd64") interlocked_and64 :: proc(dst: ^i64, desired: i64) -> i64 ---
@(link_name="InterlockedOr64") interlocked_or64 :: proc(dst: ^i64, desired: i64) -> i64 ---
}
@(default_calling_convention = "std")
foreign kernel32 {
@(link_name="_mm_pause") mm_pause :: proc() ---;
@(link_name="ReadWriteBarrier") read_write_barrier :: proc() ---;
@(link_name="WriteBarrier") write_barrier :: proc() ---;
@(link_name="ReadBarrier") read_barrier :: proc() ---;
@(link_name="_mm_pause") mm_pause :: proc() ---
@(link_name="ReadWriteBarrier") read_write_barrier :: proc() ---
@(link_name="WriteBarrier") write_barrier :: proc() ---
@(link_name="ReadBarrier") read_barrier :: proc() ---
@(link_name="CreateThread")
create_thread :: proc(thread_attributes: ^Security_Attributes, stack_size: uint, start_routine: proc "stdcall" (rawptr) -> u32,
parameter: rawptr, creation_flags: u32, thread_id: ^u32) -> Handle ---;
@(link_name="ResumeThread") resume_thread :: proc(thread: Handle) -> u32 ---;
@(link_name="GetThreadPriority") get_thread_priority :: proc(thread: Handle) -> i32 ---;
@(link_name="SetThreadPriority") set_thread_priority :: proc(thread: Handle, priority: i32) -> Bool ---;
@(link_name="GetExitCodeThread") get_exit_code_thread :: proc(thread: Handle, exit_code: ^u32) -> Bool ---;
@(link_name="TerminateThread") terminate_thread :: proc(thread: Handle, exit_code: u32) -> Bool ---;
parameter: rawptr, creation_flags: u32, thread_id: ^u32) -> Handle ---
@(link_name="ResumeThread") resume_thread :: proc(thread: Handle) -> u32 ---
@(link_name="GetThreadPriority") get_thread_priority :: proc(thread: Handle) -> i32 ---
@(link_name="SetThreadPriority") set_thread_priority :: proc(thread: Handle, priority: i32) -> Bool ---
@(link_name="GetExitCodeThread") get_exit_code_thread :: proc(thread: Handle, exit_code: ^u32) -> Bool ---
@(link_name="TerminateThread") terminate_thread :: proc(thread: Handle, exit_code: u32) -> Bool ---
@(link_name="InitializeCriticalSection") initialize_critical_section :: proc(critical_section: ^Critical_Section) ---;
@(link_name="InitializeCriticalSectionAndSpinCount") initialize_critical_section_and_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) -> b32 ---;
@(link_name="DeleteCriticalSection") delete_critical_section :: proc(critical_section: ^Critical_Section) ---;
@(link_name="SetCriticalSectionSpinCount") set_critical_section_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) -> u32 ---;
@(link_name="TryEnterCriticalSection") try_enter_critical_section :: proc(critical_section: ^Critical_Section) -> b8 ---;
@(link_name="EnterCriticalSection") enter_critical_section :: proc(critical_section: ^Critical_Section) ---;
@(link_name="LeaveCriticalSection") leave_critical_section :: proc(critical_section: ^Critical_Section) ---;
@(link_name="InitializeCriticalSection") initialize_critical_section :: proc(critical_section: ^Critical_Section) ---
@(link_name="InitializeCriticalSectionAndSpinCount") initialize_critical_section_and_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) -> b32 ---
@(link_name="DeleteCriticalSection") delete_critical_section :: proc(critical_section: ^Critical_Section) ---
@(link_name="SetCriticalSectionSpinCount") set_critical_section_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) -> u32 ---
@(link_name="TryEnterCriticalSection") try_enter_critical_section :: proc(critical_section: ^Critical_Section) -> b8 ---
@(link_name="EnterCriticalSection") enter_critical_section :: proc(critical_section: ^Critical_Section) ---
@(link_name="LeaveCriticalSection") leave_critical_section :: proc(critical_section: ^Critical_Section) ---
@(link_name="CreateEventA") create_event_a :: proc(event_attributes: ^Security_Attributes, manual_reset, initial_state: Bool, name: cstring) -> Handle ---;
@(link_name="CreateEventW") create_event_w :: proc(event_attributes: ^Security_Attributes, manual_reset, initial_state: Bool, name: Wstring) -> Handle ---;
@(link_name="PulseEvent") pulse_event :: proc(event: Handle) -> Bool ---;
@(link_name="SetEvent") set_event :: proc(event: Handle) -> Bool ---;
@(link_name="ResetEvent") reset_event :: proc(event: Handle) -> Bool ---;
@(link_name="CreateEventA") create_event_a :: proc(event_attributes: ^Security_Attributes, manual_reset, initial_state: Bool, name: cstring) -> Handle ---
@(link_name="CreateEventW") create_event_w :: proc(event_attributes: ^Security_Attributes, manual_reset, initial_state: Bool, name: Wstring) -> Handle ---
@(link_name="PulseEvent") pulse_event :: proc(event: Handle) -> Bool ---
@(link_name="SetEvent") set_event :: proc(event: Handle) -> Bool ---
@(link_name="ResetEvent") reset_event :: proc(event: Handle) -> Bool ---
@(link_name="LoadLibraryA") load_library_a :: proc(c_str: cstring) -> Hmodule ---;
@(link_name="LoadLibraryW") load_library_w :: proc(c_str: Wstring) -> Hmodule ---;
@(link_name="FreeLibrary") free_library :: proc(h: Hmodule) -> Bool ---;
@(link_name="GetProcAddress") get_proc_address :: proc(h: Hmodule, c_str: cstring) -> rawptr ---;
@(link_name="LoadLibraryA") load_library_a :: proc(c_str: cstring) -> Hmodule ---
@(link_name="LoadLibraryW") load_library_w :: proc(c_str: Wstring) -> Hmodule ---
@(link_name="FreeLibrary") free_library :: proc(h: Hmodule) -> Bool ---
@(link_name="GetProcAddress") get_proc_address :: proc(h: Hmodule, c_str: cstring) -> rawptr ---
@(link_name="GetFullPathNameA") get_full_path_name_a :: proc(filename: cstring, buffer_length: u32, buffer: cstring, file_part: ^Wstring) -> u32 ---;
@(link_name="GetFullPathNameW") get_full_path_name_w :: proc(filename: Wstring, buffer_length: u32, buffer: Wstring, file_part: ^Wstring) -> u32 ---;
@(link_name="GetLongPathNameA") get_long_path_name_a :: proc(short, long: cstring, len: u32) -> u32 ---;
@(link_name="GetLongPathNameW") get_long_path_name_w :: proc(short, long: Wstring, len: u32) -> u32 ---;
@(link_name="GetShortPathNameA") get_short_path_name_a :: proc(long, short: cstring, len: u32) -> u32 ---;
@(link_name="GetShortPathNameW") get_short_path_name_w :: proc(long, short: Wstring, len: u32) -> u32 ---;
@(link_name="GetFullPathNameA") get_full_path_name_a :: proc(filename: cstring, buffer_length: u32, buffer: cstring, file_part: ^Wstring) -> u32 ---
@(link_name="GetFullPathNameW") get_full_path_name_w :: proc(filename: Wstring, buffer_length: u32, buffer: Wstring, file_part: ^Wstring) -> u32 ---
@(link_name="GetLongPathNameA") get_long_path_name_a :: proc(short, long: cstring, len: u32) -> u32 ---
@(link_name="GetLongPathNameW") get_long_path_name_w :: proc(short, long: Wstring, len: u32) -> u32 ---
@(link_name="GetShortPathNameA") get_short_path_name_a :: proc(long, short: cstring, len: u32) -> u32 ---
@(link_name="GetShortPathNameW") get_short_path_name_w :: proc(long, short: Wstring, len: u32) -> u32 ---
@(link_name="GetCurrentDirectoryA") get_current_directory_a :: proc(buffer_length: u32, buffer: cstring) -> u32 ---;
@(link_name="GetCurrentDirectoryA") get_current_directory_a :: proc(buffer_length: u32, buffer: cstring) -> u32 ---
}
Memory_Basic_Information :: struct {
@@ -213,23 +213,23 @@ foreign kernel32 {
@(link_name="VirtualQuery") virtual_query :: proc(address: rawptr, buffer: ^Memory_Basic_Information, length: uint) -> uint ---
}
MEM_COMMIT :: 0x00001000;
MEM_RESERVE :: 0x00002000;
MEM_DECOMMIT :: 0x00004000;
MEM_RELEASE :: 0x00008000;
MEM_RESET :: 0x00080000;
MEM_RESET_UNDO :: 0x01000000;
MEM_COMMIT :: 0x00001000
MEM_RESERVE :: 0x00002000
MEM_DECOMMIT :: 0x00004000
MEM_RELEASE :: 0x00008000
MEM_RESET :: 0x00080000
MEM_RESET_UNDO :: 0x01000000
MEM_LARGE_PAGES :: 0x20000000;
MEM_PHYSICAL :: 0x00400000;
MEM_TOP_DOWN :: 0x00100000;
MEM_WRITE_WATCH :: 0x00200000;
MEM_LARGE_PAGES :: 0x20000000
MEM_PHYSICAL :: 0x00400000
MEM_TOP_DOWN :: 0x00100000
MEM_WRITE_WATCH :: 0x00200000
PAGE_NOACCESS :: 0x01;
PAGE_READONLY :: 0x02;
PAGE_READWRITE :: 0x04;
PAGE_WRITECOPY :: 0x08;
PAGE_EXECUTE :: 0x10;
PAGE_EXECUTE_READ :: 0x20;
PAGE_EXECUTE_READWRITE :: 0x40;
PAGE_EXECUTE_WRITECOPY :: 0x80;
PAGE_NOACCESS :: 0x01
PAGE_READONLY :: 0x02
PAGE_READWRITE :: 0x04
PAGE_WRITECOPY :: 0x08
PAGE_EXECUTE :: 0x10
PAGE_EXECUTE_READ :: 0x20
PAGE_EXECUTE_READWRITE :: 0x40
PAGE_EXECUTE_WRITECOPY :: 0x80
+3 -3
View File
@@ -9,10 +9,10 @@ Com_Init :: enum {
Apartment_Threaded = 0x2,
Disable_OLE1_DDE = 0x4,
Speed_Over_Memory = 0x8,
};
}
@(default_calling_convention = "std")
foreign ole32 {
@(link_name ="CoInitializeEx") com_init_ex :: proc(reserved: rawptr, co_init: Com_Init) ->Hresult ---;
@(link_name = "CoUninitialize") com_shutdown :: proc() ---;
@(link_name ="CoInitializeEx") com_init_ex :: proc(reserved: rawptr, co_init: Com_Init) ->Hresult ---
@(link_name = "CoUninitialize") com_shutdown :: proc() ---
}
+1 -1
View File
@@ -5,5 +5,5 @@ foreign import "system:shell32.lib"
@(default_calling_convention = "std")
foreign shell32 {
@(link_name="CommandLineToArgvW") command_line_to_argv_w :: proc(cmd_list: Wstring, num_args: ^i32) -> ^Wstring ---;
@(link_name="CommandLineToArgvW") command_line_to_argv_w :: proc(cmd_list: Wstring, num_args: ^i32) -> ^Wstring ---
}
+141 -141
View File
@@ -41,71 +41,71 @@ Menu_Item_Info_W :: struct {
cch: u32,
}
MF_BYCOMMAND :: 0x00000000;
MF_BYPOSITION :: 0x00000400;
MF_BITMAP :: 0x00000004;
MF_CHECKED :: 0x00000008;
MF_DISABLED :: 0x00000002;
MF_ENABLED :: 0x00000000;
MF_GRAYED :: 0x00000001;
MF_MENUBARBREAK :: 0x00000020;
MF_MENUBREAK :: 0x00000040;
MF_OWNERDRAW :: 0x00000100;
MF_POPUP :: 0x00000010;
MF_SEPARATOR :: 0x00000800;
MF_STRING :: 0x00000000;
MF_UNCHECKED :: 0x00000000;
MF_BYCOMMAND :: 0x00000000
MF_BYPOSITION :: 0x00000400
MF_BITMAP :: 0x00000004
MF_CHECKED :: 0x00000008
MF_DISABLED :: 0x00000002
MF_ENABLED :: 0x00000000
MF_GRAYED :: 0x00000001
MF_MENUBARBREAK :: 0x00000020
MF_MENUBREAK :: 0x00000040
MF_OWNERDRAW :: 0x00000100
MF_POPUP :: 0x00000010
MF_SEPARATOR :: 0x00000800
MF_STRING :: 0x00000000
MF_UNCHECKED :: 0x00000000
MB_ABORTRETRYIGNORE :: 0x00000002;
MB_CANCELTRYCONTINUE :: 0x00000006;
MB_HELP :: 0x00004000;
MB_OK :: 0x00000000;
MB_OKCANCEL :: 0x00000001;
MB_RETRYCANCEL :: 0x00000005;
MB_YESNO :: 0x00000004;
MB_YESNOCANCEL :: 0x00000003;
MB_ABORTRETRYIGNORE :: 0x00000002
MB_CANCELTRYCONTINUE :: 0x00000006
MB_HELP :: 0x00004000
MB_OK :: 0x00000000
MB_OKCANCEL :: 0x00000001
MB_RETRYCANCEL :: 0x00000005
MB_YESNO :: 0x00000004
MB_YESNOCANCEL :: 0x00000003
MB_ICONEXCLAMATION :: 0x00000030;
MB_ICONWARNING :: 0x00000030;
MB_ICONINFORMATION :: 0x00000040;
MB_ICONASTERISK :: 0x00000040;
MB_ICONQUESTION :: 0x00000020;
MB_ICONSTOP :: 0x00000010;
MB_ICONERROR :: 0x00000010;
MB_ICONHAND :: 0x00000010;
MB_ICONEXCLAMATION :: 0x00000030
MB_ICONWARNING :: 0x00000030
MB_ICONINFORMATION :: 0x00000040
MB_ICONASTERISK :: 0x00000040
MB_ICONQUESTION :: 0x00000020
MB_ICONSTOP :: 0x00000010
MB_ICONERROR :: 0x00000010
MB_ICONHAND :: 0x00000010
MB_DEFBUTTON1 :: 0x00000000;
MB_DEFBUTTON2 :: 0x00000100;
MB_DEFBUTTON3 :: 0x00000200;
MB_DEFBUTTON4 :: 0x00000300;
MB_DEFBUTTON1 :: 0x00000000
MB_DEFBUTTON2 :: 0x00000100
MB_DEFBUTTON3 :: 0x00000200
MB_DEFBUTTON4 :: 0x00000300
MB_APPLMODAL :: 0x00000000;
MB_SYSTEMMODAL :: 0x00001000;
MB_TASKMODAL :: 0x00002000;
MB_APPLMODAL :: 0x00000000
MB_SYSTEMMODAL :: 0x00001000
MB_TASKMODAL :: 0x00002000
MB_DEFAULT_DESKTOP_ONLY :: 0x00020000;
MB_RIGHT :: 0x00080000;
MB_RTLREADING :: 0x00100000;
MB_SETFOREGROUND :: 0x00010000;
MB_TOPMOST :: 0x00040000;
MB_SERVICE_NOTIFICATION :: 0x00200000;
MB_DEFAULT_DESKTOP_ONLY :: 0x00020000
MB_RIGHT :: 0x00080000
MB_RTLREADING :: 0x00100000
MB_SETFOREGROUND :: 0x00010000
MB_TOPMOST :: 0x00040000
MB_SERVICE_NOTIFICATION :: 0x00200000
@(default_calling_convention = "std")
foreign user32 {
@(link_name="GetDesktopWindow") get_desktop_window :: proc() -> Hwnd ---;
@(link_name="ShowCursor") show_cursor :: proc(show: Bool) -> i32 ---;
@(link_name="GetCursorPos") get_cursor_pos :: proc(p: ^Point) -> Bool ---;
@(link_name="SetCursorPos") set_cursor_pos :: proc(x, y: i32) -> Bool ---;
@(link_name="ScreenToClient") screen_to_client :: proc(h: Hwnd, p: ^Point) -> Bool ---;
@(link_name="ClientToScreen") client_to_screen :: proc(h: Hwnd, p: ^Point) -> Bool ---;
@(link_name="PostQuitMessage") post_quit_message :: proc(exit_code: i32) ---;
@(link_name="SetWindowTextA") set_window_text_a :: proc(hwnd: Hwnd, c_string: cstring) -> Bool ---;
@(link_name="SetWindowTextW") set_window_text_w :: proc(hwnd: Hwnd, c_string: Wstring) -> Bool ---;
@(link_name="RegisterClassA") register_class_a :: proc(wc: ^Wnd_Class_A) -> i16 ---;
@(link_name="RegisterClassW") register_class_w :: proc(wc: ^Wnd_Class_W) -> i16 ---;
@(link_name="RegisterClassExA") register_class_ex_a :: proc(wc: ^Wnd_Class_Ex_A) -> i16 ---;
@(link_name="RegisterClassExW") register_class_ex_w :: proc(wc: ^Wnd_Class_Ex_W) -> i16 ---;
@(link_name="GetDesktopWindow") get_desktop_window :: proc() -> Hwnd ---
@(link_name="ShowCursor") show_cursor :: proc(show: Bool) -> i32 ---
@(link_name="GetCursorPos") get_cursor_pos :: proc(p: ^Point) -> Bool ---
@(link_name="SetCursorPos") set_cursor_pos :: proc(x, y: i32) -> Bool ---
@(link_name="ScreenToClient") screen_to_client :: proc(h: Hwnd, p: ^Point) -> Bool ---
@(link_name="ClientToScreen") client_to_screen :: proc(h: Hwnd, p: ^Point) -> Bool ---
@(link_name="PostQuitMessage") post_quit_message :: proc(exit_code: i32) ---
@(link_name="SetWindowTextA") set_window_text_a :: proc(hwnd: Hwnd, c_string: cstring) -> Bool ---
@(link_name="SetWindowTextW") set_window_text_w :: proc(hwnd: Hwnd, c_string: Wstring) -> Bool ---
@(link_name="RegisterClassA") register_class_a :: proc(wc: ^Wnd_Class_A) -> i16 ---
@(link_name="RegisterClassW") register_class_w :: proc(wc: ^Wnd_Class_W) -> i16 ---
@(link_name="RegisterClassExA") register_class_ex_a :: proc(wc: ^Wnd_Class_Ex_A) -> i16 ---
@(link_name="RegisterClassExW") register_class_ex_w :: proc(wc: ^Wnd_Class_Ex_W) -> i16 ---
@(link_name="CreateWindowExA")
create_window_ex_a :: proc(ex_style: u32,
@@ -113,7 +113,7 @@ foreign user32 {
style: u32,
x, y, w, h: i32,
parent: Hwnd, menu: Hmenu, instance: Hinstance,
param: rawptr) -> Hwnd ---;
param: rawptr) -> Hwnd ---
@(link_name="CreateWindowExW")
create_window_ex_w :: proc(ex_style: u32,
@@ -121,82 +121,82 @@ foreign user32 {
style: u32,
x, y, w, h: i32,
parent: Hwnd, menu: Hmenu, instance: Hinstance,
param: rawptr) -> Hwnd ---;
param: rawptr) -> Hwnd ---
@(link_name="ShowWindow") show_window :: proc(hwnd: Hwnd, cmd_show: i32) -> Bool ---;
@(link_name="TranslateMessage") translate_message :: proc(msg: ^Msg) -> Bool ---;
@(link_name="DispatchMessageA") dispatch_message_a :: proc(msg: ^Msg) -> Lresult ---;
@(link_name="DispatchMessageW") dispatch_message_w :: proc(msg: ^Msg) -> Lresult ---;
@(link_name="UpdateWindow") update_window :: proc(hwnd: Hwnd) -> Bool ---;
@(link_name="GetMessageA") get_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---;
@(link_name="GetMessageW") get_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---;
@(link_name="ShowWindow") show_window :: proc(hwnd: Hwnd, cmd_show: i32) -> Bool ---
@(link_name="TranslateMessage") translate_message :: proc(msg: ^Msg) -> Bool ---
@(link_name="DispatchMessageA") dispatch_message_a :: proc(msg: ^Msg) -> Lresult ---
@(link_name="DispatchMessageW") dispatch_message_w :: proc(msg: ^Msg) -> Lresult ---
@(link_name="UpdateWindow") update_window :: proc(hwnd: Hwnd) -> Bool ---
@(link_name="GetMessageA") get_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---
@(link_name="GetMessageW") get_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---
@(link_name="PeekMessageA") peek_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---;
@(link_name="PeekMessageW") peek_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---;
@(link_name="PeekMessageA") peek_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---
@(link_name="PeekMessageW") peek_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---
@(link_name="PostMessageA") post_message_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Bool ---;
@(link_name="PostMessageW") post_message_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Bool ---;
@(link_name="SendMessageA") send_message_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---;
@(link_name="SendMessageW") send_message_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---;
@(link_name="PostMessageA") post_message_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Bool ---
@(link_name="PostMessageW") post_message_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Bool ---
@(link_name="SendMessageA") send_message_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---
@(link_name="SendMessageW") send_message_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---
@(link_name="DefWindowProcA") def_window_proc_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---;
@(link_name="DefWindowProcW") def_window_proc_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---;
@(link_name="DefWindowProcA") def_window_proc_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---
@(link_name="DefWindowProcW") def_window_proc_w :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---
@(link_name="AdjustWindowRect") adjust_window_rect :: proc(rect: ^Rect, style: u32, menu: Bool) -> Bool ---;
@(link_name="GetActiveWindow") get_active_window :: proc() -> Hwnd ---;
@(link_name="AdjustWindowRect") adjust_window_rect :: proc(rect: ^Rect, style: u32, menu: Bool) -> Bool ---
@(link_name="GetActiveWindow") get_active_window :: proc() -> Hwnd ---
@(link_name="DestroyWindow") destroy_window :: proc(wnd: Hwnd) -> Bool ---;
@(link_name="DescribePixelFormat") describe_pixel_format :: proc(dc: Hdc, pixel_format: i32, bytes: u32, pfd: ^Pixel_Format_Descriptor) -> i32 ---;
@(link_name="DestroyWindow") destroy_window :: proc(wnd: Hwnd) -> Bool ---
@(link_name="DescribePixelFormat") describe_pixel_format :: proc(dc: Hdc, pixel_format: i32, bytes: u32, pfd: ^Pixel_Format_Descriptor) -> i32 ---
@(link_name="GetMonitorInfoA") get_monitor_info_a :: proc(monitor: Hmonitor, mi: ^Monitor_Info) -> Bool ---;
@(link_name="MonitorFromWindow") monitor_from_window :: proc(wnd: Hwnd, flags: u32) -> Hmonitor ---;
@(link_name="GetMonitorInfoA") get_monitor_info_a :: proc(monitor: Hmonitor, mi: ^Monitor_Info) -> Bool ---
@(link_name="MonitorFromWindow") monitor_from_window :: proc(wnd: Hwnd, flags: u32) -> Hmonitor ---
@(link_name="SetWindowPos") set_window_pos :: proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) -> Bool ---;
@(link_name="SetWindowPos") set_window_pos :: proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) -> Bool ---
@(link_name="GetWindowPlacement") get_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---;
@(link_name="SetWindowPlacement") set_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---;
@(link_name="GetWindowRect") get_window_rect :: proc(wnd: Hwnd, rect: ^Rect) -> Bool ---;
@(link_name="GetWindowPlacement") get_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---
@(link_name="SetWindowPlacement") set_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---
@(link_name="GetWindowRect") get_window_rect :: proc(wnd: Hwnd, rect: ^Rect) -> Bool ---
@(link_name="GetWindowLongPtrA") get_window_long_ptr_a :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---;
@(link_name="SetWindowLongPtrA") set_window_long_ptr_a :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---;
@(link_name="GetWindowLongPtrW") get_window_long_ptr_w :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---;
@(link_name="SetWindowLongPtrW") set_window_long_ptr_w :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---;
@(link_name="GetWindowLongPtrA") get_window_long_ptr_a :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---
@(link_name="SetWindowLongPtrA") set_window_long_ptr_a :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---
@(link_name="GetWindowLongPtrW") get_window_long_ptr_w :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---
@(link_name="SetWindowLongPtrW") set_window_long_ptr_w :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---
@(link_name="GetWindowText") get_window_text :: proc(wnd: Hwnd, str: cstring, maxCount: i32) -> i32 ---;
@(link_name="GetWindowText") get_window_text :: proc(wnd: Hwnd, str: cstring, maxCount: i32) -> i32 ---
@(link_name="GetClientRect") get_client_rect :: proc(hwnd: Hwnd, rect: ^Rect) -> Bool ---;
@(link_name="GetClientRect") get_client_rect :: proc(hwnd: Hwnd, rect: ^Rect) -> Bool ---
@(link_name="GetDC") get_dc :: proc(h: Hwnd) -> Hdc ---;
@(link_name="ReleaseDC") release_dc :: proc(wnd: Hwnd, hdc: Hdc) -> i32 ---;
@(link_name="GetDC") get_dc :: proc(h: Hwnd) -> Hdc ---
@(link_name="ReleaseDC") release_dc :: proc(wnd: Hwnd, hdc: Hdc) -> i32 ---
@(link_name="MapVirtualKeyA") map_virtual_key_a :: proc(scancode: u32, map_type: u32) -> u32 ---;
@(link_name="MapVirtualKeyW") map_virtual_key_w :: proc(scancode: u32, map_type: u32) -> u32 ---;
@(link_name="MapVirtualKeyA") map_virtual_key_a :: proc(scancode: u32, map_type: u32) -> u32 ---
@(link_name="MapVirtualKeyW") map_virtual_key_w :: proc(scancode: u32, map_type: u32) -> u32 ---
@(link_name="GetKeyState") get_key_state :: proc(v_key: i32) -> i16 ---;
@(link_name="GetAsyncKeyState") get_async_key_state :: proc(v_key: i32) -> i16 ---;
@(link_name="GetKeyState") get_key_state :: proc(v_key: i32) -> i16 ---
@(link_name="GetAsyncKeyState") get_async_key_state :: proc(v_key: i32) -> i16 ---
@(link_name="SetForegroundWindow") set_foreground_window :: proc(h: Hwnd) -> Bool ---;
@(link_name="SetFocus") set_focus :: proc(h: Hwnd) -> Hwnd ---;
@(link_name="SetForegroundWindow") set_foreground_window :: proc(h: Hwnd) -> Bool ---
@(link_name="SetFocus") set_focus :: proc(h: Hwnd) -> Hwnd ---
@(link_name="LoadImageA") load_image_a :: proc(instance: Hinstance, name: cstring, type_: u32, x_desired, y_desired : i32, load : u32) -> Handle ---;
@(link_name="LoadIconA") load_icon_a :: proc(instance: Hinstance, icon_name: cstring) -> Hicon ---;
@(link_name="DestroyIcon") destroy_icon :: proc(icon: Hicon) -> Bool ---;
@(link_name="LoadImageA") load_image_a :: proc(instance: Hinstance, name: cstring, type_: u32, x_desired, y_desired : i32, load : u32) -> Handle ---
@(link_name="LoadIconA") load_icon_a :: proc(instance: Hinstance, icon_name: cstring) -> Hicon ---
@(link_name="DestroyIcon") destroy_icon :: proc(icon: Hicon) -> Bool ---
@(link_name="LoadCursorA") load_cursor_a :: proc(instance: Hinstance, cursor_name: cstring) -> Hcursor ---;
@(link_name="LoadCursorW") load_cursor_w :: proc(instance: Hinstance, cursor_name: Wstring) -> Hcursor ---;
@(link_name="GetCursor") get_cursor :: proc() -> Hcursor ---;
@(link_name="SetCursor") set_cursor :: proc(cursor: Hcursor) -> Hcursor ---;
@(link_name="LoadCursorA") load_cursor_a :: proc(instance: Hinstance, cursor_name: cstring) -> Hcursor ---
@(link_name="LoadCursorW") load_cursor_w :: proc(instance: Hinstance, cursor_name: Wstring) -> Hcursor ---
@(link_name="GetCursor") get_cursor :: proc() -> Hcursor ---
@(link_name="SetCursor") set_cursor :: proc(cursor: Hcursor) -> Hcursor ---
@(link_name="RegisterRawInputDevices") register_raw_input_devices :: proc(raw_input_device: ^Raw_Input_Device, num_devices, size: u32) -> Bool ---;
@(link_name="RegisterRawInputDevices") register_raw_input_devices :: proc(raw_input_device: ^Raw_Input_Device, num_devices, size: u32) -> Bool ---
@(link_name="GetRawInputData") get_raw_input_data :: proc(raw_input: Hrawinput, command: u32, data: rawptr, size: ^u32, size_header: u32) -> u32 ---;
@(link_name="GetRawInputData") get_raw_input_data :: proc(raw_input: Hrawinput, command: u32, data: rawptr, size: ^u32, size_header: u32) -> u32 ---
@(link_name="MapVirtualKeyExW") map_virtual_key_ex_w :: proc(code, map_type: u32, hkl: HKL) -> u32 ---;
@(link_name="MapVirtualKeyExA") map_virtual_key_ex_a :: proc(code, map_type: u32, hkl: HKL) -> u32 ---;
@(link_name="MapVirtualKeyExW") map_virtual_key_ex_w :: proc(code, map_type: u32, hkl: HKL) -> u32 ---
@(link_name="MapVirtualKeyExA") map_virtual_key_ex_a :: proc(code, map_type: u32, hkl: HKL) -> u32 ---
@(link_name="EnumDisplayMonitors") enum_display_monitors :: proc(hdc: Hdc, rect: ^Rect, enum_proc: Monitor_Enum_Proc, lparam: Lparam) -> bool ---;
@(link_name="EnumDisplayMonitors") enum_display_monitors :: proc(hdc: Hdc, rect: ^Rect, enum_proc: Monitor_Enum_Proc, lparam: Lparam) -> bool ---
}
@(default_calling_convention = "std")
@@ -244,35 +244,35 @@ foreign user32 {
}
_IDC_APPSTARTING := rawptr(uintptr(32650));
_IDC_ARROW := rawptr(uintptr(32512));
_IDC_CROSS := rawptr(uintptr(32515));
_IDC_HAND := rawptr(uintptr(32649));
_IDC_HELP := rawptr(uintptr(32651));
_IDC_IBEAM := rawptr(uintptr(32513));
_IDC_ICON := rawptr(uintptr(32641));
_IDC_NO := rawptr(uintptr(32648));
_IDC_SIZE := rawptr(uintptr(32640));
_IDC_SIZEALL := rawptr(uintptr(32646));
_IDC_SIZENESW := rawptr(uintptr(32643));
_IDC_SIZENS := rawptr(uintptr(32645));
_IDC_SIZENWSE := rawptr(uintptr(32642));
_IDC_SIZEWE := rawptr(uintptr(32644));
_IDC_UPARROW := rawptr(uintptr(32516));
_IDC_WAIT := rawptr(uintptr(32514));
IDC_APPSTARTING := cstring(_IDC_APPSTARTING);
IDC_ARROW := cstring(_IDC_ARROW);
IDC_CROSS := cstring(_IDC_CROSS);
IDC_HAND := cstring(_IDC_HAND);
IDC_HELP := cstring(_IDC_HELP);
IDC_IBEAM := cstring(_IDC_IBEAM);
IDC_ICON := cstring(_IDC_ICON);
IDC_NO := cstring(_IDC_NO);
IDC_SIZE := cstring(_IDC_SIZE);
IDC_SIZEALL := cstring(_IDC_SIZEALL);
IDC_SIZENESW := cstring(_IDC_SIZENESW);
IDC_SIZENS := cstring(_IDC_SIZENS);
IDC_SIZENWSE := cstring(_IDC_SIZENWSE);
IDC_SIZEWE := cstring(_IDC_SIZEWE);
IDC_UPARROW := cstring(_IDC_UPARROW);
IDC_WAIT := cstring(_IDC_WAIT);
_IDC_APPSTARTING := rawptr(uintptr(32650))
_IDC_ARROW := rawptr(uintptr(32512))
_IDC_CROSS := rawptr(uintptr(32515))
_IDC_HAND := rawptr(uintptr(32649))
_IDC_HELP := rawptr(uintptr(32651))
_IDC_IBEAM := rawptr(uintptr(32513))
_IDC_ICON := rawptr(uintptr(32641))
_IDC_NO := rawptr(uintptr(32648))
_IDC_SIZE := rawptr(uintptr(32640))
_IDC_SIZEALL := rawptr(uintptr(32646))
_IDC_SIZENESW := rawptr(uintptr(32643))
_IDC_SIZENS := rawptr(uintptr(32645))
_IDC_SIZENWSE := rawptr(uintptr(32642))
_IDC_SIZEWE := rawptr(uintptr(32644))
_IDC_UPARROW := rawptr(uintptr(32516))
_IDC_WAIT := rawptr(uintptr(32514))
IDC_APPSTARTING := cstring(_IDC_APPSTARTING)
IDC_ARROW := cstring(_IDC_ARROW)
IDC_CROSS := cstring(_IDC_CROSS)
IDC_HAND := cstring(_IDC_HAND)
IDC_HELP := cstring(_IDC_HELP)
IDC_IBEAM := cstring(_IDC_IBEAM)
IDC_ICON := cstring(_IDC_ICON)
IDC_NO := cstring(_IDC_NO)
IDC_SIZE := cstring(_IDC_SIZE)
IDC_SIZEALL := cstring(_IDC_SIZEALL)
IDC_SIZENESW := cstring(_IDC_SIZENESW)
IDC_SIZENS := cstring(_IDC_SIZENS)
IDC_SIZENWSE := cstring(_IDC_SIZENWSE)
IDC_SIZEWE := cstring(_IDC_SIZEWE)
IDC_UPARROW := cstring(_IDC_UPARROW)
IDC_WAIT := cstring(_IDC_WAIT)
+34 -34
View File
@@ -3,16 +3,16 @@ package win32
foreign import "system:opengl32.lib"
CONTEXT_MAJOR_VERSION_ARB :: 0x2091;
CONTEXT_MINOR_VERSION_ARB :: 0x2092;
CONTEXT_FLAGS_ARB :: 0x2094;
CONTEXT_PROFILE_MASK_ARB :: 0x9126;
CONTEXT_FORWARD_COMPATIBLE_BIT_ARB :: 0x0002;
CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001;
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002;
CONTEXT_MAJOR_VERSION_ARB :: 0x2091
CONTEXT_MINOR_VERSION_ARB :: 0x2092
CONTEXT_FLAGS_ARB :: 0x2094
CONTEXT_PROFILE_MASK_ARB :: 0x9126
CONTEXT_FORWARD_COMPATIBLE_BIT_ARB :: 0x0002
CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002
Hglrc :: distinct Handle;
Color_Ref :: distinct u32;
Hglrc :: distinct Handle
Color_Ref :: distinct u32
Layer_Plane_Descriptor :: struct {
size: u16,
@@ -41,7 +41,7 @@ Layer_Plane_Descriptor :: struct {
transparent: Color_Ref,
}
Point_Float :: struct {x, y: f32};
Point_Float :: struct {x, y: f32}
Glyph_Metrics_Float :: struct {
black_box_x: f32,
@@ -51,64 +51,64 @@ Glyph_Metrics_Float :: struct {
cell_inc_y: f32,
}
Create_Context_Attribs_ARB_Type :: #type proc "c" (hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc;
Choose_Pixel_Format_ARB_Type :: #type proc "c" (hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool;
Swap_Interval_EXT_Type :: #type proc "c" (interval: i32) -> bool;
Get_Extensions_String_ARB_Type :: #type proc "c" (Hdc) -> cstring;
Create_Context_Attribs_ARB_Type :: #type proc "c" (hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc
Choose_Pixel_Format_ARB_Type :: #type proc "c" (hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool
Swap_Interval_EXT_Type :: #type proc "c" (interval: i32) -> bool
Get_Extensions_String_ARB_Type :: #type proc "c" (Hdc) -> cstring
// Procedures
create_context_attribs_arb: Create_Context_Attribs_ARB_Type;
choose_pixel_format_arb: Choose_Pixel_Format_ARB_Type;
swap_interval_ext: Swap_Interval_EXT_Type;
get_extensions_string_arb: Get_Extensions_String_ARB_Type;
create_context_attribs_arb: Create_Context_Attribs_ARB_Type
choose_pixel_format_arb: Choose_Pixel_Format_ARB_Type
swap_interval_ext: Swap_Interval_EXT_Type
get_extensions_string_arb: Get_Extensions_String_ARB_Type
foreign opengl32 {
@(link_name="wglCreateContext")
create_context :: proc(hdc: Hdc) -> Hglrc ---;
create_context :: proc(hdc: Hdc) -> Hglrc ---
@(link_name="wglMakeCurrent")
make_current :: proc(hdc: Hdc, hglrc: Hglrc) -> Bool ---;
make_current :: proc(hdc: Hdc, hglrc: Hglrc) -> Bool ---
@(link_name="wglGetProcAddress")
get_gl_proc_address :: proc(c_str: cstring) -> rawptr ---;
get_gl_proc_address :: proc(c_str: cstring) -> rawptr ---
@(link_name="wglDeleteContext")
delete_context :: proc(hglrc: Hglrc) -> Bool ---;
delete_context :: proc(hglrc: Hglrc) -> Bool ---
@(link_name="wglCopyContext")
copy_context :: proc(src, dst: Hglrc, mask: u32) -> Bool ---;
copy_context :: proc(src, dst: Hglrc, mask: u32) -> Bool ---
@(link_name="wglCreateLayerContext")
create_layer_context :: proc(hdc: Hdc, layer_plane: i32) -> Hglrc ---;
create_layer_context :: proc(hdc: Hdc, layer_plane: i32) -> Hglrc ---
@(link_name="wglDescribeLayerPlane")
describe_layer_plane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^Layer_Plane_Descriptor) -> Bool ---;
describe_layer_plane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^Layer_Plane_Descriptor) -> Bool ---
@(link_name="wglGetCurrentContext")
get_current_context :: proc() -> Hglrc ---;
get_current_context :: proc() -> Hglrc ---
@(link_name="wglGetCurrentDC")
get_current_dc :: proc() -> Hdc ---;
get_current_dc :: proc() -> Hdc ---
@(link_name="wglGetLayerPaletteEntries")
get_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---;
get_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---
@(link_name="wglRealizeLayerPalette")
realize_layer_palette :: proc(hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool ---;
realize_layer_palette :: proc(hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool ---
@(link_name="wglSetLayerPaletteEntries")
set_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---;
set_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---
@(link_name="wglShareLists")
share_lists :: proc(hglrc1, hglrc2: Hglrc) -> Bool ---;
share_lists :: proc(hglrc1, hglrc2: Hglrc) -> Bool ---
@(link_name="wglSwapLayerBuffers")
swap_layer_buffers :: proc(hdc: Hdc, planes: u32) -> Bool ---;
swap_layer_buffers :: proc(hdc: Hdc, planes: u32) -> Bool ---
@(link_name="wglUseFontBitmaps")
use_font_bitmaps :: proc(hdc: Hdc, first, count, list_base: u32) -> Bool ---;
use_font_bitmaps :: proc(hdc: Hdc, first, count, list_base: u32) -> Bool ---
@(link_name="wglUseFontOutlines")
use_font_outlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_Metrics_Float) -> Bool ---;
use_font_outlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_Metrics_Float) -> Bool ---
}
+1 -1
View File
@@ -6,5 +6,5 @@ foreign import "system:winmm.lib"
@(default_calling_convention = "std")
foreign winmm {
@(link_name="timeGetTime") time_get_time :: proc() -> u32 ---;
@(link_name="timeGetTime") time_get_time :: proc() -> u32 ---
}
+1 -1
View File
@@ -63,5 +63,5 @@ foreign advapi32 {
lpCurrentDirectory: wstring,
lpStartupInfo: LPSTARTUPINFO,
lpProcessInformation: LPPROCESS_INFORMATION,
) -> BOOL ---;
) -> BOOL ---
}
+1 -1
View File
@@ -3,7 +3,7 @@ package sys_windows
foreign import bcrypt "system:Bcrypt.lib"
BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD : 0x00000002;
BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD : 0x00000002
@(default_calling_convention="stdcall")
foreign bcrypt {
+111 -111
View File
@@ -83,14 +83,14 @@ foreign kernel32 {
lpThreadId: LPDWORD,
) -> HANDLE ---
SwitchToThread :: proc() -> BOOL ---
ResumeThread :: proc(thread: HANDLE) -> DWORD ---;
GetThreadPriority :: proc(thread: HANDLE) -> c_int ---;
SetThreadPriority :: proc(thread: HANDLE, priority: c_int) -> BOOL ---;
GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL ---;
TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL ---;
ResumeThread :: proc(thread: HANDLE) -> DWORD ---
GetThreadPriority :: proc(thread: HANDLE) -> c_int ---
SetThreadPriority :: proc(thread: HANDLE, priority: c_int) -> BOOL ---
GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL ---
TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL ---
CreateSemaphoreW :: proc(attributes: LPSECURITY_ATTRIBUTES, initial_count, maximum_count: LONG, name: LPCSTR) -> HANDLE ---;
ReleaseSemaphore :: proc(semaphore: HANDLE, release_count: LONG, previous_count: ^LONG) -> BOOL ---;
CreateSemaphoreW :: proc(attributes: LPSECURITY_ATTRIBUTES, initial_count, maximum_count: LONG, name: LPCSTR) -> HANDLE ---
ReleaseSemaphore :: proc(semaphore: HANDLE, release_count: LONG, previous_count: ^LONG) -> BOOL ---
WaitForSingleObject :: proc(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD ---
Sleep :: proc(dwMilliseconds: DWORD) ---
@@ -285,35 +285,35 @@ foreign kernel32 {
}
STANDARD_RIGHTS_REQUIRED :: DWORD(0x000F0000);
SECTION_QUERY :: DWORD(0x0001);
SECTION_MAP_WRITE :: DWORD(0x0002);
SECTION_MAP_READ :: DWORD(0x0004);
SECTION_MAP_EXECUTE :: DWORD(0x0008);
SECTION_EXTEND_SIZE :: DWORD(0x0010);
SECTION_ALL_ACCESS :: STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE;
SECTION_MAP_EXECUTE_EXPLICIT :: DWORD(0x0020);
STANDARD_RIGHTS_REQUIRED :: DWORD(0x000F0000)
SECTION_QUERY :: DWORD(0x0001)
SECTION_MAP_WRITE :: DWORD(0x0002)
SECTION_MAP_READ :: DWORD(0x0004)
SECTION_MAP_EXECUTE :: DWORD(0x0008)
SECTION_EXTEND_SIZE :: DWORD(0x0010)
SECTION_ALL_ACCESS :: STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE
SECTION_MAP_EXECUTE_EXPLICIT :: DWORD(0x0020)
FILE_MAP_WRITE :: SECTION_MAP_WRITE;
FILE_MAP_READ :: SECTION_MAP_READ;
FILE_MAP_ALL_ACCESS :: SECTION_ALL_ACCESS;
FILE_MAP_EXECUTE :: SECTION_MAP_EXECUTE_EXPLICIT;
FILE_MAP_COPY :: DWORD(0x00000001);
FILE_MAP_RESERVE :: DWORD(0x80000000);
FILE_MAP_TARGETS_INVALID :: DWORD(0x40000000);
FILE_MAP_LARGE_PAGES :: DWORD(0x20000000);
FILE_MAP_WRITE :: SECTION_MAP_WRITE
FILE_MAP_READ :: SECTION_MAP_READ
FILE_MAP_ALL_ACCESS :: SECTION_ALL_ACCESS
FILE_MAP_EXECUTE :: SECTION_MAP_EXECUTE_EXPLICIT
FILE_MAP_COPY :: DWORD(0x00000001)
FILE_MAP_RESERVE :: DWORD(0x80000000)
FILE_MAP_TARGETS_INVALID :: DWORD(0x40000000)
FILE_MAP_LARGE_PAGES :: DWORD(0x20000000)
PAGE_NOACCESS :: 0x01;
PAGE_READONLY :: 0x02;
PAGE_READWRITE :: 0x04;
PAGE_WRITECOPY :: 0x08;
PAGE_EXECUTE :: 0x10;
PAGE_EXECUTE_READ :: 0x20;
PAGE_EXECUTE_READWRITE :: 0x40;
PAGE_EXECUTE_WRITECOPY :: 0x80;
PAGE_GUARD :: 0x100;
PAGE_NOCACHE :: 0x200;
PAGE_WRITECOMBINE :: 0x400;
PAGE_NOACCESS :: 0x01
PAGE_READONLY :: 0x02
PAGE_READWRITE :: 0x04
PAGE_WRITECOPY :: 0x08
PAGE_EXECUTE :: 0x10
PAGE_EXECUTE_READ :: 0x20
PAGE_EXECUTE_READWRITE :: 0x40
PAGE_EXECUTE_WRITECOPY :: 0x80
PAGE_GUARD :: 0x100
PAGE_NOCACHE :: 0x200
PAGE_WRITECOMBINE :: 0x400
MEMORY_BASIC_INFORMATION :: struct {
BaseAddress: PVOID,
@@ -325,20 +325,20 @@ MEMORY_BASIC_INFORMATION :: struct {
Protect: DWORD,
Type: DWORD,
}
PMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION;
LPMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION;
PMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION
LPMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION
MEM_COMMIT :: 0x1000;
MEM_RESERVE :: 0x2000;
MEM_DECOMMIT :: 0x4000;
MEM_RELEASE :: 0x8000;
MEM_FREE :: 0x10000;
MEM_PRIVATE :: 0x20000;
MEM_MAPPED :: 0x40000;
MEM_RESET :: 0x80000;
MEM_TOP_DOWN :: 0x100000;
MEM_LARGE_PAGES :: 0x20000000;
MEM_4MB_PAGES :: 0x80000000;
MEM_COMMIT :: 0x1000
MEM_RESERVE :: 0x2000
MEM_DECOMMIT :: 0x4000
MEM_RELEASE :: 0x8000
MEM_FREE :: 0x10000
MEM_PRIVATE :: 0x20000
MEM_MAPPED :: 0x40000
MEM_RESET :: 0x80000
MEM_TOP_DOWN :: 0x100000
MEM_LARGE_PAGES :: 0x20000000
MEM_4MB_PAGES :: 0x80000000
foreign kernel32 {
VirtualAlloc :: proc(
@@ -346,63 +346,63 @@ foreign kernel32 {
dwSize: SIZE_T,
flAllocationType: DWORD,
flProtect: DWORD,
) -> LPVOID ---;
) -> LPVOID ---
VirtualProtect :: proc(
lpAddress: LPVOID,
dwSize: SIZE_T,
flNewProtect: DWORD,
lpflOldProtect: PDWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualFree :: proc(
lpAddress: LPVOID,
dwSize: SIZE_T,
dwFreeType: DWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualQuery :: proc(
lpAddress: LPCVOID,
lpBuffer: PMEMORY_BASIC_INFORMATION,
dwLength: SIZE_T,
) -> SIZE_T ---;
) -> SIZE_T ---
VirtualAllocEx :: proc(
hProcess: HANDLE,
lpAddress: LPVOID,
dwSize: SIZE_T,
flAllocationType: DWORD,
flProtect: DWORD,
) -> LPVOID ---;
) -> LPVOID ---
VirtualFreeEx :: proc(
hProcess: HANDLE,
lpAddress: LPVOID,
dwSize: SIZE_T,
dwFreeType: DWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualProtectEx :: proc(
hProcess: HANDLE,
lpAddress: LPVOID,
dwSize: SIZE_T,
flNewProtect: DWORD,
lpflOldProtect: PDWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualQueryEx :: proc(
hProcess: HANDLE,
lpAddress: LPCVOID,
lpBuffer: PMEMORY_BASIC_INFORMATION,
dwLength: SIZE_T,
) -> SIZE_T ---;
) -> SIZE_T ---
ReadProcessMemory :: proc(
hProcess: HANDLE,
lpBaseAddress: LPCVOID,
lpBuffer: LPVOID,
nSize: SIZE_T,
lpNumberOfBytesRead: ^SIZE_T,
) -> BOOL ---;
) -> BOOL ---
WriteProcessMemory :: proc(
hProcess: HANDLE,
lpBaseAddress: LPVOID,
lpBuffer: LPCVOID,
nSize: SIZE_T,
lpNumberOfBytesWritten: ^SIZE_T,
) -> BOOL ---;
) -> BOOL ---
CreateFileMappingW :: proc(
hFile: HANDLE,
lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
@@ -410,19 +410,19 @@ foreign kernel32 {
dwMaximumSizeHigh: DWORD,
dwMaximumSizeLow: DWORD,
lpName: LPCWSTR,
) -> HANDLE ---;
) -> HANDLE ---
OpenFileMappingW :: proc(
dwDesiredAccess: DWORD,
bInheritHandle: BOOL,
lpName: LPCWSTR,
) -> HANDLE ---;
) -> HANDLE ---
MapViewOfFile :: proc(
hFileMappingObject: HANDLE,
dwDesiredAccess: DWORD,
dwFileOffsetHigh: DWORD,
dwFileOffsetLow: DWORD,
dwNumberOfBytesToMap: SIZE_T,
) -> LPVOID ---;
) -> LPVOID ---
MapViewOfFileEx :: proc(
hFileMappingObject: HANDLE,
dwDesiredAccess: DWORD,
@@ -430,35 +430,35 @@ foreign kernel32 {
dwFileOffsetLow: DWORD,
dwNumberOfBytesToMap: SIZE_T,
lpBaseAddress: LPVOID,
) -> LPVOID ---;
) -> LPVOID ---
FlushViewOfFile :: proc(
lpBaseAddress: LPCVOID,
dwNumberOfBytesToFlush: SIZE_T,
) -> BOOL ---;
) -> BOOL ---
UnmapViewOfFile :: proc(
lpBaseAddress: LPCVOID,
) -> BOOL ---;
GetLargePageMinimum :: proc() -> SIZE_T ---;
) -> BOOL ---
GetLargePageMinimum :: proc() -> SIZE_T ---
GetProcessWorkingSetSizeEx :: proc(
hProcess: HANDLE,
lpMinimumWorkingSetSize: PSIZE_T,
lpMaximumWorkingSetSize: PSIZE_T,
Flags: PDWORD,
) -> BOOL ---;
) -> BOOL ---
SetProcessWorkingSetSizeEx :: proc(
hProcess: HANDLE,
dwMinimumWorkingSetSize: SIZE_T,
dwMaximumWorkingSetSize: SIZE_T,
Flags: DWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualLock :: proc(
lpAddress: LPVOID,
dwSize: SIZE_T,
) -> BOOL ---;
) -> BOOL ---
VirtualUnlock :: proc(
lpAddress: LPVOID,
dwSize: SIZE_T,
) -> BOOL ---;
) -> BOOL ---
GetWriteWatch :: proc(
dwFlags: DWORD,
lpBaseAddress: PVOID,
@@ -466,11 +466,11 @@ foreign kernel32 {
lpAddresses: ^PVOID,
lpdwCount: ^ULONG_PTR,
lpdwGranularity: LPDWORD,
) -> UINT ---;
) -> UINT ---
ResetWriteWatch :: proc(
lpBaseAddress: LPVOID,
dwRegionSize: SIZE_T,
) -> UINT ---;
) -> UINT ---
}
@@ -478,36 +478,36 @@ MEMORY_RESOURCE_NOTIFICATION_TYPE :: enum c_int {
LowMemoryResourceNotification,
HighMemoryResourceNotification,
}
LowMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.LowMemoryResourceNotification;
HighMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.HighMemoryResourceNotification;
LowMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.LowMemoryResourceNotification
HighMemoryResourceNotification :: MEMORY_RESOURCE_NOTIFICATION_TYPE.HighMemoryResourceNotification
foreign kernel32 {
CreateMemoryResourceNotification :: proc(
NotificationType: MEMORY_RESOURCE_NOTIFICATION_TYPE,
) -> HANDLE ---;
) -> HANDLE ---
QueryMemoryResourceNotification :: proc(
ResourceNotificationHandle: HANDLE,
ResourceState: PBOOL,
) -> BOOL ---;
) -> BOOL ---
}
FILE_CACHE_MAX_HARD_ENABLE :: DWORD(0x00000001);
FILE_CACHE_MAX_HARD_DISABLE :: DWORD(0x00000002);
FILE_CACHE_MIN_HARD_ENABLE :: DWORD(0x00000004);
FILE_CACHE_MIN_HARD_DISABLE :: DWORD(0x00000008);
FILE_CACHE_MAX_HARD_ENABLE :: DWORD(0x00000001)
FILE_CACHE_MAX_HARD_DISABLE :: DWORD(0x00000002)
FILE_CACHE_MIN_HARD_ENABLE :: DWORD(0x00000004)
FILE_CACHE_MIN_HARD_DISABLE :: DWORD(0x00000008)
foreign kernel32 {
GetSystemFileCacheSize :: proc(
lpMinimumFileCacheSize: PSIZE_T,
lpMaximumFileCacheSize: PSIZE_T,
lpFlags: PDWORD,
) -> BOOL ---;
) -> BOOL ---
SetSystemFileCacheSize :: proc(
MinimumFileCacheSize: SIZE_T,
MaximumFileCacheSize: SIZE_T,
Flags: DWORD,
) -> BOOL ---;
) -> BOOL ---
CreateFileMappingNumaW :: proc(
hFile: HANDLE,
lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
@@ -516,7 +516,7 @@ foreign kernel32 {
dwMaximumSizeLow: DWORD,
lpName: LPCWSTR,
nndPreferred: DWORD,
) -> HANDLE ---;
) -> HANDLE ---
}
WIN32_MEMORY_RANGE_ENTRY :: struct {
@@ -524,7 +524,7 @@ WIN32_MEMORY_RANGE_ENTRY :: struct {
NumberOfBytes: SIZE_T,
}
PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY;
PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY
foreign kernel32 {
PrefetchVirtualMemory :: proc(
@@ -532,45 +532,45 @@ foreign kernel32 {
NumberOfEntries: ULONG_PTR,
VirtualAddresses: PWIN32_MEMORY_RANGE_ENTRY,
Flags: ULONG,
) -> BOOL ---;
) -> BOOL ---
CreateFileMappingFromApp :: proc(
hFile: HANDLE,
SecurityAttributes: PSECURITY_ATTRIBUTES,
PageProtection: ULONG,
MaximumSize: ULONG64,
Name: PCWSTR,
) -> HANDLE ---;
) -> HANDLE ---
MapViewOfFileFromApp :: proc(
hFileMappingObject: HANDLE,
DesiredAccess: ULONG,
FileOffset: ULONG64,
NumberOfBytesToMap: SIZE_T,
) -> PVOID ---;
) -> PVOID ---
UnmapViewOfFileEx :: proc(
BaseAddress: PVOID,
UnmapFlags: ULONG,
) -> BOOL ---;
) -> BOOL ---
AllocateUserPhysicalPages :: proc(
hProcess: HANDLE,
NumberOfPages: PULONG_PTR,
PageArray: PULONG_PTR,
) -> BOOL ---;
) -> BOOL ---
FreeUserPhysicalPages :: proc(
hProcess: HANDLE,
NumberOfPages: PULONG_PTR,
PageArray: PULONG_PTR,
) -> BOOL ---;
) -> BOOL ---
MapUserPhysicalPages :: proc(
VirtualAddress: PVOID,
NumberOfPages: ULONG_PTR,
PageArray: PULONG_PTR,
) -> BOOL ---;
) -> BOOL ---
AllocateUserPhysicalPagesNuma :: proc(
hProcess: HANDLE,
NumberOfPages: PULONG_PTR,
PageArray: PULONG_PTR,
nndPreferred: DWORD,
) -> BOOL ---;
) -> BOOL ---
VirtualAllocExNuma :: proc(
hProcess: HANDLE,
lpAddress: LPVOID,
@@ -578,26 +578,26 @@ foreign kernel32 {
flAllocationType: DWORD,
flProtect: DWORD,
nndPreferred: DWORD,
) -> LPVOID ---;
) -> LPVOID ---
}
MEHC_PATROL_SCRUBBER_PRESENT :: ULONG(0x1);
MEHC_PATROL_SCRUBBER_PRESENT :: ULONG(0x1)
foreign kernel32 {
GetMemoryErrorHandlingCapabilities :: proc(
Capabilities: PULONG,
) -> BOOL ---;
) -> BOOL ---
}
PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "stdcall" ();
PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "stdcall" ()
foreign kernel32 {
RegisterBadMemoryNotification :: proc(
Callback: PBAD_MEMORY_CALLBACK_ROUTINE,
) -> PVOID ---;
) -> PVOID ---
UnregisterBadMemoryNotification :: proc(
RegistrationHandle: PVOID,
) -> BOOL ---;
) -> BOOL ---
}
OFFER_PRIORITY :: enum c_int {
@@ -606,48 +606,48 @@ OFFER_PRIORITY :: enum c_int {
VmOfferPriorityBelowNormal,
VmOfferPriorityNormal,
}
VmOfferPriorityVeryLow :: OFFER_PRIORITY.VmOfferPriorityVeryLow;
VmOfferPriorityLow :: OFFER_PRIORITY.VmOfferPriorityLow;
VmOfferPriorityBelowNormal :: OFFER_PRIORITY.VmOfferPriorityBelowNormal;
VmOfferPriorityNormal :: OFFER_PRIORITY.VmOfferPriorityNormal;
VmOfferPriorityVeryLow :: OFFER_PRIORITY.VmOfferPriorityVeryLow
VmOfferPriorityLow :: OFFER_PRIORITY.VmOfferPriorityLow
VmOfferPriorityBelowNormal :: OFFER_PRIORITY.VmOfferPriorityBelowNormal
VmOfferPriorityNormal :: OFFER_PRIORITY.VmOfferPriorityNormal
foreign kernel32 {
OfferVirtualMemory :: proc(
VirtualAddress: PVOID,
Size: SIZE_T,
Priority: OFFER_PRIORITY,
) -> DWORD ---;
) -> DWORD ---
ReclaimVirtualMemory :: proc(
VirtualAddress: PVOID,
Size: SIZE_T,
) -> DWORD ---;
) -> DWORD ---
DiscardVirtualMemory :: proc(
VirtualAddress: PVOID,
Size: SIZE_T,
) -> DWORD ---;
) -> DWORD ---
VirtualAllocFromApp :: proc(
BaseAddress: PVOID,
Size: SIZE_T,
AllocationType: ULONG,
Protection: ULONG,
) -> PVOID ---;
) -> PVOID ---
VirtualProtectFromApp :: proc(
Address: PVOID,
Size: SIZE_T,
NewProtection: ULONG,
OldProtection: PULONG,
) -> BOOL ---;
) -> BOOL ---
OpenFileMappingFromApp :: proc(
DesiredAccess: ULONG,
InheritHandle: BOOL,
Name: PCWSTR,
) -> HANDLE ---;
) -> HANDLE ---
}
WIN32_MEMORY_INFORMATION_CLASS :: enum c_int {
MemoryRegionInfo,
}
MemoryRegionInfo :: WIN32_MEMORY_INFORMATION_CLASS.MemoryRegionInfo;
MemoryRegionInfo :: WIN32_MEMORY_INFORMATION_CLASS.MemoryRegionInfo
WIN32_MEMORY_REGION_INFORMATION :: struct {
AllocationBase: PVOID,
@@ -664,7 +664,7 @@ WIN32_MEMORY_REGION_INFORMATION_u :: struct #raw_union {
WIN32_MEMORY_REGION_INFORMATION_u_s :: struct {
Bitfield: ULONG,
}
WIN32_MEMORY_REGION_INFORMATION_u_s_Bitfield :: distinct ULONG;
WIN32_MEMORY_REGION_INFORMATION_u_s_Bitfield :: distinct ULONG
/*bit_field #align align_of(ULONG) {
Private : 1-0,
MappedDataFile : 2-1,
@@ -697,7 +697,7 @@ foreign kernel32 {
}
NUMA_NO_PREFERRED_NODE :: 0xffffffff;
NUMA_NO_PREFERRED_NODE :: 0xffffffff
MapViewOfFile2 :: #force_inline proc(
FileMappingHandle: HANDLE,
@@ -717,7 +717,7 @@ MapViewOfFile2 :: #force_inline proc(
AllocationType,
PageProtection,
NUMA_NO_PREFERRED_NODE,
);
)
}
foreign kernel32 {
@@ -725,5 +725,5 @@ foreign kernel32 {
ProcessHandle: HANDLE,
BaseAddress: PVOID,
UnmapFlags: ULONG,
) -> BOOL ---;
) -> BOOL ---
}
+5 -5
View File
@@ -10,29 +10,29 @@ foreign netapi32 {
level: DWORD,
user_info: ^USER_INFO_1, // Perhaps make this a #raw_union with USER_INFO1..4 when we need the other levels.
parm_err: ^DWORD,
) -> NET_API_STATUS ---;
) -> NET_API_STATUS ---
NetUserDel :: proc(
servername: wstring,
username: wstring,
) -> NET_API_STATUS ---;
) -> NET_API_STATUS ---
NetUserGetInfo :: proc(
servername: wstring,
username: wstring,
level: DWORD,
user_info: ^USER_INFO_1,
) -> NET_API_STATUS ---;
) -> NET_API_STATUS ---
NetLocalGroupAddMembers :: proc(
servername: wstring,
groupname: wstring,
level: DWORD,
group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these.
totalentries: DWORD,
) -> NET_API_STATUS ---;
) -> NET_API_STATUS ---
NetLocalGroupDelMembers :: proc(
servername: wstring,
groupname: wstring,
level: DWORD,
group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these.
totalentries: DWORD,
) -> NET_API_STATUS ---;
) -> NET_API_STATUS ---
}
+1 -1
View File
@@ -5,5 +5,5 @@ foreign import ntdll_lib "system:ntdll.lib"
@(default_calling_convention="std")
foreign ntdll_lib {
RtlGetVersion :: proc(lpVersionInformation: ^OSVERSIONINFOEXW) -> NTSTATUS ---;
RtlGetVersion :: proc(lpVersionInformation: ^OSVERSIONINFOEXW) -> NTSTATUS ---
}
+322 -322
View File
@@ -3,179 +3,179 @@ package sys_windows
import "core:c"
c_char :: c.char;
c_uchar :: c.uchar;
c_int :: c.int;
c_uint :: c.uint;
c_long :: c.long;
c_longlong :: c.longlong;
c_ulong :: c.ulong;
c_short :: c.short;
c_ushort :: c.ushort;
size_t :: c.size_t;
wchar_t :: c.wchar_t;
c_char :: c.char
c_uchar :: c.uchar
c_int :: c.int
c_uint :: c.uint
c_long :: c.long
c_longlong :: c.longlong
c_ulong :: c.ulong
c_short :: c.short
c_ushort :: c.ushort
size_t :: c.size_t
wchar_t :: c.wchar_t
DWORD :: c_ulong;
HANDLE :: distinct LPVOID;
HINSTANCE :: HANDLE;
HMODULE :: distinct HINSTANCE;
HRESULT :: distinct LONG;
HWND :: distinct HANDLE;
HMONITOR :: distinct HANDLE;
BOOL :: distinct b32;
BYTE :: distinct u8;
BOOLEAN :: distinct b8;
GROUP :: distinct c_uint;
LARGE_INTEGER :: distinct c_longlong;
LONG :: c_long;
UINT :: c_uint;
INT :: c_int;
SHORT :: c_short;
USHORT :: c_ushort;
WCHAR :: wchar_t;
SIZE_T :: uint;
PSIZE_T :: ^SIZE_T;
WORD :: u16;
CHAR :: c_char;
ULONG_PTR :: uint;
PULONG_PTR :: ^ULONG_PTR;
LPULONG_PTR :: ^ULONG_PTR;
DWORD_PTR :: ULONG_PTR;
LONG_PTR :: int;
ULONG :: c_ulong;
UCHAR :: BYTE;
NTSTATUS :: c.long;
DWORD :: c_ulong
HANDLE :: distinct LPVOID
HINSTANCE :: HANDLE
HMODULE :: distinct HINSTANCE
HRESULT :: distinct LONG
HWND :: distinct HANDLE
HMONITOR :: distinct HANDLE
BOOL :: distinct b32
BYTE :: distinct u8
BOOLEAN :: distinct b8
GROUP :: distinct c_uint
LARGE_INTEGER :: distinct c_longlong
LONG :: c_long
UINT :: c_uint
INT :: c_int
SHORT :: c_short
USHORT :: c_ushort
WCHAR :: wchar_t
SIZE_T :: uint
PSIZE_T :: ^SIZE_T
WORD :: u16
CHAR :: c_char
ULONG_PTR :: uint
PULONG_PTR :: ^ULONG_PTR
LPULONG_PTR :: ^ULONG_PTR
DWORD_PTR :: ULONG_PTR
LONG_PTR :: int
ULONG :: c_ulong
UCHAR :: BYTE
NTSTATUS :: c.long
UINT8 :: u8;
UINT16 :: u16;
UINT32 :: u32;
UINT64 :: u64;
UINT8 :: u8
UINT16 :: u16
UINT32 :: u32
UINT64 :: u64
INT8 :: i8;
INT16 :: i16;
INT32 :: i32;
INT64 :: i64;
INT8 :: i8
INT16 :: i16
INT32 :: i32
INT64 :: i64
ULONG64 :: u64;
LONG64 :: i64;
ULONG64 :: u64
LONG64 :: i64
PDWORD_PTR :: ^DWORD_PTR;
ATOM :: distinct WORD;
PDWORD_PTR :: ^DWORD_PTR
ATOM :: distinct WORD
wstring :: [^]WCHAR;
wstring :: [^]WCHAR
PBYTE :: ^BYTE;
LPBYTE :: ^BYTE;
PBOOL :: ^BOOL;
LPBOOL :: ^BOOL;
LPCSTR :: cstring;
LPCWSTR :: wstring;
LPDWORD :: ^DWORD;
PCSTR :: cstring;
PCWSTR :: wstring;
PDWORD :: ^DWORD;
LPHANDLE :: ^HANDLE;
LPOVERLAPPED :: ^OVERLAPPED;
LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION;
PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES;
LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES;
LPSTARTUPINFO :: ^STARTUPINFO;
PVOID :: rawptr;
LPVOID :: rawptr;
PINT :: ^INT;
LPINT :: ^INT;
PUINT :: ^UINT;
LPUINT :: ^UINT;
LPWCH :: ^WCHAR;
LPWORD :: ^WORD;
PULONG :: ^ULONG;
LPWIN32_FIND_DATAW :: ^WIN32_FIND_DATAW;
LPWSADATA :: ^WSADATA;
LPWSAPROTOCOL_INFO :: ^WSAPROTOCOL_INFO;
LPSTR :: ^CHAR;
LPWSTR :: ^WCHAR;
LPFILETIME :: ^FILETIME;
LPWSABUF :: ^WSABUF;
LPWSAOVERLAPPED :: distinct rawptr;
LPWSAOVERLAPPED_COMPLETION_ROUTINE :: distinct rawptr;
LPCVOID :: rawptr;
PBYTE :: ^BYTE
LPBYTE :: ^BYTE
PBOOL :: ^BOOL
LPBOOL :: ^BOOL
LPCSTR :: cstring
LPCWSTR :: wstring
LPDWORD :: ^DWORD
PCSTR :: cstring
PCWSTR :: wstring
PDWORD :: ^DWORD
LPHANDLE :: ^HANDLE
LPOVERLAPPED :: ^OVERLAPPED
LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION
PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
LPSTARTUPINFO :: ^STARTUPINFO
PVOID :: rawptr
LPVOID :: rawptr
PINT :: ^INT
LPINT :: ^INT
PUINT :: ^UINT
LPUINT :: ^UINT
LPWCH :: ^WCHAR
LPWORD :: ^WORD
PULONG :: ^ULONG
LPWIN32_FIND_DATAW :: ^WIN32_FIND_DATAW
LPWSADATA :: ^WSADATA
LPWSAPROTOCOL_INFO :: ^WSAPROTOCOL_INFO
LPSTR :: ^CHAR
LPWSTR :: ^WCHAR
LPFILETIME :: ^FILETIME
LPWSABUF :: ^WSABUF
LPWSAOVERLAPPED :: distinct rawptr
LPWSAOVERLAPPED_COMPLETION_ROUTINE :: distinct rawptr
LPCVOID :: rawptr
PCONDITION_VARIABLE :: ^CONDITION_VARIABLE;
PLARGE_INTEGER :: ^LARGE_INTEGER;
PSRWLOCK :: ^SRWLOCK;
PCONDITION_VARIABLE :: ^CONDITION_VARIABLE
PLARGE_INTEGER :: ^LARGE_INTEGER
PSRWLOCK :: ^SRWLOCK
SOCKET :: distinct uintptr; // TODO
socklen_t :: c_int;
ADDRESS_FAMILY :: USHORT;
SOCKET :: distinct uintptr // TODO
socklen_t :: c_int
ADDRESS_FAMILY :: USHORT
TRUE :: BOOL(true);
FALSE :: BOOL(false);
TRUE :: BOOL(true)
FALSE :: BOOL(false)
SIZE :: struct {
cx: LONG,
cy: LONG,
}
PSIZE :: ^SIZE;
LPSIZE :: ^SIZE;
PSIZE :: ^SIZE
LPSIZE :: ^SIZE
FILE_ATTRIBUTE_READONLY: DWORD : 0x00000001;
FILE_ATTRIBUTE_HIDDEN: DWORD : 0x00000002;
FILE_ATTRIBUTE_SYSTEM: DWORD : 0x00000004;
FILE_ATTRIBUTE_DIRECTORY: DWORD : 0x00000010;
FILE_ATTRIBUTE_ARCHIVE: DWORD : 0x00000020;
FILE_ATTRIBUTE_DEVICE: DWORD : 0x00000040;
FILE_ATTRIBUTE_NORMAL: DWORD : 0x00000080;
FILE_ATTRIBUTE_TEMPORARY: DWORD : 0x00000100;
FILE_ATTRIBUTE_SPARSE_FILE: DWORD : 0x00000200;
FILE_ATTRIBUTE_REPARSE_Point: DWORD : 0x00000400;
FILE_ATTRIBUTE_REPARSE_POINT: DWORD : 0x00000400;
FILE_ATTRIBUTE_COMPRESSED: DWORD : 0x00000800;
FILE_ATTRIBUTE_OFFLINE: DWORD : 0x00001000;
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD : 0x00002000;
FILE_ATTRIBUTE_ENCRYPTED: DWORD : 0x00004000;
FILE_ATTRIBUTE_READONLY: DWORD : 0x00000001
FILE_ATTRIBUTE_HIDDEN: DWORD : 0x00000002
FILE_ATTRIBUTE_SYSTEM: DWORD : 0x00000004
FILE_ATTRIBUTE_DIRECTORY: DWORD : 0x00000010
FILE_ATTRIBUTE_ARCHIVE: DWORD : 0x00000020
FILE_ATTRIBUTE_DEVICE: DWORD : 0x00000040
FILE_ATTRIBUTE_NORMAL: DWORD : 0x00000080
FILE_ATTRIBUTE_TEMPORARY: DWORD : 0x00000100
FILE_ATTRIBUTE_SPARSE_FILE: DWORD : 0x00000200
FILE_ATTRIBUTE_REPARSE_Point: DWORD : 0x00000400
FILE_ATTRIBUTE_REPARSE_POINT: DWORD : 0x00000400
FILE_ATTRIBUTE_COMPRESSED: DWORD : 0x00000800
FILE_ATTRIBUTE_OFFLINE: DWORD : 0x00001000
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD : 0x00002000
FILE_ATTRIBUTE_ENCRYPTED: DWORD : 0x00004000
FILE_SHARE_READ: DWORD : 0x00000001;
FILE_SHARE_WRITE: DWORD : 0x00000002;
FILE_SHARE_DELETE: DWORD : 0x00000004;
FILE_GENERIC_ALL: DWORD : 0x10000000;
FILE_GENERIC_EXECUTE: DWORD : 0x20000000;
FILE_GENERIC_READ: DWORD : 0x80000000;
FILE_SHARE_READ: DWORD : 0x00000001
FILE_SHARE_WRITE: DWORD : 0x00000002
FILE_SHARE_DELETE: DWORD : 0x00000004
FILE_GENERIC_ALL: DWORD : 0x10000000
FILE_GENERIC_EXECUTE: DWORD : 0x20000000
FILE_GENERIC_READ: DWORD : 0x80000000
CREATE_NEW: DWORD : 1;
CREATE_ALWAYS: DWORD : 2;
OPEN_ALWAYS: DWORD : 4;
OPEN_EXISTING: DWORD : 3;
TRUNCATE_EXISTING: DWORD : 5;
CREATE_NEW: DWORD : 1
CREATE_ALWAYS: DWORD : 2
OPEN_ALWAYS: DWORD : 4
OPEN_EXISTING: DWORD : 3
TRUNCATE_EXISTING: DWORD : 5
FILE_WRITE_DATA: DWORD : 0x00000002;
FILE_APPEND_DATA: DWORD : 0x00000004;
FILE_WRITE_EA: DWORD : 0x00000010;
FILE_WRITE_ATTRIBUTES: DWORD : 0x00000100;
READ_CONTROL: DWORD : 0x00020000;
SYNCHRONIZE: DWORD : 0x00100000;
GENERIC_READ: DWORD : 0x80000000;
GENERIC_WRITE: DWORD : 0x40000000;
STANDARD_RIGHTS_WRITE: DWORD : READ_CONTROL;
FILE_WRITE_DATA: DWORD : 0x00000002
FILE_APPEND_DATA: DWORD : 0x00000004
FILE_WRITE_EA: DWORD : 0x00000010
FILE_WRITE_ATTRIBUTES: DWORD : 0x00000100
READ_CONTROL: DWORD : 0x00020000
SYNCHRONIZE: DWORD : 0x00100000
GENERIC_READ: DWORD : 0x80000000
GENERIC_WRITE: DWORD : 0x40000000
STANDARD_RIGHTS_WRITE: DWORD : READ_CONTROL
FILE_GENERIC_WRITE: DWORD : STANDARD_RIGHTS_WRITE |
FILE_WRITE_DATA |
FILE_WRITE_ATTRIBUTES |
FILE_WRITE_EA |
FILE_APPEND_DATA |
SYNCHRONIZE;
SYNCHRONIZE
FILE_FLAG_OPEN_REPARSE_POINT: DWORD : 0x00200000;
FILE_FLAG_BACKUP_SEMANTICS: DWORD : 0x02000000;
SECURITY_SQOS_PRESENT: DWORD : 0x00100000;
FILE_FLAG_OPEN_REPARSE_POINT: DWORD : 0x00200000
FILE_FLAG_BACKUP_SEMANTICS: DWORD : 0x02000000
SECURITY_SQOS_PRESENT: DWORD : 0x00100000
FIONBIO: c_ulong : 0x8004667e;
FIONBIO: c_ulong : 0x8004667e
GET_FILEEX_INFO_LEVELS :: distinct i32;
GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0;
GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1;
GET_FILEEX_INFO_LEVELS :: distinct i32
GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0
GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1
WIN32_FIND_DATAW :: struct {
@@ -191,126 +191,126 @@ WIN32_FIND_DATAW :: struct {
cAlternateFileName: [14]wchar_t,
}
WSA_FLAG_OVERLAPPED: DWORD : 0x01;
WSA_FLAG_NO_HANDLE_INHERIT: DWORD : 0x80;
WSA_FLAG_OVERLAPPED: DWORD : 0x01
WSA_FLAG_NO_HANDLE_INHERIT: DWORD : 0x80
WSADESCRIPTION_LEN :: 256;
WSASYS_STATUS_LEN :: 128;
WSAPROTOCOL_LEN: DWORD : 255;
INVALID_SOCKET :: ~SOCKET(0);
WSADESCRIPTION_LEN :: 256
WSASYS_STATUS_LEN :: 128
WSAPROTOCOL_LEN: DWORD : 255
INVALID_SOCKET :: ~SOCKET(0)
WSAEACCES: c_int : 10013;
WSAEINVAL: c_int : 10022;
WSAEWOULDBLOCK: c_int : 10035;
WSAEPROTOTYPE: c_int : 10041;
WSAEADDRINUSE: c_int : 10048;
WSAEADDRNOTAVAIL: c_int : 10049;
WSAECONNABORTED: c_int : 10053;
WSAECONNRESET: c_int : 10054;
WSAENOTCONN: c_int : 10057;
WSAESHUTDOWN: c_int : 10058;
WSAETIMEDOUT: c_int : 10060;
WSAECONNREFUSED: c_int : 10061;
WSAEACCES: c_int : 10013
WSAEINVAL: c_int : 10022
WSAEWOULDBLOCK: c_int : 10035
WSAEPROTOTYPE: c_int : 10041
WSAEADDRINUSE: c_int : 10048
WSAEADDRNOTAVAIL: c_int : 10049
WSAECONNABORTED: c_int : 10053
WSAECONNRESET: c_int : 10054
WSAENOTCONN: c_int : 10057
WSAESHUTDOWN: c_int : 10058
WSAETIMEDOUT: c_int : 10060
WSAECONNREFUSED: c_int : 10061
MAX_PROTOCOL_CHAIN: DWORD : 7;
MAX_PROTOCOL_CHAIN: DWORD : 7
MAXIMUM_REPARSE_DATA_BUFFER_SIZE :: 16 * 1024;
FSCTL_GET_REPARSE_POINT: DWORD : 0x900a8;
IO_REPARSE_TAG_SYMLINK: DWORD : 0xa000000c;
IO_REPARSE_TAG_MOUNT_POINT: DWORD : 0xa0000003;
SYMLINK_FLAG_RELATIVE: DWORD : 0x00000001;
FSCTL_SET_REPARSE_POINT: DWORD : 0x900a4;
MAXIMUM_REPARSE_DATA_BUFFER_SIZE :: 16 * 1024
FSCTL_GET_REPARSE_POINT: DWORD : 0x900a8
IO_REPARSE_TAG_SYMLINK: DWORD : 0xa000000c
IO_REPARSE_TAG_MOUNT_POINT: DWORD : 0xa0000003
SYMLINK_FLAG_RELATIVE: DWORD : 0x00000001
FSCTL_SET_REPARSE_POINT: DWORD : 0x900a4
SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD : 0x1;
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD : 0x2;
SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD : 0x1
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE: DWORD : 0x2
STD_INPUT_HANDLE: DWORD : ~DWORD(0) -10 + 1;
STD_OUTPUT_HANDLE: DWORD : ~DWORD(0) -11 + 1;
STD_ERROR_HANDLE: DWORD : ~DWORD(0) -12 + 1;
STD_INPUT_HANDLE: DWORD : ~DWORD(0) -10 + 1
STD_OUTPUT_HANDLE: DWORD : ~DWORD(0) -11 + 1
STD_ERROR_HANDLE: DWORD : ~DWORD(0) -12 + 1
PROGRESS_CONTINUE: DWORD : 0;
PROGRESS_CONTINUE: DWORD : 0
ERROR_FILE_NOT_FOUND: DWORD : 2;
ERROR_PATH_NOT_FOUND: DWORD : 3;
ERROR_ACCESS_DENIED: DWORD : 5;
ERROR_NOT_ENOUGH_MEMORY: DWORD : 8;
ERROR_INVALID_HANDLE: DWORD : 6;
ERROR_NO_MORE_FILES: DWORD : 18;
ERROR_SHARING_VIOLATION: DWORD : 32;
ERROR_LOCK_VIOLATION: DWORD : 33;
ERROR_HANDLE_EOF: DWORD : 38;
ERROR_NOT_SUPPORTED: DWORD : 50;
ERROR_FILE_EXISTS: DWORD : 80;
ERROR_INVALID_PARAMETER: DWORD : 87;
ERROR_BROKEN_PIPE: DWORD : 109;
ERROR_CALL_NOT_IMPLEMENTED: DWORD : 120;
ERROR_INSUFFICIENT_BUFFER: DWORD : 122;
ERROR_INVALID_NAME: DWORD : 123;
ERROR_LOCK_FAILED: DWORD : 167;
ERROR_ALREADY_EXISTS: DWORD : 183;
ERROR_NO_DATA: DWORD : 232;
ERROR_ENVVAR_NOT_FOUND: DWORD : 203;
ERROR_OPERATION_ABORTED: DWORD : 995;
ERROR_IO_PENDING: DWORD : 997;
ERROR_TIMEOUT: DWORD : 0x5B4;
ERROR_NO_UNICODE_TRANSLATION: DWORD : 1113;
ERROR_FILE_NOT_FOUND: DWORD : 2
ERROR_PATH_NOT_FOUND: DWORD : 3
ERROR_ACCESS_DENIED: DWORD : 5
ERROR_NOT_ENOUGH_MEMORY: DWORD : 8
ERROR_INVALID_HANDLE: DWORD : 6
ERROR_NO_MORE_FILES: DWORD : 18
ERROR_SHARING_VIOLATION: DWORD : 32
ERROR_LOCK_VIOLATION: DWORD : 33
ERROR_HANDLE_EOF: DWORD : 38
ERROR_NOT_SUPPORTED: DWORD : 50
ERROR_FILE_EXISTS: DWORD : 80
ERROR_INVALID_PARAMETER: DWORD : 87
ERROR_BROKEN_PIPE: DWORD : 109
ERROR_CALL_NOT_IMPLEMENTED: DWORD : 120
ERROR_INSUFFICIENT_BUFFER: DWORD : 122
ERROR_INVALID_NAME: DWORD : 123
ERROR_LOCK_FAILED: DWORD : 167
ERROR_ALREADY_EXISTS: DWORD : 183
ERROR_NO_DATA: DWORD : 232
ERROR_ENVVAR_NOT_FOUND: DWORD : 203
ERROR_OPERATION_ABORTED: DWORD : 995
ERROR_IO_PENDING: DWORD : 997
ERROR_TIMEOUT: DWORD : 0x5B4
ERROR_NO_UNICODE_TRANSLATION: DWORD : 1113
E_NOTIMPL :: HRESULT(-0x7fff_bfff); // 0x8000_4001
E_NOTIMPL :: HRESULT(-0x7fff_bfff) // 0x8000_4001
INVALID_HANDLE :: HANDLE(~uintptr(0));
INVALID_HANDLE_VALUE :: INVALID_HANDLE;
INVALID_HANDLE :: HANDLE(~uintptr(0))
INVALID_HANDLE_VALUE :: INVALID_HANDLE
FACILITY_NT_BIT: DWORD : 0x1000_0000;
FACILITY_NT_BIT: DWORD : 0x1000_0000
FORMAT_MESSAGE_FROM_SYSTEM: DWORD : 0x00001000;
FORMAT_MESSAGE_FROM_HMODULE: DWORD : 0x00000800;
FORMAT_MESSAGE_IGNORE_INSERTS: DWORD : 0x00000200;
FORMAT_MESSAGE_FROM_SYSTEM: DWORD : 0x00001000
FORMAT_MESSAGE_FROM_HMODULE: DWORD : 0x00000800
FORMAT_MESSAGE_IGNORE_INSERTS: DWORD : 0x00000200
TLS_OUT_OF_INDEXES: DWORD : 0xFFFFFFFF;
TLS_OUT_OF_INDEXES: DWORD : 0xFFFFFFFF
DLL_THREAD_DETACH: DWORD : 3;
DLL_PROCESS_DETACH: DWORD : 0;
CREATE_SUSPENDED :: DWORD(0x00000004);
DLL_THREAD_DETACH: DWORD : 3
DLL_PROCESS_DETACH: DWORD : 0
CREATE_SUSPENDED :: DWORD(0x00000004)
INFINITE :: ~DWORD(0);
INFINITE :: ~DWORD(0)
DUPLICATE_SAME_ACCESS: DWORD : 0x00000002;
DUPLICATE_SAME_ACCESS: DWORD : 0x00000002
CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{};
SRWLOCK_INIT :: SRWLOCK{};
CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{}
SRWLOCK_INIT :: SRWLOCK{}
DETACHED_PROCESS: DWORD : 0x00000008;
CREATE_NEW_PROCESS_GROUP: DWORD : 0x00000200;
CREATE_UNICODE_ENVIRONMENT: DWORD : 0x00000400;
STARTF_USESTDHANDLES: DWORD : 0x00000100;
DETACHED_PROCESS: DWORD : 0x00000008
CREATE_NEW_PROCESS_GROUP: DWORD : 0x00000200
CREATE_UNICODE_ENVIRONMENT: DWORD : 0x00000400
STARTF_USESTDHANDLES: DWORD : 0x00000100
AF_INET: c_int : 2;
AF_INET6: c_int : 23;
SD_BOTH: c_int : 2;
SD_RECEIVE: c_int : 0;
SD_SEND: c_int : 1;
SOCK_DGRAM: c_int : 2;
SOCK_STREAM: c_int : 1;
SOL_SOCKET: c_int : 0xffff;
SO_RCVTIMEO: c_int : 0x1006;
SO_SNDTIMEO: c_int : 0x1005;
SO_REUSEADDR: c_int : 0x0004;
IPPROTO_IP: c_int : 0;
IPPROTO_TCP: c_int : 6;
IPPROTO_IPV6: c_int : 41;
TCP_NODELAY: c_int : 0x0001;
IP_TTL: c_int : 4;
IPV6_V6ONLY: c_int : 27;
SO_ERROR: c_int : 0x1007;
SO_BROADCAST: c_int : 0x0020;
IP_MULTICAST_LOOP: c_int : 11;
IPV6_MULTICAST_LOOP: c_int : 11;
IP_MULTICAST_TTL: c_int : 10;
IP_ADD_MEMBERSHIP: c_int : 12;
IP_DROP_MEMBERSHIP: c_int : 13;
IPV6_ADD_MEMBERSHIP: c_int : 12;
IPV6_DROP_MEMBERSHIP: c_int : 13;
MSG_PEEK: c_int : 0x2;
AF_INET: c_int : 2
AF_INET6: c_int : 23
SD_BOTH: c_int : 2
SD_RECEIVE: c_int : 0
SD_SEND: c_int : 1
SOCK_DGRAM: c_int : 2
SOCK_STREAM: c_int : 1
SOL_SOCKET: c_int : 0xffff
SO_RCVTIMEO: c_int : 0x1006
SO_SNDTIMEO: c_int : 0x1005
SO_REUSEADDR: c_int : 0x0004
IPPROTO_IP: c_int : 0
IPPROTO_TCP: c_int : 6
IPPROTO_IPV6: c_int : 41
TCP_NODELAY: c_int : 0x0001
IP_TTL: c_int : 4
IPV6_V6ONLY: c_int : 27
SO_ERROR: c_int : 0x1007
SO_BROADCAST: c_int : 0x0020
IP_MULTICAST_LOOP: c_int : 11
IPV6_MULTICAST_LOOP: c_int : 11
IP_MULTICAST_TTL: c_int : 10
IP_ADD_MEMBERSHIP: c_int : 12
IP_DROP_MEMBERSHIP: c_int : 13
IPV6_ADD_MEMBERSHIP: c_int : 12
IPV6_DROP_MEMBERSHIP: c_int : 13
MSG_PEEK: c_int : 0x2
ip_mreq :: struct {
imr_multiaddr: in_addr,
@@ -322,59 +322,59 @@ ipv6_mreq :: struct {
ipv6mr_interface: c_uint,
}
VOLUME_NAME_DOS: DWORD : 0x0;
MOVEFILE_REPLACE_EXISTING: DWORD : 1;
VOLUME_NAME_DOS: DWORD : 0x0
MOVEFILE_REPLACE_EXISTING: DWORD : 1
FILE_BEGIN: DWORD : 0;
FILE_CURRENT: DWORD : 1;
FILE_END: DWORD : 2;
FILE_BEGIN: DWORD : 0
FILE_CURRENT: DWORD : 1
FILE_END: DWORD : 2
WAIT_OBJECT_0: DWORD : 0x00000000;
WAIT_TIMEOUT: DWORD : 258;
WAIT_FAILED: DWORD : 0xFFFFFFFF;
WAIT_OBJECT_0: DWORD : 0x00000000
WAIT_TIMEOUT: DWORD : 258
WAIT_FAILED: DWORD : 0xFFFFFFFF
PIPE_ACCESS_INBOUND: DWORD : 0x00000001;
PIPE_ACCESS_OUTBOUND: DWORD : 0x00000002;
FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD : 0x00080000;
FILE_FLAG_OVERLAPPED: DWORD : 0x40000000;
PIPE_WAIT: DWORD : 0x00000000;
PIPE_TYPE_BYTE: DWORD : 0x00000000;
PIPE_REJECT_REMOTE_CLIENTS: DWORD : 0x00000008;
PIPE_READMODE_BYTE: DWORD : 0x00000000;
PIPE_ACCESS_INBOUND: DWORD : 0x00000001
PIPE_ACCESS_OUTBOUND: DWORD : 0x00000002
FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD : 0x00080000
FILE_FLAG_OVERLAPPED: DWORD : 0x40000000
PIPE_WAIT: DWORD : 0x00000000
PIPE_TYPE_BYTE: DWORD : 0x00000000
PIPE_REJECT_REMOTE_CLIENTS: DWORD : 0x00000008
PIPE_READMODE_BYTE: DWORD : 0x00000000
FD_SETSIZE :: 64;
FD_SETSIZE :: 64
STACK_SIZE_PARAM_IS_A_RESERVATION: DWORD : 0x00010000;
STACK_SIZE_PARAM_IS_A_RESERVATION: DWORD : 0x00010000
INVALID_SET_FILE_POINTER :: ~DWORD(0);
INVALID_SET_FILE_POINTER :: ~DWORD(0)
HEAP_ZERO_MEMORY: DWORD : 0x00000008;
HEAP_ZERO_MEMORY: DWORD : 0x00000008
HANDLE_FLAG_INHERIT: DWORD : 0x00000001;
HANDLE_FLAG_PROTECT_FROM_CLOSE :: 0x00000002;
HANDLE_FLAG_INHERIT: DWORD : 0x00000001
HANDLE_FLAG_PROTECT_FROM_CLOSE :: 0x00000002
TOKEN_READ: DWORD : 0x20008;
TOKEN_READ: DWORD : 0x20008
CP_ACP :: 0; // default to ANSI code page
CP_OEMCP :: 1; // default to OEM code page
CP_MACCP :: 2; // default to MAC code page
CP_THREAD_ACP :: 3; // current thread's ANSI code page
CP_SYMBOL :: 42; // SYMBOL translations
CP_UTF7 :: 65000; // UTF-7 translation
CP_UTF8 :: 65001; // UTF-8 translation
CP_ACP :: 0 // default to ANSI code page
CP_OEMCP :: 1 // default to OEM code page
CP_MACCP :: 2 // default to MAC code page
CP_THREAD_ACP :: 3 // current thread's ANSI code page
CP_SYMBOL :: 42 // SYMBOL translations
CP_UTF7 :: 65000 // UTF-7 translation
CP_UTF8 :: 65001 // UTF-8 translation
MB_ERR_INVALID_CHARS :: 8;
WC_ERR_INVALID_CHARS :: 128;
MB_ERR_INVALID_CHARS :: 8
WC_ERR_INVALID_CHARS :: 128
MAX_PATH :: 0x00000104;
MAX_PATH_WIDE :: 0x8000;
MAX_PATH :: 0x00000104
MAX_PATH_WIDE :: 0x8000
INVALID_FILE_ATTRIBUTES :: -1;
INVALID_FILE_ATTRIBUTES :: -1
FILE_TYPE_DISK :: 0x0001;
FILE_TYPE_CHAR :: 0x0002;
FILE_TYPE_PIPE :: 0x0003;
FILE_TYPE_DISK :: 0x0001
FILE_TYPE_CHAR :: 0x0002
FILE_TYPE_PIPE :: 0x0003
when size_of(uintptr) == 4 {
@@ -509,7 +509,7 @@ LPPROGRESS_ROUTINE :: #type proc "stdcall" (
hSourceFile: HANDLE,
hDestinationFile: HANDLE,
lpData: LPVOID,
) -> DWORD;
) -> DWORD
CONDITION_VARIABLE :: struct {
ptr: LPVOID,
@@ -548,12 +548,12 @@ LUID :: struct {
HighPart: LONG,
}
PLUID :: ^LUID;
PLUID :: ^LUID
PGUID :: ^GUID;
PCGUID :: ^GUID;
LPGUID :: ^GUID;
LPCGUID :: ^GUID;
PGUID :: ^GUID
PCGUID :: ^GUID
LPGUID :: ^GUID
LPCGUID :: ^GUID
WSAPROTOCOLCHAIN :: struct {
@@ -607,8 +607,8 @@ FILETIME :: struct {
}
FILETIME_as_unix_nanoseconds :: proc "contextless" (ft: FILETIME) -> i64 {
t := i64(u64(ft.dwLowDateTime) | u64(ft.dwHighDateTime) << 32);
return (t - 0x019db1ded53e8000) * 100;
t := i64(u64(ft.dwLowDateTime) | u64(ft.dwHighDateTime) << 32)
return (t - 0x019db1ded53e8000) * 100
}
OVERLAPPED :: struct {
@@ -685,21 +685,21 @@ timeval :: struct {
}
EXCEPTION_CONTINUE_SEARCH: LONG : 0;
EXCEPTION_CONTINUE_EXECUTION: LONG : -1;
EXCEPTION_EXECUTE_HANDLER: LONG : 1;
EXCEPTION_CONTINUE_SEARCH: LONG : 0
EXCEPTION_CONTINUE_EXECUTION: LONG : -1
EXCEPTION_EXECUTE_HANDLER: LONG : 1
EXCEPTION_MAXIMUM_PARAMETERS :: 15;
EXCEPTION_MAXIMUM_PARAMETERS :: 15
EXCEPTION_DATATYPE_MISALIGNMENT :: 0x80000002;
EXCEPTION_BREAKPOINT :: 0x80000003;
EXCEPTION_ACCESS_VIOLATION :: 0xC0000005;
EXCEPTION_ILLEGAL_INSTRUCTION :: 0xC000001D;
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C;
EXCEPTION_INT_DIVIDE_BY_ZERO :: 0xC0000094;
EXCEPTION_INT_OVERFLOW :: 0xC0000095;
EXCEPTION_STACK_OVERFLOW :: 0xC00000FD;
STATUS_PRIVILEGED_INSTRUCTION :: 0xC0000096;
EXCEPTION_DATATYPE_MISALIGNMENT :: 0x80000002
EXCEPTION_BREAKPOINT :: 0x80000003
EXCEPTION_ACCESS_VIOLATION :: 0xC0000005
EXCEPTION_ILLEGAL_INSTRUCTION :: 0xC000001D
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C
EXCEPTION_INT_DIVIDE_BY_ZERO :: 0xC0000094
EXCEPTION_INT_OVERFLOW :: 0xC0000095
EXCEPTION_STACK_OVERFLOW :: 0xC00000FD
STATUS_PRIVILEGED_INSTRUCTION :: 0xC0000096
EXCEPTION_RECORD :: struct {
@@ -711,14 +711,14 @@ EXCEPTION_RECORD :: struct {
ExceptionInformation: [EXCEPTION_MAXIMUM_PARAMETERS]LPVOID,
}
CONTEXT :: struct{}; // TODO(bill)
CONTEXT :: struct{} // TODO(bill)
EXCEPTION_POINTERS :: struct {
ExceptionRecord: ^EXCEPTION_RECORD,
ContextRecord: ^CONTEXT,
}
PVECTORED_EXCEPTION_HANDLER :: #type proc "stdcall" (ExceptionInfo: ^EXCEPTION_POINTERS) -> LONG;
PVECTORED_EXCEPTION_HANDLER :: #type proc "stdcall" (ExceptionInfo: ^EXCEPTION_POINTERS) -> LONG
CONSOLE_READCONSOLE_CONTROL :: struct {
nLength: ULONG,
@@ -727,7 +727,7 @@ CONSOLE_READCONSOLE_CONTROL :: struct {
dwControlKeyState: ULONG,
}
PCONSOLE_READCONSOLE_CONTROL :: ^CONSOLE_READCONSOLE_CONTROL;
PCONSOLE_READCONSOLE_CONTROL :: ^CONSOLE_READCONSOLE_CONTROL
BY_HANDLE_FILE_INFORMATION :: struct {
dwFileAttributes: DWORD,
@@ -742,7 +742,7 @@ BY_HANDLE_FILE_INFORMATION :: struct {
nFileIndexLow: DWORD,
}
LPBY_HANDLE_FILE_INFORMATION :: ^BY_HANDLE_FILE_INFORMATION;
LPBY_HANDLE_FILE_INFORMATION :: ^BY_HANDLE_FILE_INFORMATION
FILE_STANDARD_INFO :: struct {
AllocationSize: LARGE_INTEGER,
@@ -792,7 +792,7 @@ OSVERSIONINFOEXW :: struct {
wSuiteMask: USHORT,
wProductType: UCHAR,
wReserved: UCHAR,
};
}
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-quota_limits
// Used in LogonUserExW
@@ -803,7 +803,7 @@ PQUOTA_LIMITS :: struct {
MaximumWorkingSetSize: SIZE_T,
PagefileLimit: SIZE_T,
TimeLimit: LARGE_INTEGER,
};
}
Logon32_Type :: enum DWORD {
INTERACTIVE = 2,
@@ -835,10 +835,10 @@ PROFILEINFOW :: struct {
lpServerName: LPWSTR,
lpPolicyPath: LPWSTR,
hProfile: HANDLE,
};
}
// Used in LookupAccountNameW
SID_NAME_USE :: distinct DWORD;
SID_NAME_USE :: distinct DWORD
SID_TYPE :: enum SID_NAME_USE {
User = 1,
@@ -854,7 +854,7 @@ SID_TYPE :: enum SID_NAME_USE {
LogonSession,
}
SECURITY_MAX_SID_SIZE :: 68;
SECURITY_MAX_SID_SIZE :: 68
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-sid
SID :: struct #packed {
@@ -862,25 +862,25 @@ SID :: struct #packed {
SubAuthorityCount: byte,
IdentifierAuthority: SID_IDENTIFIER_AUTHORITY,
SubAuthority: [15]DWORD, // Array of DWORDs
};
}
#assert(size_of(SID) == SECURITY_MAX_SID_SIZE);
SID_IDENTIFIER_AUTHORITY :: struct #packed {
Value: [6]u8,
};
}
// For NetAPI32
// https://github.com/tpn/winsdk-10/blob/master/Include/10.0.14393.0/shared/lmerr.h
// https://github.com/tpn/winsdk-10/blob/master/Include/10.0.14393.0/shared/LMaccess.h
UNLEN :: 256; // Maximum user name length
LM20_UNLEN :: 20; // LM 2.0 Maximum user name length
UNLEN :: 256 // Maximum user name length
LM20_UNLEN :: 20 // LM 2.0 Maximum user name length
GNLEN :: UNLEN; // Group name
LM20_GNLEN :: LM20_UNLEN; // LM 2.0 Group name
GNLEN :: UNLEN // Group name
LM20_GNLEN :: LM20_UNLEN // LM 2.0 Group name
PWLEN :: 256; // Maximum password length
LM20_PWLEN :: 14; // LM 2.0 Maximum password length
PWLEN :: 256 // Maximum password length
LM20_PWLEN :: 14 // LM 2.0 Maximum password length
USER_PRIV :: enum DWORD {
Guest = 0,
@@ -904,7 +904,7 @@ USER_INFO_FLAG :: enum DWORD {
Workstation_Trust_Account = 12, // 1 << 12: 0x1000,
Server_Trust_Account = 13, // 1 << 13: 0x2000,
}
USER_INFO_FLAGS :: distinct bit_set[USER_INFO_FLAG];
USER_INFO_FLAGS :: distinct bit_set[USER_INFO_FLAG]
USER_INFO_1 :: struct #packed {
name: LPWSTR,
@@ -915,12 +915,12 @@ USER_INFO_1 :: struct #packed {
comment: LPWSTR,
flags: USER_INFO_FLAGS,
script_path: LPWSTR,
};
}
#assert(size_of(USER_INFO_1) == 50);
LOCALGROUP_MEMBERS_INFO_0 :: struct #packed {
sid: ^SID,
};
}
NET_API_STATUS :: enum DWORD {
Success = 0,
+137 -137
View File
@@ -5,54 +5,54 @@ import "core:strings"
import "core:sys/win32"
LOWORD :: #force_inline proc "contextless" (x: DWORD) -> WORD {
return WORD(x & 0xffff);
return WORD(x & 0xffff)
}
HIWORD :: #force_inline proc "contextless" (x: DWORD) -> WORD {
return WORD(x >> 16);
return WORD(x >> 16)
}
utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
if len(s) < 1 {
return nil;
return nil
}
b := transmute([]byte)s;
cstr := raw_data(b);
n := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), nil, 0);
b := transmute([]byte)s
cstr := raw_data(b)
n := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), nil, 0)
if n == 0 {
return nil;
return nil
}
text := make([]u16, n+1, allocator);
text := make([]u16, n+1, allocator)
n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), raw_data(text), n);
n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), raw_data(text), n)
if n1 == 0 {
delete(text, allocator);
return nil;
delete(text, allocator)
return nil
}
text[n] = 0;
text[n] = 0
for n >= 1 && text[n-1] == 0 {
n -= 1;
n -= 1
}
return text[:n];
return text[:n]
}
utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
if res := utf8_to_utf16(s, allocator); res != nil {
return &res[0];
return &res[0]
}
return nil;
return nil
}
wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> string {
if N <= 0 {
return "";
return ""
}
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), nil, 0, nil, nil);
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), nil, 0, nil, nil)
if n == 0 {
return "";
return ""
}
// If N == -1 the call to WideCharToMultiByte assume the wide string is null terminated
@@ -60,29 +60,29 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
// also null terminated.
// If N != -1 it assumes the wide string is not null terminated and the resulting string
// will not be null terminated, we therefore have to force it to be null terminated manually.
text := make([]byte, n+1 if N != -1 else n, allocator);
text := make([]byte, n+1 if N != -1 else n, allocator)
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil);
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil)
if n1 == 0 {
delete(text, allocator);
return "";
delete(text, allocator)
return ""
}
for i in 0..<n {
if text[i] == 0 {
n = i;
break;
n = i
break
}
}
return string(text[:n]);
return string(text[:n])
}
utf16_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> string {
if len(s) == 0 {
return "";
return ""
}
return wstring_to_utf8(raw_data(s), len(s), allocator);
return wstring_to_utf8(raw_data(s), len(s), allocator)
}
// AdvAPI32, NetAPI32 and UserENV helpers.
@@ -94,58 +94,58 @@ allowed_username :: proc(username: string) -> bool {
", /, , [, ], :, |, <, >, +, =, ;, ?, *. Names also cannot include characters in the range 1-31, which are nonprintable.
*/
_DISALLOWED :: "\"/ []:|<>+=;?*,";
_DISALLOWED :: "\"/ []:|<>+=;?*,"
if len(username) > LM20_UNLEN || len(username) == 0 {
return false;
return false
}
if username[len(username)-1] == '.' {
return false;
return false
}
for r in username {
if r > 0 && r < 32 {
return false;
return false
}
}
if strings.contains_any(username, _DISALLOWED) {
return false;
return false
}
return true;
return true
}
// Returns .Success on success.
_add_user :: proc(servername: string, username: string, password: string) -> (ok: NET_API_STATUS) {
servername_w: wstring;
username_w: []u16;
password_w: []u16;
servername_w: wstring
username_w: []u16
password_w: []u16
if len(servername) == 0 {
// Create account on this computer
servername_w = nil;
servername_w = nil
} else {
server := utf8_to_utf16(servername, context.temp_allocator);
servername_w = &server[0];
server := utf8_to_utf16(servername, context.temp_allocator)
servername_w = &server[0]
}
if len(username) == 0 || len(username) > LM20_UNLEN {
return .BadUsername;
return .BadUsername
}
if !allowed_username(username) {
return .BadUsername;
return .BadUsername
}
if len(password) == 0 || len(password) > LM20_PWLEN {
return .BadPassword;
return .BadPassword
}
username_w = utf8_to_utf16(username, context.temp_allocator);
password_w = utf8_to_utf16(password, context.temp_allocator);
username_w = utf8_to_utf16(username, context.temp_allocator)
password_w = utf8_to_utf16(password, context.temp_allocator)
level := DWORD(1);
parm_err: DWORD;
level := DWORD(1)
parm_err: DWORD
user_info := USER_INFO_1{
name = &username_w[0],
@@ -156,24 +156,24 @@ _add_user :: proc(servername: string, username: string, password: string) -> (ok
comment = nil,
flags = {.Script, .Normal_Account},
script_path = nil,
};
}
ok = NetUserAdd(
servername_w,
level,
&user_info,
&parm_err,
);
)
return;
return
}
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;
pe_use := SID_TYPE.User;
username_w := utf8_to_utf16(username, context.temp_allocator)
cbsid: DWORD
computer_name_size: DWORD
pe_use := SID_TYPE.User
res := LookupAccountNameW(
nil, // Look on this computer first
@@ -183,13 +183,13 @@ get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: s
nil,
&computer_name_size,
&pe_use,
);
)
if computer_name_size == 0 {
// User didn't exist, or we'd have a size here.
return "", {}, false;
return "", {}, false
}
cname_w := make([]u16, min(computer_name_size, 1), context.temp_allocator);
cname_w := make([]u16, min(computer_name_size, 1), context.temp_allocator)
res = LookupAccountNameW(
nil,
@@ -199,23 +199,23 @@ get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: s
&cname_w[0],
&computer_name_size,
&pe_use,
);
)
if !res {
return "", {}, false;
return "", {}, false
}
computer_name = utf16_to_utf8(cname_w, context.temp_allocator);
computer_name = utf16_to_utf8(cname_w, context.temp_allocator)
ok = true;
return;
ok = true
return
}
get_sid :: proc(username: string, sid: ^SID) -> (ok: bool) {
username_w := utf8_to_utf16(username, context.temp_allocator);
cbsid: DWORD;
computer_name_size: DWORD;
pe_use := SID_TYPE.User;
username_w := utf8_to_utf16(username, context.temp_allocator)
cbsid: DWORD
computer_name_size: DWORD
pe_use := SID_TYPE.User
res := LookupAccountNameW(
nil, // Look on this computer first
@@ -225,13 +225,13 @@ get_sid :: proc(username: string, sid: ^SID) -> (ok: bool) {
nil,
&computer_name_size,
&pe_use,
);
)
if computer_name_size == 0 {
// User didn't exist, or we'd have a size here.
return false;
return false
}
cname_w := make([]u16, min(computer_name_size, 1), context.temp_allocator);
cname_w := make([]u16, min(computer_name_size, 1), context.temp_allocator)
res = LookupAccountNameW(
nil,
@@ -241,97 +241,97 @@ get_sid :: proc(username: string, sid: ^SID) -> (ok: bool) {
&cname_w[0],
&computer_name_size,
&pe_use,
);
)
if !res {
return false;
return false
}
ok = true;
return;
ok = true
return
}
add_user_to_group :: proc(sid: ^SID, group: string) -> (ok: NET_API_STATUS) {
group_member := LOCALGROUP_MEMBERS_INFO_0{
sid = sid,
};
group_name := utf8_to_utf16(group, context.temp_allocator);
}
group_name := utf8_to_utf16(group, context.temp_allocator)
ok = NetLocalGroupAddMembers(
nil,
&group_name[0],
0,
&group_member,
1,
);
return;
)
return
}
add_del_from_group :: proc(sid: ^SID, group: string) -> (ok: NET_API_STATUS) {
group_member := LOCALGROUP_MEMBERS_INFO_0{
sid = sid,
};
group_name := utf8_to_utf16(group, context.temp_allocator);
}
group_name := utf8_to_utf16(group, context.temp_allocator)
ok = NetLocalGroupDelMembers(
nil,
&group_name[0],
0,
&group_member,
1,
);
return;
)
return
}
add_user_profile :: proc(username: string) -> (ok: bool, profile_path: string) {
username_w := utf8_to_utf16(username, context.temp_allocator);
username_w := utf8_to_utf16(username, context.temp_allocator)
sid := SID{};
ok = get_sid(username, &sid);
sid := SID{}
ok = get_sid(username, &sid)
if ok == false {
return false, "";
return false, ""
}
sb: wstring;
res := ConvertSidToStringSidW(&sid, &sb);
sb: wstring
res := ConvertSidToStringSidW(&sid, &sb)
if res == false {
return false, "";
return false, ""
}
defer win32.local_free(sb);
defer win32.local_free(sb)
pszProfilePath := make([]u16, 257, context.temp_allocator);
pszProfilePath := make([]u16, 257, context.temp_allocator)
res2 := CreateProfile(
sb,
&username_w[0],
&pszProfilePath[0],
257,
);
)
if res2 != 0 {
return false, "";
return false, ""
}
profile_path = wstring_to_utf8(&pszProfilePath[0], 257);
profile_path = wstring_to_utf8(&pszProfilePath[0], 257)
return true, profile_path;
return true, profile_path
}
delete_user_profile :: proc(username: string) -> (ok: bool) {
sid := SID{};
ok = get_sid(username, &sid);
sid := SID{}
ok = get_sid(username, &sid)
if ok == false {
return false;
return false
}
sb: wstring;
res := ConvertSidToStringSidW(&sid, &sb);
sb: wstring
res := ConvertSidToStringSidW(&sid, &sb)
if res == false {
return false;
return false
}
defer win32.local_free(sb);
defer win32.local_free(sb)
res2 := DeleteProfileW(
sb,
nil,
nil,
);
return bool(res2);
)
return bool(res2)
}
add_user :: proc(servername: string, username: string, password: string) -> (ok: bool) {
@@ -343,24 +343,24 @@ add_user :: proc(servername: string, username: string, password: string) -> (ok:
TODO: SecureZeroMemory the password after use.
*/
res := _add_user(servername, username, password);
res := _add_user(servername, username, password)
if res != .Success {
return false;
return false
}
// Grab the SID to add the user to the Users group.
sid: SID;
ok2 := get_sid(username, &sid);
sid: SID
ok2 := get_sid(username, &sid)
if ok2 == false {
return false;
return false
}
ok3 := add_user_to_group(&sid, "Users");
ok3 := add_user_to_group(&sid, "Users")
if ok3 != .Success {
return false;
return false
}
return true;
return true
}
delete_user :: proc(servername: string, username: string) -> (ok: bool) {
@@ -371,24 +371,24 @@ delete_user :: proc(servername: string, username: string) -> (ok: bool) {
TODO: Add a bool that governs whether to delete the profile from this wrapper?
*/
servername_w: wstring;
servername_w: wstring
if len(servername) == 0 {
// Delete account on this computer
servername_w = nil;
servername_w = nil
} else {
server := utf8_to_utf16(servername, context.temp_allocator);
servername_w = &server[0];
server := utf8_to_utf16(servername, context.temp_allocator)
servername_w = &server[0]
}
username_w := utf8_to_utf16(username);
username_w := utf8_to_utf16(username)
res := NetUserDel(
servername_w,
&username_w[0],
);
)
if res != .Success {
return false;
return false
}
return true;
return true
}
run_as_user :: proc(username, password, application, commandline: string, pi: ^PROCESS_INFORMATION, wait := true) -> (ok: bool) {
@@ -402,17 +402,17 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P
*/
username_w := utf8_to_utf16(username);
domain_w := utf8_to_utf16(".");
password_w := utf8_to_utf16(password);
app_w := utf8_to_utf16(application);
username_w := utf8_to_utf16(username)
domain_w := utf8_to_utf16(".")
password_w := utf8_to_utf16(password)
app_w := utf8_to_utf16(application)
commandline_w: []u16 = {0};
commandline_w: []u16 = {0}
if len(commandline) > 0 {
commandline_w = utf8_to_utf16(commandline);
commandline_w = utf8_to_utf16(commandline)
}
user_token: HANDLE;
user_token: HANDLE
ok = bool(LogonUserW(
lpszUsername = &username_w[0],
@@ -421,16 +421,16 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P
dwLogonType = .NEW_CREDENTIALS,
dwLogonProvider = .WINNT50,
phToken = &user_token,
));
))
if !ok {
return false;
return false
// err := GetLastError();
// fmt.printf("GetLastError: %v\n", err);
}
si := STARTUPINFO{};
si.cb = size_of(STARTUPINFO);
pi := pi;
si := STARTUPINFO{}
si.cb = size_of(STARTUPINFO)
pi := pi
ok = bool(CreateProcessAsUserW(
user_token,
@@ -444,15 +444,15 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P
nil, // current directory: inherit from parent if nil
&si,
pi,
));
))
if ok {
if wait {
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE)
CloseHandle(pi.hProcess)
CloseHandle(pi.hThread)
}
return true;
return true
} else {
return false;
return false
}
}