@@ -633,8 +633,9 @@ pub mod types {
633
633
pub mod bsd44 {
634
634
}
635
635
pub mod extra {
636
+ use ptr;
636
637
use libc:: types:: common:: c95:: c_void;
637
- use libc:: types:: os:: arch:: c95:: { c_char, c_int, c_uint} ;
638
+ use libc:: types:: os:: arch:: c95:: { c_char, c_int, c_uint, size_t } ;
638
639
use libc:: types:: os:: arch:: c95:: { c_long, c_ulong} ;
639
640
use libc:: types:: os:: arch:: c95:: { wchar_t} ;
640
641
use libc:: types:: os:: arch:: c99:: { c_ulonglong} ;
@@ -665,6 +666,7 @@ pub mod types {
665
666
pub type LPSECURITY_ATTRIBUTES = LPVOID ;
666
667
667
668
pub type LPVOID = * mut c_void ;
669
+ pub type LPCVOID = * c_void ;
668
670
pub type LPBYTE = * mut BYTE ;
669
671
pub type LPWORD = * mut WORD ;
670
672
pub type LPDWORD = * mut DWORD ;
@@ -674,6 +676,7 @@ pub mod types {
674
676
pub type PBOOL = * mut BOOL ;
675
677
pub type WCHAR = wchar_t ;
676
678
pub type WORD = u16 ;
679
+ pub type SIZE_T = size_t ;
677
680
678
681
pub type time64_t = i64 ;
679
682
pub type int64 = i64 ;
@@ -707,6 +710,50 @@ pub mod types {
707
710
dwThreadId : DWORD
708
711
}
709
712
pub type LPPROCESS_INFORMATION = * mut PROCESS_INFORMATION ;
713
+
714
+ pub struct SYSTEM_INFO {
715
+ wProcessorArchitecture : WORD ,
716
+ wReserved : WORD ,
717
+ dwPageSize : DWORD ,
718
+ lpMinimumApplicationAddress : LPVOID ,
719
+ lpMaximumApplicationAddress : LPVOID ,
720
+ dwActiveProcessorMask : DWORD ,
721
+ dwNumberOfProcessors : DWORD ,
722
+ dwProcessorType : DWORD ,
723
+ dwAllocationGranularity : DWORD ,
724
+ wProcessorLevel : WORD ,
725
+ wProcessorRevision : WORD
726
+ }
727
+ pub type LPSYSTEM_INFO = * mut SYSTEM_INFO ;
728
+
729
+ impl SYSTEM_INFO {
730
+ pub fn new ( ) -> SYSTEM_INFO {
731
+ SYSTEM_INFO {
732
+ wProcessorArchitecture : 0 ,
733
+ wReserved : 0 ,
734
+ dwPageSize : 0 ,
735
+ lpMinimumApplicationAddress : ptr:: null ( ) ,
736
+ lpMaximumApplicationAddress : ptr:: null ( ) ,
737
+ dwActiveProcessorMask : 0 ,
738
+ dwNumberOfProcessors : 0 ,
739
+ dwProcessorType : 0 ,
740
+ dwAllocationGranularity : 0 ,
741
+ wProcessorLevel : 0 ,
742
+ wProcessorRevision : 0
743
+ }
744
+ }
745
+ }
746
+
747
+ pub struct MEMORY_BASIC_INFORMATION {
748
+ BaseAddress : LPVOID ,
749
+ AllocationBase : LPVOID ,
750
+ AllocationProtect : DWORD ,
751
+ RegionSize : SIZE_T ,
752
+ State : DWORD ,
753
+ Protect : DWORD ,
754
+ Type : DWORD
755
+ }
756
+ pub type LPMEMORY_BASIC_INFORMATION = * mut MEMORY_BASIC_INFORMATION ;
710
757
}
711
758
}
712
759
}
@@ -974,7 +1021,12 @@ pub mod consts {
974
1021
pub static O_NOINHERIT : c_int = 128 ;
975
1022
976
1023
pub static ERROR_SUCCESS : c_int = 0 ;
1024
+ pub static ERROR_INVALID_HANDLE : c_int = 6 ;
1025
+ pub static ERROR_DISK_FULL : c_int = 112 ;
977
1026
pub static ERROR_INSUFFICIENT_BUFFER : c_int = 122 ;
1027
+ pub static ERROR_ALREADY_EXISTS : c_int = 183 ;
1028
+ pub static ERROR_INVALID_ADDRESS : c_int = 487 ;
1029
+ pub static ERROR_FILE_INVALID : c_int = 1006 ;
978
1030
pub static INVALID_HANDLE_VALUE : c_int = -1 ;
979
1031
980
1032
pub static DELETE : DWORD = 0x00010000 ;
@@ -1020,6 +1072,49 @@ pub mod consts {
1020
1072
1021
1073
pub static INFINITE : DWORD = -1 ;
1022
1074
pub static STILL_ACTIVE : DWORD = 259 ;
1075
+
1076
+ pub static MEM_COMMIT : DWORD = 0x00001000 ;
1077
+ pub static MEM_RESERVE : DWORD = 0x00002000 ;
1078
+ pub static MEM_DECOMMIT : DWORD = 0x00004000 ;
1079
+ pub static MEM_RELEASE : DWORD = 0x00008000 ;
1080
+ pub static MEM_RESET : DWORD = 0x00080000 ;
1081
+ pub static MEM_RESET_UNDO : DWORD = 0x1000000 ;
1082
+ pub static MEM_LARGE_PAGES : DWORD = 0x20000000 ;
1083
+ pub static MEM_PHYSICAL : DWORD = 0x00400000 ;
1084
+ pub static MEM_TOP_DOWN : DWORD = 0x00100000 ;
1085
+ pub static MEM_WRITE_WATCH : DWORD = 0x00200000 ;
1086
+
1087
+ pub static PAGE_EXECUTE : DWORD = 0x10 ;
1088
+ pub static PAGE_EXECUTE_READ : DWORD = 0x20 ;
1089
+ pub static PAGE_EXECUTE_READWRITE : DWORD = 0x40 ;
1090
+ pub static PAGE_EXECUTE_WRITECOPY : DWORD = 0x80 ;
1091
+ pub static PAGE_NOACCESS : DWORD = 0x01 ;
1092
+ pub static PAGE_READONLY : DWORD = 0x02 ;
1093
+ pub static PAGE_READWRITE : DWORD = 0x04 ;
1094
+ pub static PAGE_WRITECOPY : DWORD = 0x08 ;
1095
+ pub static PAGE_GUARD : DWORD = 0x100 ;
1096
+ pub static PAGE_NOCACHE : DWORD = 0x200 ;
1097
+ pub static PAGE_WRITECOMBINE : DWORD = 0x400 ;
1098
+
1099
+ pub static SEC_COMMIT : DWORD = 0x8000000 ;
1100
+ pub static SEC_IMAGE : DWORD = 0x1000000 ;
1101
+ pub static SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000 ;
1102
+ pub static SEC_LARGE_PAGES : DWORD = 0x80000000 ;
1103
+ pub static SEC_NOCACHE : DWORD = 0x10000000 ;
1104
+ pub static SEC_RESERVE : DWORD = 0x4000000 ;
1105
+ pub static SEC_WRITECOMBINE : DWORD = 0x40000000 ;
1106
+
1107
+ pub static FILE_MAP_ALL_ACCESS : DWORD = 0xf001f ;
1108
+ pub static FILE_MAP_READ : DWORD = 0x4 ;
1109
+ pub static FILE_MAP_WRITE : DWORD = 0x2 ;
1110
+ pub static FILE_MAP_COPY : DWORD = 0x1 ;
1111
+ pub static FILE_MAP_EXECUTE : DWORD = 0x20 ;
1112
+
1113
+ pub static PROCESSOR_ARCHITECTURE_INTEL : WORD = 0 ;
1114
+ pub static PROCESSOR_ARCHITECTURE_ARM : WORD = 5 ;
1115
+ pub static PROCESSOR_ARCHITECTURE_IA64 : WORD = 6 ;
1116
+ pub static PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9 ;
1117
+ pub static PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff ;
1023
1118
}
1024
1119
}
1025
1120
@@ -2620,11 +2715,13 @@ pub mod funcs {
2620
2715
2621
2716
pub mod kernel32 {
2622
2717
use libc:: types:: os:: arch:: c95:: { c_uint} ;
2623
- use libc:: types:: os:: arch:: extra:: { BOOL , DWORD , HMODULE } ;
2718
+ use libc:: types:: os:: arch:: extra:: { BOOL , DWORD , SIZE_T , HMODULE } ;
2624
2719
use libc:: types:: os:: arch:: extra:: { LPCWSTR , LPWSTR , LPCTSTR ,
2625
- LPTSTR , LPTCH , LPDWORD , LPVOID } ;
2720
+ LPTSTR , LPTCH , LPDWORD , LPVOID ,
2721
+ LPCVOID } ;
2626
2722
use libc:: types:: os:: arch:: extra:: { LPSECURITY_ATTRIBUTES , LPSTARTUPINFO ,
2627
- LPPROCESS_INFORMATION } ;
2723
+ LPPROCESS_INFORMATION ,
2724
+ LPMEMORY_BASIC_INFORMATION } ;
2628
2725
use libc:: types:: os:: arch:: extra:: { HANDLE , LPHANDLE } ;
2629
2726
2630
2727
#[ abi = "stdcall" ]
@@ -2687,6 +2784,37 @@ pub mod funcs {
2687
2784
unsafe fn WaitForSingleObject ( hHandle : HANDLE , dwMilliseconds : DWORD ) -> DWORD ;
2688
2785
unsafe fn TerminateProcess ( hProcess : HANDLE , uExitCode : c_uint ) -> BOOL ;
2689
2786
unsafe fn GetExitCodeProcess ( hProcess : HANDLE , lpExitCode : LPDWORD ) -> BOOL ;
2787
+
2788
+ unsafe fn GetSystemInfo ( lpSystemInfo : LPSYSTEM_INFO ) ;
2789
+ unsafe fn VirtualAlloc ( lpAddress : LPVOID ,
2790
+ dwSize : SIZE_T ,
2791
+ flAllocationType : DWORD ,
2792
+ flProtect : DWORD ) -> LPVOID ;
2793
+ unsafe fn VirtualFree ( lpAddress : LPVOID ,
2794
+ dwSize : SIZE_T ,
2795
+ dwFreeType : DWORD ) -> BOOL ;
2796
+ unsafe fn VirtualLock ( lpAddress : LPVOID , dwSize : SIZE_T ) -> BOOL ;
2797
+ unsafe fn VirtualUnlock ( lpAddress : LPVOID , dwSize : SIZE_T ) -> BOOL ;
2798
+ unsafe fn VirtualProtect ( lpAddress : LPVOID ,
2799
+ dwSize : SIZE_T ,
2800
+ flNewProtect : DWORD ,
2801
+ lpflOldProtect : LPDWORD ) -> BOOL ;
2802
+ unsafe fn VirtualQuery ( lpAddress : LPCVOID ,
2803
+ lpBuffer : LPMEMORY_BASIC_INFORMATION ,
2804
+ dwLength : SIZE_T ) -> SIZE_T ;
2805
+
2806
+ unsafe fn CreateFileMappingW ( hFile : HANDLE ,
2807
+ lpAttributes : LPSECURITY_ATTRIBUTES ,
2808
+ flProtect : DWORD ,
2809
+ dwMaximumSizeHigh : DWORD ,
2810
+ dwMaximumSizeLow : DWORD ,
2811
+ lpName : LPCTSTR ) -> HANDLE ;
2812
+ unsafe fn MapViewOfFile ( hFileMappingObject : HANDLE ,
2813
+ dwDesiredAccess : DWORD ,
2814
+ dwFileOffsetHigh : DWORD ,
2815
+ dwFileOffsetLow : DWORD ,
2816
+ dwNumberOfBytesToMap : SIZE_T ) -> LPVOID ;
2817
+ unsafe fn UnmapViewOfFile ( lpBaseAddress : LPCVOID ) -> BOOL ;
2690
2818
}
2691
2819
}
2692
2820
0 commit comments