@@ -582,12 +582,16 @@ pub mod types {
582
582
583
583
pub type LPWSTR = * mut WCHAR ;
584
584
pub type LPSTR = * mut CHAR ;
585
+ pub type LPTSTR = * mut CHAR ;
585
586
586
587
// Not really, but opaque to us.
587
588
pub type LPSECURITY_ATTRIBUTES = LPVOID ;
588
589
589
590
pub type LPVOID = * mut c_void ;
591
+ pub type LPBYTE = * mut BYTE ;
590
592
pub type LPWORD = * mut WORD ;
593
+ pub type LPDWORD = * mut DWORD ;
594
+ pub type LPHANDLE = * mut HANDLE ;
591
595
592
596
pub type LRESULT = LONG_PTR ;
593
597
pub type PBOOL = * mut BOOL ;
@@ -596,6 +600,36 @@ pub mod types {
596
600
597
601
pub type time64_t = i64 ;
598
602
pub type int64 = i64 ;
603
+
604
+ pub struct STARTUPINFO {
605
+ cb : DWORD ,
606
+ lpReserved : LPTSTR ,
607
+ lpDesktop : LPTSTR ,
608
+ lpTitle : LPTSTR ,
609
+ dwX : DWORD ,
610
+ dwY : DWORD ,
611
+ dwXSize : DWORD ,
612
+ dwYSize : DWORD ,
613
+ dwXCountChars : DWORD ,
614
+ dwYCountCharts : DWORD ,
615
+ dwFillAttribute : DWORD ,
616
+ dwFlags : DWORD ,
617
+ wShowWindow : WORD ,
618
+ cbReserved2 : WORD ,
619
+ lpReserved2 : LPBYTE ,
620
+ hStdInput : HANDLE ,
621
+ hStdOutput : HANDLE ,
622
+ hStdError : HANDLE
623
+ }
624
+ pub type LPSTARTUPINFO = * mut STARTUPINFO ;
625
+
626
+ pub struct PROCESS_INFORMATION {
627
+ hProcess : HANDLE ,
628
+ hThread : HANDLE ,
629
+ dwProcessId : DWORD ,
630
+ dwThreadId : DWORD
631
+ }
632
+ pub type LPPROCESS_INFORMATION = * mut PROCESS_INFORMATION ;
599
633
}
600
634
}
601
635
}
@@ -848,13 +882,62 @@ pub mod consts {
848
882
pub mod bsd44 {
849
883
}
850
884
pub mod extra {
885
+ use libc:: types:: os:: arch:: extra:: { DWORD , BOOL } ;
886
+
887
+ pub static TRUE : BOOL = 1 ;
888
+ pub static FALSE : BOOL = 0 ;
889
+
851
890
pub static O_TEXT : int = 16384 ;
852
891
pub static O_BINARY : int = 32768 ;
853
892
pub static O_NOINHERIT : int = 128 ;
854
893
855
894
pub static ERROR_SUCCESS : int = 0 ;
856
895
pub static ERROR_INSUFFICIENT_BUFFER : int = 122 ;
857
896
pub static INVALID_HANDLE_VALUE : int = -1 ;
897
+
898
+ pub static DELETE : DWORD = 0x00010000 ;
899
+ pub static READ_CONTROL : DWORD = 0x00020000 ;
900
+ pub static SYNCHRONIZE : DWORD = 0x00100000 ;
901
+ pub static WRITE_DAC : DWORD = 0x00040000 ;
902
+ pub static WRITE_OWNER : DWORD = 0x00080000 ;
903
+
904
+ pub static PROCESS_CREATE_PROCESS : DWORD = 0x0080 ;
905
+ pub static PROCESS_CREATE_THREAD : DWORD = 0x0002 ;
906
+ pub static PROCESS_DUP_HANDLE : DWORD = 0x0040 ;
907
+ pub static PROCESS_QUERY_INFORMATION : DWORD = 0x0400 ;
908
+ pub static PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000 ;
909
+ pub static PROCESS_SET_INFORMATION : DWORD = 0x0200 ;
910
+ pub static PROCESS_SET_QUOTA : DWORD = 0x0100 ;
911
+ pub static PROCESS_SUSPEND_RESUME : DWORD = 0x0800 ;
912
+ pub static PROCESS_TERMINATE : DWORD = 0x0001 ;
913
+ pub static PROCESS_VM_OPERATION : DWORD = 0x0008 ;
914
+ pub static PROCESS_VM_READ : DWORD = 0x0010 ;
915
+ pub static PROCESS_VM_WRITE : DWORD = 0x0020 ;
916
+
917
+ pub static STARTF_FORCEONFEEDBACK : DWORD = 0x00000040 ;
918
+ pub static STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080 ;
919
+ pub static STARTF_PREVENTPINNING : DWORD = 0x00002000 ;
920
+ pub static STARTF_RUNFULLSCREEN : DWORD = 0x00000020 ;
921
+ pub static STARTF_TITLEISAPPID : DWORD = 0x00001000 ;
922
+ pub static STARTF_TITLEISLINKNAME : DWORD = 0x00000800 ;
923
+ pub static STARTF_USECOUNTCHARS : DWORD = 0x00000008 ;
924
+ pub static STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010 ;
925
+ pub static STARTF_USEHOTKEY : DWORD = 0x00000200 ;
926
+ pub static STARTF_USEPOSITION : DWORD = 0x00000004 ;
927
+ pub static STARTF_USESHOWWINDOW : DWORD = 0x00000001 ;
928
+ pub static STARTF_USESIZE : DWORD = 0x00000002 ;
929
+ pub static STARTF_USESTDHANDLES : DWORD = 0x00000100 ;
930
+
931
+ pub static WAIT_ABANDONED : DWORD = 0x00000080 ;
932
+ pub static WAIT_OBJECT_0 : DWORD = 0x00000000 ;
933
+ pub static WAIT_TIMEOUT : DWORD = 0x00000102 ;
934
+ pub static WAIT_FAILED : DWORD = -1 ;
935
+
936
+ pub static DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001 ;
937
+ pub static DUPLICATE_SAME_ACCESS : DWORD = 0x00000002 ;
938
+
939
+ pub static INFINITE : DWORD = -1 ;
940
+ pub static STILL_ACTIVE : DWORD = 259 ;
858
941
}
859
942
}
860
943
@@ -1751,12 +1834,24 @@ pub mod funcs {
1751
1834
1752
1835
unsafe fn sysctlnametomib ( name : * c_char , mibp : * mut c_int ,
1753
1836
sizep : * mut size_t ) -> c_int ;
1837
+
1838
+ unsafe fn getdtablesize ( ) -> c_int ;
1754
1839
}
1755
1840
}
1756
1841
1757
1842
1758
1843
#[ cfg( target_os = "linux" ) ]
1759
1844
#[ cfg( target_os = "android" ) ]
1845
+ pub mod bsd44 {
1846
+ use libc:: types:: os:: arch:: c95:: { c_int} ;
1847
+
1848
+ #[ abi = "cdecl" ]
1849
+ pub extern {
1850
+ unsafe fn getdtablesize ( ) -> c_int ;
1851
+ }
1852
+ }
1853
+
1854
+
1760
1855
#[ cfg( target_os = "win32" ) ]
1761
1856
pub mod bsd44 {
1762
1857
}
@@ -1790,9 +1885,11 @@ pub mod funcs {
1790
1885
pub mod kernel32 {
1791
1886
use libc:: types:: os:: arch:: c95:: { c_uint} ;
1792
1887
use libc:: types:: os:: arch:: extra:: { BOOL , DWORD , HMODULE } ;
1793
- use libc:: types:: os:: arch:: extra:: { LPCWSTR , LPWSTR , LPTCH } ;
1794
- use libc:: types:: os:: arch:: extra:: { LPSECURITY_ATTRIBUTES } ;
1795
- use libc:: types:: os:: arch:: extra:: { HANDLE } ;
1888
+ use libc:: types:: os:: arch:: extra:: { LPCWSTR , LPWSTR , LPCTSTR ,
1889
+ LPTSTR , LPTCH , LPDWORD , LPVOID } ;
1890
+ use libc:: types:: os:: arch:: extra:: { LPSECURITY_ATTRIBUTES , LPSTARTUPINFO ,
1891
+ LPPROCESS_INFORMATION } ;
1892
+ use libc:: types:: os:: arch:: extra:: { HANDLE , LPHANDLE } ;
1796
1893
1797
1894
#[ abi = "stdcall" ]
1798
1895
pub extern "stdcall" {
@@ -1829,19 +1926,45 @@ pub mod funcs {
1829
1926
findFileData : HANDLE )
1830
1927
-> BOOL ;
1831
1928
unsafe fn FindClose ( findFile : HANDLE ) -> BOOL ;
1929
+ unsafe fn DuplicateHandle ( hSourceProcessHandle : HANDLE ,
1930
+ hSourceHandle : HANDLE ,
1931
+ hTargetProcessHandle : HANDLE ,
1932
+ lpTargetHandle : LPHANDLE ,
1933
+ dwDesiredAccess : DWORD ,
1934
+ bInheritHandle : BOOL ,
1935
+ dwOptions : DWORD ) -> BOOL ;
1832
1936
unsafe fn CloseHandle ( hObject : HANDLE ) -> BOOL ;
1937
+ unsafe fn OpenProcess ( dwDesiredAccess : DWORD ,
1938
+ bInheritHandle : BOOL ,
1939
+ dwProcessId : DWORD ) -> HANDLE ;
1940
+ unsafe fn GetCurrentProcess ( ) -> HANDLE ;
1941
+ unsafe fn CreateProcessA ( lpApplicationName : LPCTSTR ,
1942
+ lpCommandLine : LPTSTR ,
1943
+ lpProcessAttributes : LPSECURITY_ATTRIBUTES ,
1944
+ lpThreadAttributes : LPSECURITY_ATTRIBUTES ,
1945
+ bInheritHandles : BOOL ,
1946
+ dwCreationFlags : DWORD ,
1947
+ lpEnvironment : LPVOID ,
1948
+ lpCurrentDirectory : LPCTSTR ,
1949
+ lpStartupInfo : LPSTARTUPINFO ,
1950
+ lpProcessInformation : LPPROCESS_INFORMATION ) -> BOOL ;
1951
+ unsafe fn WaitForSingleObject ( hHandle : HANDLE , dwMilliseconds : DWORD ) -> DWORD ;
1833
1952
unsafe fn TerminateProcess ( hProcess : HANDLE , uExitCode : c_uint ) -> BOOL ;
1953
+ unsafe fn GetExitCodeProcess ( hProcess : HANDLE , lpExitCode : LPDWORD ) -> BOOL ;
1834
1954
}
1835
1955
}
1836
1956
1837
1957
pub mod msvcrt {
1838
- use libc:: types:: os:: arch:: c95:: c_int;
1958
+ use libc:: types:: os:: arch:: c95:: { c_int, c_long } ;
1839
1959
1840
1960
#[ abi = "cdecl" ]
1841
1961
#[ nolink]
1842
1962
pub extern {
1843
1963
#[ link_name = "_commit" ]
1844
1964
unsafe fn commit ( fd : c_int ) -> c_int ;
1965
+
1966
+ #[ link_name = "_get_osfhandle" ]
1967
+ unsafe fn get_osfhandle ( fd : c_int ) -> c_long ;
1845
1968
}
1846
1969
}
1847
1970
}
0 commit comments