本文整理汇总了C++中RtlLeaveCriticalSection函数的典型用法代码示例。如果您正苦于以下问题:C++ RtlLeaveCriticalSection函数的具体用法?C++ RtlLeaveCriticalSection怎么用?C++ RtlLeaveCriticalSection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RtlLeaveCriticalSection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RtlEnterCriticalSection
//------------------------------------------------------------------------
// CSocketMap::Lookup()
//
// Given a socket handle, find the associated LSP socket object.
//------------------------------------------------------------------------
RSOCKET *CSocketMap::Lookup( SOCKET hSocket )
{
SOCKET_MAP_ENTRY *pMap = m_pMap;
if (!pMap)
{
return 0;
}
NTSTATUS Status = RtlEnterCriticalSection(&m_cs);
for (DWORD i=0; i<m_dwMapSize; i++)
{
if (pMap->hSocket == hSocket)
{
Status = RtlLeaveCriticalSection(&m_cs);
return pMap->pRSocket;
}
pMap++;
}
Status = RtlLeaveCriticalSection(&m_cs);
return 0;
}
示例2: DbgpIsAppInHashTable
PDBGP_APP_THREAD
DbgpIsAppInHashTable(
IN PCLIENT_ID AppClientId
)
/*++
Routine Description:
This routine scans the application thread hash table looking
for an application thread that matches the specified client id.
If a matching application thread is found, then its address is
returned.
Arguments:
AppClientId - Supplies the address of ClientId of the application
thread to locate.
Return Value:
NULL - No application thread with a matching ClientId could be located.
NON-NULL - Returns the address of the application thread that
matches the specified ClientId.
--*/
{
ULONG Index;
PLIST_ENTRY Head, Next;
PDBGP_APP_THREAD AppThread;
RtlEnterCriticalSection(&DbgpHashTableLock);
Index = DBGP_THREAD_CLIENT_ID_TO_INDEX(AppClientId);
Head = &DbgpAppThreadHashTable[Index];
Next = Head->Flink;
while ( Next != Head ) {
AppThread = CONTAINING_RECORD(Next,DBGP_APP_THREAD,HashTableLinks);
if ( DBGP_CLIENT_IDS_EQUAL(
&AppThread->AppClientId,
AppClientId
)) {
RtlLeaveCriticalSection(&DbgpHashTableLock);
//DbgpDumpAppThread(AppThread);
return AppThread;
}
Next = Next->Flink;
}
RtlLeaveCriticalSection(&DbgpHashTableLock);
#if DBG
// DbgPrint("DBGSS: AppThread for %lx.%lx Not Found\n",AppClientId->UniqueProcess,AppClientId->UniqueThread);
#endif // DBG
return NULL;
}
示例3: RtlpRemoveHeapFromProcessList
/* Usermode only! */
VOID
NTAPI
RtlpRemoveHeapFromProcessList(PHEAP Heap)
{
PPEB Peb;
PHEAP *Current, *Next;
ULONG Count;
/* Get PEB */
Peb = RtlGetCurrentPeb();
/* Acquire the lock */
RtlEnterCriticalSection(&RtlpProcessHeapsListLock);
/* Check if we don't need anything to do */
if ((Heap->ProcessHeapsListIndex == 0) ||
(Heap->ProcessHeapsListIndex > Peb->NumberOfHeaps) ||
(Peb->NumberOfHeaps == 0))
{
/* Release the lock */
RtlLeaveCriticalSection(&RtlpProcessHeapsListLock);
return;
}
/* The process actually has more than one heap.
Use classic, lernt from university times algorithm for removing an entry
from a static array */
Current = (PHEAP *)&Peb->ProcessHeaps[Heap->ProcessHeapsListIndex - 1];
Next = Current + 1;
/* How many items we need to shift to the left */
Count = Peb->NumberOfHeaps - (Heap->ProcessHeapsListIndex - 1);
/* Move them all in a loop */
while (--Count)
{
/* Copy it and advance next pointer */
*Current = *Next;
/* Update its index */
(*Current)->ProcessHeapsListIndex -= 1;
/* Advance pointers */
Current++;
Next++;
}
/* Decrease total number of heaps */
Peb->NumberOfHeaps--;
/* Zero last unused item */
Peb->ProcessHeaps[Peb->NumberOfHeaps] = NULL;
Heap->ProcessHeapsListIndex = 0;
/* Release the lock */
RtlLeaveCriticalSection(&RtlpProcessHeapsListLock);
}
示例4: DbgpIsAppProcessInHashTable
PDBGP_APP_PROCESS
DbgpIsAppProcessInHashTable(
IN PCLIENT_ID AppClientId
)
/*++
Routine Description:
This routine scans the application process hash table looking for an
application process whose ClientId.UniqueOrocess field matches the
specified client id's.
If a matching application process is found, then its address is
returned.
Arguments:
AppClientId - Supplies the address of ClientId of the application
process to locate.
Return Value:
NULL - No application process with a matching ClientId could be located.
NON-NULL - Returns the address of the application process that
matches the specified ClientId.
--*/
{
ULONG Index;
PLIST_ENTRY Head, Next;
PDBGP_APP_PROCESS AppProcess;
RtlEnterCriticalSection(&DbgpHashTableLock);
Index = DBGP_PROCESS_CLIENT_ID_TO_INDEX(AppClientId);
Head = &DbgpAppProcessHashTable[Index];
Next = Head->Flink;
while ( Next != Head ) {
AppProcess = CONTAINING_RECORD(Next,DBGP_APP_PROCESS,HashTableLinks);
if ( AppProcess->AppClientId.UniqueProcess == AppClientId->UniqueProcess) {
RtlLeaveCriticalSection(&DbgpHashTableLock);
return AppProcess;
}
Next = Next->Flink;
}
RtlLeaveCriticalSection(&DbgpHashTableLock);
#if DBG
// DbgPrint("DBGSS: AppProcess for %lx.%lx Not Found\n",AppClientId->UniqueProcess,AppClientId->UniqueThread);
#endif // DBG
return NULL;
}
示例5: InitUserApiHook
BOOL
WINAPI
InitUserApiHook(HINSTANCE hInstance, USERAPIHOOKPROC pfn)
{
USERAPIHOOK uah;
ResetUserApiHook(&uah);
RtlEnterCriticalSection(&gcsUserApiHook);
if (!pfn(uahLoadInit,&uah) || // Swap data, User32 to and Uxtheme from!
uah.ForceResetUserApiHook != (FARPROC)ForceResetUserApiHook ||
uah.size <= 0 )
{
RtlLeaveCriticalSection(&gcsUserApiHook);
return FALSE;
}
if ( ghmodUserApiHook )
{
if ( ghmodUserApiHook != hInstance )
{
RtlLeaveCriticalSection(&gcsUserApiHook);
pfn(uahStop, 0);
return FALSE;
}
gcLoadUserApiHook++;
}
else
{
ghmodUserApiHook = hInstance;
// Do not over write GetRealWindowOwner.
RtlCopyMemory(&guah, &uah, sizeof(USERAPIHOOK) - sizeof(LONG));
gpfnInitUserApi = pfn;
gcLoadUserApiHook = 1;
gfUserApiHook = 1;
// Copy Message Masks
CopyMsgMask(&guah.DefWndProcArray,
&uah.DefWndProcArray,
&grgbDwpLiteHookMsg,
sizeof(grgbDwpLiteHookMsg));
CopyMsgMask(&guah.WndProcArray,
&uah.WndProcArray,
&grgbWndLiteHookMsg,
sizeof(grgbWndLiteHookMsg));
CopyMsgMask(&guah.DlgProcArray,
&uah.DlgProcArray,
&grgbDlgLiteHookMsg,
sizeof(grgbDlgLiteHookMsg));
}
RtlLeaveCriticalSection(&gcsUserApiHook);
return TRUE;
}
示例6: WWS32FindAndRemoveAsyncContext
PWINSOCK_ASYNC_CONTEXT_BLOCK
WWS32FindAndRemoveAsyncContext (
IN HANDLE AsyncTaskHandle32
)
{
PWINSOCK_ASYNC_CONTEXT_BLOCK context;
PLIST_ENTRY listEntry;
RtlEnterCriticalSection( &WWS32CriticalSection );
//
// Walk the global list of async context blocks, looking for
// one that matches the specified task handle.
//
for ( listEntry = WWS32AsyncContextBlockListHead.Flink;
listEntry != &WWS32AsyncContextBlockListHead;
listEntry = listEntry->Flink ) {
context = CONTAINING_RECORD(
listEntry,
WINSOCK_ASYNC_CONTEXT_BLOCK,
ContextBlockListEntry
);
if ( context->AsyncTaskHandle32 == AsyncTaskHandle32 ) {
//
// Found a match. Remove it from the global list, leave
// the critical section, and return the context block.
//
RemoveEntryList( &context->ContextBlockListEntry );
RtlLeaveCriticalSection( &WWS32CriticalSection );
return context;
}
}
//
// A matching context block was not found on the list.
//
RtlLeaveCriticalSection( &WWS32CriticalSection );
return NULL;
} // WWS32FindAndRemoveAsyncContext
示例7: TIME_GetBias
/***********************************************************************
* TIME_GetBias [internal]
*
* Helper function calculates delta local time from UTC.
*
* PARAMS
* utc [I] The current utc time.
* pdaylight [I] Local daylight.
*
* RETURNS
* The bias for the current timezone.
*/
static LONG TIME_GetBias(void)
{
static time_t last_utc;
static LONG last_bias;
LONG ret;
time_t utc;
utc = time( NULL );
RtlEnterCriticalSection( &TIME_tz_section );
if (utc != last_utc)
{
RTL_DYNAMIC_TIME_ZONE_INFORMATION tzi;
int is_dst = init_tz_info( &tzi );
last_utc = utc;
last_bias = tzi.Bias;
last_bias += is_dst ? tzi.DaylightBias : tzi.StandardBias;
last_bias *= SECSPERMIN;
}
ret = last_bias;
RtlLeaveCriticalSection( &TIME_tz_section );
return ret;
}
示例8: __regs_VxDCall
/***********************************************************************
* VxDCall0 (KERNEL32.1)
* VxDCall1 (KERNEL32.2)
* VxDCall2 (KERNEL32.3)
* VxDCall3 (KERNEL32.4)
* VxDCall4 (KERNEL32.5)
* VxDCall5 (KERNEL32.6)
* VxDCall6 (KERNEL32.7)
* VxDCall7 (KERNEL32.8)
* VxDCall8 (KERNEL32.9)
*/
void WINAPI __regs_VxDCall( DWORD service, CONTEXT86 *context )
{
int i;
VxDCallProc proc = NULL;
RtlEnterCriticalSection( &vxd_section );
for (i = 0; i < NB_VXD_SERVICES; i++)
{
if (HIWORD(service) != vxd_services[i].service) continue;
if (!vxd_services[i].module) /* need to load it */
{
if ((vxd_services[i].module = LoadLibraryW( vxd_services[i].name )))
vxd_services[i].proc = (VxDCallProc)GetProcAddress( vxd_services[i].module, "VxDCall" );
}
proc = vxd_services[i].proc;
break;
}
RtlLeaveCriticalSection( &vxd_section );
if (proc) context->Eax = proc( service, context );
else
{
FIXME( "Unknown/unimplemented VxD (%08x)\n", service);
context->Eax = 0xffffffff; /* FIXME */
}
}
示例9: get_vxd_proc
/* retrieve the DeviceIoControl function for a Vxd given a file handle */
static DeviceIoProc get_vxd_proc( HANDLE handle )
{
DeviceIoProc ret = NULL;
int status, i;
IO_STATUS_BLOCK io;
FILE_INTERNAL_INFORMATION info;
status = NtQueryInformationFile( handle, &io, &info, sizeof(info), FileInternalInformation );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
return NULL;
}
RtlEnterCriticalSection( &vxd_section );
for (i = 0; i < MAX_VXD_MODULES; i++)
{
if (!vxd_modules[i].module) break;
if (vxd_modules[i].index.QuadPart == info.IndexNumber.QuadPart)
{
if (!(ret = vxd_modules[i].proc)) SetLastError( ERROR_INVALID_FUNCTION );
goto done;
}
}
/* FIXME: Here we could go through the directory to find the VxD name and load it. */
/* Let's wait to find out if there are actually apps out there that try to share */
/* VxD handles between processes, before we go to the trouble of implementing it. */
ERR( "handle %p not found in module list, inherited from another process?\n", handle );
done:
RtlLeaveCriticalSection( &vxd_section );
return ret;
}
示例10: EndUserApiHook
BOOL
FASTCALL
EndUserApiHook(VOID)
{
HMODULE hModule;
USERAPIHOOKPROC pfn;
BOOL Ret = FALSE;
if ( !InterlockedDecrement(&gcCallUserApiHook) )
{
if ( !gcLoadUserApiHook )
{
RtlEnterCriticalSection(&gcsUserApiHook);
pfn = gpfnInitUserApi;
hModule = ghmodUserApiHook;
ghmodUserApiHook = NULL;
gpfnInitUserApi = NULL;
RtlLeaveCriticalSection(&gcsUserApiHook);
if ( pfn ) Ret = pfn(uahStop, 0);
if ( hModule ) Ret = FreeLibrary(hModule);
}
}
return Ret;
}
示例11: SmpCheckDuplicateMuSessionId
BOOLEAN
NTAPI
SmpCheckDuplicateMuSessionId(IN ULONG MuSessionId)
{
PSMP_SUBSYSTEM Subsystem;
BOOLEAN FoundDuplicate = FALSE;
PLIST_ENTRY NextEntry;
/* Lock the subsystem database */
RtlEnterCriticalSection(&SmpKnownSubSysLock);
/* Scan each entry */
NextEntry = SmpKnownSubSysHead.Flink;
while (NextEntry != &SmpKnownSubSysHead)
{
/* Check if this entry has the same session ID */
Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
if (Subsystem->MuSessionId == MuSessionId)
{
/* Break out of here! */
FoundDuplicate = TRUE;
break;
}
/* Keep going */
NextEntry = NextEntry->Flink;
}
/* Release the database and return the result */
RtlLeaveCriticalSection(&SmpKnownSubSysLock);
return FoundDuplicate;
}
示例12: RtlAddVectoredExceptionHandler
/*
* @implemented
*/
PVOID NTAPI
RtlAddVectoredExceptionHandler(IN ULONG FirstHandler,
IN PVECTORED_EXCEPTION_HANDLER VectoredHandler)
{
PRTL_VECTORED_EXCEPTION_HANDLER veh;
veh = RtlAllocateHeap(RtlGetProcessHeap(),
0,
sizeof(RTL_VECTORED_EXCEPTION_HANDLER));
if(veh != NULL)
{
veh->VectoredHandler = RtlEncodePointer(VectoredHandler);
veh->Refs = 1;
veh->Deleted = FALSE;
RtlEnterCriticalSection(&RtlpVectoredExceptionLock);
if(FirstHandler != 0)
{
InsertHeadList(&RtlpVectoredExceptionHead,
&veh->ListEntry);
}
else
{
InsertTailList(&RtlpVectoredExceptionHead,
&veh->ListEntry);
}
InterlockedIncrement (&RtlpVectoredExceptionsInstalled);
RtlLeaveCriticalSection(&RtlpVectoredExceptionLock);
}
return veh;
}
示例13: ConSrvFreeHandlesTable
static VOID
ConSrvFreeHandlesTable(IN PCONSOLE_PROCESS_DATA ProcessData)
{
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
if (ProcessData->HandleTable != NULL)
{
ULONG i;
/*
* ProcessData->ConsoleHandle is NULL (and the assertion fails) when
* ConSrvFreeHandlesTable is called in ConSrvConnect during the
* allocation of a new console.
*/
// ASSERT(ProcessData->ConsoleHandle);
if (ProcessData->ConsoleHandle != NULL)
{
/* Close all the console handles */
for (i = 0; i < ProcessData->HandleTableSize; i++)
{
ConSrvCloseHandle(&ProcessData->HandleTable[i]);
}
}
/* Free the handles table memory */
ConsoleFreeHeap(ProcessData->HandleTable);
ProcessData->HandleTable = NULL;
}
ProcessData->HandleTableSize = 0;
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
}
示例14: crLdrEnumerateLoadedModules
NTSTATUS WINAPI
crLdrEnumerateLoadedModules(IN BOOLEAN ReservedFlag,
IN PLDR_ENUM_CALLBACK EnumProc,
IN PVOID Context)
{
if (ReservedFlag || EnumProc == NULL) {
return STATUS_INVALID_PARAMETER;
}
if (LdrpInLdrInit) {
RtlEnterCriticalSection(&LdrpLoaderLock);
}
LIST_ENTRY *currentNode = PebLdr.InLoadOrderModuleList.Flink;
BOOLEAN stop = FALSE;
__try {
while(currentNode != &PebLdr.InLoadOrderModuleList) {
LDR_DATA_TABLE_ENTRY* entry = CONTAINING_RECORD(currentNode, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
EnumProc(entry, Context, &stop);
if (stop) {
break;
}
currentNode = currentNode->Flink;
}
}
__finally {
if (LdrpInLdrInit) {
RtlLeaveCriticalSection(&LdrpLoaderLock);
}
}
return STATUS_SUCCESS;
}
示例15: RtlpAddHeapToProcessList
/* Usermode only! */
VOID
NTAPI
RtlpAddHeapToProcessList(PHEAP Heap)
{
PPEB Peb;
/* Get PEB */
Peb = RtlGetCurrentPeb();
/* Acquire the lock */
RtlEnterCriticalSection(&RtlpProcessHeapsListLock);
//_SEH2_TRY {
/* Check if max number of heaps reached */
if (Peb->NumberOfHeaps == Peb->MaximumNumberOfHeaps)
{
// TODO: Handle this case
ASSERT(FALSE);
}
/* Add the heap to the process heaps */
Peb->ProcessHeaps[Peb->NumberOfHeaps] = Heap;
Peb->NumberOfHeaps++;
Heap->ProcessHeapsListIndex = (USHORT)Peb->NumberOfHeaps;
// } _SEH2_FINALLY {
/* Release the lock */
RtlLeaveCriticalSection(&RtlpProcessHeapsListLock);
// } _SEH2_END
}