Ejemplo n.º 1
0
static BOOLEAN
BalloonPopulatePfnArray(
    IN  ULONG                   Requested,
    OUT PULONG                  pPopulated
    )
{
    xen_memory_reservation_t    reservation;
    LARGE_INTEGER               Start;
    LARGE_INTEGER               End;
    ULONGLONG                   TimeDelta;
    BOOLEAN                     Slow;
    ULONG                       Populated;

    XM_ASSERT(Requested <= BALLOON_PFN_ARRAY_SIZE);

    KeQuerySystemTime(&Start);

    RangeSetPopMany(&(Balloon.PfnsBalloonedOut),
                    &(Balloon.PfnArray[0]),
                    Requested);

    SET_XEN_GUEST_HANDLE(reservation.extent_start, Balloon.PfnArray);
    reservation.extent_order = 0;
    reservation.mem_flags = 0;   // unused
    reservation.domid = DOMID_SELF;
    reservation.nr_extents = Requested;

    Populated = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
    if (Populated < Requested) {
        Balloon.PartialPopulate++;

        // This should not fail as we're simply handing back part of a range we'd previously popped.
        RangeSetAddItems(&(Balloon.PfnsBalloonedOut),
                         &(Balloon.PfnArray[Populated]),
                         Requested - Populated);
    } else if (Populated > Requested) {
        XM_BUG();
    }

    RangeSetDropRseCache(&(Balloon.PfnsBalloonedOut));

    TraceVerbose(("%s: %d page(s)\n", __FUNCTION__, Populated));

    KeQuerySystemTime(&End);
    TimeDelta = (End.QuadPart - Start.QuadPart) / 10000ull;

    Slow = FALSE;
    if (TimeDelta != 0) {
        ULONGLONG   Rate;

        Rate = (ULONGLONG)(Populated * 1000) / TimeDelta;
        if (Rate < MIN_PAGES_PER_S) {
            TraceWarning(("%s: ran for more than %dms\n", __FUNCTION__, TimeDelta));
            Slow = TRUE;
        }
    }

    *pPopulated = Populated;
    return Slow;
}
Ejemplo n.º 2
0
u32_t
sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
{
    LARGE_INTEGER LargeTimeout, PreWaitTime, PostWaitTime;
    UINT64 TimeDiff;
    NTSTATUS Status;
    PVOID Message;
    PLWIP_MESSAGE_CONTAINER Container;
    PLIST_ENTRY Entry;
    KIRQL OldIrql;
    PVOID WaitObjects[] = {&mbox->Event, &TerminationEvent};
    
    LargeTimeout.QuadPart = Int32x32To64(timeout, -10000);
    
    KeQuerySystemTime(&PreWaitTime);

    Status = KeWaitForMultipleObjects(2,
                                      WaitObjects,
                                      WaitAny,
                                      Executive,
                                      KernelMode,
                                      FALSE,
                                      timeout != 0 ? &LargeTimeout : NULL,
                                      NULL);

    if (Status == STATUS_WAIT_0)
    {
        KeAcquireSpinLock(&mbox->Lock, &OldIrql);
        Entry = RemoveHeadList(&mbox->ListHead);
        ASSERT(Entry);
        if (IsListEmpty(&mbox->ListHead))
            KeClearEvent(&mbox->Event);
        KeReleaseSpinLock(&mbox->Lock, OldIrql);
        
        Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry);
        Message = Container->Message;
        ExFreePool(Container);
        
        if (msg)
            *msg = Message;

        KeQuerySystemTime(&PostWaitTime);
        TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart;
        TimeDiff /= 10000;
        
        return TimeDiff;
    }
    else if (Status == STATUS_WAIT_1)
    {
        /* DON'T remove ourselves from the thread list! */
        PsTerminateSystemThread(STATUS_SUCCESS);
        
        /* We should never get here! */
        ASSERT(FALSE);
        
        return 0;
    }
    
    return SYS_ARCH_TIMEOUT;
}
Ejemplo n.º 3
0
void RemoveUnseenProcesses(void)
{
    KIRQL irql;
    int i;
    TIME liCurrentTime;

    if (g_proc_hash) {
        KeAcquireSpinLock(&g_proc_hash_guard, &irql);
        KeQuerySystemTime(&liCurrentTime);

        for (i = 0; i < HASH_SIZE; i++) {
            proc_entry_t *ote = g_proc_hash[i];
            while (ote) {
                proc_entry_t *ote2 = ote->next;

                if(RtlLargeIntegerLessThan(liCurrentTime, ote->lastseen)) {
                    FreeProcessData((ProcessData *)ote->pProcInfo);
                    free((ProcessData *)ote->pProcInfo);
                    free(ote);
                    ote = ote2;
                } else
                    ote = ote->next;
            }
        }

        KeReleaseSpinLock(&g_proc_hash_guard, irql);
    }
}
unsigned long getSystemTime()
{
	LARGE_INTEGER time;	
	KeQuerySystemTime(&time);
	
	return (unsigned long) ((time.QuadPart / 10000000) - 11643609600);
}
Ejemplo n.º 5
0
//Callback from process creation.
VOID ProcessCreationCB(
_In_ HANDLE ParentId,
_In_ HANDLE ProcessId,
_In_ BOOLEAN Create)
{
	PRECORD_LIST recordList = SpyNewRecord();
	if (!recordList)
		return;

	if (Create)
	{
		recordList->LogRecord.Data.RecordType = CREATE_OP;
		recordList->LogRecord.Data.ProcessId = (FILE_ID)ProcessId;
		recordList->LogRecord.Data.ThreadId = (FILE_ID)ParentId;
	}
	else
	{
		recordList->LogRecord.Data.RecordType = EXIT_OP;
		recordList->LogRecord.Data.ProcessId = (FILE_ID)ProcessId;
	}
	//Set the time for the originating and completion itme.
	KeQuerySystemTime(&recordList->LogRecord.Data.OriginatingTime);
	recordList->LogRecord.Data.CompletionTime = recordList->LogRecord.Data.OriginatingTime;
	//Set the name to ""
	UNICODE_STRING emptySTR;
	RtlInitUnicodeString(&emptySTR, L"");
	SpySetRecordNameAndEcpData(&recordList->LogRecord, &emptySTR, &emptySTR);
	//Send to the userland!
	SpyLog(recordList);
}
Ejemplo n.º 6
0
VOID __stdcall Filter(ULONG ServiceId, ULONG TableBase, ULONG Argc, ULONG StackAddr) {
	ULONG pid = (ULONG)PsGetCurrentProcessId();
	if (pid == g_nPid) {
		ULONG i;
		PXBoxData pData=(PXBoxData)ExAllocateFromNPagedLookasideList(&g_nPageList);
		if(!pData)
			return;
		
		if (StackAddr < MmUserProbeAddress)
			pData->bFromUser = 1;
		else
			pData->bFromUser = 0;
		
		if (TableBase == (ULONG)KeServiceDescriptorTable.ServiceTableBase)
			pData->bFromSSDT = 1;
		else
			pData->bFromSSDT = 0;

		if (Argc > 16)
			Argc = 16;
		pData->argc = (UCHAR)Argc;
		for (i = 0; i < Argc; ++i)
			pData->args[i] = ((PULONG)StackAddr)[i];

		pData->pid = (ULONG)pid;
		pData->tid = (ULONG)PsGetCurrentThreadId();
		pData->sid = ServiceId;
		KeQuerySystemTime(&pData->time);
		ExInterlockedInsertTailList(&g_linkListHead, &pData->ListEntry, &g_lock);
		KeReleaseSemaphore( &g_keySemaphore, 0, 1, FALSE );
	}
}
Ejemplo n.º 7
0
FBCALL double fb_Timer( void )
{
#if defined( HOST_DOS ) || defined( HOST_UNIX )
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return (((double)tv.tv_sec * 1000000.0) + (double)tv.tv_usec) * 0.000001;

#elif defined( HOST_WIN32 )
	LARGE_INTEGER count;

	if( timer == TIMER_NONE ) {
		if( QueryPerformanceFrequency( &count ) ) {
			frequency = 1.0 / (double)count.QuadPart;
			timer = TIMER_HIGHRES;
		} else {
			timer = TIMER_NORMAL;
		}
	}

	if( timer == TIMER_NORMAL ) {
		return (double)GetTickCount( ) * 0.001;
	} else {
		QueryPerformanceCounter( &count );
		return (double)count.QuadPart * frequency;
	}

#elif defined( HOST_XBOX )
	LARGE_INTEGER t;
	KeQuerySystemTime(&t);
	return ((double)(t.QuadPart) * 100.0);

#else
#	error TODO
#endif
}
Ejemplo n.º 8
0
VOID
SpyLogPostOperationData (
	_In_ PCFLT_RELATED_OBJECTS FltObjects,
    _Inout_ PRECORD_LIST RecordList
    )
/*++

Routine Description:

    This is called from the post-operation callback routine to copy the
    necessary information into the log record.

    NOTE:  This code must be NON-PAGED because it can be called on the
           paging path or at DPC level.

Arguments:

    Data - The Data structure that contains the information we want to record.

    RecordList - Where we want to save the data

Return Value:

    None.

--*/
{
	UNREFERENCED_PARAMETER(FltObjects);

    PRECORD_DATA recordData = &RecordList->LogRecord.Data;
	recordData->Flags = 0;
    KeQuerySystemTime( &recordData->CompletionTime );
}
Ejemplo n.º 9
0
/*
 * @implemented
 */
VOID
NTAPI
IoWriteErrorLogEntry(IN PVOID ElEntry)
{
    PERROR_LOG_ENTRY LogEntry;
    KIRQL Irql;

    /* Get the main header */
    LogEntry = (PERROR_LOG_ENTRY)((ULONG_PTR)ElEntry -
                                  sizeof(ERROR_LOG_ENTRY));

    /* Get time stamp */
    KeQuerySystemTime(&LogEntry->TimeStamp);

    /* Acquire the lock and insert this write in the list */
    KeAcquireSpinLock(&IopLogListLock, &Irql);
    InsertHeadList(&IopErrorLogListHead, &LogEntry->ListEntry);

    /* Check if the worker is running */
    if (!IopLogWorkerRunning)
    {
#if 0
        /* It's not, initialize it and queue it */
        ExInitializeWorkItem(&IopErrorLogWorkItem,
                             IopLogWorker,
                             &IopErrorLogWorkItem);
        ExQueueWorkItem(&IopErrorLogWorkItem, DelayedWorkQueue);
        IopLogWorkerRunning = TRUE;
#endif
    }

    /* Release the lock and return */
    KeReleaseSpinLock(&IopLogListLock, Irql);
}
Ejemplo n.º 10
0
VOID
NTAPI
VideoPortQuerySystemTime(
    OUT PLARGE_INTEGER CurrentTime)
{
    KeQuerySystemTime(CurrentTime);
}
Ejemplo n.º 11
0
void
AFSTagInitialLogEntry()
{

    LARGE_INTEGER liTime, liLocalTime;
    TIME_FIELDS timeFields;

    KeQuerySystemTime( &liTime);

    ExSystemTimeToLocalTime( &liTime,
                             &liLocalTime);

    RtlTimeToTimeFields( &liLocalTime,
                         &timeFields);

    AFSDbgLogMsg( 0,
                  0,
                  "AFS Log Initialized %d-%d-%d %d:%d Level %d Subsystems %08lX\n",
                  timeFields.Month,
                  timeFields.Day,
                  timeFields.Year,
                  timeFields.Hour,
                  timeFields.Minute,
                  AFSTraceLevel,
                  AFSTraceComponent);

    return;
}
Ejemplo n.º 12
0
__inline static VOID
USBPcapInitializePcapHeader(PUSBPCAP_ROOTHUB_DATA pData,
                            pcaprec_hdr_t *pcapHeader,
                            UINT32 bytes)
{
    LARGE_INTEGER  time;

    /*
     * Updated approximately every ten milliseconds.
     *
     * TODO: Get higer precision timestamp.
     */
    KeQuerySystemTime(&time);

    pcapHeader->ts_sec = (UINT32)(time.QuadPart/10000000-11644473600);
    pcapHeader->ts_usec = (UINT32)((time.QuadPart%10000000)/10);

    /* Obey the snaplen limit */
    if (bytes > pData->snaplen)
    {
        pcapHeader->incl_len = pData->snaplen;
    }
    else
    {
        pcapHeader->incl_len = bytes;
    }
    pcapHeader->orig_len = bytes;
}
Ejemplo n.º 13
0
BOOLEAN CMAPI
HvSyncHive(
   PHHIVE RegistryHive)
{
   ASSERT(RegistryHive->ReadOnly == FALSE);

   if (RtlFindSetBits(&RegistryHive->DirtyVector, 1, 0) == ~0U)
   {
      return TRUE;
   }

   /* Update hive header modification time */
   KeQuerySystemTime(&RegistryHive->BaseBlock->TimeStamp);

   /* Update log file */
   if (!HvpWriteLog(RegistryHive))
   {
      return FALSE;
   }

   /* Update hive file */
   if (!HvpWriteHive(RegistryHive, TRUE))
   {
      return FALSE;
   }

   /* Clear dirty bitmap. */
   RtlClearAllBits(&RegistryHive->DirtyVector);
   RegistryHive->DirtyCount = 0;

   return TRUE;
}
Ejemplo n.º 14
0
VOID
SpyLogPreOperationData (
    _Inout_ PRECORD_LIST RecordList
    )
/*++

Routine Description:

    This is called from the pre-operation callback routine to copy the
    necessary information into the log record.

    NOTE:  This code must be NON-PAGED because it can be called on the
           paging path.

Arguments:

    Data - The Data structure that contains the information we want to record.

    FltObjects - Pointer to the io objects involved in this operation.

    RecordList - Where we want to save the data

Return Value:

    None.

--*/
{
    PRECORD_DATA recordData = &RecordList->LogRecord.Data;

	recordData->Flags			= 0L;
    recordData->ProcessId       = (FILE_ID)PsGetCurrentProcessId();

    KeQuerySystemTime( &recordData->OriginatingTime );
}
Ejemplo n.º 15
0
void
sys_init(void)
{   
    KeInitializeSpinLock(&ThreadListLock);
    InitializeListHead(&ThreadListHead);
    
    KeQuerySystemTime(&StartTime);
    
    KeInitializeEvent(&TerminationEvent, NotificationEvent, FALSE);
    
    ExInitializeNPagedLookasideList(&MessageLookasideList,
                                    NULL,
                                    NULL,
                                    0,
                                    sizeof(struct lwip_callback_msg),
                                    LWIP_MESSAGE_TAG,
                                    0);
    
    ExInitializeNPagedLookasideList(&QueueEntryLookasideList,
                                    NULL,
                                    NULL,
                                    0,
                                    sizeof(QUEUE_ENTRY),
                                    LWIP_QUEUE_TAG,
                                    0);
}
//
//  Set the interval between frames here.
//
NTSTATUS
CImageHardwareSimulation::
SetPhotoFrameRate(
    _In_    ULONGLONG TimePerFrame
)
{
    PAGED_CODE();

    //  Prevent state-changes during this call.
    KScopedMutex    Lock(m_ListLock);

    m_TimePerFrame = TimePerFrame;

    //
    // Reschedule the timer if the hardware isn't being stopped.
    //
    if( m_PinState == PinRunning )  // && !m_StopHardware )
    {
        //  First restart our start time.  We can't use the old time.
        KeQuerySystemTime( &m_StartTime );

        //
        // Reschedule the timer for the next interrupt time.
        //
        m_StartTime.QuadPart += m_TimePerFrame;
        m_InterruptTime = 0;

        m_IsrTimer.Set( m_StartTime );
    }
    return STATUS_SUCCESS;
}
Ejemplo n.º 17
0
BOOLEAN 
	natbFwSessionCreate(
		IN PFILTER_COMMON_CONTROL_BLOCK pAdapter,
		IN ULONG srcIpAddr,
		IN ULONG dstIpAddr,
		IN USHORT srcPort,
		IN USHORT dstPort,
		IN ULONG bOutgoing,
		IN UCHAR uProto
	)
{
	NDIS_SPIN_LOCK	*pSessionLock;
	PLIST_ENTRY		pSessionList;
	ULONG uHashindex;
	BOOLEAN bOk = FALSE;
	FLT_FW_SESSION *pFwSess;

	uHashindex = FLT_FW_SESSION_HASH_VALUE(
		srcIpAddr, 
		srcPort,
		dstIpAddr,
		dstPort);

	pSessionLock = pAdapter->FwSessionLocks + uHashindex;
	pSessionList = pAdapter->FwSessionList + uHashindex;

	pFwSess = ExAllocatePoolWithTag(0, sizeof(FLT_FW_SESSION), 'sF1N');
	ASSERT(pFwSess);
	if(NULL == pFwSess){
		return FALSE;
	}

	memset(pFwSess, 0, sizeof(*pFwSess));

	pFwSess->state = SESSION_STATE_SYN_RCV;
	pFwSess->protocol = uProto;
	pFwSess->out = bOutgoing;
	pFwSess->dstIpAddr = dstIpAddr;
	pFwSess->srcIpAddr = srcIpAddr;
	pFwSess->srcPort = srcPort;
	pFwSess->dstPort = dstPort;

	if(g_LogPktPass || g_LogPktDrop)
		natvLogSession("FIREWALL", pFwSess, SESSION_STATE_UNKNOWN, "created");

	KeQuerySystemTime ( &pFwSess->UpdateTime );

	NdisAcquireSpinLock(&g_FwSessionLock);

	NdisAcquireSpinLock(pSessionLock);
	InsertTailList(pSessionList, &pFwSess->ListEntry);
	InsertTailList(&g_FwSessionList, &pFwSess->GlobalEntry);
	pFwSess->pAdapter = pAdapter;
	NdisReleaseSpinLock(pSessionLock);

	NdisReleaseSpinLock(&g_FwSessionLock);

	return TRUE;
}
Ejemplo n.º 18
0
/*
 * With 64 bits, we can cover about 583 years at a nanosecond resolution.
 * Windows counts time from 1601 so we do have about 100 years before we
 * overflow.
 */
static unsigned long long time(void)
{
	LARGE_INTEGER li;

	KeQuerySystemTime(&li);

        return li.QuadPart*100;
}
Ejemplo n.º 19
0
u32_t sys_now(void)
{
    LARGE_INTEGER CurrentTime;
    
    KeQuerySystemTime(&CurrentTime);
    
    return (CurrentTime.QuadPart - StartTime.QuadPart) / 10000;
}
Ejemplo n.º 20
0
/*****************************************************************************
 * GetTheCurrentTime()
 *****************************************************************************
 * Get the current time, in milliseconds (KeQuerySystemTime returns units of
 * 100ns each).
 */
ULONG GetTheCurrentTime()
{
    LARGE_INTEGER Time;

    KeQuerySystemTime(&Time);

    return (ULONG)(Time.QuadPart / (10 * 1000));
}
Ejemplo n.º 21
0
/****************************************************************************
REMARKS:
This function reads the high resolution timer.
****************************************************************************/
void NAPI GA_TimerRead(
    GA_largeInteger *value)
{
    if (haveRDTSC)
        _GA_readTimeStamp(value);
    else
        KeQuerySystemTime((LARGE_INTEGER*)value);
}
Ejemplo n.º 22
0
static void change_file_info_func(void *data, VOID *buffer, ULONG len)
{
	struct fuse_attr *attr = (struct fuse_attr *)data;
	FILE_BASIC_INFORMATION *fbi = (FILE_BASIC_INFORMATION *)buffer;

	fbi->LastAccessTime = unix_time_to_windows_time(attr->atime);
	fbi->LastWriteTime = unix_time_to_windows_time(attr->mtime);
	KeQuerySystemTime(&fbi->ChangeTime);
}
Ejemplo n.º 23
0
FAT_TIME_STAMP
FatGetCurrentFatTime (
    IN PIRP_CONTEXT IrpContext
    )

/*++

Routine Description:

    This routine returns the current system time in Fat time

Arguments:

Return Value:

    FAT_TIME_STAMP - Receives the current system time

--*/

{
    LARGE_INTEGER Time;
    TIME_FIELDS TimeFields;
    FAT_TIME_STAMP FatTime;

    //
    //  Get the current system time, and map it into a time field record.
    //

    KeQuerySystemTime( &Time );

    ExSystemTimeToLocalTime( &Time, &Time );

    //
    //  Always add almost two seconds to round up to the nearest double second.
    //

    Time.QuadPart = Time.QuadPart + AlmostTwoSeconds;

    (VOID)RtlTimeToTimeFields( &Time, &TimeFields );

    //
    //  Now simply copy over the information
    //

    FatTime.Time.DoubleSeconds = (USHORT)(TimeFields.Second / 2);
    FatTime.Time.Minute        = (USHORT)(TimeFields.Minute);
    FatTime.Time.Hour          = (USHORT)(TimeFields.Hour);

    FatTime.Date.Year          = (USHORT)(TimeFields.Year - 1980);
    FatTime.Date.Month         = (USHORT)(TimeFields.Month);
    FatTime.Date.Day           = (USHORT)(TimeFields.Day);

    UNREFERENCED_PARAMETER( IrpContext );

    return FatTime;
}
Ejemplo n.º 24
0
/*	
	Process Callback that is called every time a process event occurs. Creates
	a kernel event which can be used to notify userspace processes. 
*/
VOID ProcessCallback(
	IN HANDLE  hParentId, 
	IN HANDLE  hProcessId, 
	IN BOOLEAN bCreate
	)
{
	NTSTATUS status;
	LARGE_INTEGER currentSystemTime;
	LARGE_INTEGER currentLocalTime;
	TIME_FIELDS timeFields;
	UNICODE_STRING processImagePath;
	PCAPTURE_PROCESS_MANAGER pProcessManager;

	/* Get the current time */
	KeQuerySystemTime(&currentSystemTime);
	ExSystemTimeToLocalTime(&currentSystemTime,&currentLocalTime);
	RtlTimeToTimeFields(&currentLocalTime,&timeFields);

    /* Get the process manager from the device extension */
    pProcessManager = gpDeviceObject->DeviceExtension;

	pProcessManager->pCurrentProcessEvent = ExAllocatePoolWithTag(NonPagedPool, sizeof(PROCESS_EVENT), PROCESS_POOL_TAG);

	if(pProcessManager->pCurrentProcessEvent == NULL)
	{
		return;
	}

	RtlCopyMemory(&pProcessManager->pCurrentProcessEvent->time, &timeFields, sizeof(TIME_FIELDS));

	processImagePath.Length = 0;
	processImagePath.MaximumLength = 0;

	status = GetProcessImageName(hProcessId, &processImagePath);
	if(status == STATUS_BUFFER_OVERFLOW)
	{
		processImagePath.Buffer = ExAllocatePoolWithTag(NonPagedPool, processImagePath.MaximumLength, PROCESS_POOL_TAG);
		if(processImagePath.Buffer != NULL)
		{
			status = GetProcessImageName(hProcessId, &processImagePath);
			if(NT_SUCCESS(status))
			{
				DbgPrint("CaptureProcessMonitor: %i %i=>%i:%wZ\n", bCreate, hParentId, hProcessId, &processImagePath);
				RtlStringCbCopyUnicodeString(pProcessManager->pCurrentProcessEvent->processPath, 1024, &processImagePath);
			}
			ExFreePoolWithTag(processImagePath.Buffer,PROCESS_POOL_TAG);
		}
	}

	pProcessManager->pCurrentProcessEvent->hParentProcessId = hParentId;
	pProcessManager->pCurrentProcessEvent->hProcessId = hProcessId;
	pProcessManager->pCurrentProcessEvent->bCreated = bCreate;

	KeSetEvent(pProcessManager->eNewProcessEvent, 0, FALSE);
	KeClearEvent(pProcessManager->eNewProcessEvent);
}
Ejemplo n.º 25
0
//----- (08001203) --------------------------------------------------------
NTSTATUS 
DMCreateClose(
	PDEVICE_OBJECT	DeviceObject, 
	PIRP			Irp
	)
{
	PIO_STACK_LOCATION		IrpStack;
	NTSTATUS				status;
	LARGE_INTEGER			PerfCount;
	LARGE_INTEGER			CurrentTime;
	ULONG					seq;
	PDEVICE_ENTRY			DevEntry;

	IrpStack = IoGetCurrentIrpStackLocation(Irp);

	if ( DeviceObject == g_pDeviceObject )
	{
		Irp->IoStatus.Status = STATUS_SUCCESS;
		Irp->IoStatus.Information = 0;

		g_bGUIActive = (IrpStack->MajorFunction == IRP_MJ_CREATE);

		IofCompleteRequest(Irp, 0);
		status = STATUS_SUCCESS;
	}
	else
	{
		if ( g_bUsePerfCounter )
		{
			PerfCount = KeQueryPerformanceCounter(NULL);
			CurrentTime.QuadPart = 0;
		}
		else
		{
			KeQuerySystemTime(&CurrentTime);
			PerfCount.QuadPart = 0;
		}

		seq = InterlockedIncrement(&Sequence);

		DevEntry = LookupEntryByDevObj(DeviceObject);
		if ( DevEntry )
		{
			LogRecord(
				seq,
				&CurrentTime,
				DevEntry->DiskNumber,
				"%s",
				IrpStack->MajorFunction == IRP_MJ_CLOSE ? "IRP_MJ_CLOSE" : "IRP_MJ_CREATE");
		}

		status = DefaultDispatch(DeviceObject, Irp, seq, g_bUsePerfCounter, &PerfCount);
	}

	return status;
}
Ejemplo n.º 26
0
//GetTimeStamp
void GetTimeStamp(uint64* pTime)
{
    LARGE_INTEGER systemTime;
    KeQuerySystemTime(&systemTime);

    LARGE_INTEGER localTime;
    ExSystemTimeToLocalTime(&systemTime, &localTime);

    *pTime = (uint64)localTime.QuadPart;
}
Ejemplo n.º 27
0
UINT64
AcpiOsGetTimer(
    void)
{
    LARGE_INTEGER CurrentTime;

    KeQuerySystemTime(&CurrentTime);

    return CurrentTime.QuadPart;
}
Ejemplo n.º 28
0
int restrictEnabled() {
  LARGE_INTEGER curtime, diff;
  KeQuerySystemTime(&curtime);
  diff = RtlLargeIntegerSubtract(curtime, Globals.DRIVERSTARTTIME);
  
  if (RtlLargeIntegerGreaterThan(diff,
				 Globals.RESTRICT_STARTUP_TIMEOUT))
    return 1;
  return 0;
}
Ejemplo n.º 29
0
ULONG GetCurrentTime()
{
	LARGE_INTEGER currentSystemTime;
	LARGE_INTEGER currentLocalTime;
	ULONG time;

	KeQuerySystemTime(&currentSystemTime);
	ExSystemTimeToLocalTime(&currentSystemTime,&currentLocalTime);
	RtlTimeToSecondsSince1970(&currentLocalTime, &time);
	return time;
}
Ejemplo n.º 30
0
static VOID
XenVbd_SendEvent(WDFDEVICE device) {
  PXENVBD_FILTER_DATA xvfd = GetXvfd(device);
  NTSTATUS status;
  WDFREQUEST request;
  WDF_REQUEST_SEND_OPTIONS send_options;
  IO_STACK_LOCATION stack;
  PUCHAR buf;
  PSCSI_REQUEST_BLOCK srb;
  PSRB_IO_CONTROL sic;

  status = WdfRequestCreate(WDF_NO_OBJECT_ATTRIBUTES, xvfd->wdf_target, &request);
  if (status != STATUS_SUCCESS) {
    FUNCTION_MSG("WdfRequestCreate failed %08x\n", status);
    /* this is bad - event will be dropped */
    return;
  }

  buf = ExAllocatePoolWithTag(NonPagedPool, sizeof(SCSI_REQUEST_BLOCK) + sizeof(SRB_IO_CONTROL) + sizeof(LARGE_INTEGER), XENVBD_POOL_TAG);
  RtlZeroMemory(buf, sizeof(SCSI_REQUEST_BLOCK) + sizeof(SRB_IO_CONTROL));
  srb = (PSCSI_REQUEST_BLOCK)(buf);
  sic = (PSRB_IO_CONTROL)(buf + sizeof(SCSI_REQUEST_BLOCK));
  
  srb->Length = sizeof(SCSI_REQUEST_BLOCK);
  srb->SrbFlags = SRB_FLAGS_BYPASS_FROZEN_QUEUE | SRB_FLAGS_NO_QUEUE_FREEZE;
  srb->PathId = 0;
  srb->TargetId = 0;
  srb->Lun = 0;
  srb->OriginalRequest = WdfRequestWdmGetIrp(request);
  srb->Function = SRB_FUNCTION_IO_CONTROL;
  srb->DataBuffer = sic;
  srb->DataTransferLength = sizeof(SCSI_REQUEST_BLOCK) + sizeof(SRB_IO_CONTROL);
  srb->TimeOutValue = (ULONG)-1;
  
  sic->HeaderLength = sizeof(SRB_IO_CONTROL);
  memcpy(sic->Signature, XENVBD_CONTROL_SIG, 8);
  sic->Timeout = (ULONG)-1;
  sic->ControlCode = XENVBD_CONTROL_EVENT;
  
  KeQuerySystemTime((PLARGE_INTEGER)((PUCHAR)buf + sizeof(SCSI_REQUEST_BLOCK) + sizeof(SRB_IO_CONTROL)));

  RtlZeroMemory(&stack, sizeof(IO_STACK_LOCATION));
  stack.MajorFunction = IRP_MJ_SCSI;
  stack.MinorFunction = IRP_MN_SCSI_CLASS;
  stack.Parameters.Scsi.Srb = srb;

  WdfRequestWdmFormatUsingStackLocation(request, &stack);
  WdfRequestSetCompletionRoutine(request, XenVbd_SendEventComplete, buf);
  
  WDF_REQUEST_SEND_OPTIONS_INIT(&send_options, 0); //WDF_REQUEST_SEND_OPTION_IGNORE_TARGET_STATE);
  if (!WdfRequestSend(request, xvfd->wdf_target, &send_options)) {
    FUNCTION_MSG("Error sending request\n");
  }
}