| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
use ctypes::c_int; |
| 7 |
use shared::basetsd::{DWORD_PTR, SIZE_T}; |
| 8 |
use shared::guiddef::GUID; |
| 9 |
use shared::minwindef::{BOOL, DWORD, LPBOOL, LPDWORD, PULONG}; |
| 10 |
use um::winnt::{HRESULT, LARGE_INTEGER, WCHAR}; |
| 11 |
ENUM!{enum WCT_OBJECT_TYPE { |
| 12 |
WctCriticalSectionType = 1, |
| 13 |
WctSendMessageType, |
| 14 |
WctMutexType, |
| 15 |
WctAlpcType, |
| 16 |
WctComType, |
| 17 |
WctThreadWaitType, |
| 18 |
WctProcessWaitType, |
| 19 |
WctThreadType, |
| 20 |
WctComActivationType, |
| 21 |
WctUnknownType, |
| 22 |
WctSocketIoType, |
| 23 |
WctSmbIoType, |
| 24 |
WctMaxType, |
| 25 |
}} |
| 26 |
ENUM!{enum WCT_OBJECT_STATUS { |
| 27 |
WctStatusNoAccess = 1, |
| 28 |
WctStatusRunning, |
| 29 |
WctStatusBlocked, |
| 30 |
WctStatusPidOnly, |
| 31 |
WctStatusPidOnlyRpcss, |
| 32 |
WctStatusOwned, |
| 33 |
WctStatusNotOwned, |
| 34 |
WctStatusAbandoned, |
| 35 |
WctStatusUnknown, |
| 36 |
WctStatusError, |
| 37 |
WctStatusMax, |
| 38 |
}} |
| 39 |
pub const WCT_MAX_NODE_COUNT: SIZE_T = 16; |
| 40 |
pub const WCT_OBJNAME_LENGTH: SIZE_T = 128; |
| 41 |
STRUCT!{struct WAITCHAIN_NODE_INFO_LOCK_OBJECT { |
| 42 |
ObjectName: [WCHAR; WCT_OBJNAME_LENGTH], |
| 43 |
Timeout: LARGE_INTEGER, |
| 44 |
Alertable: BOOL, |
| 45 |
}} |
| 46 |
STRUCT!{struct WAITCHAIN_NODE_INFO_THREAD_OBJECT { |
| 47 |
ProcessId: DWORD, |
| 48 |
ThreadId: DWORD, |
| 49 |
WaitTime: DWORD, |
| 50 |
ContextSwitches: DWORD, |
| 51 |
}} |
| 52 |
UNION!{union WAITCHAIN_NODE_INFO_u { |
| 53 |
[u64; 34], |
| 54 |
LockObject LockObject_mut: WAITCHAIN_NODE_INFO_LOCK_OBJECT, |
| 55 |
ThreadObject ThreadObject_mut: WAITCHAIN_NODE_INFO_THREAD_OBJECT, |
| 56 |
}} |
| 57 |
STRUCT!{struct WAITCHAIN_NODE_INFO { |
| 58 |
ObjectType: WCT_OBJECT_TYPE, |
| 59 |
ObjectStatus: WCT_OBJECT_STATUS, |
| 60 |
u: WAITCHAIN_NODE_INFO_u, |
| 61 |
}} |
| 62 |
pub type PWAITCHAIN_NODE_INFO = *mut WAITCHAIN_NODE_INFO; |
| 63 |
DECLARE_HANDLE!{HWCT, HWCT__} |
| 64 |
FN!{cdecl PWAITCHAINCALLBACK( |
| 65 |
WctHandle: HWCT, |
| 66 |
Context: DWORD_PTR, |
| 67 |
CallbackStatus: DWORD, |
| 68 |
NodeCount: LPDWORD, |
| 69 |
NodeInfoArray: PWAITCHAIN_NODE_INFO, |
| 70 |
IsCycle: LPBOOL, |
| 71 |
) -> ()} |
| 72 |
pub const WCT_ASYNC_OPEN_FLAG: DWORD = 1; |
| 73 |
pub const WCTP_OPEN_ALL_FLAGS: DWORD = WCT_ASYNC_OPEN_FLAG; |
| 74 |
extern "system" { |
| 75 |
pub fn OpenThreadWaitChainSession( |
| 76 |
Flags: DWORD, |
| 77 |
callback: PWAITCHAINCALLBACK, |
| 78 |
) -> HWCT; |
| 79 |
pub fn CloseThreadWaitChainSession( |
| 80 |
WctHandle: HWCT, |
| 81 |
); |
| 82 |
} |
| 83 |
pub const WCT_OUT_OF_PROC_FLAG: DWORD = 0x1; |
| 84 |
pub const WCT_OUT_OF_PROC_COM_FLAG: DWORD = 0x2; |
| 85 |
pub const WCT_OUT_OF_PROC_CS_FLAG: DWORD = 0x4; |
| 86 |
pub const WCT_NETWORK_IO_FLAG: DWORD = 0x8; |
| 87 |
pub const WCTP_GETINFO_ALL_FLAGS: DWORD = WCT_OUT_OF_PROC_FLAG | WCT_OUT_OF_PROC_COM_FLAG |
| 88 |
| WCT_OUT_OF_PROC_CS_FLAG; |
| 89 |
extern "system" { |
| 90 |
pub fn GetThreadWaitChain( |
| 91 |
WctHandle: HWCT, |
| 92 |
Context: DWORD_PTR, |
| 93 |
Flags: DWORD, |
| 94 |
ThreadId: DWORD, |
| 95 |
NodeCount: LPDWORD, |
| 96 |
NodeInfoArray: PWAITCHAIN_NODE_INFO, |
| 97 |
IsCycle: LPBOOL, |
| 98 |
) -> BOOL; |
| 99 |
} |
| 100 |
FN!{cdecl PCOGETCALLSTATE( |
| 101 |
c_int, |
| 102 |
PULONG, |
| 103 |
) -> HRESULT} |
| 104 |
FN!{cdecl PCOGETACTIVATIONSTATE( |
| 105 |
GUID, |
| 106 |
DWORD, |
| 107 |
*mut DWORD, |
| 108 |
) -> HRESULT} |
| 109 |
extern "system" { |
| 110 |
pub fn RegisterWaitChainCOMCallback( |
| 111 |
CallStateCallback: PCOGETCALLSTATE, |
| 112 |
ActivationStateCallback: PCOGETACTIVATIONSTATE, |
| 113 |
); |
| 114 |
} |