📄 kernel.h
字号:
typedef struct {
BOOLEAN isLocked; /* Whether this block is locked */
int size; /* Size of the block (including the size
of the MEMLOCK_INFO) */
void *next, *prev; /* Next, previous memory block */
#if defined( __BEOS__ )
area_id areaID; /* Needed for page locking under BeOS */
#endif /* BeOS and BeOS areas */
#ifndef NDEBUG
BYTE canary[ CANARY_SIZE ]; /* Canary for spotting overwrites */
#endif /* NDEBUG */
} MEMLOCK_INFO;
/* The kernel data block, containing all variables used by the kernel. With
the exception of the special-case values at the start, all values in this
block should be set to use zero/NULL as their ground state (for example a
boolean variable should have a ground state of FALSE (zero) rather than
TRUE (nonzero)) */
typedef struct {
/* The kernel initialisation state and a lock to protect it. The
lock and shutdown level value are handled externally and aren't
cleared when the kernel data block as a whole is cleared */
#ifdef USE_THREADS
MUTEX_DECLARE_STORAGE( initialisation );
#endif /* USE_THREADS */
SHUTDOWN_LEVEL shutdownLevel; /* Kernel shutting level */
/* Everything from this point on is cleared at init and shutdown */
BOOLEAN isInitialised; /* Whether kernel initialised */
/* The kernel object table and object table management info */
OBJECT_INFO *objectTable; /* Pointer to object table */
int objectTableSize; /* Current table size */
int objectUniqueID; /* Unique ID for next object */
OBJECT_STATE_INFO objectStateInfo; /* Object allocation state */
#ifdef USE_THREADS
MUTEX_DECLARE_STORAGE( objectTable );
#endif /* USE_THREADS */
/* The kernel message dispatcher queue */
MESSAGE_QUEUE_DATA messageQueue[ MESSAGE_QUEUE_SIZE ];
int queueEnd; /* Points past last queue element */
/* The kernel semaphores */
SEMAPHORE_INFO semaphoreInfo[ SEMAPHORE_LAST ];
#ifdef USE_THREADS
MUTEX_DECLARE_STORAGE( semaphore );
#endif /* USE_THREADS */
/* The kernel mutexes. Since mutexes usually aren't scalar values and
are declared and accessed via macros that manipulate various fields,
we have to declare a pile of them individually rather than using an
array of mutexes */
#ifdef USE_THREADS
MUTEX_DECLARE_STORAGE( mutex1 );
MUTEX_DECLARE_STORAGE( mutex2 );
#endif /* USE_THREADS */
/* The kernel secure memory list and a lock to protect it */
MEMLOCK_INFO *allocatedListHead, *allocatedListTail;
#ifdef USE_THREADS
MUTEX_DECLARE_STORAGE( allocation );
#endif /* USE_THREADS */
/* A marker for the end of the kernel data, used during init/shutdown */
int endMarker;
} KERNEL_DATA;
/* When we start up and shut down the kernel, we need to clear the kernel
data. However, the init lock may have been set by an external management
function, so we can't clear that part of the kernel data. In addition,
on shutdown the shutdown level value must stay set so that any threads
still running will be forced to exit at the earliest possible instance,
and remain set after the shutdown has completed. To handle this, we use
the following macro to clear only the appropriate area of the kernel data
block */
#define CLEAR_KERNEL_DATA() zeroise( ( void * ) ( &krnlDataBlock.isInitialised ), \
&krnlDataBlock.endMarker - &krnlDataBlock.isInitialised )
/****************************************************************************
* *
* ACL Functions *
* *
****************************************************************************/
/* Prototypes for functions in certm_acl.c */
int preDispatchCheckCertMgmtAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
/* Prototypes for functions in key_acl.c */
int preDispatchCheckKeysetAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
/* Prototypes for functions in mech_acl.c */
int preDispatchCheckMechanismWrapAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckMechanismSignAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckMechanismDeriveAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
/* Prototypes for functions in msg_acl.c */
int preDispatchSignalDependentObjects( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckAttributeAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *auxInfo );
int preDispatchCheckCompareParam( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckCheckParam( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckActionAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckState( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue, const void *dummy );
int preDispatchCheckParamHandleOpt( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *auxInfo );
int preDispatchCheckStateParamHandle( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *auxInfo );
int preDispatchCheckExportAccess( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchCheckData( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int preDispatchSetObjectOwner( const int objectHandle,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *dummy );
int postDispatchMakeObjectExternal( const int dummy,
const MESSAGE_TYPE message,
const void *messageDataPtr,
const int messageValue,
const void *auxInfo );
int postDispatchForwardToDependentObject( const int objectHandle,
const MESSAGE_TYPE message,
const void *dummy1,
const int messageValue,
const void *dummy2 );
int postDispatchUpdateUsageCount( const int objectHandle,
const MESSAGE_TYPE message,
const void *dummy1,
const int messageValue,
const void *dummy2 );
int postDispatchChangeState( const int objectHandle,
const MESSAGE_TYPE message,
const void *dummy1,
const int messageValue,
const void *dummy2 );
int postDispatchChangeStateOpt( const int objectHandle,
const MESSAGE_TYPE message,
const void *dummy1,
const int messageValue,
const void *auxInfo );
/****************************************************************************
* *
* Kernel Functions *
* *
****************************************************************************/
/* Prototypes for functions in attr_acl.c */
const void *findAttributeACL( const CRYPT_ATTRIBUTE_TYPE attribute,
const BOOLEAN isInternalMessage );
/* Prototypes for functions in int_msg.c */
int getPropertyAttribute( const int objectHandle,
const CRYPT_ATTRIBUTE_TYPE attribute,
void *messageDataPtr );
int setPropertyAttribute( const int objectHandle,
const CRYPT_ATTRIBUTE_TYPE attribute,
void *messageDataPtr );
int incRefCount( const int objectHandle, const int dummy1,
const void *dummy2, const BOOLEAN dummy3 );
int decRefCount( const int objectHandle, const int dummy1,
const void *dummy2, const BOOLEAN isInternal );
int getDependentObject( const int objectHandle, const int targetType,
const void *messageDataPtr,
const BOOLEAN dummy );
int setDependentObject( const int objectHandle, const int incReferenceCount,
const void *messageDataPtr,
const BOOLEAN dummy );
int cloneObject( const int objectHandle, const int clonedObject,
const void *dummy1, const BOOLEAN dummy2 );
/* Prototypes for functions in sendmsg.c */
int findTargetType( const int originalObjectHandle, const int targets );
int checkTargetType( const int objectHandle, const int targets );
int waitForObject( const int objectHandle, OBJECT_INFO **objectInfoPtrPtr );
/* Prototypes for functions in objects.c */
void destroyObjectData( const int objectHandle );
int destroyObjects( void );
/* Prototypes for functions in semaphore.c */
void setSemaphore( const SEMAPHORE_TYPE semaphore,
const MUTEX_HANDLE object );
void clearSemaphore( const SEMAPHORE_TYPE semaphore );
/* Init/shutdown functions for each kernel module */
int initAllocation( KERNEL_DATA *krnlDataPtr );
void endAllocation( void );
int initAttributeACL( KERNEL_DATA *krnlDataPtr );
void endAttributeACL( void );
int initCertMgmtACL( KERNEL_DATA *krnlDataPtr );
void endCertMgmtACL( void );
int initInternalMsgs( KERNEL_DATA *krnlDataPtr );
void endInternalMsgs( void );
int initKeymgmtACL( KERNEL_DATA *krnlDataPtr );
void endKeymgmtACL( void );
int initMechanismACL( KERNEL_DATA *krnlDataPtr );
void endMechanismACL( void );
int initMessageACL( KERNEL_DATA *krnlDataPtr );
void endMessageACL( void );
int initObjects( KERNEL_DATA *krnlDataPtr );
void endObjects( void );
int initObjectAltAccess( KERNEL_DATA *krnlDataPtr );
void endObjectAltAccess( void );
int initSemaphores( KERNEL_DATA *krnlDataPtr );
void endSemaphores( void );
int initSendMessage( KERNEL_DATA *krnlDataPtr );
void endSendMessage( void );
#endif /* _KERNEL_DEFINED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -