本文整理汇总了C++中PsGetCurrentThread函数的典型用法代码示例。如果您正苦于以下问题:C++ PsGetCurrentThread函数的具体用法?C++ PsGetCurrentThread怎么用?C++ PsGetCurrentThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PsGetCurrentThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FsRtlStackOverflowRead
VOID
FsRtlStackOverflowRead (
IN PVOID Context
)
/*++
Routine Description:
This routine processes all of the stack overflow request posted by
the various file systems
Arguments:
Return Value:
None.
--*/
{
PSTACK_OVERFLOW_ITEM StackOverflowItem;
//
// Since stack overflow reads are always recursive, set the
// TopLevelIrp field appropriately so that recursive reads
// from this point will not think they are top level.
//
PsGetCurrentThread()->TopLevelIrp = FSRTL_FSP_TOP_LEVEL_IRP;
//
// Get a pointer to the stack overflow item and then call
// the callback routine to do the work
//
StackOverflowItem = (PSTACK_OVERFLOW_ITEM)Context;
(StackOverflowItem->StackOverflowRoutine)(StackOverflowItem->Context,
StackOverflowItem->Event);
//
// Deallocate the work item, or simply return the serial item.
//
if (StackOverflowItem == &StackOverflowFallback) {
KeSetEvent( &StackOverflowFallbackSerialEvent, 0, FALSE );
} else {
ExFreePool( StackOverflowItem );
}
PsGetCurrentThread()->TopLevelIrp = (ULONG_PTR)NULL;
}
示例2: DLDpFindCurrentThread
POWNER_ENTRY DLDpFindCurrentThread(
IN PERESOURCE Resource,
IN ERESOURCE_THREAD Thread
) {
if (Resource->OwnerThreads[0].OwnerThread == Thread) return &(Resource->OwnerThreads[0]);
if (Resource->OwnerThreads[1].OwnerThread == Thread) return &(Resource->OwnerThreads[1]);
POWNER_ENTRY LastEntry, CurrentEntry, FirstEmptyEntry = NULL;
if (!(Resource->OwnerThreads[1].OwnerThread)) FirstEmptyEntry = &(Resource->OwnerThreads[1]);
CurrentEntry = Resource->OwnerTable;
LastEntry = &(Resource->OwnerTable[Resource->OwnerThreads[0].TableSize]);
while (CurrentEntry != LastEntry) {
if (CurrentEntry->OwnerThread == Thread) {
PCHAR CurrentThread = (PCHAR)PsGetCurrentThread();
*((PULONG)(CurrentThread + 0x136)) = CurrentEntry - Resource->OwnerTable;
return CurrentEntry;
}
if (!(CurrentEntry->OwnerThread)) {
FirstEmptyEntry = CurrentEntry;
}
CurrentEntry++;
}
if (FirstEmptyEntry) {
PCHAR CurrentThread = (PCHAR)PsGetCurrentThread();
*((PULONG)(CurrentThread + 0x136)) = FirstEmptyEntry - Resource->OwnerTable;
return FirstEmptyEntry;
} else {
// Grow OwnerTable
USHORT OldSize = Resource->OwnerThreads[0].TableSize;
USHORT NewSize = 3;
if (OldSize) NewSize = OldSize + 4;
POWNER_ENTRY NewEntry = (POWNER_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(OWNER_ENTRY)*NewSize,RESOURCE_TABLE_TAG);
RtlZeroMemory(NewEntry,sizeof(OWNER_ENTRY)*NewSize);
if (Resource->OwnerTable) {
RtlMoveMemory(NewEntry,Resource->OwnerTable,sizeof(OWNER_ENTRY)*OldSize);
ExFreePool(Resource->OwnerTable);
}
Resource->OwnerTable = NewEntry;
PCHAR CurrentThread = (PCHAR)PsGetCurrentThread();
*((PULONG)(CurrentThread + 0x136)) = OldSize;
Resource->OwnerThreads[0].TableSize = NewSize;
return &(NewEntry[OldSize]);
}
}
示例3: FsRtlStackOverflowRead
VOID
FsRtlStackOverflowRead (
IN PVOID Context
)
/*++
Routine Description:
This routine processes all of the stack overflow request posted by
the various file systems
Arguments:
Return Value:
None.
--*/
{
PSTACK_OVERFLOW_ITEM StackOverflowItem;
//
// Since stack overflow reads are always recursive, set the
// TopLevelIrp field appropriately so that recurive reads
// from this point will not think they are top level.
//
PsGetCurrentThread()->TopLevelIrp = FSRTL_FSP_TOP_LEVEL_IRP;
//
// Get a pointer to the stack overflow item and then call
// the callback routine to do the work
//
StackOverflowItem = (PSTACK_OVERFLOW_ITEM)Context;
(StackOverflowItem->StackOverflowRoutine)(StackOverflowItem->Context,
StackOverflowItem->Event);
//
// Deallocate the work item and then go back to the loop to
// to wait for another work item
//
ExFreePool( StackOverflowItem );
PsGetCurrentThread()->TopLevelIrp = (ULONG)NULL;
}
示例4: SeImpersonateClientEx
/*
* @implemented
*/
NTSTATUS
NTAPI
SeImpersonateClientEx(IN PSECURITY_CLIENT_CONTEXT ClientContext,
IN PETHREAD ServerThread OPTIONAL)
{
BOOLEAN EffectiveOnly;
PAGED_CODE();
if (ClientContext->DirectlyAccessClientToken == FALSE)
{
EffectiveOnly = ClientContext->SecurityQos.EffectiveOnly;
}
else
{
EffectiveOnly = ClientContext->DirectAccessEffectiveOnly;
}
if (ServerThread == NULL)
{
ServerThread = PsGetCurrentThread();
}
return PsImpersonateClient(ServerThread,
ClientContext->ClientToken,
TRUE,
EffectiveOnly,
ClientContext->SecurityQos.ImpersonationLevel);
}
示例5: AFSIs64BitProcess
BOOLEAN
AFSIs64BitProcess( IN ULONGLONG ProcessId)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
BOOLEAN bIs64Bit = FALSE;
AFSProcessCB *pProcessCB = NULL;
AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSDeviceObject->DeviceExtension;
__Enter
{
AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSIs64BitProcess Acquiring Control ProcessTree.TreeLock lock %p SHARED %08lX\n",
pDeviceExt->Specific.Control.ProcessTree.TreeLock,
PsGetCurrentThread()));
AFSAcquireShared( pDeviceExt->Specific.Control.ProcessTree.TreeLock,
TRUE);
ntStatus = AFSLocateHashEntry( pDeviceExt->Specific.Control.ProcessTree.TreeHead,
(ULONGLONG)ProcessId,
(AFSBTreeEntry **)&pProcessCB);
if( pProcessCB != NULL)
{
bIs64Bit = BooleanFlagOn( pProcessCB->Flags, AFS_PROCESS_FLAG_IS_64BIT);
}
AFSReleaseResource( pDeviceExt->Specific.Control.ProcessTree.TreeLock);
}
return bIs64Bit;
}
示例6: DxEngIsHdevLockedByCurrentThread
BOOLEAN
APIENTRY
DxEngIsHdevLockedByCurrentThread(HDEV hDev)
{ // Based on EngIsSemaphoreOwnedByCurrentThread w/o the Ex call.
PERESOURCE pSem = (PERESOURCE)(((PPDEVOBJ)hDev)->hsemDevLock);
return pSem->OwnerEntry.OwnerThread == (ERESOURCE_THREAD)PsGetCurrentThread();
}
示例7: changeTrapFlagForThreadAPC
/* Changing the thread context should be done from within the thread */
VOID changeTrapFlagForThreadAPC(
IN PKAPC Apc,
IN PKNORMAL_ROUTINE *NormalRoutine,
IN PVOID *NormalContext,
IN PVOID *SystemArgument1,
IN PVOID *SystemArgument2 )
{
int isSetTheFlag = (int)Apc->SystemArgument1;
KEVENT * operationComplete = (KEVENT *)Apc->SystemArgument2;
UNREFERENCED_PARAMETER(NormalRoutine);
UNREFERENCED_PARAMETER(NormalContext);
UNREFERENCED_PARAMETER(SystemArgument1);
UNREFERENCED_PARAMETER(SystemArgument2);
PAGED_CODE();
ADDRESS ethread = (ADDRESS)PsGetCurrentThread();
if (0 == isSetTheFlag)
{
changeTrapFlag(ethread, 0);
}
else
{
changeTrapFlag(ethread, 1);
}
KeSetEvent(operationComplete, 0, FALSE);
}
示例8: NtReplyPort
/*
* @implemented
*/
NTSTATUS
NTAPI
NtReplyPort(IN HANDLE PortHandle,
IN PPORT_MESSAGE ReplyMessage)
{
PLPCP_PORT_OBJECT Port;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
NTSTATUS Status;
PLPCP_MESSAGE Message;
PETHREAD Thread = PsGetCurrentThread(), WakeupThread;
//PORT_MESSAGE CapturedReplyMessage;
PAGED_CODE();
LPCTRACE(LPC_REPLY_DEBUG,
"Handle: %p. Message: %p.\n",
PortHandle,
ReplyMessage);
if (KeGetPreviousMode() == UserMode)
{
_SEH2_TRY
{
ProbeForRead(ReplyMessage, sizeof(PORT_MESSAGE), sizeof(ULONG));
/*RtlCopyMemory(&CapturedReplyMessage, ReplyMessage, sizeof(PORT_MESSAGE));
ReplyMessage = &CapturedReplyMessage;*/
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
DPRINT1("SEH crash [1]\n");
DbgBreakPoint();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
示例9: NtUserCallNoParam
/*
* @unimplemented
*/
DWORD_PTR
APIENTRY
NtUserCallNoParam(DWORD Routine)
{
DWORD_PTR Result = 0;
DECLARE_RETURN(DWORD_PTR);
TRACE("Enter NtUserCallNoParam\n");
UserEnterExclusive();
switch(Routine)
{
case NOPARAM_ROUTINE_CREATEMENU:
Result = (DWORD_PTR)UserCreateMenu(FALSE);
break;
case NOPARAM_ROUTINE_CREATEMENUPOPUP:
Result = (DWORD_PTR)UserCreateMenu(TRUE);
break;
case NOPARAM_ROUTINE_DESTROY_CARET:
Result = (DWORD_PTR)co_IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread);
break;
case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
Result = (DWORD_PTR)IntInitMessagePumpHook();
break;
case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP:
Result = (DWORD_PTR)IntUninitMessagePumpHook();
break;
case NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO:
Result = (DWORD_PTR)MsqGetMessageExtraInfo();
break;
case NOPARAM_ROUTINE_MSQCLEARWAKEMASK:
RETURN( (DWORD_PTR)IntMsqClearWakeMask());
case NOPARAM_ROUTINE_GETMSESSAGEPOS:
{
PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
RETURN( (DWORD_PTR)MAKELONG(pti->ptLast.x, pti->ptLast.y));
}
case NOPARAM_ROUTINE_RELEASECAPTURE:
RETURN( (DWORD_PTR)IntReleaseCapture());
default:
ERR("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine);
EngSetLastError(ERROR_INVALID_PARAMETER);
break;
}
RETURN(Result);
CLEANUP:
TRACE("Leave NtUserCallNoParam, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
示例10: PspSystemThreadStartup
VOID
NTAPI
PspSystemThreadStartup(IN PKSTART_ROUTINE StartRoutine,
IN PVOID StartContext)
{
PETHREAD Thread;
PSTRACE(PS_THREAD_DEBUG,
"StartRoutine: %p StartContext: %p\n", StartRoutine, StartContext);
/* Unlock the dispatcher Database */
KeLowerIrql(PASSIVE_LEVEL);
Thread = PsGetCurrentThread();
/* Make sure the thread isn't gone */
_SEH2_TRY
{
if (!(Thread->Terminated) && !(Thread->DeadThread))
{
/* Call the Start Routine */
StartRoutine(StartContext);
}
}
_SEH2_EXCEPT(PspUnhandledExceptionInSystemThread(_SEH2_GetExceptionInformation()))
{
/* Bugcheck if we got here */
KeBugCheck(KMODE_EXCEPTION_NOT_HANDLED);
}
_SEH2_END;
/* Exit the thread */
PspTerminateThreadByPointer(Thread, STATUS_SUCCESS, TRUE);
}
示例11: co_UserHideCaret
BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL)
{
PTHREADINFO pti;
PUSER_MESSAGE_QUEUE ThreadQueue;
if (Window) ASSERT_REFS_CO(Window);
if(Window && Window->head.pti->pEThread != PsGetCurrentThread())
{
EngSetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
pti = PsGetCurrentThreadWin32Thread();
ThreadQueue = pti->MessageQueue;
if(Window && ThreadQueue->CaretInfo->hWnd != Window->head.h)
{
EngSetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
if(ThreadQueue->CaretInfo->Visible)
{
PWND pwnd = UserGetWindowObject(ThreadQueue->CaretInfo->hWnd);
IntKillTimer(pwnd, IDCARETTIMER, TRUE);
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0;
}
return TRUE;
}
示例12: PsLookupProcessByProcessId
NTSTATUS
PsLookupProcessByProcessId(
__in HANDLE ProcessId,
__deref_out PEPROCESS *Process
)
/*++
Routine Description:
This function accepts the process id of a process and returns a
referenced pointer to the process.
Arguments:
ProcessId - Specifies the Process ID of the process.
Process - Returns a referenced pointer to the process specified by the
process id.
Return Value:
STATUS_SUCCESS - A process was located based on the contents of
the process id.
STATUS_INVALID_PARAMETER - The process was not found.
--*/
{
PHANDLE_TABLE_ENTRY CidEntry;
PEPROCESS lProcess;
PETHREAD CurrentThread;
NTSTATUS Status;
PAGED_CODE();
Status = STATUS_INVALID_PARAMETER;
CurrentThread = PsGetCurrentThread ();
KeEnterCriticalRegionThread (&CurrentThread->Tcb);
CidEntry = ExMapHandleToPointer(PspCidTable, ProcessId);
if (CidEntry != NULL) {
lProcess = (PEPROCESS)CidEntry->Object;
if (lProcess->Pcb.Header.Type == ProcessObject &&
lProcess->GrantedAccess != 0) {
if (ObReferenceObjectSafe(lProcess)) {
*Process = lProcess;
Status = STATUS_SUCCESS;
}
}
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
KeLeaveCriticalRegionThread (&CurrentThread->Tcb);
return Status;
}
示例13: MiCreatePebOrTeb
NTSTATUS
NTAPI
MiCreatePebOrTeb(IN PEPROCESS Process,
IN ULONG Size,
OUT PULONG_PTR Base)
{
PETHREAD Thread = PsGetCurrentThread();
PMMVAD_LONG Vad;
NTSTATUS Status;
ULONG RandomCoeff;
ULONG_PTR StartAddress, EndAddress;
LARGE_INTEGER CurrentTime;
TABLE_SEARCH_RESULT Result = TableFoundNode;
PMMADDRESS_NODE Parent;
/* Allocate a VAD */
Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD_LONG), 'ldaV');
if (!Vad) return STATUS_NO_MEMORY;
/* Setup the primary flags with the size, and make it commited, private, RW */
Vad->u.LongFlags = 0;
Vad->u.VadFlags.CommitCharge = BYTES_TO_PAGES(Size);
Vad->u.VadFlags.MemCommit = TRUE;
Vad->u.VadFlags.PrivateMemory = TRUE;
Vad->u.VadFlags.Protection = MM_READWRITE;
Vad->u.VadFlags.NoChange = TRUE;
/* Setup the secondary flags to make it a secured, writable, long VAD */
Vad->u2.LongFlags2 = 0;
Vad->u2.VadFlags2.OneSecured = TRUE;
Vad->u2.VadFlags2.LongVad = TRUE;
Vad->u2.VadFlags2.ReadOnly = FALSE;
/* Lock the process address space */
KeAcquireGuardedMutex(&Process->AddressCreationLock);
/* Check if this is a PEB creation */
if (Size == sizeof(PEB))
{
/* Start at the highest valid address */
StartAddress = (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1;
/* Select the random coefficient */
KeQueryTickCount(&CurrentTime);
CurrentTime.LowPart &= ((64 * _1KB) >> PAGE_SHIFT) - 1;
if (CurrentTime.LowPart <= 1) CurrentTime.LowPart = 2;
RandomCoeff = CurrentTime.LowPart << PAGE_SHIFT;
/* Select the highest valid address minus the random coefficient */
StartAddress -= RandomCoeff;
EndAddress = StartAddress + ROUND_TO_PAGES(Size) - 1;
/* Try to find something below the random upper margin */
Result = MiFindEmptyAddressRangeDownTree(ROUND_TO_PAGES(Size),
EndAddress,
PAGE_SIZE,
&Process->VadRoot,
Base,
&Parent);
}
示例14: OcTplTestFuncParam10
NTSTATUS
OcTplTestFuncParam10(
IN ULONG_PTR Param1,
IN ULONG_PTR Param2,
IN ULONG_PTR Param3,
IN ULONG_PTR Param4,
IN ULONG_PTR Param5,
IN ULONG_PTR Param6,
IN ULONG_PTR Param7,
IN ULONG_PTR Param8,
IN ULONG_PTR Param9,
IN ULONG_PTR Param10
)
{
g_FunctionCalled[ 0xA ] = TRUE;
DbgPrint(" ThreadpoolTest: OcTplTestFuncParam10 Thread = 0x%ph \n", PsGetCurrentThread() );
OC_TPL_CHECK_PARAMETER( 1 )
OC_TPL_CHECK_PARAMETER( 2 )
OC_TPL_CHECK_PARAMETER( 3 )
OC_TPL_CHECK_PARAMETER( 4 )
OC_TPL_CHECK_PARAMETER( 5 )
OC_TPL_CHECK_PARAMETER( 6 )
OC_TPL_CHECK_PARAMETER( 7 )
OC_TPL_CHECK_PARAMETER( 8 )
OC_TPL_CHECK_PARAMETER( 9 )
OC_TPL_CHECK_PARAMETER( 10 )
Sleep(300);
return STATUS_SUCCESS;
}
示例15: FsRtlWorkerThread
/*
* @implemented
*/
VOID
NTAPI
FsRtlWorkerThread(IN PVOID StartContext)
{
KIRQL Irql;
PLIST_ENTRY Entry;
PWORK_QUEUE_ITEM WorkItem;
ULONG QueueId = (ULONG)StartContext;
/* Set our priority according to the queue we're dealing with */
KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY + QueueId);
/* Loop for events */
for (;;)
{
/* Look for next event */
Entry = KeRemoveQueue(&FsRtlWorkerQueues[QueueId], KernelMode, NULL);
WorkItem = CONTAINING_RECORD(Entry, WORK_QUEUE_ITEM, List);
/* Call its routine (here: FsRtlStackOverflowRead) */
WorkItem->WorkerRoutine(WorkItem->Parameter);
/* Check we're still at passive level or bugcheck */
Irql = KeGetCurrentIrql();
if (Irql != PASSIVE_LEVEL)
{
KeBugCheckEx(IRQL_NOT_LESS_OR_EQUAL, (ULONG_PTR)WorkItem->WorkerRoutine,
(ULONG_PTR)Irql, (ULONG_PTR)WorkItem->WorkerRoutine,
(ULONG_PTR)WorkItem);
}
}
}