当前位置: 首页>>代码示例>>C++>>正文


C++ RtlLeaveCriticalSection函数代码示例

本文整理汇总了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;
}
开发者ID:shuowen,项目名称:OpenNT,代码行数:31,代码来源:cmap.cpp

示例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;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:60,代码来源:dbgapsup.c

示例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);
}
开发者ID:hoangduit,项目名称:reactos,代码行数:60,代码来源:heapuser.c

示例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;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:57,代码来源:dbgapsup.c

示例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;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:55,代码来源:usrapihk.c

示例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
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:48,代码来源:wsdata.c

示例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;
}
开发者ID:kernelOfTruth,项目名称:wine,代码行数:38,代码来源:time.c

示例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 */
    }
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:37,代码来源:vxd.c

示例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;
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:35,代码来源:vxd.c

示例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;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:28,代码来源:usrapihk.c

示例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;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:32,代码来源:smsessn.c

示例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;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:34,代码来源:vectoreh.c

示例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);
}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:32,代码来源:handle.c

示例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;
}
开发者ID:cradiator,项目名称:CrMisc,代码行数:33,代码来源:LdrLoadLib.cpp

示例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
}
开发者ID:hoangduit,项目名称:reactos,代码行数:32,代码来源:heapuser.c


注:本文中的RtlLeaveCriticalSection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。