windows.odin 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. // +build windows
  2. package win32
  3. foreign import "system:kernel32.lib"
  4. foreign import "system:user32.lib"
  5. foreign import "system:gdi32.lib"
  6. foreign import "system:winmm.lib"
  7. foreign import "system:shell32.lib"
  8. Handle :: distinct rawptr;
  9. Hwnd :: distinct Handle;
  10. Hdc :: distinct Handle;
  11. Hinstance :: distinct Handle;
  12. Hicon :: distinct Handle;
  13. Hcursor :: distinct Handle;
  14. Hmenu :: distinct Handle;
  15. Hbrush :: distinct Handle;
  16. Hgdiobj :: distinct Handle;
  17. Hmodule :: distinct Handle;
  18. Hmonitor :: distinct Handle;
  19. Hrawinput :: distinct Handle;
  20. HKL :: distinct Handle;
  21. Wparam :: distinct uint;
  22. Lparam :: distinct int;
  23. Lresult :: distinct int;
  24. Wnd_Proc :: distinct #type proc "c" (Hwnd, u32, Wparam, Lparam) -> Lresult;
  25. Long_Ptr :: distinct int;
  26. Bool :: distinct b32;
  27. Wstring :: ^u16;
  28. Point :: struct {
  29. x, y: i32,
  30. }
  31. Wnd_Class_Ex_A :: struct {
  32. size, style: u32,
  33. wnd_proc: Wnd_Proc,
  34. cls_extra, wnd_extra: i32,
  35. instance: Hinstance,
  36. icon: Hicon,
  37. cursor: Hcursor,
  38. background: Hbrush,
  39. menu_name, class_name: cstring,
  40. sm: Hicon,
  41. }
  42. Wnd_Class_Ex_W :: struct {
  43. size, style: u32,
  44. wnd_proc: Wnd_Proc,
  45. cls_extra, wnd_extra: i32,
  46. instance: Hinstance,
  47. icon: Hicon,
  48. cursor: Hcursor,
  49. background: Hbrush,
  50. menu_name, class_name: Wstring,
  51. sm: Hicon,
  52. }
  53. Msg :: struct {
  54. hwnd: Hwnd,
  55. message: u32,
  56. wparam: Wparam,
  57. lparam: Lparam,
  58. time: u32,
  59. pt: Point,
  60. }
  61. Rect :: struct {
  62. left: i32,
  63. top: i32,
  64. right: i32,
  65. bottom: i32,
  66. }
  67. Filetime :: struct {
  68. lo, hi: u32,
  69. }
  70. Systemtime :: struct {
  71. year, month: u16,
  72. day_of_week, day: u16,
  73. hour, minute, second, millisecond: u16,
  74. }
  75. By_Handle_File_Information :: struct {
  76. file_attributes: u32,
  77. creation_time,
  78. last_access_time,
  79. last_write_time: Filetime,
  80. volume_serial_number,
  81. file_size_high,
  82. file_size_low,
  83. number_of_links,
  84. file_index_high,
  85. file_index_low: u32,
  86. }
  87. File_Attribute_Data :: struct {
  88. file_attributes: u32,
  89. creation_time,
  90. last_access_time,
  91. last_write_time: Filetime,
  92. file_size_high,
  93. file_size_low: u32,
  94. }
  95. Find_Data_W :: struct{
  96. file_attributes: u32,
  97. creation_time: Filetime,
  98. last_access_time: Filetime,
  99. last_write_time: Filetime,
  100. file_size_high: u32,
  101. file_size_low: u32,
  102. reserved0: u32,
  103. reserved1: u32,
  104. file_name: [MAX_PATH]u16,
  105. alternate_file_name: [14]u16,
  106. }
  107. Find_Data_A :: struct{
  108. file_attributes: u32,
  109. creation_time: Filetime,
  110. last_access_time: Filetime,
  111. last_write_time: Filetime,
  112. file_size_high: u32,
  113. file_size_low: u32,
  114. reserved0: u32,
  115. reserved1: u32,
  116. file_name: [MAX_PATH]byte,
  117. alternate_file_name: [14]byte,
  118. }
  119. Security_Attributes :: struct {
  120. length: u32,
  121. security_descriptor: rawptr,
  122. inherit_handle: Bool,
  123. }
  124. Process_Information :: struct {
  125. process: Handle,
  126. thread: Handle,
  127. process_id: u32,
  128. thread_id: u32
  129. }
  130. Startup_Info :: struct {
  131. cb: u32,
  132. reserved: Wstring,
  133. desktop: Wstring,
  134. title: Wstring,
  135. x: u32,
  136. y: u32,
  137. x_size: u32,
  138. y_size: u32,
  139. x_count_chars: u32,
  140. y_count_chars: u32,
  141. fill_attribute: u32,
  142. flags: u32,
  143. show_window: u16,
  144. _: u16,
  145. _: cstring,
  146. stdin: Handle,
  147. stdout: Handle,
  148. stderr: Handle,
  149. }
  150. Pixel_Format_Descriptor :: struct {
  151. size,
  152. version,
  153. flags: u32,
  154. pixel_type,
  155. color_bits,
  156. red_bits,
  157. red_shift,
  158. green_bits,
  159. green_shift,
  160. blue_bits,
  161. blue_shift,
  162. alpha_bits,
  163. alpha_shift,
  164. accum_bits,
  165. accum_red_bits,
  166. accum_green_bits,
  167. accum_blue_bits,
  168. accum_alpha_bits,
  169. depth_bits,
  170. stencil_bits,
  171. aux_buffers,
  172. layer_type,
  173. reserved: byte,
  174. layer_mask,
  175. visible_mask,
  176. damage_mask: u32,
  177. }
  178. Critical_Section :: struct {
  179. debug_info: ^Critical_Section_Debug,
  180. lock_count: i32,
  181. recursion_count: i32,
  182. owning_thread: Handle,
  183. lock_semaphore: Handle,
  184. spin_count: ^u32,
  185. }
  186. Critical_Section_Debug :: struct {
  187. typ: u16,
  188. creator_back_trace_index: u16,
  189. critical_section: ^Critical_Section,
  190. process_locks_list: ^List_Entry,
  191. entry_count: u32,
  192. contention_count: u32,
  193. flags: u32,
  194. creator_back_trace_index_high: u16,
  195. spare_word: u16,
  196. }
  197. List_Entry :: struct {flink, blink: ^List_Entry};
  198. Raw_Input_Device :: struct {
  199. usage_page: u16,
  200. usage: u16,
  201. flags: u32,
  202. wnd_target: Hwnd,
  203. }
  204. Raw_Input_Header :: struct {
  205. kind: u32,
  206. size: u32,
  207. device: Handle,
  208. wparam: Wparam,
  209. }
  210. Raw_HID :: struct {
  211. size_hid: u32,
  212. count: u32,
  213. raw_data: [1]byte,
  214. }
  215. Raw_Keyboard :: struct {
  216. make_code: u16,
  217. flags: u16,
  218. reserved: u16,
  219. vkey: u16,
  220. message: u32,
  221. extra_information: u32,
  222. }
  223. Raw_Mouse :: struct {
  224. flags: u16,
  225. using data: struct #raw_union {
  226. buttons: u32,
  227. using _: struct {
  228. button_flags: u16,
  229. button_data: u16,
  230. },
  231. },
  232. raw_buttons: u32,
  233. last_x: i32,
  234. last_y: i32,
  235. extra_information: u32,
  236. }
  237. Raw_Input :: struct {
  238. using header: Raw_Input_Header,
  239. data: struct #raw_union {
  240. mouse: Raw_Mouse,
  241. keyboard: Raw_Keyboard,
  242. hid: Raw_HID,
  243. },
  244. }
  245. Overlapped :: struct {
  246. internal: ^u64,
  247. internal_high: ^u64,
  248. using _: struct #raw_union {
  249. using _: struct {
  250. offset: u32,
  251. offset_high: u32,
  252. },
  253. pointer: rawptr,
  254. },
  255. event: Handle,
  256. }
  257. File_Notify_Information :: struct {
  258. next_entry_offset: u32,
  259. action: u32,
  260. file_name_length: u32,
  261. file_name: [1]u16,
  262. }
  263. MAPVK_VK_TO_VSC :: 0;
  264. MAPVK_VSC_TO_VK :: 1;
  265. MAPVK_VK_TO_CHAR :: 2;
  266. MAPVK_VSC_TO_VK_EX :: 3;
  267. INVALID_HANDLE :: Handle(~uintptr(0));
  268. CREATE_SUSPENDED :: 0x00000004;
  269. STACK_SIZE_PARAM_IS_A_RESERVATION :: 0x00010000;
  270. WAIT_ABANDONED :: 0x00000080;
  271. WAIT_OBJECT_0 :: 0;
  272. WAIT_TIMEOUT :: 0x00000102;
  273. WAIT_FAILED :: 0xffffffff;
  274. CS_VREDRAW :: 0x0001;
  275. CS_HREDRAW :: 0x0002;
  276. CS_OWNDC :: 0x0020;
  277. CW_USEDEFAULT :: -0x80000000;
  278. WS_OVERLAPPED :: 0;
  279. WS_MAXIMIZEBOX :: 0x00010000;
  280. WS_MINIMIZEBOX :: 0x00020000;
  281. WS_THICKFRAME :: 0x00040000;
  282. WS_SYSMENU :: 0x00080000;
  283. WS_BORDER :: 0x00800000;
  284. WS_CAPTION :: 0x00C00000;
  285. WS_VISIBLE :: 0x10000000;
  286. WS_POPUP :: 0x80000000;
  287. WS_MAXIMIZE :: 0x01000000;
  288. WS_MINIMIZE :: 0x20000000;
  289. WS_OVERLAPPEDWINDOW :: WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
  290. WS_POPUPWINDOW :: WS_POPUP | WS_BORDER | WS_SYSMENU;
  291. WM_ACTIVATE :: 0x0006;
  292. WM_ACTIVATEAPP :: 0x001C;
  293. WM_CHAR :: 0x0102;
  294. WM_CLOSE :: 0x0010;
  295. WM_CREATE :: 0x0001;
  296. WM_DESTROY :: 0x0002;
  297. WM_INPUT :: 0x00ff;
  298. WM_KEYDOWN :: 0x0100;
  299. WM_KEYUP :: 0x0101;
  300. WM_KILLFOCUS :: 0x0008;
  301. WM_QUIT :: 0x0012;
  302. WM_SETCURSOR :: 0x0020;
  303. WM_SETFOCUS :: 0x0007;
  304. WM_SIZE :: 0x0005;
  305. WM_SIZING :: 0x0214;
  306. WM_SYSKEYDOWN :: 0x0104;
  307. WM_SYSKEYUP :: 0x0105;
  308. WM_USER :: 0x0400;
  309. WM_WINDOWPOSCHANGED :: 0x0047;
  310. WM_MOUSEWHEEL :: 0x020A;
  311. WM_MOUSEMOVE :: 0x0200;
  312. WM_LBUTTONDOWN :: 0x0201;
  313. WM_LBUTTONUP :: 0x0202;
  314. WM_LBUTTONDBLCLK :: 0x0203;
  315. WM_RBUTTONDOWN :: 0x0204;
  316. WM_RBUTTONUP :: 0x0205;
  317. WM_RBUTTONDBLCLK :: 0x0206;
  318. WM_MBUTTONDOWN :: 0x0207;
  319. WM_MBUTTONUP :: 0x0208;
  320. WM_MBUTTONDBLCLK :: 0x0209;
  321. PM_NOREMOVE :: 0x0000;
  322. PM_REMOVE :: 0x0001;
  323. PM_NOYIELD :: 0x0002;
  324. BLACK_BRUSH :: 4;
  325. SM_CXSCREEN :: 0;
  326. SM_CYSCREEN :: 1;
  327. SW_SHOW :: 5;
  328. COLOR_BACKGROUND :: Hbrush(uintptr(1));
  329. INVALID_SET_FILE_POINTER :: ~u32(0);
  330. HEAP_ZERO_MEMORY :: 0x00000008;
  331. INFINITE :: 0xffffffff;
  332. GWL_EXSTYLE :: -20;
  333. GWLP_HINSTANCE :: -6;
  334. GWLP_ID :: -12;
  335. GWL_STYLE :: -16;
  336. GWLP_USERDATA :: -21;
  337. GWLP_WNDPROC :: -4;
  338. Hwnd_TOP :: Hwnd(uintptr(0));
  339. BI_RGB :: 0;
  340. DIB_RGB_COLORS :: 0x00;
  341. SRCCOPY: u32 : 0x00cc0020;
  342. MONITOR_DEFAULTTONULL :: 0x00000000;
  343. MONITOR_DEFAULTTOPRIMARY :: 0x00000001;
  344. MONITOR_DEFAULTTONEAREST :: 0x00000002;
  345. SWP_FRAMECHANGED :: 0x0020;
  346. SWP_NOOWNERZORDER :: 0x0200;
  347. SWP_NOZORDER :: 0x0004;
  348. SWP_NOSIZE :: 0x0001;
  349. SWP_NOMOVE :: 0x0002;
  350. // Raw Input
  351. RID_HEADER :: 0x10000005;
  352. RID_INPUT :: 0x10000003;
  353. RIDEV_APPKEYS :: 0x00000400;
  354. RIDEV_CAPTUREMOUSE :: 0x00000200;
  355. RIDEV_DEVNOTIFY :: 0x00002000;
  356. RIDEV_EXCLUDE :: 0x00000010;
  357. RIDEV_EXINPUTSINK :: 0x00001000;
  358. RIDEV_INPUTSINK :: 0x00000100;
  359. RIDEV_NOHOTKEYS :: 0x00000200;
  360. RIDEV_NOLEGACY :: 0x00000030;
  361. RIDEV_PAGEONLY :: 0x00000020;
  362. RIDEV_REMOVE :: 0x00000001;
  363. RIM_TYPEMOUSE :: 0;
  364. RIM_TYPEKEYBOARD :: 1;
  365. RIM_TYPEHID :: 2;
  366. MOUSE_ATTRIBUTES_CHANGED :: 0x04;
  367. MOUSE_MOVE_RELATIVE :: 0;
  368. MOUSE_MOVE_ABSOLUTE :: 1;
  369. MOUSE_VIRTUAL_DESKTOP :: 0x02;
  370. RI_MOUSE_BUTTON_1_DOWN :: 0x0001;
  371. RI_MOUSE_BUTTON_1_UP :: 0x0002;
  372. RI_MOUSE_BUTTON_2_DOWN :: 0x0004;
  373. RI_MOUSE_BUTTON_2_UP :: 0x0008;
  374. RI_MOUSE_BUTTON_3_DOWN :: 0x0010;
  375. RI_MOUSE_BUTTON_3_UP :: 0x0020;
  376. RI_MOUSE_BUTTON_4_DOWN :: 0x0040;
  377. RI_MOUSE_BUTTON_4_UP :: 0x0080;
  378. RI_MOUSE_BUTTON_5_DOWN :: 0x0100;
  379. RI_MOUSE_BUTTON_5_UP :: 0x0200;
  380. RI_MOUSE_LEFT_BUTTON_DOWN :: 0x0001;
  381. RI_MOUSE_LEFT_BUTTON_UP :: 0x0002;
  382. RI_MOUSE_MIDDLE_BUTTON_DOWN :: 0x0010;
  383. RI_MOUSE_MIDDLE_BUTTON_UP :: 0x0020;
  384. RI_MOUSE_RIGHT_BUTTON_DOWN :: 0x0004;
  385. RI_MOUSE_RIGHT_BUTTON_UP :: 0x0008;
  386. RI_MOUSE_WHEEL :: 0x0400;
  387. RI_KEY_MAKE :: 0x00;
  388. RI_KEY_BREAK :: 0x01;
  389. RI_KEY_E0 :: 0x02;
  390. RI_KEY_E1 :: 0x04;
  391. RI_KEY_TERMSRV_SET_LED :: 0x08;
  392. RI_KEY_TERMSRV_SHADOW :: 0x10;
  393. // Windows OpenGL
  394. PFD_TYPE_RGBA :: 0;
  395. PFD_TYPE_COLORINDEX :: 1;
  396. PFD_MAIN_PLANE :: 0;
  397. PFD_OVERLAY_PLANE :: 1;
  398. PFD_UNDERLAY_PLANE :: -1;
  399. PFD_DOUBLEBUFFER :: 1;
  400. PFD_STEREO :: 2;
  401. PFD_DRAW_TO_WINDOW :: 4;
  402. PFD_DRAW_TO_BITMAP :: 8;
  403. PFD_SUPPORT_GDI :: 16;
  404. PFD_SUPPORT_OPENGL :: 32;
  405. PFD_GENERIC_FORMAT :: 64;
  406. PFD_NEED_PALETTE :: 128;
  407. PFD_NEED_SYSTEM_PALETTE :: 0x00000100;
  408. PFD_SWAP_EXCHANGE :: 0x00000200;
  409. PFD_SWAP_COPY :: 0x00000400;
  410. PFD_SWAP_LAYER_BUFFERS :: 0x00000800;
  411. PFD_GENERIC_ACCELERATED :: 0x00001000;
  412. PFD_DEPTH_DONTCARE :: 0x20000000;
  413. PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000;
  414. PFD_STEREO_DONTCARE :: 0x80000000;
  415. GET_FILEEX_INFO_LEVELS :: distinct i32;
  416. GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0;
  417. GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1;
  418. STARTF_USESHOWWINDOW :: 0x00000001;
  419. STARTF_USESIZE :: 0x00000002;
  420. STARTF_USEPOSITION :: 0x00000004;
  421. STARTF_USECOUNTCHARS :: 0x00000008;
  422. STARTF_USEFILLATTRIBUTE :: 0x00000010;
  423. STARTF_RUNFULLSCREEN :: 0x00000020; // ignored for non-x86 platforms
  424. STARTF_FORCEONFEEDBACK :: 0x00000040;
  425. STARTF_FORCEOFFFEEDBACK :: 0x00000080;
  426. STARTF_USESTDHANDLES :: 0x00000100;
  427. STARTF_USEHOTKEY :: 0x00000200;
  428. STARTF_TITLEISLINKNAME :: 0x00000800;
  429. STARTF_TITLEISAPPID :: 0x00001000;
  430. STARTF_PREVENTPINNING :: 0x00002000;
  431. STARTF_UNTRUSTEDSOURCE :: 0x00008000;
  432. MOVEFILE_REPLACE_EXISTING :: 0x00000001;
  433. MOVEFILE_COPY_ALLOWED :: 0x00000002;
  434. MOVEFILE_DELAY_UNTIL_REBOOT :: 0x00000004;
  435. MOVEFILE_WRITE_THROUGH :: 0x00000008;
  436. MOVEFILE_CREATE_HARDLINK :: 0x00000010;
  437. MOVEFILE_FAIL_IF_NOT_TRACKABLE :: 0x00000020;
  438. FILE_NOTIFY_CHANGE_FILE_NAME :: 0x00000001;
  439. FILE_NOTIFY_CHANGE_DIR_NAME :: 0x00000002;
  440. FILE_NOTIFY_CHANGE_ATTRIBUTES :: 0x00000004;
  441. FILE_NOTIFY_CHANGE_SIZE :: 0x00000008;
  442. FILE_NOTIFY_CHANGE_LAST_WRITE :: 0x00000010;
  443. FILE_NOTIFY_CHANGE_LAST_ACCESS :: 0x00000020;
  444. FILE_NOTIFY_CHANGE_CREATION :: 0x00000040;
  445. FILE_NOTIFY_CHANGE_SECURITY :: 0x00000100;
  446. FILE_FLAG_WRITE_THROUGH :: 0x80000000;
  447. FILE_FLAG_OVERLAPPED :: 0x40000000;
  448. FILE_FLAG_NO_BUFFERING :: 0x20000000;
  449. FILE_FLAG_RANDOM_ACCESS :: 0x10000000;
  450. FILE_FLAG_SEQUENTIAL_SCAN :: 0x08000000;
  451. FILE_FLAG_DELETE_ON_CLOSE :: 0x04000000;
  452. FILE_FLAG_BACKUP_SEMANTICS :: 0x02000000;
  453. FILE_FLAG_POSIX_SEMANTICS :: 0x01000000;
  454. FILE_FLAG_SESSION_AWARE :: 0x00800000;
  455. FILE_FLAG_OPEN_REPARSE_POINT :: 0x00200000;
  456. FILE_FLAG_OPEN_NO_RECALL :: 0x00100000;
  457. FILE_FLAG_FIRST_PIPE_INSTANCE :: 0x00080000;
  458. FILE_ACTION_ADDED :: 0x00000001;
  459. FILE_ACTION_REMOVED :: 0x00000002;
  460. FILE_ACTION_MODIFIED :: 0x00000003;
  461. FILE_ACTION_RENAMED_OLD_NAME :: 0x00000004;
  462. FILE_ACTION_RENAMED_NEW_NAME :: 0x00000005;
  463. CP_ACP :: 0; // default to ANSI code page
  464. CP_OEMCP :: 1; // default to OEM code page
  465. CP_MACCP :: 2; // default to MAC code page
  466. CP_THREAD_ACP :: 3; // current thread's ANSI code page
  467. CP_SYMBOL :: 42; // SYMBOL translations
  468. CP_UTF7 :: 65000; // UTF-7 translation
  469. CP_UTF8 :: 65001; // UTF-8 translation
  470. @(default_calling_convention = "std")
  471. foreign kernel32 {
  472. @(link_name="GetLastError") get_last_error :: proc() -> i32 ---;
  473. @(link_name="CreateProcessA") create_process_a :: proc(application_name, command_line: cstring,
  474. process_attributes, thread_attributes: ^Security_Attributes,
  475. inherit_handle: Bool, creation_flags: u32, environment: rawptr,
  476. current_direcotry: cstring, startup_info: ^Startup_Info,
  477. process_information: ^Process_Information) -> Bool ---;
  478. @(link_name="CreateProcessW") create_process_w :: proc(application_name, command_line: Wstring,
  479. process_attributes, thread_attributes: ^Security_Attributes,
  480. inherit_handle: Bool, creation_flags: u32, environment: rawptr,
  481. current_direcotry: cstring, startup_info: ^Startup_Info,
  482. process_information: ^Process_Information) -> Bool ---;
  483. @(link_name="GetExitCodeProcess") get_exit_code_process :: proc(process: Handle, exit: ^u32) -> Bool ---;
  484. @(link_name="ExitProcess") exit_process :: proc(exit_code: u32) ---;
  485. @(link_name="GetModuleHandleA") get_module_handle_a :: proc(module_name: cstring) -> Hinstance ---;
  486. @(link_name="GetModuleHandleW") get_module_handle_w :: proc(module_name: Wstring) -> Hinstance ---;
  487. @(link_name="Sleep") sleep :: proc(ms: i32) -> i32 ---;
  488. @(link_name="QueryPerformanceFrequency") query_performance_frequency :: proc(result: ^i64) -> i32 ---;
  489. @(link_name="QueryPerformanceCounter") query_performance_counter :: proc(result: ^i64) -> i32 ---;
  490. @(link_name="OutputDebugStringA") output_debug_string_a :: proc(c_str: cstring) ---;
  491. @(link_name="GetCommandLineA") get_command_line_a :: proc() -> cstring ---;
  492. @(link_name="GetCommandLineW") get_command_line_w :: proc() -> Wstring ---;
  493. @(link_name="GetSystemMetrics") get_system_metrics :: proc(index: i32) -> i32 ---;
  494. @(link_name="GetCurrentThreadId") get_current_thread_id :: proc() -> u32 ---;
  495. @(link_name="GetSystemTimeAsFileTime") get_system_time_as_file_time :: proc(system_time_as_file_time: ^Filetime) ---;
  496. @(link_name="FileTimeToLocalFileTime") file_time_to_local_file_time :: proc(file_time: ^Filetime, local_file_time: ^Filetime) -> Bool ---;
  497. @(link_name="FileTimeToSystemTime") file_time_to_system_time :: proc(file_time: ^Filetime, system_time: ^Systemtime) -> Bool ---;
  498. @(link_name="SystemTimeToFileTime") system_time_to_file_time :: proc(system_time: ^Systemtime, file_time: ^Filetime) -> Bool ---;
  499. @(link_name="CloseHandle") close_handle :: proc(h: Handle) -> i32 ---;
  500. @(link_name="GetStdHandle") get_std_handle :: proc(h: i32) -> Handle ---;
  501. @(link_name="CreateFileA")
  502. create_file_a :: proc(filename: cstring, desired_access, share_module: u32,
  503. security: rawptr,
  504. creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---;
  505. @(link_name="CreateFileW")
  506. create_file_w :: proc(filename: Wstring, desired_access, share_module: u32,
  507. security: rawptr,
  508. creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---;
  509. @(link_name="ReadFile") read_file :: proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool ---;
  510. @(link_name="WriteFile") write_file :: proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool ---;
  511. @(link_name="GetFileSizeEx") get_file_size_ex :: proc(file_handle: Handle, file_size: ^i64) -> Bool ---;
  512. @(link_name="GetFileAttributesA") get_file_attributes_a :: proc(filename: cstring) -> u32 ---;
  513. @(link_name="GetFileAttributesW") get_file_attributes_w :: proc(filename: Wstring) -> u32 ---;
  514. @(link_name="GetFileAttributesExA") get_file_attributes_ex_a :: proc(filename: cstring, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> Bool ---;
  515. @(link_name="GetFileInformationByHandle") get_file_information_by_handle :: proc(file_handle: Handle, file_info: ^By_Handle_File_Information) -> Bool ---;
  516. @(link_name="CreateDirectoryA") create_directory_a :: proc(path: cstring, security_attributes: ^Security_Attributes) -> Bool ---;
  517. @(link_name="CreateDirectoryW") create_directory_w :: proc(path: Wstring, security_attributes: ^Security_Attributes) -> Bool ---;
  518. @(link_name="GetFileType") get_file_type :: proc(file_handle: Handle) -> u32 ---;
  519. @(link_name="SetFilePointer") set_file_pointer :: proc(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 ---;
  520. @(link_name="SetHandleInformation") set_handle_information :: proc(obj: Handle, mask, flags: u32) -> Bool ---;
  521. @(link_name="FindFirstFileA") find_first_file_a :: proc(file_name: cstring, data: ^Find_Data_A) -> Handle ---;
  522. @(link_name="FindNextFileA") find_next_file_a :: proc(file: Handle, data: ^Find_Data_A) -> Bool ---;
  523. @(link_name="FindFirstFileW") find_first_file_w :: proc(file_name: Wstring, data: ^Find_Data_W) -> Handle ---;
  524. @(link_name="FindNextFileW") find_next_file_w :: proc(file: Handle, data: ^Find_Data_W) -> Bool ---;
  525. @(link_name="FindClose") find_close :: proc(file: Handle) -> Bool ---;
  526. @(link_name="MoveFileExA") move_file_ex_a :: proc(existing, new: cstring, flags: u32) -> Bool ---;
  527. @(link_name="DeleteFileA") delete_file_a :: proc(file_name: cstring) -> Bool ---;
  528. @(link_name="CopyFileA") copy_file_a :: proc(existing, new: cstring, fail_if_exists: Bool) -> Bool ---;
  529. @(link_name="MoveFileExW") move_file_ex_w :: proc(existing, new: Wstring, flags: u32) -> Bool ---;
  530. @(link_name="DeleteFileW") delete_file_w :: proc(file_name: Wstring) -> Bool ---;
  531. @(link_name="CopyFileW") copy_file_w :: proc(existing, new: Wstring, fail_if_exists: Bool) -> Bool ---;
  532. @(link_name="HeapAlloc") heap_alloc :: proc(h: Handle, flags: u32, bytes: int) -> rawptr ---;
  533. @(link_name="HeapReAlloc") heap_realloc :: proc(h: Handle, flags: u32, memory: rawptr, bytes: int) -> rawptr ---;
  534. @(link_name="HeapFree") heap_free :: proc(h: Handle, flags: u32, memory: rawptr) -> Bool ---;
  535. @(link_name="GetProcessHeap") get_process_heap :: proc() -> Handle ---;
  536. @(link_name="LocalAlloc") local_alloc :: proc(flags: u32, bytes: int) -> rawptr ---;
  537. @(link_name="LocalReAlloc") local_realloc :: proc(mem: rawptr, bytes: int, flags: uint) -> rawptr ---;
  538. @(link_name="LocalFree") local_free :: proc(mem: rawptr) -> rawptr ---;
  539. @(link_name="FindFirstChangeNotificationA") find_first_change_notification_a :: proc(path: cstring, watch_subtree: Bool, filter: u32) -> Handle ---;
  540. @(link_name="FindNextChangeNotification") find_next_change_notification :: proc(h: Handle) -> Bool ---;
  541. @(link_name="FindCloseChangeNotification") find_close_change_notification :: proc(h: Handle) -> Bool ---;
  542. @(link_name="ReadDirectoryChangesW") read_directory_changes_w :: proc(dir: Handle, buf: rawptr, buf_length: u32,
  543. watch_subtree: Bool, notify_filter: u32,
  544. bytes_returned: ^u32, overlapped: ^Overlapped,
  545. completion: rawptr) -> Bool ---;
  546. @(link_name="WideCharToMultiByte") wide_char_to_multi_byte :: proc(code_page: u32, flags: u32,
  547. wchar_str: Wstring, wchar: i32,
  548. multi_str: cstring, multi: i32,
  549. default_char: cstring, used_default_char: ^Bool) -> i32 ---;
  550. @(link_name="MultiByteToWideChar") multi_byte_to_wide_char :: proc(code_page: u32, flags: u32,
  551. mb_str: cstring, mb: i32,
  552. wc_str: Wstring, wc: i32) -> i32 ---;
  553. @(link_name="CreateSemaphoreA") create_semaphore_a :: proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: cstring) -> Handle ---;
  554. @(link_name="ReleaseSemaphore") release_semaphore :: proc(semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool ---;
  555. @(link_name="WaitForSingleObject") wait_for_single_object :: proc(handle: Handle, milliseconds: u32) -> u32 ---;
  556. }
  557. @(default_calling_convention = "c")
  558. foreign kernel32 {
  559. @(link_name="InterlockedCompareExchange") interlocked_compare_exchange :: proc(dst: ^i32, exchange, comparand: i32) -> i32 ---;
  560. @(link_name="InterlockedExchange") interlocked_exchange :: proc(dst: ^i32, desired: i32) -> i32 ---;
  561. @(link_name="InterlockedExchangeAdd") interlocked_exchange_add :: proc(dst: ^i32, desired: i32) -> i32 ---;
  562. @(link_name="InterlockedAnd") interlocked_and :: proc(dst: ^i32, desired: i32) -> i32 ---;
  563. @(link_name="InterlockedOr") interlocked_or :: proc(dst: ^i32, desired: i32) -> i32 ---;
  564. @(link_name="InterlockedCompareExchange64") interlocked_compare_exchange64 :: proc(dst: ^i64, exchange, comparand: i64) -> i64 ---;
  565. @(link_name="InterlockedExchange64") interlocked_exchange64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
  566. @(link_name="InterlockedExchangeAdd64") interlocked_exchange_add64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
  567. @(link_name="InterlockedAnd64") interlocked_and64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
  568. @(link_name="InterlockedOr64") interlocked_or64 :: proc(dst: ^i64, desired: i64) -> i64 ---;
  569. }
  570. @(default_calling_convention = "std")
  571. foreign kernel32 {
  572. @(link_name="_mm_pause") mm_pause :: proc() ---;
  573. @(link_name="ReadWriteBarrier") read_write_barrier :: proc() ---;
  574. @(link_name="WriteBarrier") write_barrier :: proc() ---;
  575. @(link_name="ReadBarrier") read_barrier :: proc() ---;
  576. @(link_name="CreateThread")
  577. create_thread :: proc(thread_attributes: ^Security_Attributes, stack_size: int, start_routine: rawptr,
  578. parameter: rawptr, creation_flags: u32, thread_id: ^u32) -> Handle ---;
  579. @(link_name="ResumeThread") resume_thread :: proc(thread: Handle) -> u32 ---;
  580. @(link_name="GetThreadPriority") get_thread_priority :: proc(thread: Handle) -> i32 ---;
  581. @(link_name="SetThreadPriority") set_thread_priority :: proc(thread: Handle, priority: i32) -> Bool ---;
  582. @(link_name="GetExitCodeThread") get_exit_code_thread :: proc(thread: Handle, exit_code: ^u32) -> Bool ---;
  583. @(link_name="TerminateThread") terminate_thread :: proc(thread: Handle, exit_code: u32) -> Bool ---;
  584. @(link_name="InitializeCriticalSection") initialize_critical_section :: proc(critical_section: ^Critical_Section) ---;
  585. @(link_name="InitializeCriticalSectionAndSpinCount") initialize_critical_section_and_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) ---;
  586. @(link_name="DeleteCriticalSection") delete_critical_section :: proc(critical_section: ^Critical_Section) ---;
  587. @(link_name="SetCriticalSectionSpinCount") set_critical_section_spin_count :: proc(critical_section: ^Critical_Section, spin_count: u32) -> u32 ---;
  588. @(link_name="TryEnterCriticalSection") try_enter_critical_section :: proc(critical_section: ^Critical_Section) -> Bool ---;
  589. @(link_name="EnterCriticalSection") enter_critical_section :: proc(critical_section: ^Critical_Section) ---;
  590. @(link_name="LeaveCriticalSection") leave_critical_section :: proc(critical_section: ^Critical_Section) ---;
  591. @(link_name="CreateEventA") create_event_a :: proc(event_attributes: ^Security_Attributes, manual_reset, initial_state: Bool, name: cstring) -> Handle ---;
  592. @(link_name="PulseEvent") pulse_event :: proc(event: Handle) -> Bool ---;
  593. @(link_name="SetEvent") set_event :: proc(event: Handle) -> Bool ---;
  594. @(link_name="ResetEvent") reset_event :: proc(event: Handle) -> Bool ---;
  595. @(link_name="LoadLibraryA") load_library_a :: proc(c_str: cstring) -> Hmodule ---;
  596. @(link_name="LoadLibraryW") load_library_w :: proc(c_str: Wstring) -> Hmodule ---;
  597. @(link_name="FreeLibrary") free_library :: proc(h: Hmodule) ---;
  598. @(link_name="GetProcAddress") get_proc_address :: proc(h: Hmodule, c_str: cstring) -> rawptr ---;
  599. }
  600. @(default_calling_convention = "std")
  601. foreign user32 {
  602. @(link_name="GetDesktopWindow") get_desktop_window :: proc() -> Hwnd ---;
  603. @(link_name="ShowCursor") show_cursor :: proc(show: Bool) ---;
  604. @(link_name="GetCursorPos") get_cursor_pos :: proc(p: ^Point) -> Bool ---;
  605. @(link_name="SetCursorPos") set_cursor_pos :: proc(x, y: i32) -> Bool ---;
  606. @(link_name="ScreenToClient") screen_to_client :: proc(h: Hwnd, p: ^Point) -> Bool ---;
  607. @(link_name="ClientToScreen") client_to_screen :: proc(h: Hwnd, p: ^Point) -> Bool ---;
  608. @(link_name="PostQuitMessage") post_quit_message :: proc(exit_code: i32) ---;
  609. @(link_name="SetWindowTextA") set_window_text_a :: proc(hwnd: Hwnd, c_string: cstring) -> Bool ---;
  610. @(link_name="RegisterClassExA") register_class_ex_a :: proc(wc: ^Wnd_Class_Ex_A) -> i16 ---;
  611. @(link_name="RegisterClassExW") register_class_ex_w :: proc(wc: ^Wnd_Class_Ex_W) -> i16 ---;
  612. @(link_name="CreateWindowExA")
  613. create_window_ex_a :: proc(ex_style: u32,
  614. class_name, title: cstring,
  615. style: u32,
  616. x, y, w, h: i32,
  617. parent: Hwnd, menu: Hmenu, instance: Hinstance,
  618. param: rawptr) -> Hwnd ---;
  619. @(link_name="CreateWindowExW")
  620. create_window_ex_w :: proc(ex_style: u32,
  621. class_name, title: Wstring,
  622. style: u32,
  623. x, y, w, h: i32,
  624. parent: Hwnd, menu: Hmenu, instance: Hinstance,
  625. param: rawptr) -> Hwnd ---;
  626. @(link_name="ShowWindow") show_window :: proc(hwnd: Hwnd, cmd_show: i32) -> Bool ---;
  627. @(link_name="TranslateMessage") translate_message :: proc(msg: ^Msg) -> Bool ---;
  628. @(link_name="DispatchMessageA") dispatch_message_a :: proc(msg: ^Msg) -> Lresult ---;
  629. @(link_name="DispatchMessageW") dispatch_message_w :: proc(msg: ^Msg) -> Lresult ---;
  630. @(link_name="UpdateWindow") update_window :: proc(hwnd: Hwnd) -> Bool ---;
  631. @(link_name="GetMessageA") get_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---;
  632. @(link_name="GetMessageW") get_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max: u32) -> Bool ---;
  633. @(link_name="PeekMessageA") peek_message_a :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---;
  634. @(link_name="PeekMessageW") peek_message_w :: proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool ---;
  635. @(link_name="PostMessageA") post_message :: proc(hwnd: Hwnd, msg, wparam, lparam: u32) -> Bool ---;
  636. @(link_name="DefWindowProcA") def_window_proc_a :: proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult ---;
  637. @(link_name="AdjustWindowRect") adjust_window_rect :: proc(rect: ^Rect, style: u32, menu: Bool) -> Bool ---;
  638. @(link_name="GetActiveWindow") get_active_window :: proc() -> Hwnd ---;
  639. @(link_name="DestroyWindow") destroy_window :: proc(wnd: Hwnd) -> Bool ---;
  640. @(link_name="DescribePixelFormat") describe_pixel_format :: proc(dc: Hdc, pixel_format: i32, bytes: u32, pfd: ^Pixel_Format_Descriptor) -> i32 ---;
  641. @(link_name="GetMonitor_InfoA") get_monitor_info_a :: proc(monitor: Hmonitor, mi: ^Monitor_Info) -> Bool ---;
  642. @(link_name="MonitorFromWindow") monitor_from_window :: proc(wnd: Hwnd, flags: u32) -> Hmonitor ---;
  643. @(link_name="SetWindowPos") set_window_pos :: proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) ---;
  644. @(link_name="GetWindowPlacement") get_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---;
  645. @(link_name="SetWindowPlacement") set_window_placement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool ---;
  646. @(link_name="GetWindowRect") get_window_rect :: proc(wnd: Hwnd, rect: ^Rect) -> Bool ---;
  647. @(link_name="GetWindowLongPtrA") get_window_long_ptr_a :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---;
  648. @(link_name="SetWindowLongPtrA") set_window_long_ptr_a :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---;
  649. @(link_name="GetWindowLongPtrW") get_window_long_ptr_w :: proc(wnd: Hwnd, index: i32) -> Long_Ptr ---;
  650. @(link_name="SetWindowLongPtrW") set_window_long_ptr_w :: proc(wnd: Hwnd, index: i32, new: Long_Ptr) -> Long_Ptr ---;
  651. @(link_name="GetWindowText") get_window_text :: proc(wnd: Hwnd, str: cstring, maxCount: i32) -> i32 ---;
  652. @(link_name="GetClientRect") get_client_rect :: proc(hwnd: Hwnd, rect: ^Rect) -> Bool ---;
  653. @(link_name="GetDC") get_dc :: proc(h: Hwnd) -> Hdc ---;
  654. @(link_name="ReleaseDC") release_dc :: proc(wnd: Hwnd, hdc: Hdc) -> i32 ---;
  655. @(link_name="MapVirtualKeyA") map_virtual_key_a :: proc(scancode: u32, map_type: u32) -> u32 ---;
  656. @(link_name="MapVirtualKeyW") map_virtual_key_w :: proc(scancode: u32, map_type: u32) -> u32 ---;
  657. @(link_name="GetKeyState") get_key_state :: proc(v_key: i32) -> i16 ---;
  658. @(link_name="GetAsyncKeyState") get_async_key_state :: proc(v_key: i32) -> i16 ---;
  659. @(link_name="SetForegroundWindow") set_foreground_window :: proc(h: Hwnd) -> Bool ---;
  660. @(link_name="SetFocus") set_focus :: proc(h: Hwnd) -> Hwnd ---;
  661. @(link_name="LoadImageA") load_image_a :: proc(instance: Hinstance, name: cstring, type_: u32, x_desired, y_desired : i32, load : u32) -> Handle ---;
  662. @(link_name="LoadIconA") load_icon_a :: proc(instance: Hinstance, icon_name: cstring) -> Hicon ---;
  663. @(link_name="DestroyIcon") destroy_icon :: proc(icon: Hicon) -> Bool ---;
  664. @(link_name="LoadCursorA") load_cursor_a :: proc(instance: Hinstance, cursor_name: cstring) -> Hcursor ---;
  665. @(link_name="GetCursor") get_cursor :: proc() -> Hcursor ---;
  666. @(link_name="SetCursor") set_cursor :: proc(cursor: Hcursor) -> Hcursor ---;
  667. @(link_name="RegisterRawInputDevices") register_raw_input_devices :: proc(raw_input_device: ^Raw_Input_Device, num_devices, size: u32) -> Bool ---;
  668. @(link_name="GetRawInputData") get_raw_input_data :: proc(raw_input: Hrawinput, command: u32, data: rawptr, size: ^u32, size_header: u32) -> u32 ---;
  669. @(link_name="MapVirtualKeyExW") map_virtual_key_ex_w :: proc(code, map_type: u32, hkl: HKL) ---;
  670. @(link_name="MapVirtualKeyExA") map_virtual_key_ex_a :: proc(code, map_type: u32, hkl: HKL) ---;
  671. }
  672. @(default_calling_convention = "std")
  673. foreign gdi32 {
  674. @(link_name="GetStockObject") get_stock_object :: proc(fn_object: i32) -> Hgdiobj ---;
  675. @(link_name="StretchDIBits")
  676. stretch_dibits :: proc(hdc: Hdc,
  677. x_dst, y_dst, width_dst, height_dst: i32,
  678. x_src, y_src, width_src, header_src: i32,
  679. bits: rawptr, bits_info: ^Bitmap_Info,
  680. usage: u32,
  681. rop: u32) -> i32 ---;
  682. @(link_name="SetPixelFormat") set_pixel_format :: proc(hdc: Hdc, pixel_format: i32, pfd: ^Pixel_Format_Descriptor) -> Bool ---;
  683. @(link_name="ChoosePixelFormat") choose_pixel_format :: proc(hdc: Hdc, pfd: ^Pixel_Format_Descriptor) -> i32 ---;
  684. @(link_name="SwapBuffers") swap_buffers :: proc(hdc: Hdc) -> Bool ---;
  685. }
  686. @(default_calling_convention = "std")
  687. foreign shell32 {
  688. @(link_name="CommandLineToArgvW") command_line_to_argv_w :: proc(cmd_list: Wstring, num_args: ^i32) -> ^Wstring ---;
  689. }
  690. @(default_calling_convention = "std")
  691. foreign winmm {
  692. @(link_name="timeGetTime") time_get_time :: proc() -> u32 ---;
  693. }
  694. get_query_performance_frequency :: proc() -> i64 {
  695. r: i64;
  696. query_performance_frequency(&r);
  697. return r;
  698. }
  699. HIWORD_W :: proc(wParam: Wparam) -> u16 { return u16((u32(wParam) >> 16) & 0xffff); }
  700. HIWORD_L :: proc(lParam: Lparam) -> u16 { return u16((u32(lParam) >> 16) & 0xffff); }
  701. LOWORD_W :: proc(wParam: Wparam) -> u16 { return u16(wParam); }
  702. LOWORD_L :: proc(lParam: Lparam) -> u16 { return u16(lParam); }
  703. is_key_down :: inline proc(key: Key_Code) -> bool { return get_async_key_state(i32(key)) < 0; }
  704. MAX_PATH :: 0x00000104;
  705. HANDLE_FLAG_INHERIT :: 1;
  706. HANDLE_FLAG_PROTECT_FROM_CLOSE :: 2;
  707. FILE_BEGIN :: 0;
  708. FILE_CURRENT :: 1;
  709. FILE_END :: 2;
  710. FILE_SHARE_READ :: 0x00000001;
  711. FILE_SHARE_WRITE :: 0x00000002;
  712. FILE_SHARE_DELETE :: 0x00000004;
  713. FILE_GENERIC_ALL :: 0x10000000;
  714. FILE_GENERIC_EXECUTE :: 0x20000000;
  715. FILE_GENERIC_WRITE :: 0x40000000;
  716. FILE_GENERIC_READ :: 0x80000000;
  717. FILE_APPEND_DATA :: 0x0004;
  718. STD_INPUT_HANDLE :: -10;
  719. STD_OUTPUT_HANDLE :: -11;
  720. STD_ERROR_HANDLE :: -12;
  721. CREATE_NEW :: 1;
  722. CREATE_ALWAYS :: 2;
  723. OPEN_EXISTING :: 3;
  724. OPEN_ALWAYS :: 4;
  725. TRUNCATE_EXISTING :: 5;
  726. INVALID_FILE_ATTRIBUTES :: -1;
  727. FILE_ATTRIBUTE_READONLY :: 0x00000001;
  728. FILE_ATTRIBUTE_HIDDEN :: 0x00000002;
  729. FILE_ATTRIBUTE_SYSTEM :: 0x00000004;
  730. FILE_ATTRIBUTE_DIRECTORY :: 0x00000010;
  731. FILE_ATTRIBUTE_ARCHIVE :: 0x00000020;
  732. FILE_ATTRIBUTE_DEVICE :: 0x00000040;
  733. FILE_ATTRIBUTE_NORMAL :: 0x00000080;
  734. FILE_ATTRIBUTE_TEMPORARY :: 0x00000100;
  735. FILE_ATTRIBUTE_SPARSE_FILE :: 0x00000200;
  736. FILE_ATTRIBUTE_REPARSE_Point :: 0x00000400;
  737. FILE_ATTRIBUTE_COMPRESSED :: 0x00000800;
  738. FILE_ATTRIBUTE_OFFLINE :: 0x00001000;
  739. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED :: 0x00002000;
  740. FILE_ATTRIBUTE_ENCRYPTED :: 0x00004000;
  741. FILE_TYPE_DISK :: 0x0001;
  742. FILE_TYPE_CHAR :: 0x0002;
  743. FILE_TYPE_PIPE :: 0x0003;
  744. Monitor_Info :: struct {
  745. size: u32,
  746. monitor: Rect,
  747. work: Rect,
  748. flags: u32,
  749. }
  750. Window_Placement :: struct {
  751. length: u32,
  752. flags: u32,
  753. show_cmd: u32,
  754. min_pos: Point,
  755. max_pos: Point,
  756. normal_pos: Rect,
  757. }
  758. Bitmap_Info_Header :: struct {
  759. size: u32,
  760. width, height: i32,
  761. planes, bit_count: i16,
  762. compression: u32,
  763. size_image: u32,
  764. x_pels_per_meter: i32,
  765. y_pels_per_meter: i32,
  766. clr_used: u32,
  767. clr_important: u32,
  768. }
  769. Bitmap_Info :: struct {
  770. using header: Bitmap_Info_Header,
  771. colors: [1]Rgb_Quad,
  772. }
  773. Rgb_Quad :: struct {blue, green, red, reserved: byte}
  774. Key_Code :: enum i32 {
  775. Unknown = 0x00,
  776. Lbutton = 0x01,
  777. Rbutton = 0x02,
  778. Cancel = 0x03,
  779. Mbutton = 0x04,
  780. Xbutton1 = 0x05,
  781. Xbutton2 = 0x06,
  782. Back = 0x08,
  783. Tab = 0x09,
  784. Clear = 0x0C,
  785. Return = 0x0D,
  786. Shift = 0x10,
  787. Control = 0x11,
  788. Menu = 0x12,
  789. Pause = 0x13,
  790. Capital = 0x14,
  791. Kana = 0x15,
  792. Hangeul = 0x15,
  793. Hangul = 0x15,
  794. Junja = 0x17,
  795. Final = 0x18,
  796. Hanja = 0x19,
  797. Kanji = 0x19,
  798. Escape = 0x1B,
  799. Convert = 0x1C,
  800. NonConvert = 0x1D,
  801. Accept = 0x1E,
  802. ModeChange = 0x1F,
  803. Space = 0x20,
  804. Prior = 0x21,
  805. Next = 0x22,
  806. End = 0x23,
  807. Home = 0x24,
  808. Left = 0x25,
  809. Up = 0x26,
  810. Right = 0x27,
  811. Down = 0x28,
  812. Select = 0x29,
  813. Print = 0x2A,
  814. Execute = 0x2B,
  815. Snapshot = 0x2C,
  816. Insert = 0x2D,
  817. Delete = 0x2E,
  818. Help = 0x2F,
  819. Num0 = '0',
  820. Num1 = '1',
  821. Num2 = '2',
  822. Num3 = '3',
  823. Num4 = '4',
  824. Num5 = '5',
  825. Num6 = '6',
  826. Num7 = '7',
  827. Num8 = '8',
  828. Num9 = '9',
  829. A = 'A',
  830. B = 'B',
  831. C = 'C',
  832. D = 'D',
  833. E = 'E',
  834. F = 'F',
  835. G = 'G',
  836. H = 'H',
  837. I = 'I',
  838. J = 'J',
  839. K = 'K',
  840. L = 'L',
  841. M = 'M',
  842. N = 'N',
  843. O = 'O',
  844. P = 'P',
  845. Q = 'Q',
  846. R = 'R',
  847. S = 'S',
  848. T = 'T',
  849. U = 'U',
  850. V = 'V',
  851. W = 'W',
  852. X = 'X',
  853. Y = 'Y',
  854. Z = 'Z',
  855. Lwin = 0x5B,
  856. Rwin = 0x5C,
  857. Apps = 0x5D,
  858. Numpad0 = 0x60,
  859. Numpad1 = 0x61,
  860. Numpad2 = 0x62,
  861. Numpad3 = 0x63,
  862. Numpad4 = 0x64,
  863. Numpad5 = 0x65,
  864. Numpad6 = 0x66,
  865. Numpad7 = 0x67,
  866. Numpad8 = 0x68,
  867. Numpad9 = 0x69,
  868. Multiply = 0x6A,
  869. Add = 0x6B,
  870. Separator = 0x6C,
  871. Subtract = 0x6D,
  872. Decimal = 0x6E,
  873. Divide = 0x6F,
  874. F1 = 0x70,
  875. F2 = 0x71,
  876. F3 = 0x72,
  877. F4 = 0x73,
  878. F5 = 0x74,
  879. F6 = 0x75,
  880. F7 = 0x76,
  881. F8 = 0x77,
  882. F9 = 0x78,
  883. F10 = 0x79,
  884. F11 = 0x7A,
  885. F12 = 0x7B,
  886. F13 = 0x7C,
  887. F14 = 0x7D,
  888. F15 = 0x7E,
  889. F16 = 0x7F,
  890. F17 = 0x80,
  891. F18 = 0x81,
  892. F19 = 0x82,
  893. F20 = 0x83,
  894. F21 = 0x84,
  895. F22 = 0x85,
  896. F23 = 0x86,
  897. F24 = 0x87,
  898. Numlock = 0x90,
  899. Scroll = 0x91,
  900. Lshift = 0xA0,
  901. Rshift = 0xA1,
  902. Lcontrol = 0xA2,
  903. Rcontrol = 0xA3,
  904. Lmenu = 0xA4,
  905. Rmenu = 0xA5,
  906. ProcessKey = 0xE5,
  907. Attn = 0xF6,
  908. Crsel = 0xF7,
  909. Exsel = 0xF8,
  910. Ereof = 0xF9,
  911. Play = 0xFA,
  912. Zoom = 0xFB,
  913. Noname = 0xFC,
  914. Pa1 = 0xFD,
  915. OemClear = 0xFE,
  916. }