1 use winapi::shared::ntdef::{ 2 BOOLEAN, CHAR, HANDLE, LARGE_INTEGER, LONG, NTSTATUS, PHANDLE, PLARGE_INTEGER, 3 POBJECT_ATTRIBUTES, PULONG, PUNICODE_STRING, PVOID, UCHAR, ULONG, UNICODE_STRING, WAIT_TYPE, 4 }; 5 use winapi::um::winnt::{ 6 ACCESS_MASK, GENERIC_MAPPING, PSECURITY_DESCRIPTOR, SECURITY_INFORMATION, 7 STANDARD_RIGHTS_REQUIRED, 8 }; 9 pub const OBJECT_TYPE_CREATE: u32 = 0x0001; 10 pub const OBJECT_TYPE_ALL_ACCESS: ACCESS_MASK = STANDARD_RIGHTS_REQUIRED | 0x1; 11 pub const DIRECTORY_QUERY: u32 = 0x0001; 12 pub const DIRECTORY_TRAVERSE: u32 = 0x0002; 13 pub const DIRECTORY_CREATE_OBJECT: u32 = 0x0004; 14 pub const DIRECTORY_CREATE_SUBDIRECTORY: u32 = 0x0008; 15 pub const DIRECTORY_ALL_ACCESS: ACCESS_MASK = STANDARD_RIGHTS_REQUIRED | 0xf; 16 pub const SYMBOLIC_LINK_QUERY: u32 = 0x0001; 17 pub const SYMBOLIC_LINK_ALL_ACCESS: ACCESS_MASK = STANDARD_RIGHTS_REQUIRED | 0x1; 18 pub const OBJ_PROTECT_CLOSE: u32 = 0x00000001; 19 pub const OBJ_INHERIT: u32 = 0x00000002; 20 pub const OBJ_AUDIT_OBJECT_CLOSE: u32 = 0x00000004; 21 ENUM!{enum OBJECT_INFORMATION_CLASS { 22 ObjectBasicInformation = 0, 23 ObjectNameInformation = 1, 24 ObjectTypeInformation = 2, 25 ObjectTypesInformation = 3, 26 ObjectHandleFlagInformation = 4, 27 ObjectSessionInformation = 5, 28 ObjectSessionObjectInformation = 6, 29 MaxObjectInfoClass = 7, 30 }} 31 STRUCT!{struct OBJECT_BASIC_INFORMATION { 32 Attributes: ULONG, 33 GrantedAccess: ACCESS_MASK, 34 HandleCount: ULONG, 35 PointerCount: ULONG, 36 PagedPoolCharge: ULONG, 37 NonPagedPoolCharge: ULONG, 38 Reserved: [ULONG; 3], 39 NameInfoSize: ULONG, 40 TypeInfoSize: ULONG, 41 SecurityDescriptorSize: ULONG, 42 CreationTime: LARGE_INTEGER, 43 }} 44 pub type POBJECT_BASIC_INFORMATION = *mut OBJECT_BASIC_INFORMATION; 45 STRUCT!{struct OBJECT_NAME_INFORMATION { 46 Name: UNICODE_STRING, 47 }} 48 pub type POBJECT_NAME_INFORMATION = *mut OBJECT_NAME_INFORMATION; 49 STRUCT!{struct OBJECT_TYPE_INFORMATION { 50 TypeName: UNICODE_STRING, 51 TotalNumberOfObjects: ULONG, 52 TotalNumberOfHandles: ULONG, 53 TotalPagedPoolUsage: ULONG, 54 TotalNonPagedPoolUsage: ULONG, 55 TotalNamePoolUsage: ULONG, 56 TotalHandleTableUsage: ULONG, 57 HighWaterNumberOfObjects: ULONG, 58 HighWaterNumberOfHandles: ULONG, 59 HighWaterPagedPoolUsage: ULONG, 60 HighWaterNonPagedPoolUsage: ULONG, 61 HighWaterNamePoolUsage: ULONG, 62 HighWaterHandleTableUsage: ULONG, 63 InvalidAttributes: ULONG, 64 GenericMapping: GENERIC_MAPPING, 65 ValidAccessMask: ULONG, 66 SecurityRequired: BOOLEAN, 67 MaintainHandleCount: BOOLEAN, 68 TypeIndex: UCHAR, 69 ReservedByte: CHAR, 70 PoolType: ULONG, 71 DefaultPagedPoolCharge: ULONG, 72 DefaultNonPagedPoolCharge: ULONG, 73 }} 74 pub type POBJECT_TYPE_INFORMATION = *mut OBJECT_TYPE_INFORMATION; 75 STRUCT!{struct OBJECT_TYPES_INFORMATION { 76 NumberOfTypes: ULONG, 77 }} 78 pub type POBJECT_TYPES_INFORMATION = *mut OBJECT_TYPES_INFORMATION; 79 STRUCT!{struct OBJECT_HANDLE_FLAG_INFORMATION { 80 Inherit: BOOLEAN, 81 ProtectFromClose: BOOLEAN, 82 }} 83 pub type POBJECT_HANDLE_FLAG_INFORMATION = *mut OBJECT_HANDLE_FLAG_INFORMATION; 84 EXTERN!{extern "system" { 85 fn NtQueryObject( 86 Handle: HANDLE, 87 ObjectInformationClass: OBJECT_INFORMATION_CLASS, 88 ObjectInformation: PVOID, 89 ObjectInformationLength: ULONG, 90 ReturnLength: PULONG, 91 ) -> NTSTATUS; 92 fn NtSetInformationObject( 93 Handle: HANDLE, 94 ObjectInformationClass: OBJECT_INFORMATION_CLASS, 95 ObjectInformation: PVOID, 96 ObjectInformationLength: ULONG, 97 ) -> NTSTATUS; 98 }} 99 pub const DUPLICATE_CLOSE_SOURCE: u32 = 0x00000001; 100 pub const DUPLICATE_SAME_ACCESS: u32 = 0x00000002; 101 pub const DUPLICATE_SAME_ATTRIBUTES: u32 = 0x00000004; 102 EXTERN!{extern "system" { 103 fn NtDuplicateObject( 104 SourceProcessHandle: HANDLE, 105 SourceHandle: HANDLE, 106 TargetProcessHandle: HANDLE, 107 TargetHandle: PHANDLE, 108 DesiredAccess: ACCESS_MASK, 109 HandleAttributes: ULONG, 110 Options: ULONG, 111 ) -> NTSTATUS; 112 fn NtMakeTemporaryObject( 113 Handle: HANDLE, 114 ) -> NTSTATUS; 115 fn NtMakePermanentObject( 116 Handle: HANDLE, 117 ) -> NTSTATUS; 118 fn NtSignalAndWaitForSingleObject( 119 SignalHandle: HANDLE, 120 WaitHandle: HANDLE, 121 Alertable: BOOLEAN, 122 Timeout: PLARGE_INTEGER, 123 ) -> NTSTATUS; 124 fn NtWaitForSingleObject( 125 Handle: HANDLE, 126 Alertable: BOOLEAN, 127 Timeout: PLARGE_INTEGER, 128 ) -> NTSTATUS; 129 fn NtWaitForMultipleObjects( 130 Count: ULONG, 131 Handles: *mut HANDLE, 132 WaitType: WAIT_TYPE, 133 Alertable: BOOLEAN, 134 Timeout: PLARGE_INTEGER, 135 ) -> NTSTATUS; 136 fn NtWaitForMultipleObjects32( 137 Count: ULONG, 138 Handles: *mut LONG, 139 WaitType: WAIT_TYPE, 140 Alertable: BOOLEAN, 141 Timeout: PLARGE_INTEGER, 142 ) -> NTSTATUS; 143 fn NtSetSecurityObject( 144 Handle: HANDLE, 145 SecurityInformation: SECURITY_INFORMATION, 146 SecurityDescriptor: PSECURITY_DESCRIPTOR, 147 ) -> NTSTATUS; 148 fn NtQuerySecurityObject( 149 Handle: HANDLE, 150 SecurityInformation: SECURITY_INFORMATION, 151 SecurityDescriptor: PSECURITY_DESCRIPTOR, 152 Length: ULONG, 153 LengthNeeded: PULONG, 154 ) -> NTSTATUS; 155 fn NtClose( 156 Handle: HANDLE, 157 ) -> NTSTATUS; 158 fn NtCompareObjects( 159 FirstObjectHandle: HANDLE, 160 SecondObjectHandle: HANDLE, 161 ) -> NTSTATUS; 162 fn NtCreateDirectoryObject( 163 DirectoryHandle: PHANDLE, 164 DesiredAccess: ACCESS_MASK, 165 ObjectAttributes: POBJECT_ATTRIBUTES, 166 ) -> NTSTATUS; 167 fn NtCreateDirectoryObjectEx( 168 DirectoryHandle: PHANDLE, 169 DesiredAccess: ACCESS_MASK, 170 ObjectAttributes: POBJECT_ATTRIBUTES, 171 ShadowDirectoryHandle: HANDLE, 172 Flags: ULONG, 173 ) -> NTSTATUS; 174 fn NtOpenDirectoryObject( 175 DirectoryHandle: PHANDLE, 176 DesiredAccess: ACCESS_MASK, 177 ObjectAttributes: POBJECT_ATTRIBUTES, 178 ) -> NTSTATUS; 179 }} 180 STRUCT!{struct OBJECT_DIRECTORY_INFORMATION { 181 Name: UNICODE_STRING, 182 TypeName: UNICODE_STRING, 183 }} 184 pub type POBJECT_DIRECTORY_INFORMATION = *mut OBJECT_DIRECTORY_INFORMATION; 185 EXTERN!{extern "system" { 186 fn NtQueryDirectoryObject( 187 DirectoryHandle: HANDLE, 188 Buffer: PVOID, 189 Length: ULONG, 190 ReturnSingleEntry: BOOLEAN, 191 RestartScan: BOOLEAN, 192 Context: PULONG, 193 ReturnLength: PULONG, 194 ) -> NTSTATUS; 195 fn NtCreatePrivateNamespace( 196 NamespaceHandle: PHANDLE, 197 DesiredAccess: ACCESS_MASK, 198 ObjectAttributes: POBJECT_ATTRIBUTES, 199 BoundaryDescriptor: PVOID, 200 ) -> NTSTATUS; 201 fn NtOpenPrivateNamespace( 202 NamespaceHandle: PHANDLE, 203 DesiredAccess: ACCESS_MASK, 204 ObjectAttributes: POBJECT_ATTRIBUTES, 205 BoundaryDescriptor: PVOID, 206 ) -> NTSTATUS; 207 fn NtDeletePrivateNamespace( 208 NamespaceHandle: HANDLE, 209 ) -> NTSTATUS; 210 fn NtCreateSymbolicLinkObject( 211 LinkHandle: PHANDLE, 212 DesiredAccess: ACCESS_MASK, 213 ObjectAttributes: POBJECT_ATTRIBUTES, 214 LinkTarget: PUNICODE_STRING, 215 ) -> NTSTATUS; 216 fn NtOpenSymbolicLinkObject( 217 LinkHandle: PHANDLE, 218 DesiredAccess: ACCESS_MASK, 219 ObjectAttributes: POBJECT_ATTRIBUTES, 220 ) -> NTSTATUS; 221 fn NtQuerySymbolicLinkObject( 222 LinkHandle: HANDLE, 223 LinkTarget: PUNICODE_STRING, 224 ReturnedLength: PULONG, 225 ) -> NTSTATUS; 226 }} 227