⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpprt.cpp

📁 一个开放源码的bt848/878驱动程序的源码
💻 CPP
字号:

#include "Debug.hpp"
#include "CppRt.hpp"

/**************************************************************************\
* Module Name: ourcrt.cpp
*
* This file contains magic that prevents the c runtimes from being 
* linked in.  If they are linked in, the driver will not load.
* This primarily comes into play when your driver is C++.
*
\**************************************************************************/

extern "C" const int _fltused = 0;

/**************************************************************************\
* int __cdecl _purecall
*
* This function serves to avoid linking the CRT library for C++ code.
*
* History:
*  24-Aug-1998 -by- Tom Zakrajsek [tomz]
*   Documented it.
*
\**************************************************************************/

int __cdecl _purecall( void )
{
	ERROR(("purecall was called!\n"));
	return( FALSE );
}

VOID InitCppRT(void) {}
VOID TermCppRT(void) {}

//////////////////////////////////////////////////////////////////
// memory allocation operators

void * _cdecl operator new( size_t sz )
{
   PVOID p = ExAllocatePoolWithTag( NonPagedPool, sz , '848b' );
   DUMP(("Alloc %x got = %x\n", sz, p ) );
   return p;
}

void _cdecl operator delete( void *p )
{
   DUMP(("deleting = %x\n", p ) );
   if ( p ) {
      ExFreePool( p );
   }
}

#ifndef VC_4X_BUILD
// In VC versions below 5.0, the following two cases are covered by the 
// new and delete defined above. The following syntax is invalid in pre-
// 5.0 versions.
void * _cdecl operator new[]( size_t sz )  
{
   PVOID p = ExAllocatePoolWithTag( NonPagedPool, sz , '848b' );
   DUMP(("Alloc %x got = %x\n", sz, p ) );
   return p;
}

void _cdecl operator delete []( void *p )
{
   DUMP(( "deleting [] = %x\n", p ) );
   if ( p ) {
      ExFreePool( p );
   }
}
#endif

////////////////////////////////////////////////////////////////////
// Delay routines

// Delay function in us
void udelay( DWORD time ) // delay in us.
{
	LARGE_INTEGER tm;
	tm.QuadPart = - int( time * 10); // Relative mode
	KeDelayExecutionThread( KernelMode , FALSE , &tm );
}

// Delay function in ms
void mdelay( DWORD time )
{
	LARGE_INTEGER tm;
	tm.QuadPart = - int( time * 10000 ); // Relative mode
	KeDelayExecutionThread( KernelMode , FALSE , &tm );
}

// GetTickCount in milliseconds
ULONG GetTickCountInMs( void )
{
	LARGE_INTEGER t;
	KeQuerySystemTime(&t);
	return (ULONG)( t.QuadPart / 10000 );
}

void busywaitus( DWORD time ) 
{
	// First delay in multiples of 32 us (a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -