• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NtWaitForSingleObject函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NtWaitForSingleObject函数的典型用法代码示例。如果您正苦于以下问题:C++ NtWaitForSingleObject函数的具体用法?C++ NtWaitForSingleObject怎么用?C++ NtWaitForSingleObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NtWaitForSingleObject函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: DeviceInstallThread

/* Loop to install all queued devices installations */
static ULONG NTAPI
DeviceInstallThread(IN PVOID Parameter)
{
    HINF hSetupInf = *(HINF*)Parameter;
    PSLIST_ENTRY ListEntry;
    DeviceInstallParams* Params;
    LARGE_INTEGER Timeout;

    for (;;)
    {
        ListEntry = RtlInterlockedPopEntrySList(&DeviceInstallListHead);

        if (ListEntry == NULL)
        {
            /*
             * The list is now empty, but there may be a new enumerated device
             * that is going to be added to the list soon. In order to avoid
             * setting the hNoPendingInstalls event to release it soon after,
             * we wait for maximum 1 second for no PnP enumeration event being
             * received before declaring that no pending installations are
             * taking place and setting the corresponding event.
             */
            Timeout.QuadPart = -10000000LL; /* Wait for 1 second */
            if (NtWaitForSingleObject(hDeviceInstallListNotEmpty, FALSE, &Timeout) == STATUS_TIMEOUT)
            {
                /* We timed out: set the event and do the actual wait */
                NtSetEvent(hNoPendingInstalls, NULL);
                NtWaitForSingleObject(hDeviceInstallListNotEmpty, FALSE, NULL);
            }
        }
        else
        {
            NtResetEvent(hNoPendingInstalls, NULL);
            Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
            InstallDevice(hSetupInf, hEnumKey, hServicesKey, Params->DeviceIds);
            RtlFreeHeap(ProcessHeap, 0, Params);
        }
    }

    return 0;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:42,代码来源:devinst.c


示例2: WaitForSingleObjectEx

/*
 * @implemented
 */
DWORD
WINAPI
WaitForSingleObjectEx(IN HANDLE hHandle,
                      IN DWORD dwMilliseconds,
                      IN BOOL bAlertable)
{
    PLARGE_INTEGER TimePtr;
    LARGE_INTEGER Time;
    NTSTATUS Status;
    RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActCtx;

    /* APCs must execute with the default activation context */
    if (bAlertable)
    {
        /* Setup the frame */
        RtlZeroMemory(&ActCtx, sizeof(ActCtx));
        ActCtx.Size = sizeof(ActCtx);
        ActCtx.Format = RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER;
        RtlActivateActivationContextUnsafeFast(&ActCtx, NULL);
    }

    /* Get real handle */
    hHandle = TranslateStdHandle(hHandle);

    /* Check for console handle */
    if ((IsConsoleHandle(hHandle)) && (VerifyConsoleIoHandle(hHandle)))
    {
        /* Get the real wait handle */
        hHandle = GetConsoleInputWaitHandle();
    }

    /* Convert the timeout */
    TimePtr = BaseFormatTimeOut(&Time, dwMilliseconds);

    /* Start wait loop */
    do
    {
        /* Do the wait */
        Status = NtWaitForSingleObject(hHandle, (BOOLEAN)bAlertable, TimePtr);
        if (!NT_SUCCESS(Status))
        {
            /* The wait failed */
            BaseSetLastNTError(Status);
            Status = WAIT_FAILED;
        }
    } while ((Status == STATUS_ALERTED) && (bAlertable));

    /* Cleanup the activation context */
    if (bAlertable) RtlDeactivateActivationContextUnsafeFast(&ActCtx);

    /* Return wait status */
    return Status;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:56,代码来源:synch.c


示例3: LockFile

/*
 * @implemented
 */
BOOL
WINAPI
LockFile(IN HANDLE hFile,
         IN DWORD dwFileOffsetLow,
         IN DWORD dwFileOffsetHigh,
         IN DWORD nNumberOfBytesToLockLow,
         IN DWORD nNumberOfBytesToLockHigh)
{
    IO_STATUS_BLOCK IoStatusBlock;
    NTSTATUS Status;
    LARGE_INTEGER BytesToLock, Offset;

    /* Is this a console handle? */
    if (IsConsoleHandle(hFile))
    {
        /* Can't "lock" a console! */
        BaseSetLastNTError(STATUS_INVALID_HANDLE);
        return FALSE;
    }

    /* Setup the parameters in NT style and call the native API */
    BytesToLock.u.LowPart = nNumberOfBytesToLockLow;
    BytesToLock.u.HighPart = nNumberOfBytesToLockHigh;
    Offset.u.LowPart = dwFileOffsetLow;
    Offset.u.HighPart = dwFileOffsetHigh;
    Status = NtLockFile(hFile,
                        NULL,
                        NULL,
                        NULL,
                        &IoStatusBlock,
                        &Offset,
                        &BytesToLock,
                        0,
                        TRUE,
                        TRUE);
    if (Status == STATUS_PENDING)
    {
        /* Wait for completion if needed */
        Status = NtWaitForSingleObject(hFile, FALSE, NULL);
        if (NT_SUCCESS(Status)) Status = IoStatusBlock.Status;
    }

    /* Check if we failed */
    if (!NT_SUCCESS(Status))
    {
        /* Convert the error code and fail */
        BaseSetLastNTError(Status);
        return FALSE;
    }

    /* Success! */
    return TRUE;
}
开发者ID:GYGit,项目名称:reactos,代码行数:56,代码来源:lock.c


示例4: IHF_ActiveDetachProcess

IHFSERVICE DWORD IHFAPI IHF_ActiveDetachProcess(DWORD pid)
{
	DWORD module, engine, dwWrite;
	HANDLE hProc, hThread, hCmd;	
	IO_STATUS_BLOCK ios;
	//man->LockHookman();
	ProcessRecord* pr = man->GetProcessRecord(pid);
	hCmd = man->GetCmdHandleByPID(pid);
	if (pr == 0 || hCmd == 0) return FALSE;
	//hProc = pr->process_handle; //This handle may be closed(thus invalid) during the detach process.
	NtDuplicateObject(NtCurrentProcess(), pr->process_handle, 
		NtCurrentProcess(), &hProc, 0, 0, DUPLICATE_SAME_ACCESS); //Make a copy of the process handle.
	module = pr->module_register;
	if (module == 0) return FALSE;
	engine = pr->engine_register;
	engine &= ~0xFF;
	SendParam sp = {};
	sp.type = 4;
	NtWriteFile(hCmd, 0,0,0, &ios, &sp, sizeof(SendParam),0,0);
	//cmdq->AddRequest(sp, pid);
	dwWrite = 0x1000;
	hThread = IthCreateThread(LdrUnloadDll, engine, hProc);
	if (hThread == 0 || 
		hThread == INVALID_HANDLE_VALUE) return FALSE;
	NtWaitForSingleObject(hThread, 0, 0);
	NtClose(hThread);
	hThread = IthCreateThread(LdrUnloadDll, module, hProc);
	if (hThread == 0 ||
		hThread == INVALID_HANDLE_VALUE) return FALSE;
	NtWaitForSingleObject(hThread, 0, 0);
	//man->UnlockHookman();
	THREAD_BASIC_INFORMATION info;
	NtQueryInformationThread(hThread, ThreadBasicInformation, &info, sizeof(info), 0);					
	NtClose(hThread);
	NtSetEvent(hPipeExist, 0);
	FreeThreadStart(hProc);
	NtClose(hProc);
	dwWrite = 0x1000;
	return info.ExitStatus;
}
开发者ID:Alex12235,项目名称:interactive-text-hooker,代码行数:40,代码来源:main.cpp


示例5: PhpTailQueryObjectHack

NTSTATUS PhpTailQueryObjectHack(
    __out_opt PULONG ReturnLength
    )
{
    NTSTATUS status;
    LARGE_INTEGER timeout;

    PhQueryObjectContext.Initialized = TRUE;

    // Allow the worker thread to start.
    NtSetEvent(PhQueryObjectStartEvent, NULL);
    // Wait for the work to complete, with a timeout of 1 second.
    timeout.QuadPart = -1000 * PH_TIMEOUT_MS;
    status = NtWaitForSingleObject(PhQueryObjectCompletedEvent, FALSE, &timeout);

    PhQueryObjectContext.Initialized = FALSE;

    // Return normally if the work was completed.
    if (status == STATUS_WAIT_0)
    {
        ULONG returnLength;

        status = PhQueryObjectContext.Status;
        returnLength = PhQueryObjectContext.ReturnLength;

        PhReleaseQueuedLockExclusive(&PhQueryObjectMutex);

        if (ReturnLength)
            *ReturnLength = returnLength;

        return status;
    }
    // Kill the worker thread if it took too long.
    // else if (status == STATUS_TIMEOUT)
    else
    {
        // Kill the thread.
        if (NT_SUCCESS(NtTerminateThread(PhQueryObjectThreadHandle, STATUS_TIMEOUT)))
        {
            PhQueryObjectThreadHandle = NULL;

            // Delete the fiber (and free the thread stack).
            DeleteFiber(PhQueryObjectFiber);
            PhQueryObjectFiber = NULL;
        }

        PhReleaseQueuedLockExclusive(&PhQueryObjectMutex);

        return STATUS_UNSUCCESSFUL;
    }
}
开发者ID:john-peterson,项目名称:processhacker,代码行数:51,代码来源:hndlinfo.c


示例6: PhpWfsoThreadStart

static NTSTATUS PhpWfsoThreadStart(
    _In_ PVOID Parameter
    )
{
    HANDLE eventHandle;
    LARGE_INTEGER timeout;

    eventHandle = Parameter;

    timeout.QuadPart = -(LONGLONG)UInt32x32To64(5, PH_TIMEOUT_SEC);
    NtWaitForSingleObject(eventHandle, FALSE, &timeout);

    return STATUS_SUCCESS;
}
开发者ID:PKRoma,项目名称:ProcessHacker,代码行数:14,代码来源:anawait.c


示例7: ClearDumpInfo

void ClearDumpInfo (void)
{
    NTSTATUS   Status;


    //
    // Pause profiling?
    //
    if (fPause) {
	Status = NtPulseEvent (hPauseEvent, NULL);
        if (!NT_SUCCESS(Status)) {
            fprintf (pfLog, "WSTDUMP: ClearDumpInfo () - NtPulseEvent() "
			    "failed for PAUSE event - %lx\n", Status);
            exit (1);
        }
    }
    //
    // Dump data?
    //
    else if (fDump) {
        Status = NtPulseEvent (hDumpEvent, NULL);
        if (!NT_SUCCESS(Status)) {
            fprintf (pfLog, "WSTDUMP: ClearDumpInfo () - NtPulseEvent() "
                            "failed for DUMP event - %lx\n", Status);
            exit (1);
        }
    }
    //
    // Clear data?
    //
    else if (fClear) {
        Status = NtPulseEvent (hClearEvent, NULL);
        if (!NT_SUCCESS(Status)) {
            fprintf (pfLog, "WSTDUMP: ClearDumpInfo () - NtPulseEvent() "
                            "failed for CLEAR event - %lx\n", Status);
            exit (1);
        }
    }
    //
	// Wait for the DONE event..
    //
	Sleep (500);
	Status = NtWaitForSingleObject (hDoneEvent, FALSE, NULL);
    if (!NT_SUCCESS(Status)) {
        fprintf (pfLog, "WSTDUMP: ClearDumpInfo () - NtWaitForSingleObject() "
                        "failed for DONE event - %lx\n", Status);
        exit (1);
    }

} /* ClearDumpInfo() */
开发者ID:mingpen,项目名称:OpenNT,代码行数:50,代码来源:wstdump.c


示例8: UpdateDotNetTraceInfoWithTimeout

ULONG UpdateDotNetTraceInfoWithTimeout(
    __in PASMPAGE_CONTEXT Context,
    __in BOOLEAN ClrV2,
    __in_opt PLARGE_INTEGER Timeout
    )
{
    HANDLE threadHandle;

    // ProcessDotNetTrace is not guaranteed to complete within any period of time, because
    // the target process might terminate before it writes the DCStartComplete_V1 event.
    // If the timeout is reached, the trace handle is closed, forcing ProcessTrace to stop
    // processing.

    Context->TraceClrV2 = ClrV2;
    Context->TraceResult = 0;
    Context->TraceHandleActive = 0;
    Context->TraceHandle = 0;

    threadHandle = PhCreateThread(0, UpdateDotNetTraceInfoThreadStart, Context);

    if (NtWaitForSingleObject(threadHandle, FALSE, Timeout) != STATUS_WAIT_0)
    {
        // Timeout has expired. Stop the trace processing if it's still active.
        // BUG: This assumes that the thread is in ProcessTrace. It might still be
        // setting up though!
        if (_InterlockedExchange(&Context->TraceHandleActive, 0) == 1)
        {
            CloseTrace(Context->TraceHandle);
        }

        NtWaitForSingleObject(threadHandle, FALSE, NULL);
    }

    NtClose(threadHandle);

    return Context->TraceResult;
}
开发者ID:john-peterson,项目名称:processhacker,代码行数:37,代码来源:asmpage.c


示例9: FsRtlpRegisterProviderWithMUP

NTSTATUS
FsRtlpRegisterProviderWithMUP(IN HANDLE MupHandle,
                              IN PCUNICODE_STRING RedirectorDeviceName,
                              IN BOOLEAN MailslotsSupported)
{
    NTSTATUS Status;
    ULONG BufferSize;
    IO_STATUS_BLOCK IoStatusBlock;
    PMUP_PROVIDER_REGISTRATION_INFO RegistrationInfo;

    PAGED_CODE();

    DPRINT1("FsRtlpRegisterProviderWithMUP(%p, %wZ, %u)\n", (PVOID)MupHandle, RedirectorDeviceName, MailslotsSupported);

    /* We have to be able to store the name and the registration information */
    BufferSize = RedirectorDeviceName->Length + sizeof(MUP_PROVIDER_REGISTRATION_INFO);
    RegistrationInfo = ExAllocatePoolWithTag(NonPagedPool, BufferSize, TAG_UNC);
    if (RegistrationInfo == NULL)
    {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    /* Set the information about the provider (including its name) */
    RegistrationInfo->RedirectorDeviceNameOffset = sizeof(MUP_PROVIDER_REGISTRATION_INFO);
    RegistrationInfo->RedirectorDeviceNameLength = RedirectorDeviceName->Length;
    RegistrationInfo->MailslotsSupported = MailslotsSupported;
    RtlCopyMemory((PWSTR)((ULONG_PTR)RegistrationInfo + RegistrationInfo->RedirectorDeviceNameOffset),
                  RedirectorDeviceName->Buffer, RedirectorDeviceName->Length);

    /* Call MUP with the registration FSCTL */
    Status = NtFsControlFile(MupHandle, NULL, NULL, NULL,
                             &IoStatusBlock, FSCTL_MUP_REGISTER_PROVIDER,
                             RegistrationInfo, BufferSize, NULL, 0);
    if (Status == STATUS_PENDING)
    {
        Status = NtWaitForSingleObject(MupHandle, TRUE, NULL);
    }

    if (NT_SUCCESS(Status))
    {
        Status = IoStatusBlock.Status;
    }

    /* And we're done! */
    ASSERT(NT_SUCCESS(Status));
    ExFreePoolWithTag(RegistrationInfo, TAG_UNC);

    return Status;
}
开发者ID:GYGit,项目名称:reactos,代码行数:49,代码来源:unc.c


示例10: IHF_ModifyHook

IHFSERVICE DWORD IHFAPI IHF_ModifyHook(DWORD pid, HookParam* hp)
{
	SendParam sp;
	HANDLE hModify,hCmd;
	hCmd = GetCmdHandleByPID(pid);
	if (hCmd == 0) return -1;
	hModify = IthCreateEvent(L"ITH_MODIFY_HOOK");
	sp.type = IHF_COMMAND_MODIFY_HOOK;
	sp.hp = *hp;
	IO_STATUS_BLOCK ios;
	if (NT_SUCCESS(NtWriteFile(hCmd, 0,0,0, &ios, &sp, sizeof(SendParam), 0, 0)))
		NtWaitForSingleObject(hModify, 0, 0);
	NtClose(hModify);
	man -> RemoveSingleHook(pid, sp.hp.addr);
	return 0;
}
开发者ID:Alex12235,项目名称:interactive-text-hooker,代码行数:16,代码来源:main.cpp


示例11: RtlClipWaitForInput

/*++
 * @name RtlClipWaitForInput
 *
 * The RtlClipWaitForInput routine waits for input from an input device.
 *
 * @param hDriver
 *        Handle of the driver/device to get input from.
 *
 * @param Buffer
 *        Input buffer.
 *
 * @param BufferSize
 *        Size of the input buffer.
 *
 * @return STATUS_SUCCESS or error code from the read operation.
 *
 * @remarks This routine waits for input to be available.
 *
 *--*/
NTSTATUS
RtlClipWaitForInput(IN HANDLE hDriver,
                    IN PVOID Buffer,
                    IN OUT PULONG BufferSize)
{
    IO_STATUS_BLOCK Iosb;
    LARGE_INTEGER ByteOffset;
    NTSTATUS Status;

    //
    // Clean up the I/O Status block and read from byte 0
    //
    RtlZeroMemory(&Iosb, sizeof(Iosb));
    RtlZeroMemory(&ByteOffset, sizeof(ByteOffset));

    //
    // Try to read the data
    //
    Status = NtReadFile(hDriver,
                        hEvent,
                        NULL,
                        NULL,
                        &Iosb,
                        Buffer,
                        *BufferSize,
                        &ByteOffset,
                        NULL);

    //
    // Check if data is pending
    //
    if (Status == STATUS_PENDING)
    {
        //
        // Wait on the data to be read
        //
        Status = NtWaitForSingleObject(hEvent, TRUE, NULL);
    }

    //
    // Return status and how much data was read
    //
    *BufferSize = (ULONG)Iosb.Information;
    return Status;
}
开发者ID:aaam,项目名称:NativeShell,代码行数:64,代码来源:input.c


示例12: WeLockServerSharedData

BOOLEAN WeLockServerSharedData(
    __out PWE_HOOK_SHARED_DATA *Data
    )
{
    LARGE_INTEGER timeout;

    if (!WeServerSharedSectionLock)
        return FALSE;

    timeout.QuadPart = -WE_CLIENT_MESSAGE_TIMEOUT * PH_TIMEOUT_MS;

    if (NtWaitForSingleObject(WeServerSharedSectionLock, FALSE, &timeout) != WAIT_OBJECT_0)
        return FALSE;

    *Data = WeServerSharedData;

    return TRUE;
}
开发者ID:john-peterson,项目名称:processhacker,代码行数:18,代码来源:hook.c


示例13: IHF_RemoveHook

IHFSERVICE DWORD IHFAPI IHF_RemoveHook(DWORD pid, DWORD addr)
{

	HANDLE hRemoved,hCmd;
	hCmd = GetCmdHandleByPID(pid);
	if (hCmd == 0) return -1;
	hRemoved = IthCreateEvent(L"ITH_REMOVE_HOOK");
	SendParam sp = {};
	IO_STATUS_BLOCK ios;
	sp.type = IHF_COMMAND_REMOVE_HOOK;
	sp.hp.addr = addr;
	//cmdq -> AddRequest(sp, pid);
	NtWriteFile(hCmd, 0,0,0, &ios, &sp, sizeof(SendParam),0,0);
	NtWaitForSingleObject(hRemoved, 0, 0);
	NtClose(hRemoved);
	man -> RemoveSingleHook(pid, sp.hp.addr);
	return 0;
}
开发者ID:Alex12235,项目名称:interactive-text-hooker,代码行数:18,代码来源:main.cpp


示例14: ReadConsoleInput

BOOL
WINAPI
ReadConsoleInput(
    IN HANDLE hConsoleInput,
    OUT PINPUT_RECORD lpBuffer,
    IN DWORD nLength,
    OUT LPDWORD lpNumberOfEventsRead)
{
    LARGE_INTEGER Offset;
    IO_STATUS_BLOCK IoStatusBlock;
    KEYBOARD_INPUT_DATA InputData;
    NTSTATUS Status;

    Offset.QuadPart = 0;
    Status = NtReadFile(hConsoleInput,
                        NULL,
                        NULL,
                        NULL,
                        &IoStatusBlock,
                        &InputData,
                        sizeof(KEYBOARD_INPUT_DATA),
                        &Offset,
                        0);
    if (Status == STATUS_PENDING)
    {
        Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
        Status = IoStatusBlock.Status;
    }
    if (!NT_SUCCESS(Status))
        return FALSE;

    lpBuffer->EventType = KEY_EVENT;
    Status = IntTranslateKey(&InputData, &lpBuffer->Event.KeyEvent);
    if (!NT_SUCCESS(Status))
        return FALSE;

    *lpNumberOfEventsRead = 1;
    return TRUE;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:39,代码来源:console.c


示例15: GetAddrEntries

static
NTSTATUS
GetAddrEntries(
    _In_ HANDLE TcpFile,
    _In_ TDIEntityID InterfaceID,
    _Out_ IPAddrEntry* Entries,
    _In_ ULONG NumEntries)
{
    TCP_REQUEST_QUERY_INFORMATION_EX TcpQueryInfo;
    IO_STATUS_BLOCK StatusBlock;
    NTSTATUS Status;

    ZeroMemory(&TcpQueryInfo, sizeof(TcpQueryInfo));
    TcpQueryInfo.ID.toi_class = INFO_CLASS_PROTOCOL;
    TcpQueryInfo.ID.toi_type = INFO_TYPE_PROVIDER;
    TcpQueryInfo.ID.toi_id = IP_MIB_ADDRTABLE_ENTRY_ID;
    TcpQueryInfo.ID.toi_entity = InterfaceID;

    Status = NtDeviceIoControlFile(
        TcpFile,
        NULL,
        NULL,
        NULL,
        &StatusBlock,
        IOCTL_TCP_QUERY_INFORMATION_EX,
        &TcpQueryInfo,
        sizeof(TcpQueryInfo),
        Entries,
        NumEntries * sizeof(Entries[0]));
    if (Status == STATUS_PENDING)
    {
        /* So we have to wait a bit */
        Status = NtWaitForSingleObject(TcpFile, FALSE, NULL);
        if (NT_SUCCESS(Status))
            Status = StatusBlock.Status;
    }

    return Status;
}
开发者ID:oneminot,项目名称:reactos,代码行数:39,代码来源:address.c


示例16: XWriteFile

int XWriteFile(
	int handle, 
	void *buffer,
	unsigned int numberOfBytesToWrite,
	unsigned int *numberOfBytesWritten)
{
	IO_STATUS_BLOCK ioStatusBlock;
	NTSTATUS        status;

#ifdef DEBUG
	debugPrint("XWriteFile handle=%08x numberOfBytesToWrite=%08x\n", handle, numberOfBytesToWrite);
#endif

	if(numberOfBytesWritten)
		*numberOfBytesWritten = 0;
	
	status = NtWriteFile(
		(void*)handle,
		NULL,
		NULL,
		NULL,
		&ioStatusBlock,
		buffer,
		numberOfBytesToWrite,
		NULL);
	
	if (status == STATUS_PENDING)
		status = NtWaitForSingleObject((void*)handle, FALSE, NULL);
	
	if (!NT_SUCCESS(status))
		return RtlNtStatusToDosError(status);
	else
	{
		if (numberOfBytesWritten)
			*numberOfBytesWritten = (unsigned int)ioStatusBlock.Information;

		return STATUS_SUCCESS;
	}
}
开发者ID:vrichomme,项目名称:posix4msvc,代码行数:39,代码来源:nt_fileio.c


示例17: EnableUserModePnpManager

BOOLEAN
EnableUserModePnpManager(VOID)
{
    LARGE_INTEGER Timeout;

    /* Start the PnP thread */
    if (hPnpThread != NULL)
        NtResumeThread(hPnpThread, NULL);

    /*
     * Wait a little bit so that we get a chance to have some events being
     * queued by the time the device-installation thread becomes resumed.
     */
    Timeout.QuadPart = -10000000LL; /* Wait for 1 second */
    NtWaitForSingleObject(hDeviceInstallListNotEmpty, FALSE, &Timeout);

    /* Start the device installation thread */
    if (hDeviceInstallThread != NULL)
        NtResumeThread(hDeviceInstallThread, NULL);

    return TRUE;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:22,代码来源:devinst.c


示例18: XReadFile

int XReadFile(
	int handle,
	void *buffer,
	unsigned int numberOfBytesToRead,
	unsigned int *numberOfBytesRead)
{
	IO_STATUS_BLOCK ioStatusBlock;
	NTSTATUS        status;

#ifdef DEBUG
	debugPrint("XReadFile handle=%08x numberOfBytesToRead=%08x\n", handle, numberOfBytesToRead);
#endif
	
	if (numberOfBytesRead)
		*numberOfBytesRead = 0;
	
	status = NtReadFile(
		(void*)handle,
		NULL,
		NULL,
		NULL,
		(void*)&ioStatusBlock,
		(void*)buffer,
		numberOfBytesToRead,
		NULL);
	
	if (status == STATUS_SUCCESS)
		status = NtWaitForSingleObject((void*)handle, FALSE, (void*)NULL);
	
	if (!NT_SUCCESS(status))
		return RtlNtStatusToDosError(status);
	else
	{
		if (numberOfBytesRead)
			*numberOfBytesRead = (unsigned int)ioStatusBlock.Information;
		return STATUS_SUCCESS;
	}
}
开发者ID:vrichomme,项目名称:posix4msvc,代码行数:38,代码来源:nt_fileio.c


示例19: GetInterfaceEntry

/*
 * Fills the IFEntry buffer from tcpip.sys.
 * The buffer size MUST be FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1]).
 * See MSDN IFEntry struct definition if you don't believe me. ;-)
 */
static
NTSTATUS
GetInterfaceEntry(
    _In_ HANDLE TcpFile,
    _In_ TDIEntityID InterfaceID,
    _Out_ IFEntry* Entry)
{
    TCP_REQUEST_QUERY_INFORMATION_EX TcpQueryInfo;
    IO_STATUS_BLOCK StatusBlock;
    NTSTATUS Status;

    ZeroMemory(&TcpQueryInfo, sizeof(TcpQueryInfo));
    TcpQueryInfo.ID.toi_class = INFO_CLASS_PROTOCOL;
    TcpQueryInfo.ID.toi_type = INFO_TYPE_PROVIDER;
    TcpQueryInfo.ID.toi_id = IP_MIB_STATS_ID;
    TcpQueryInfo.ID.toi_entity = InterfaceID;

    Status = NtDeviceIoControlFile(
        TcpFile,
        NULL,
        NULL,
        NULL,
        &StatusBlock,
        IOCTL_TCP_QUERY_INFORMATION_EX,
        &TcpQueryInfo,
        sizeof(TcpQueryInfo),
        Entry,
        FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1]));
    if (Status == STATUS_PENDING)
    {
        /* So we have to wait a bit */
        Status = NtWaitForSingleObject(TcpFile, FALSE, NULL);
        if (NT_SUCCESS(Status))
            Status = StatusBlock.Status;
    }

    return Status;
}
开发者ID:oneminot,项目名称:reactos,代码行数:43,代码来源:address.c


示例20: ThreadProc1

static DWORD WINAPI
ThreadProc1(LPVOID parm)
{
    LARGE_INTEGER waittime;
    NTSTATUS res;
    HANDLE e;
    GET_NTDLL(NtWaitForSingleObject,
              (IN HANDLE ObjectHandle, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut));
    print("starting thread...\n");

    e = CreateEvent(NULL, FALSE, FALSE, "foo");
    waittime.QuadPart = -((int)500 * TIMER_UNITS_PER_MILLISECOND);
    control = 1;
    do {
        res = NtWaitForSingleObject(e, false /* not alertable */, &waittime);
    } while (control);
    __asm {
        mov   reg_eax, eax
        mov   reg_ebx, ebx
        mov   reg_ecx, ecx
        mov   reg_edx, edx
        mov   reg_edi, edi
        mov   reg_esi, esi
        mov   reg_esp, esp
        mov   reg_ebp, ebp
    }
    print("res is " PFMT " but shouldn't get here!!!\n", res);
#if VERBOSE
    print("registers: " PFMT " " PFMT " " PFMT " " PFMT " " PFMT " " PFMT " " PFMT
          " " PFMT "\n",
          reg_eax, reg_ebx, reg_ecx, reg_edx, reg_edi, reg_esi, reg_esp, reg_ebp);
#endif
    CloseHandle(e);

    print("exiting thread\n");
    return -1;
}
开发者ID:djmott,项目名称:dynamorio,代码行数:37,代码来源:setcxtsyscall.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Null函数代码示例发布时间:2022-05-30
下一篇:
C++ NtUnmapViewOfSection函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap