예제 #1
0
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();
}
_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;
}
예제 #3
0
// 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;
}
예제 #4
0
// 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;
}
예제 #5
0
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;
}
예제 #6
0
파일: bitmaps.c 프로젝트: GYGit/reactos
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;
}
예제 #7
0
// 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;
}
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;
}
예제 #9
0
// 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);
}
예제 #10
0
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);
}
예제 #11
0
/*++

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;
}
예제 #12
0
// 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);
  }
}
예제 #13
0
// 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();
}
예제 #14
0
__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;
}
예제 #15
0
// 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);
}
예제 #16
0
VOID
SimSensorQueueIoStop (
    _In_ WDFQUEUE Queue,
    _In_ WDFREQUEST Request,
    _In_ ULONG ActionFlags
    )

/*++

Routine Description:

    This routine is called when the framework is stopping the request's I/O
    queue.

Arguments:

    Queue - Supplies handle to the framework queue object that is associated
            with the I/O request.

    Request - Supplies handle to a framework request object.

    ActionFlags - Supplies the reason that the callback is being called.

Return Value:

    None.

--*/

{

    NTSTATUS Status;

    UNREFERENCED_PARAMETER(Queue);

    if(ActionFlags & WdfRequestStopRequestCancelable) {
        Status = WdfRequestUnmarkCancelable(Request);
        if (Status == STATUS_CANCELLED) {
            goto SimSensorQueueIoStopEnd;
        }

        NT_ASSERT(NT_SUCCESS(Status));
    }

    WdfRequestStopAcknowledge(Request, FALSE);

SimSensorQueueIoStopEnd:

    return;
}
_IRQL_requires_same_
VOID SubscriptionBFEStateChangeCallback(_Inout_ VOID* pContext,
                                        _In_ FWPM_SERVICE_STATE bfeState)
{
#if DBG

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

#endif /// DBG
   
   NT_ASSERT(pContext);

   NTSTATUS                status      = STATUS_SUCCESS;
   WFPSAMPLER_DEVICE_DATA* pDeviceData = (WFPSAMPLER_DEVICE_DATA*)pContext;

   switch(bfeState)
   {
      case FWPM_SERVICE_RUNNING:
      {
         if(pDeviceData->pEngineHandle == 0)
         {
            status = KrnlHlprFwpmSessionCreateEngineHandle(&(pDeviceData->pEngineHandle));
            HLPR_BAIL_ON_FAILURE(status);
         }

         break;
      }
      case FWPM_SERVICE_STOP_PENDING:
      {
         KrnlHlprFwpmSessionDestroyEngineHandle(&(pDeviceData->pEngineHandle));

         break;
      }
   }

   HLPR_BAIL_LABEL:

#if DBG

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

#endif /// DBG

   return;
}
void RosUmdResource::InitSharedResourceFromExistingAllocation (
    const RosAllocationExchange* ExistingAllocationPtr,
    D3D10DDI_HKMRESOURCE hKMResource,
    D3DKMT_HANDLE hKMAllocation,        // can this be a D3D10DDI_HKMALLOCATION?
    D3D10DDI_HRTRESOURCE hRTResource
    )
{
    assert(m_signature == _SIGNATURE::CONSTRUCTED);

    ROS_LOG_TRACE(
        "Opening existing resource. "
        "(ExistingAllocationPtr->m_hwWidth/HeightPixels = %u,%u  "
        "ExistingAllocationPtr->m_hwSizeBytes = %u, "
        "ExistingAllocationPtr->m_isPrimary = %d, "
        "hRTResource = 0x%p, "
        "hKMResource= 0x%x, "
        "hKMAllocation = 0x%x)",
        ExistingAllocationPtr->m_hwWidthPixels,
        ExistingAllocationPtr->m_hwHeightPixels,
        ExistingAllocationPtr->m_hwSizeBytes,
        ExistingAllocationPtr->m_isPrimary,
        hRTResource.handle,
        hKMResource.handle,
        hKMAllocation);

    // copy members from the existing allocation into this object
    RosAllocationExchange* basePtr = this;
    *basePtr = *ExistingAllocationPtr;

    // HW specific information calculated based on the fields above
    CalculateMemoryLayout();

    NT_ASSERT(
        (m_hwLayout == ExistingAllocationPtr->m_hwLayout) &&
        (m_hwWidthPixels == ExistingAllocationPtr->m_hwWidthPixels) &&
        (m_hwHeightPixels == ExistingAllocationPtr->m_hwHeightPixels) &&
        (m_hwSizeBytes == ExistingAllocationPtr->m_hwSizeBytes));

    m_hRTResource = hRTResource;
    m_hKMResource = hKMResource.handle;
    m_hKMAllocation = hKMAllocation;

    m_mostRecentFence = RosUmdCommandBuffer::s_nullFence;
    m_allocationListIndex = 0;

    m_pData = nullptr;
    m_pSysMemCopy = nullptr;

    m_signature = _SIGNATURE::INITIALIZED;
}
예제 #19
0
otError otPlatSettingsGet(otInstance *otCtx, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
{
    NT_ASSERT(otCtx);
    PMS_FILTER pFilter = otCtxToFilter(otCtx);

    NTSTATUS status = 
        FilterReadSetting(
            pFilter,
            aKey,
            aIndex,
            aValue,
            aValueLength);

    return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
}
예제 #20
0
__inline
NET_BUFFER_LIST* 
TailOfNetBufferListChain(
   _In_ NET_BUFFER_LIST* netBufferListChain
   )
{
   NT_ASSERT(netBufferListChain != NULL);

   while (netBufferListChain->Next != NULL)
   {
      netBufferListChain = netBufferListChain->Next;
   }

   return netBufferListChain;
}
VOID CFileObject::OnDestroy(_In_ WDFOBJECT FileObject)
{
    FunctionEntry("...");

    CFileObject *pFileObject = GetFileObject(FileObject);

    NT_ASSERT(pFileObject != nullptr);

    if (pFileObject->m_FileObject == FileObject) {
        // File object constructed using placement 'new' so explicitly invoke destructor
        pFileObject->~CFileObject();
    }

    FunctionReturnVoid();
}
NTSTATUS
RosKmAdapter::NotifyAcpiEvent(
    IN_DXGK_EVENT_TYPE  EventType,
    IN_ULONG            Event,
    IN_PVOID            Argument,
    OUT_PULONG          AcpiFlags)
{
    EventType;
    Event;
    Argument;
    AcpiFlags;

    NT_ASSERT(false);
    return STATUS_SUCCESS;
}
예제 #23
0
otError otPlatSettingsSet(otInstance *otCtx, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
{
    NT_ASSERT(otCtx);
    PMS_FILTER pFilter = otCtxToFilter(otCtx);

    NTSTATUS status = 
        FilterWriteSetting(
            pFilter,
            aKey,
            0,
            aValue,
            aValueLength);

    return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
}
예제 #24
0
파일: driver.cpp 프로젝트: MHesham/bsp
_Use_decl_annotations_
NTSTATUS DriverEntry (
    DRIVER_OBJECT* DriverObjectPtr,
    UNICODE_STRING* RegistryPathPtr
    )
{
    PAGED_CODE();

    //
    // Initialize logging
    //
    {
        WPP_INIT_TRACING(DriverObjectPtr, RegistryPathPtr);
        RECORDER_CONFIGURE_PARAMS recorderConfigureParams;
        RECORDER_CONFIGURE_PARAMS_INIT(&recorderConfigureParams);
        WppRecorderConfigure(&recorderConfigureParams);
#if DBG
        WPP_RECORDER_LEVEL_FILTER(BSC_TRACING_VERBOSE) = TRUE;
#endif // DBG
    }

    NTSTATUS status;

    WDFDRIVER wdfDriver;
    {
        WDF_DRIVER_CONFIG wdfDriverConfig;
        WDF_DRIVER_CONFIG_INIT(&wdfDriverConfig, OnDeviceAdd);
        wdfDriverConfig.DriverPoolTag = BCM_I2C_POOL_TAG;
        wdfDriverConfig.EvtDriverUnload = OnDriverUnload;

        status = WdfDriverCreate(
                DriverObjectPtr,
                RegistryPathPtr,
                WDF_NO_OBJECT_ATTRIBUTES,
                &wdfDriverConfig,
                &wdfDriver);
        if (!NT_SUCCESS(status)) {
            BSC_LOG_ERROR(
                "Failed to create WDF driver object. (DriverObjectPtr = %p, RegistryPathPtr = %p)",
                DriverObjectPtr,
                RegistryPathPtr);
            return status;
        }
    }

    NT_ASSERT(NT_SUCCESS(status));
    return STATUS_SUCCESS;
}
예제 #25
0
VOID
ShvVmxHandleExit (
    _In_ PSHV_VP_STATE VpState
    )
{
    //
    // This is the generic VM-Exit handler. Decode the reason for the exit and
    // call the appropriate handler. As per Intel specifications, given that we
    // have requested no optional exits whatsoever, we should only see CPUID,
    // INVD, XSETBV and other VMX instructions. GETSEC cannot happen as we do
    // not run in SMX context.
    //
    switch (VpState->ExitReason)
    {
    case EXIT_REASON_CPUID:
        ShvVmxHandleCpuid(VpState);
        break;
    case EXIT_REASON_INVD:
        ShvVmxHandleInvd();
        break;
    case EXIT_REASON_XSETBV:
        ShvVmxHandleXsetbv(VpState);
        break;
    case EXIT_REASON_VMCALL:
    case EXIT_REASON_VMCLEAR:
    case EXIT_REASON_VMLAUNCH:
    case EXIT_REASON_VMPTRLD:
    case EXIT_REASON_VMPTRST:
    case EXIT_REASON_VMREAD:
    case EXIT_REASON_VMRESUME:
    case EXIT_REASON_VMWRITE:
    case EXIT_REASON_VMXOFF:
    case EXIT_REASON_VMXON:
        ShvVmxHandleVmx(VpState);
        break;
    default:
        NT_ASSERT(FALSE);
        break;
    }

    //
    // Move the instruction pointer to the next instruction after the one that
    // caused the exit. Since we are not doing any special handling or changing
    // of execution, this can be done for any exit reason.
    //
    VpState->GuestRip += ShvVmxRead(VM_EXIT_INSTRUCTION_LEN);
    __vmx_vmwrite(GUEST_RIP, VpState->GuestRip);
}
예제 #26
0
파일: retry.c 프로젝트: uri247/wdk80
VOID TransferPacketQueueRetryDpc(PTRANSFER_PACKET Pkt)
{
    KeInitializeDpc(&Pkt->RetryTimerDPC, TransferPacketRetryTimerDpc, Pkt);

    if (Pkt->RetryIn100nsUnits == 0){
        KeInsertQueueDpc(&Pkt->RetryTimerDPC, NULL, NULL);
    }
    else {
        LARGE_INTEGER timerPeriod;

        NT_ASSERT(Pkt->RetryIn100nsUnits < 100 * 1000 * 1000 * 10); // sanity check -- 100 seconds is normally too long
        timerPeriod.QuadPart = -(Pkt->RetryIn100nsUnits);
        KeInitializeTimer(&Pkt->RetryTimer);
        KeSetTimer(&Pkt->RetryTimer, timerPeriod, &Pkt->RetryTimerDPC);
    }
}
예제 #27
0
파일: data.c 프로젝트: GYGit/reactos
NTSTATUS
NTAPI
CreateDeviceSecurityDescriptor(IN PDEVICE_OBJECT *DeviceObject)
{
    NTSTATUS Status;
    PSECURITY_DESCRIPTOR SecurityDescriptor;
    BOOLEAN MemoryAllocated = FALSE;
    PACL Dacl = NULL;
    PVOID ObjectSecurityDescriptor = NULL;
    SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC CreateDeviceSecurityDescriptor: Entering.\n");

    /* Get the current SD of the device object */
    Status = ObGetObjectSecurity(*DeviceObject, &SecurityDescriptor, &MemoryAllocated);
    if (!NT_SUCCESS(Status))
    {
        SAC_DBG(SAC_DBG_INIT, "SAC: Unable to get security descriptor, error: %x\n", Status);
        NT_ASSERT(MemoryAllocated == FALSE);
        SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC CreateDeviceSecurityDescriptor: Exiting with status 0x%x\n", Status);
        return Status;
    }

    /* Build a DACL for it */
    Status = BuildDeviceAcl(&Dacl);
    if (Status >= 0)
    {
        ASSERT(FALSE);
    }
    else
    {
        SAC_DBG(SAC_DBG_INIT, "SAC CreateDeviceSecurityDescriptor : Unable to create Raw ACL, error : %x\n", Status);
        /* FIXME: Temporary hack */
        Status = STATUS_SUCCESS;
        goto CleanupPath;
    }

CleanupPath:
    /* Release the SD we queried */
    ObReleaseObjectSecurity(SecurityDescriptor, MemoryAllocated);

    /* Free anything else we may have allocated */
    if (ObjectSecurityDescriptor) ExFreePool(ObjectSecurityDescriptor);
    if (Dacl) SacFreePool(Dacl);

    /* All done */
    SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC CreateDeviceSecurityDescriptor: Exiting with status 0x%x\n", Status);
    return Status;
}
예제 #28
0
_IRQL_requires_same_
inline VOID KrnlHlprNDISPoolDataPurge(_Inout_ NDIS_POOL_DATA* pNDISPoolData)
{
#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " ---> KrnlHlprNDISPoolDataPurge()\n");

#endif /// DBG
   
   NT_ASSERT(pNDISPoolData);

   if(pNDISPoolData->ndisHandle)
   {
      if(pNDISPoolData->nbPoolHandle)
      {
         NdisFreeNetBufferPool(pNDISPoolData->nbPoolHandle);

         pNDISPoolData->nbPoolHandle = 0;
      }

      if(pNDISPoolData->nblPoolHandle)
      {
         NdisFreeNetBufferListPool(pNDISPoolData->nblPoolHandle);

         pNDISPoolData->nblPoolHandle = 0;
      }

      NdisFreeGenericObject((PNDIS_GENERIC_OBJECT)(pNDISPoolData->ndisHandle));

      pNDISPoolData->ndisHandle = 0;
   }

   RtlZeroMemory(pNDISPoolData,
                 sizeof(NDIS_POOL_DATA));

#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " <--- KrnlHlprNDISPoolDataPurge()\n");

#endif /// DBG
   
   return;
}
//  Function:
//      bool CImageHardwareSimulation::AdvanceFrameCounter(void)
//
//  Description:
//      Advance our frame and loop pointers to the next PFS settings.
//
//  Parameters:
//      [None]
//
//  Returns:
//      bool - true if we've reached the end of our Per Frame Settings.
//
bool
CImageHardwareSimulation::
AdvanceFrameCounter(void)
{
    PAGED_CODE();

    bool    bEOS = false;

    DBG_ENTER( "()" );

    m_GlobalFrameNumber ++;
    DBG_TRACE( "m_GlobalFrameNumber=%lld", m_GlobalFrameNumber );

    //
    //  Calculate the PFS frame & loop numbers, but only if we've
    //  gotten ISP settings.
    //
    if( m_bTriggered &&
            m_PinMode == PinBurstMode &&
            m_pIspSettings )
    {
        m_PfsFrameNumber ++;

        if( m_PfsFrameNumber >= m_PfsFrameLimit )
        {
            m_PfsFrameNumber = 0;
            m_PfsLoopNumber ++;
        }

        //  Only mark EOS if we're not in an infinite loop.
        if( m_PfsLoopLimit != 0 )
        {
            NT_ASSERT( !(m_PfsLoopNumber > m_PfsLoopLimit) );
            //  Check to see if we've hit our limit.
            if( m_PfsLoopNumber >= m_PfsLoopLimit )
            {
                DBG_TRACE( "Marking EOS" );
                bEOS = true;
            }
        }
    }

    DBG_TRACE( "m_PfsFrameNumber=%d, m_PfsLoopNumber=%d", m_PfsFrameNumber, m_PfsLoopNumber );
    DBG_TRACE( "m_PfsFrameLimit=%d,  m_PfsLoopLimit=%d",  m_PfsFrameLimit, m_PfsLoopLimit );
    DBG_LEAVE( "() = %s", bEOS ? "true" : "false" );
    return bEOS;
}
예제 #30
0
void
OobEditShutdown(
   _Out_ STREAM_EDITOR* streamEditor
   )
{
   KLOCK_QUEUE_HANDLE editLockHandle;

   KeAcquireInStackQueuedSpinLock(
      &streamEditor->oobEditInfo.editLock,
      &editLockHandle
      );

   streamEditor->oobEditInfo.shuttingDown = TRUE;

   switch (streamEditor->oobEditInfo.editState)
   {
      case OOB_EDIT_IDLE:
      {
         streamEditor->oobEditInfo.editState = OOB_EDIT_SHUT_DOWN;

         KeSetEvent(
            &gStreamEditor.oobEditInfo.editEvent,
            IO_NO_INCREMENT, 
            FALSE
            );

         break;
      }
      default:
         break;
   };

   KeReleaseInStackQueuedSpinLock(&editLockHandle);

   NT_ASSERT(gThreadObj != NULL);

   KeWaitForSingleObject(
      gThreadObj,
      Executive,
      KernelMode,
      FALSE,
      NULL
      );

   ObDereferenceObject(gThreadObj);
}