| 1 | module os |
| 2 | |
| 3 | const max_path_buffer_size = 2 * max_path_len |
| 4 | |
| 5 | // Ref - winnt.h |
| 6 | const success = 0x0000 // ERROR_SUCCESS |
| 7 | |
| 8 | const error_insufficient_buffer = 0x0082 |
| 9 | |
| 10 | const handle_generic_read = u32(0x80000000) |
| 11 | const handle_open_existing = 0x00000003 |
| 12 | |
| 13 | const file_share_read = 0x01 |
| 14 | const file_share_write = 0x02 |
| 15 | const file_share_delete = 0x04 |
| 16 | |
| 17 | const file_notify_change_file_name = 0x01 |
| 18 | const file_notify_change_dir_name = 0x02 |
| 19 | const file_notify_change_attributes = 0x04 |
| 20 | const file_notify_change_size = 0x08 |
| 21 | const file_notify_change_last_write = 0x10 |
| 22 | const file_notify_change_last_access = 0x20 |
| 23 | const file_notify_change_creation = 0x40 |
| 24 | const file_notify_change_security = 0x80 |
| 25 | |
| 26 | const file_action_added = 0x01 |
| 27 | const file_action_removed = 0x02 |
| 28 | const file_action_modified = 0x03 |
| 29 | const file_action_renamed_old_name = 0x04 |
| 30 | const file_action_renamed_new_name = 0x05 |
| 31 | |
| 32 | const file_attr_readonly = 0x00000001 |
| 33 | const file_attr_hidden = 0x00000002 |
| 34 | const file_attr_system = 0x00000004 |
| 35 | const file_attr_directory = 0x00000010 |
| 36 | const file_attr_archive = 0x00000020 |
| 37 | const file_attr_device = 0x00000040 |
| 38 | const file_attr_normal = 0x00000080 |
| 39 | const file_attr_temporary = 0x00000100 |
| 40 | const file_attr_sparse_file = 0x00000200 |
| 41 | const file_attr_reparse_point = 0x00000400 |
| 42 | const file_attr_compressed = 0x00000800 |
| 43 | const file_attr_offline = 0x00001000 |
| 44 | const file_attr_not_content_indexed = 0x00002000 |
| 45 | const file_attr_encrypted = 0x00004000 |
| 46 | const file_attr_integrity_stream = 0x00008000 |
| 47 | const file_attr_virtual = 0x00010000 |
| 48 | const file_attr_no_scrub_data = 0x00020000 |
| 49 | |
| 50 | const file_type_unknown = 0x00 |
| 51 | const file_type_disk = 0x01 |
| 52 | const file_type_char = 0x02 |
| 53 | const file_type_pipe = 0x03 |
| 54 | |
| 55 | const file_invalid_file_id = (-1) |
| 56 | |
| 57 | const invalid_handle_value = voidptr(-1) |
| 58 | |
| 59 | // https://docs.microsoft.com/en-us/windows/console/setconsolemode |
| 60 | // Input Buffer |
| 61 | const enable_echo_input = 0x0004 |
| 62 | const enable_extended_flags = 0x0080 |
| 63 | const enable_insert_mode = 0x0020 |
| 64 | const enable_line_input = 0x0002 |
| 65 | const enable_mouse_input = 0x0010 |
| 66 | const enable_processed_input = 0x0001 |
| 67 | const enable_quick_edit_mode = 0x0040 |
| 68 | const enable_window_input = 0x0008 |
| 69 | const enable_virtual_terminal_input = 0x0200 |
| 70 | // Output Screen Buffer |
| 71 | const enable_processed_output = 0x01 |
| 72 | const enable_wrap_at_eol_output = 0x02 |
| 73 | const enable_virtual_terminal_processing = 0x04 |
| 74 | const disable_newline_auto_return = 0x08 |
| 75 | const enable_lvb_grid_worldwide = 0x10 |
| 76 | |
| 77 | // File modes |
| 78 | const o_rdonly = 0x0000 // open the file read-only. |
| 79 | |
| 80 | const o_wronly = 0x0001 // open the file write-only. |
| 81 | |
| 82 | const o_rdwr = 0x0002 // open the file read-write. |
| 83 | |
| 84 | const o_append = 0x0008 // append data to the file when writing. |
| 85 | |
| 86 | const o_create = 0x0100 // create a new file if none exists. |
| 87 | |
| 88 | const o_binary = 0x8000 // input and output is not translated. |
| 89 | |
| 90 | const o_trunc = 0x0200 // truncate regular writable file when opened. |
| 91 | |
| 92 | const o_excl = 0x0400 // used with o_create, file must not exist. |
| 93 | |
| 94 | const o_sync = 0x0000 // open for synchronous I/O (ignored on Windows) |
| 95 | |
| 96 | const o_noctty = 0x0000 // make file non-controlling tty (ignored on Windows) |
| 97 | |
| 98 | const o_nonblock = 0x0000 |
| 99 | |
| 100 | const status_access_violation = u32(0xC0000005) |
| 101 | const status_in_page_error = u32(0xC0000006) |
| 102 | const status_invalid_handle = u32(0xC0000008) |
| 103 | const status_invalid_parameter = u32(0xC000000D) |
| 104 | const status_no_memory = u32(0xC0000017) |
| 105 | const status_illegal_instruction = u32(0xC000001D) |
| 106 | const status_noncontinuable_exception = u32(0xC0000025) |
| 107 | const status_invalid_disposition = u32(0xC0000026) |
| 108 | const status_array_bounds_exceeded = u32(0xC000008C) |
| 109 | const status_float_denormal_operand = u32(0xC000008D) |
| 110 | const status_float_divide_by_zero = u32(0xC000008E) |
| 111 | const status_float_inexact_result = u32(0xC000008F) |
| 112 | const status_float_invalid_operation = u32(0xC0000090) |
| 113 | const status_float_overflow = u32(0xC0000091) |
| 114 | const status_float_stack_check = u32(0xC0000092) |
| 115 | const status_float_underflow = u32(0xC0000093) |
| 116 | const status_integer_divide_by_zero = u32(0xC0000094) |
| 117 | const status_integer_overflow = u32(0xC0000095) |
| 118 | const status_privileged_instruction = u32(0xC0000096) |
| 119 | const status_stack_overflow = u32(0xC00000FD) |
| 120 | const status_dll_not_found = u32(0xC0000135) |
| 121 | const status_ordinal_not_found = u32(0xC0000138) |
| 122 | const status_entrypoint_not_found = u32(0xC0000139) |
| 123 | const status_control_c_exit = u32(0xC000013A) |
| 124 | const status_dll_init_failed = u32(0xC0000142) |
| 125 | const status_float_multiple_faults = u32(0xC00002B4) |
| 126 | const status_float_multiple_traps = u32(0xC00002B5) |
| 127 | const status_reg_nat_consumption = u32(0xC00002C9) |
| 128 | const status_heap_corruption = u32(0xC0000374) |
| 129 | const status_stack_buffer_overrun = u32(0xC0000409) |
| 130 | const status_invalid_cruntime_parameter = u32(0xC0000417) |
| 131 | const status_assertion_failure = u32(0xC0000420) |
| 132 | |
| 133 | // Windows Registry Constants |
| 134 | pub const hkey_local_machine = voidptr(0x80000002) |
| 135 | pub const hkey_current_user = voidptr(0x80000001) |
| 136 | pub const key_query_value = 0x0001 |
| 137 | pub const key_set_value = 0x0002 |
| 138 | pub const key_enumerate_sub_keys = 0x0008 |
| 139 | pub const key_wow64_32key = 0x0200 |
| 140 | |
| 141 | // Windows Messages |
| 142 | pub const hwnd_broadcast = voidptr(0xFFFF) |
| 143 | pub const wm_settingchange = 0x001A |
| 144 | pub const smto_abortifhung = 0x0002 |
| 145 | |