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


C++ NT_ASSERT函数代码示例

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


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

示例1: UfxDevice_EvtDeviceSuperSpeedPowerFeature

VOID
UfxDevice_EvtDeviceSuperSpeedPowerFeature (
    _In_ UFXDEVICE Device,
    _In_ USHORT Feature,
    _In_ BOOLEAN Set
    )
/*++

Routine Description:

    EvtDeviceSuperSpeedPowerFeature handler for the UFXDEVICE object.
    
    Handles a set or clear U1/U2 request from the host.  

Arguments:

    UfxDevice - UFXDEVICE object representing the device.

    Feature - Indicates the feature being set or cleared.  Either U1 or U2 enable.

    Set - Indicates if the feature should be set or cleared
    
--*/
{
    TraceEntry();

    if (Feature == USB_FEATURE_U1_ENABLE) {
        if (Set == TRUE) {
            //
            // #### TODO: Insert code to initiate U1  ####
            //
        } else {
            //
            // #### TODO: Insert code to exit U1 ####
            //
        }
    } else if (Feature == USB_FEATURE_U2_ENABLE) {
        if (Set == TRUE) {
            //
            // #### TODO: Insert code to initiate U2 ####
            //
        } else {
            //
            // #### TODO: Insert code to exit U2 ####
            //
        }
    } else {
        NT_ASSERT(FALSE);
    }

    UfxDeviceEventComplete(Device, STATUS_SUCCESS);
    TraceExit();
}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:53,代码来源:ufxdevice.c

示例2: CompleteBasicPacketModification

_IRQL_requires_same_
VOID CompleteBasicPacketModification(_In_ VOID* pContext,
                                     _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                     _In_ BOOLEAN dispatchLevel)
{
#if DBG

   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " ---> CompleteBasicPacketModification()\n");

#endif /// DBG

   UNREFERENCED_PARAMETER(dispatchLevel);

   NT_ASSERT(pContext);
   NT_ASSERT(pNetBufferList);
   NT_ASSERT(NT_SUCCESS(pNetBufferList->Status));

   if(pNetBufferList->Status != STATUS_SUCCESS)
      DbgPrintEx(DPFLTR_IHVNETWORK_ID,
                 DPFLTR_ERROR_LEVEL,
                 " !!!! CompleteBasicPacketModification() [status: %#x]\n",
                 pNetBufferList->Status);

   FwpsFreeCloneNetBufferList(pNetBufferList,
                              0);

   BasicPacketModificationCompletionDataDestroy((BASIC_PACKET_MODIFICATION_COMPLETION_DATA**)&pContext);

#if DBG

   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " <--- CompleteBasicPacketModification()\n");

#endif /// DBG

   return;
}
开发者ID:Realhram,项目名称:wdk81,代码行数:40,代码来源:CompletionFunctions_BasicPacketModificationCallouts.cpp

示例3: LogpBufferMessage

// Buffer the log entry to the log buffer.
_Use_decl_annotations_ static NTSTATUS LogpBufferMessage(const char *message,
                                                         LogBufferInfo *info) {
  NT_ASSERT(info);

  // Acquire a spin lock to add the log safely.
  KLOCK_QUEUE_HANDLE lock_handle = {};
  const auto old_irql = KeGetCurrentIrql();
  if (old_irql < DISPATCH_LEVEL) {
    KeAcquireInStackQueuedSpinLock(&info->spin_lock, &lock_handle);
  } else {
    KeAcquireInStackQueuedSpinLockAtDpcLevel(&info->spin_lock, &lock_handle);
  }
  NT_ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);

  // Copy the current log to the buffer.
  SIZE_T used_buffer_size = info->log_buffer_tail - info->log_buffer_head;
  auto status =
      RtlStringCchCopyA(const_cast<char *>(info->log_buffer_tail),
                        kLogpBufferUsableSize - used_buffer_size, message);

  // Update info.log_max_usage if necessary.
  if (NT_SUCCESS(status)) {
    const auto message_length = strlen(message) + 1;
    info->log_buffer_tail += message_length;
    used_buffer_size += message_length;
    if (used_buffer_size > info->log_max_usage) {
      info->log_max_usage = used_buffer_size;  // Update
    }
  } else {
    info->log_max_usage = kLogpBufferSize;  // Indicates overflow
  }
  *info->log_buffer_tail = '\0';

  if (old_irql < DISPATCH_LEVEL) {
    KeReleaseInStackQueuedSpinLock(&lock_handle);
  } else {
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&lock_handle);
  }
  return status;
}
开发者ID:JulianVolodia,项目名称:HyperPlatform,代码行数:41,代码来源:log.cpp

示例4: LogpIsLogFileEnabled

// Returns true when a log file is enabled.
EXTERN_C static bool LogpIsLogFileEnabled(_In_ const LogBufferInfo &Info) {
  if (Info.LogFileHandle) {
    NT_ASSERT(Info.LogBuffer1);
    NT_ASSERT(Info.LogBuffer2);
    NT_ASSERT(Info.LogBufferHead);
    NT_ASSERT(Info.LogBufferTail);
    return true;
  }
  NT_ASSERT(!Info.LogBuffer1);
  NT_ASSERT(!Info.LogBuffer2);
  NT_ASSERT(!Info.LogBufferHead);
  NT_ASSERT(!Info.LogBufferTail);
  return false;
}
开发者ID:2016Sun,项目名称:RemoteWriteMonitor,代码行数:15,代码来源:log.cpp

示例5: otPlatSettingsDelete

otError otPlatSettingsDelete(otInstance *otCtx, uint16_t aKey, int aIndex)
{
    NT_ASSERT(otCtx);
    PMS_FILTER pFilter = otCtxToFilter(otCtx);

    NTSTATUS status =
        FilterDeleteSetting(
            pFilter,
            aKey,
            aIndex);

    return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
}
开发者ID:abtink,项目名称:openthread,代码行数:13,代码来源:settings.c

示例6: UnsafeSetBitmapBits

BOOL
NTAPI
UnsafeSetBitmapBits(
    _Inout_ PSURFACE psurf,
    _In_ ULONG cjBits,
    _In_ const VOID *pvBits)
{
    PUCHAR pjDst;
    const UCHAR *pjSrc;
    LONG lDeltaDst, lDeltaSrc;
    ULONG nWidth, nHeight, cBitsPixel;
    NT_ASSERT(psurf->flags & API_BITMAP);
    NT_ASSERT(psurf->SurfObj.iBitmapFormat <= BMF_32BPP);

    nWidth = psurf->SurfObj.sizlBitmap.cx;
    nHeight = psurf->SurfObj.sizlBitmap.cy;
    cBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);

    /* Get pointers */
    pjDst = psurf->SurfObj.pvScan0;
    pjSrc = pvBits;
    lDeltaDst = psurf->SurfObj.lDelta;
    lDeltaSrc = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
    NT_ASSERT(lDeltaSrc <= abs(lDeltaDst));

    /* Make sure the buffer is large enough*/
    if (cjBits < (lDeltaSrc * nHeight))
        return FALSE;

    while (nHeight--)
    {
        /* Copy one line */
        memcpy(pjDst, pjSrc, lDeltaSrc);
        pjSrc += lDeltaSrc;
        pjDst += lDeltaDst;
    }

    return TRUE;
}
开发者ID:GYGit,项目名称:reactos,代码行数:39,代码来源:bitmaps.c

示例7: VmpStartVm

// Virtualize the current processor
_Use_decl_annotations_ static NTSTATUS VmpStartVm(void *context) {
  PAGED_CODE();

  HYPERPLATFORM_LOG_INFO("Initializing VMX for the processor %d.",
                         KeGetCurrentProcessorNumberEx(nullptr));
  const auto ok = AsmInitializeVm(VmpInitializeVm, context);
  NT_ASSERT(VmpIsHyperPlatformInstalled() == ok);
  if (!ok) {
    return STATUS_UNSUCCESSFUL;
  }
  HYPERPLATFORM_LOG_INFO("Initialized successfully.");
  return STATUS_SUCCESS;
}
开发者ID:N3mes1s,项目名称:HyperPlatform,代码行数:14,代码来源:vm.cpp

示例8: KrnlHlprDPCQueue

NTSTATUS KrnlHlprDPCQueue(_In_ KDEFERRED_ROUTINE* pDPCFn)
{
#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " ---> KrnlHlprDPCQueue()\n");

#endif /// DBG
   
   NT_ASSERT(pDPCFn);

   NTSTATUS  status   = STATUS_SUCCESS;
   DPC_DATA* pDPCData = 0;

   HLPR_NEW(pDPCData,
            DPC_DATA,
            WFPSAMPLER_SYSLIB_TAG);
   HLPR_BAIL_ON_ALLOC_FAILURE(pDPCData,
                              status);

   KeInitializeDpc(&(pDPCData->kdpc),
                   pDPCFn,
                   0);

   KeInsertQueueDpc(&(pDPCData->kdpc),
                    pDPCData,
                    0);

   HLPR_BAIL_LABEL:

#pragma warning(push)
#pragma warning(disable: 6001) /// pDPCData initialized with call to HLPR_NEW 

   if(status != STATUS_SUCCESS &&
      pDPCData)
      KrnlHlprDPCDataDestroy(&pDPCData);

#pragma warning(pop)

#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " <--- KrnlHlprDPCQueue() [status: %#x]\n",
              status);

#endif /// DBG
   
   return status;
}
开发者ID:340211173,项目名称:Driver,代码行数:51,代码来源:HelperFunctions_DeferredProcedureCalls.cpp

示例9: VmmpIoWrapper

// Perform IO instruction according with parameters
_Use_decl_annotations_ static void VmmpIoWrapper(bool to_memory, bool is_string,
                                                 SIZE_T size_of_access,
                                                 unsigned short port,
                                                 void *address,
                                                 unsigned long count) {
  NT_ASSERT(size_of_access == 1 || size_of_access == 2 || size_of_access == 4);

  // Update CR3 with that of the guest since below code is going to access
  // memory.
  const auto guest_cr3 = UtilVmRead(VmcsField::kGuestCr3);
  const auto vmm_cr3 = __readcr3();
  __writecr3(guest_cr3);

  // clang-format off
  if (to_memory) {
    if (is_string) {
      // IN
      switch (size_of_access) {
      case 1: *reinterpret_cast<UCHAR*>(address) = __inbyte(port); break;
      case 2: *reinterpret_cast<USHORT*>(address) = __inword(port); break;
      case 4: *reinterpret_cast<ULONG*>(address) = __indword(port); break;
      }
    } else {
      // INS
      switch (size_of_access) {
      case 1: __inbytestring(port, reinterpret_cast<UCHAR*>(address), count); break;
      case 2: __inwordstring(port, reinterpret_cast<USHORT*>(address), count); break;
      case 4: __indwordstring(port, reinterpret_cast<ULONG*>(address), count); break;
      }
    }
  } else {
    if (is_string) {
      // OUT
      switch (size_of_access) {
      case 1: __outbyte(port, *reinterpret_cast<UCHAR*>(address)); break;
      case 2: __outword(port, *reinterpret_cast<USHORT*>(address)); break;
      case 4: __outdword(port, *reinterpret_cast<ULONG*>(address)); break;
      }
    } else {
      // OUTS
      switch (size_of_access) {
      case 1: __outbytestring(port, reinterpret_cast<UCHAR*>(address), count); break;
      case 2: __outwordstring(port, reinterpret_cast<USHORT*>(address), count); break;
      case 4: __outdwordstring(port, reinterpret_cast<ULONG*>(address), count); break;
      }
    }
  }
  // clang-format on

  __writecr3(vmm_cr3);
}
开发者ID:jamella,项目名称:HyperPlatform,代码行数:52,代码来源:vmm.cpp

示例10: otPlatSettingsInit

void otPlatSettingsInit(otInstance *otCtx)
{
    NT_ASSERT(otCtx);
    PMS_FILTER pFilter = otCtxToFilter(otCtx);

    DECLARE_CONST_UNICODE_STRING(SubKeyName, L"OpenThread");

    OBJECT_ATTRIBUTES attributes;
    ULONG disposition;

    LogFuncEntry(DRIVER_DEFAULT);

    InitializeObjectAttributes(
        &attributes,
        (PUNICODE_STRING)&SubKeyName,
        OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
        pFilter->InterfaceRegKey,
        NULL);

    // Create/Open the 'OpenThread' sub key
    NTSTATUS status =
        ZwCreateKey(
            &pFilter->otSettingsRegKey,
            KEY_ALL_ACCESS,
            &attributes,
            0,
            NULL,
            REG_OPTION_NON_VOLATILE,
            &disposition);

    NT_ASSERT(NT_SUCCESS(status));
    if (!NT_SUCCESS(status))
    {
        LogError(DRIVER_DEFAULT, "ZwCreateKey for 'OpenThread' key failed, %!STATUS!", status);
    }

    LogFuncExit(DRIVER_DEFAULT);
}
开发者ID:abtink,项目名称:openthread,代码行数:38,代码来源:settings.c

示例11: ClasspDequeueIdleRequest

/*++

ClasspDequeueIdleRequest

Routine Description:

    This function will remove the next idle request from the list.
    If there are no requests in the queue, then it will return NULL.

Arguments:

    FdoExtension         - Pointer to the functional device extension

Return Value:

    Pointer to removed IRP

--*/
PIRP
ClasspDequeueIdleRequest(
    PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
    )
{
    PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
    PLIST_ENTRY listEntry = NULL;
    PIRP irp = NULL;
    KIRQL oldIrql;

    KeAcquireSpinLock(&fdoData->IdleListLock, &oldIrql);

    if (fdoData->IdleIoCount > 0) {
        listEntry = RemoveHeadList(&fdoData->IdleIrpList);
        //
        // Make sure we actaully removed a request from the list
        //
        NT_ASSERT(listEntry != &fdoData->IdleIrpList);
        //
        // Decrement the idle I/O count.
        //
        fdoData->IdleIoCount--;
        //
        // Stop the timer on last request
        //
        if (fdoData->IdleIoCount == 0) {
            ClasspStopIdleTimer(fdoData);
        }
        irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);
        NT_ASSERT(irp->Type == IO_TYPE_IRP);


        InitializeListHead(&irp->Tail.Overlay.ListEntry);
    }

    KeReleaseSpinLock(&fdoData->IdleListLock, oldIrql);
    return irp;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:56,代码来源:clntirp.c

示例12: SbppDeleteBreakpointFromList

// Deletes a breakpoint info from the list if exists
_Use_decl_annotations_ static void SbppDeleteBreakpointFromList(
    const PatchInformation& info) {
  ScopedSpinLockAtDpc scoped_lock(&g_sbpp_breakpoints_skinlock);
  auto ptrs = g_sbpp_breakpoints;
  NT_ASSERT(ptrs);
  auto iter =
      std::find_if(ptrs->begin(), ptrs->end(), [info](const auto& info2) {
        return (info.patch_address == info2->patch_address &&
                info.target_tid == info2->target_tid);
      });
  if (iter != ptrs->end()) {
    ptrs->erase(iter);
  }
}
开发者ID:johnjohnsp1,项目名称:DdiMon,代码行数:15,代码来源:shadow_bp.cpp

示例13: SbppFindPatchInfoByAddress

// Find a breakpoint object that are on the same page as the address and its
// shadow pages are reusable
_Use_decl_annotations_ static PatchInformation* SbppFindPatchInfoByAddress(
    void* address) {
  ScopedSpinLockAtDpc scoped_lock(&g_sbpp_breakpoints_skinlock);
  auto ptrs = g_sbpp_breakpoints;
  NT_ASSERT(ptrs);

  auto found = std::find_if(
      ptrs->begin(), ptrs->end(),
      [address](const auto& info) { return info->patch_address == address; });
  if (found == ptrs->cend()) {
    return nullptr;
  }
  return found->get();
}
开发者ID:johnjohnsp1,项目名称:DdiMon,代码行数:16,代码来源:shadow_bp.cpp

示例14: PwmCreateRequestGetAccess

__forceinline
void
PwmCreateRequestGetAccess(
    _In_ WDFREQUEST WdfRequest,
    _Out_ ACCESS_MASK* DesiredAccessPtr,
    _Out_ ULONG* ShareAccessPtr
    )
{
    NT_ASSERT(ARGUMENT_PRESENT(DesiredAccessPtr));
    NT_ASSERT(ARGUMENT_PRESENT(ShareAccessPtr));

    WDF_REQUEST_PARAMETERS wdfRequestParameters;
    WDF_REQUEST_PARAMETERS_INIT(&wdfRequestParameters);
    WdfRequestGetParameters(WdfRequest, &wdfRequestParameters);

    NT_ASSERTMSG(
        "Expected create request",
        wdfRequestParameters.Type == WdfRequestTypeCreate);

    *DesiredAccessPtr =
        wdfRequestParameters.Parameters.Create.SecurityContext->DesiredAccess;
    *ShareAccessPtr = wdfRequestParameters.Parameters.Create.ShareAccess;
}
开发者ID:kartben,项目名称:Windows-iotcore-samples,代码行数:23,代码来源:utility.hpp

示例15: LogpBufferFlushThreadRoutine

// A thread runs as long as info.buffer_flush_thread_should_be_alive is true and
// flushes a log buffer to a log file every kLogpLogFlushIntervalMsec msec.
_Use_decl_annotations_ static VOID LogpBufferFlushThreadRoutine(
    void *start_context) {
  PAGED_CODE();
  auto status = STATUS_SUCCESS;
  auto info = reinterpret_cast<LogBufferInfo *>(start_context);
  info->buffer_flush_thread_started = true;
  HYPERPLATFORM_LOG_DEBUG("Log thread started (TID= %p).",
                          PsGetCurrentThreadId());

  while (info->buffer_flush_thread_should_be_alive) {
    NT_ASSERT(LogpIsLogFileActivated(*info));
    if (info->log_buffer_head[0]) {
      NT_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
      NT_ASSERT(!KeAreAllApcsDisabled());
      status = LogpFlushLogBuffer(info);
      // Do not flush the file for overall performance. Even a case of
      // bug check, we should be able to recover logs by looking at both
      // log buffers.
    }
    LogpSleep(kLogpLogFlushIntervalMsec);
  }
  PsTerminateSystemThread(status);
}
开发者ID:JulianVolodia,项目名称:HyperPlatform,代码行数:25,代码来源:log.cpp


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