Parcourir la source

Merge branch 'master' of https://github.com/odin-lang/Odin

gingerBill il y a 3 ans
Parent
commit
636f0d7063
3 fichiers modifiés avec 52 ajouts et 14 suppressions
  1. 22 14
      core/sys/windows/kernel32.odin
  2. 28 0
      core/sys/windows/types.odin
  3. 2 0
      core/sys/windows/winerror.odin

+ 22 - 14
core/sys/windows/kernel32.odin

@@ -24,6 +24,8 @@ foreign kernel32 {
 	                       lpMode: LPDWORD) -> BOOL ---
 	SetConsoleMode :: proc(hConsoleHandle: HANDLE,
 	                       dwMode: DWORD) -> BOOL ---
+	SetConsoleCursorPosition :: proc(hConsoleHandle: HANDLE,
+						   dwCursorPosition: COORD) -> BOOL ---
 
 	GetFileInformationByHandle :: proc(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION) -> BOOL ---
 	SetHandleInformation :: proc(hObject: HANDLE,
@@ -94,6 +96,15 @@ foreign kernel32 {
 		dwCreationFlags: DWORD,
 		lpThreadId: LPDWORD,
 	) -> HANDLE ---
+	CreateRemoteThread :: proc(
+		hProcess: HANDLE,
+		lpThreadAttributes: LPSECURITY_ATTRIBUTES,
+		dwStackSize: SIZE_T,
+		lpStartAddress: proc "stdcall" (rawptr) -> DWORD,
+		lpParameter: LPVOID,
+		dwCreationFlags: DWORD,
+		lpThreadId: LPDWORD,
+	) -> HANDLE ---
 	SwitchToThread :: proc() -> BOOL ---
 	ResumeThread :: proc(thread: HANDLE) -> DWORD ---
 	GetThreadPriority :: proc(thread: HANDLE) -> c_int ---
@@ -326,6 +337,15 @@ foreign kernel32 {
 	SetEndOfFile :: proc(hFile: HANDLE) -> BOOL ---
 
 	CreatePipe :: proc(hReadPipe, hWritePipe: ^HANDLE, lpPipeAttributes: LPSECURITY_ATTRIBUTES, nSize: DWORD) -> BOOL ---
+
+	ConnectNamedPipe :: proc(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED,) -> BOOL ---
+	DisconnectNamedPipe :: proc(hNamedPipe: HANDLE,) -> BOOL ---
+	WaitNamedPipeW :: proc(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD,) -> BOOL ---
+
+	SetConsoleCtrlHandler :: proc(HandlerRoutine: PHANDLER_ROUTINE, Add: BOOL) -> BOOL ---
+	GenerateConsoleCtrlEvent :: proc(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL ---
+	FreeConsole :: proc() -> BOOL ---
+	GetConsoleWindow :: proc() -> HWND ---
 }
 
 
@@ -780,17 +800,5 @@ foreign kernel32 {
 	) -> BOOL ---
 }
 
-@(default_calling_convention="stdcall")
-foreign kernel32 {
-	@(link_name="SetConsoleCtrlHandler") set_console_ctrl_handler :: proc(handler: Handler_Routine, add: BOOL) -> BOOL ---
-}
-
-Handler_Routine :: proc(dwCtrlType: Control_Event) -> BOOL
-
-Control_Event :: enum DWORD {
-	control_c = 0,
-	_break    = 1,
-	close     = 2,
-	logoff    = 5,
-	shutdown  = 6,
-}
+HandlerRoutine :: proc "stdcall" (dwCtrlType: DWORD) -> BOOL
+PHANDLER_ROUTINE :: HandlerRoutine

+ 28 - 0
core/sys/windows/types.odin

@@ -1628,6 +1628,8 @@ CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{}
 SRWLOCK_INIT :: SRWLOCK{}
 
 DETACHED_PROCESS: DWORD : 0x00000008
+CREATE_NEW_CONSOLE: DWORD : 0x00000010
+CREATE_NO_WINDOW: DWORD : 0x08000000
 CREATE_NEW_PROCESS_GROUP: DWORD : 0x00000200
 CREATE_UNICODE_ENVIRONMENT: DWORD : 0x00000400
 STARTF_USESTDHANDLES: DWORD : 0x00000100
@@ -1689,6 +1691,7 @@ PIPE_WAIT: DWORD : 0x00000000
 PIPE_TYPE_BYTE: DWORD : 0x00000000
 PIPE_REJECT_REMOTE_CLIENTS: DWORD : 0x00000008
 PIPE_READMODE_BYTE: DWORD : 0x00000000
+PIPE_ACCEPT_REMOTE_CLIENTS: DWORD : 0x00000000
 
 FD_SETSIZE :: 64
 
@@ -3265,3 +3268,28 @@ IFileSaveDialogVtbl :: struct {
 	GetProperties:          proc "stdcall" (this: ^IFileSaveDialog, ppStore: ^^IPropertyStore) -> HRESULT,
 	ApplyProperties:        proc "stdcall" (this: ^IFileSaveDialog, psi: ^IShellItem, pStore: ^IPropertyStore, hwnd: HWND, pSink: ^IFileOperationProgressSink) -> HRESULT,
 }
+
+ENABLE_ECHO_INPUT : DWORD : 0x0004
+ENABLE_INSERT_MODE : DWORD : 0x0020
+ENABLE_LINE_INPUT : DWORD : 0x0002
+ENABLE_MOUSE_INPUT : DWORD : 0x0010
+ENABLE_PROCESSED_INPUT : DWORD : 0x0001
+ENABLE_QUICK_EDIT_MODE : DWORD : 0x0040
+ENABLE_WINDOW_INPUT : DWORD : 0x0008
+ENABLE_VIRTUAL_TERMINAL_INPUT : DWORD : 0x0200
+ENABLE_PROCESSED_OUTPUT : DWORD : 0x0001
+ENABLE_WRAP_AT_EOL_OUTPUT : DWORD : 0x0002
+ENABLE_VIRTUAL_TERMINAL_PROCESSING : DWORD : 0x0004
+DISABLE_NEWLINE_AUTO_RETURN : DWORD : 0x0008
+ENABLE_LVB_GRID_WORLDWIDE : DWORD : 0x0010
+
+CTRL_C_EVENT : DWORD : 0
+CTRL_BREAK_EVENT : DWORD : 1
+CTRL_CLOSE_EVENT : DWORD : 2
+CTRL_LOGOFF_EVENT : DWORD : 5
+CTRL_SHUTDOWN_EVENT : DWORD : 6
+
+COORD :: struct {
+	X: SHORT,
+	Y: SHORT,
+}

+ 2 - 0
core/sys/windows/winerror.odin

@@ -42,6 +42,8 @@ ERROR_TIMEOUT                : DWORD : 1460
 ERROR_DATATYPE_MISMATCH      : DWORD : 1629
 ERROR_UNSUPPORTED_TYPE       : DWORD : 1630
 ERROR_NOT_SAME_OBJECT        : DWORD : 1656
+ERROR_PIPE_CONNECTED         : DWORD : 0x80070217
+ERROR_PIPE_BUSY              : DWORD : 231
 
 E_NOTIMPL :: HRESULT(-0x7fff_bfff) // 0x8000_4001