?? ktmgr.h
字號:
BEGIN_DEFINE_OBJECT(__KERNEL_THREAD_MANAGER)
DWORD dwCurrentIRQL;
__KERNEL_THREAD_OBJECT* lpCurrentKernelThread; //Current kernel thread.
__PRIORITY_QUEUE* lpRunningQueue;
__PRIORITY_QUEUE* lpSuspendedQueue;
__PRIORITY_QUEUE* lpSleepingQueue;
__PRIORITY_QUEUE* lpTerminalQueue;
__PRIORITY_QUEUE* ReadyQueue[MAX_KERNEL_THREAD_PRIORITY + 1];
DWORD dwNextWakeupTick;
__THREAD_HOOK_ROUTINE lpCreateHook;
__THREAD_HOOK_ROUTINE lpEndScheduleHook;
__THREAD_HOOK_ROUTINE lpBeginScheduleHook;
__THREAD_HOOK_ROUTINE lpTerminalHook;
__THREAD_HOOK_ROUTINE (*SetThreadHook)(
DWORD dwHookType,
__THREAD_HOOK_ROUTINE lpNew);
VOID (*CallThreadHook)(
DWORD dwHookType,
__KERNEL_THREAD_OBJECT* lpPrev,
__KERNEL_THREAD_OBJECT* lpNext);
//Get a schedulable kernel thread from ready queue.
__KERNEL_THREAD_OBJECT* (*GetScheduleKernelThread)(
__COMMON_OBJECT* lpThis,
DWORD dwPriority);
//Add a ready kernel thread to ready queue.
VOID (*AddReadyKernelThread)(
__COMMON_OBJECT* lpThis,
__KERNEL_THREAD_OBJECT* lpThread);
BOOL (*Initialize)(__COMMON_OBJECT* lpThis);
__KERNEL_THREAD_OBJECT* (*CreateKernelThread)(
__COMMON_OBJECT* lpThis,
DWORD dwStackSize,
DWORD dwStatus,
DWORD dwPriority,
__KERNEL_THREAD_ROUTINE lpStartRoutine,
LPVOID lpRoutineParam,
LPVOID lpReserved,
LPSTR lpszName);
VOID (*DestroyKernelThread)(__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread
);
BOOL (*SuspendKernelThread)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread
);
BOOL (*ResumeKernelThread)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread
);
VOID (*ScheduleFromProc)(
__KERNEL_THREAD_CONTEXT* lpContext
);
VOID (*ScheduleFromInt)(
__COMMON_OBJECT* lpThis,
LPVOID lpESP
);
DWORD (*SetThreadPriority)(
__COMMON_OBJECT* lpKernelThread,
DWORD dwNewPriority
);
DWORD (*GetThreadPriority)(
__COMMON_OBJECT* lpKernelThread
);
DWORD (*TerminalKernelThread)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread
);
BOOL (*Sleep)(
__COMMON_OBJECT* lpThis,
//__COMMON_OBJECT* lpKernelThread,
DWORD dwMilliSecond
);
BOOL (*CancelSleep)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread
);
DWORD (*SetCurrentIRQL)(
__COMMON_OBJECT* lpThis,
DWORD dwNewIRQL
);
DWORD (*GetCurrentIRQL)(
__COMMON_OBJECT* lpThis
);
DWORD (*GetLastError)(
//__COMMON_OBJECT* lpKernelThread
);
DWORD (*SetLastError)(
//__COMMON_OBJECT* lpKernelThread,
DWORD dwNewError
);
DWORD (*GetThreadID)(
__COMMON_OBJECT* lpKernelThread
);
DWORD (*GetThreadStatus)(
__COMMON_OBJECT* lpKernelThread
);
DWORD (*SetThreadStatus)(
__COMMON_OBJECT* lpKernelThread,
DWORD dwStatus
);
BOOL (*SendMessage)(
__COMMON_OBJECT* lpKernelThread,
__KERNEL_THREAD_MESSAGE* lpMsg
);
BOOL (*GetMessage)(
__COMMON_OBJECT* lpKernelThread,
__KERNEL_THREAD_MESSAGE* lpMsg
);
BOOL (*MsgQueueFull)(
__COMMON_OBJECT* lpKernelThread
);
BOOL (*MsgQueueEmpty)(
__COMMON_OBJECT* lpKernelThread
);
BOOL (*LockKernelThread)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread);
VOID (*UnlockKernelThread)(
__COMMON_OBJECT* lpThis,
__COMMON_OBJECT* lpKernelThread);
END_DEFINE_OBJECT() //End of the kernel thread manager's definition.
//
//Global functions declare.
//The following routines are used to operate the kernel thread's message queue.
//
typedef DWORD (*__KERNEL_THREAD_MESSAGE_HANDLER)(WORD,WORD,DWORD); //The protype of event handler.
DWORD DispatchMessage(__KERNEL_THREAD_MESSAGE*,__KERNEL_THREAD_MESSAGE_HANDLER);
//The routine dispatch a
//message to it's handler.
BOOL GetMessage(__KERNEL_THREAD_MESSAGE*); //Get a message from the
//current kernel thread's
//message queue.
BOOL SendMessage(__COMMON_OBJECT* lpThread,__KERNEL_THREAD_MESSAGE*); //Send a message to the
//kernel thread.
/***************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
***************************************************************************************/
extern __KERNEL_THREAD_MANAGER KernelThreadManager;
//--------------------------------------------------------------------------------------
//
// SYNCHRONIZATION OBJECTS
//
//--------------------------------------------------------------------------------------
//
//Event object's definition.
//The event object is inherited from common object and common synchronization object.
//
BEGIN_DEFINE_OBJECT(__EVENT)
INHERIT_FROM_COMMON_OBJECT
INHERIT_FROM_COMMON_SYNCHRONIZATION_OBJECT
DWORD dwEventStatus;
__PRIORITY_QUEUE* lpWaitingQueue;
DWORD (*SetEvent)(__COMMON_OBJECT*);
DWORD (*ResetEvent)(__COMMON_OBJECT*);
DWORD (*WaitForThisObjectEx)(__COMMON_OBJECT*,
DWORD); //Time out waiting operation.
END_DEFINE_OBJECT()
#define EVENT_STATUS_FREE 0x00000001 //Event status.
#define EVENT_STATUS_OCCUPIED 0x00000002
//
//The following values are returned by WaitForThisObjectEx routine.
//
#define OBJECT_WAIT_MASK 0x0000FFFF
#define OBJECT_WAIT_WAITING 0x00000000
#define OBJECT_WAIT_FAILED 0x00000000
#define OBJECT_WAIT_RESOURCE 0x00000001
#define OBJECT_WAIT_TIMEOUT 0x00000002
#define OBJECT_WAIT_DELETED 0x00000004
BOOL EventInitialize(__COMMON_OBJECT*); //The event object's initializing routine
VOID EventUninitialize(__COMMON_OBJECT*); //and uninitializing routine.
//--------------------------------------------------------------------------------------
//
// MUTEX
//
//---------------------------------------------------------------------------------------
//
//The definition of MUTEX object.
//
BEGIN_DEFINE_OBJECT(__MUTEX)
INHERIT_FROM_COMMON_OBJECT //Inherit from __COMMON_OBJECT.
INHERIT_FROM_COMMON_SYNCHRONIZATION_OBJECT //Inherit from common synchronization object.
DWORD dwMutexStatus;
DWORD dwWaitingNum;
__PRIORITY_QUEUE* lpWaitingQueue;
DWORD (*ReleaseMutex)(__COMMON_OBJECT* lpThis);
DWORD (*WaitForThisObjectEx)(__COMMON_OBJECT* lpThis,
DWORD dwMillionSecond); //Extension waiting.
END_DEFINE_OBJECT()
#define MUTEX_STATUS_FREE 0x00000001
#define MUTEX_STATUS_OCCUPIED 0x00000002
//
//The initializing routine of MUTEX object and uninitializing routine.
//
BOOL MutexInitialize(__COMMON_OBJECT* lpThis);
VOID MutexUninitialize(__COMMON_OBJECT* lpThis);
//-----------------------------------------------------------------------------------
//
// SEMAPHORE
//
//-----------------------------------------------------------------------------------
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -