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

📄 itek_util.c

📁 win9x下的一个网卡驱动程序。
💻 C
字号:
/////////////////////////////////////////////////////////////////////////
// atm_util.c
//  any utility routines
//to use the following functions from standard c-library directly
#include  <string.h>
#pragma intrinsic(memcpy, memcmp, memset, strcat, strcmp, strcpy, strlen)

#pragma warning(disable:4201 4514 4100 4127)

//to include Windows95 DDK header files
//
#define	WANTVXDWRAPS

#include  <basedef.h>
#include  <vmm.h>
#include  <vxdwraps.h>
#include  <debug.h>

// copied from Miniport.h for NT3.51
#define FIELD_OFFSET(type, field)    ((LONG)&(((type *)0)->field))

#include  <ndis.h>
#include  <vwin32.h>
#include  <efilter.h>

#include	"ITek_type.h"
#include    "ITek_init.h"
#include    "ITek_util.h"

#pragma VxD_LOCKED_CODE_SEG
#pragma VxD_LOCKED_DATA_SEG


#ifdef	ITEK_TIMER

VOID	NDIS_API
ITekTimerFunction(
		IN	PVOID	SystemSpecific1,
		IN	PVOID	FunctionContext,
		IN	PVOID	SystemSpecific2,
		IN	PVOID	SystemSpecific3
		)
{
	PITEK_ADAPTER	pITekAdapter = (PITEK_ADAPTER)FunctionContext;

#ifdef	DEBUG
	Debug_Printf("ITEK:ITekTimerFunction() Entry\n");
#endif

	NdisSetTimer(
		&pITekAdapter->NdisTimer,
		ITEK_TIMEOUT_MSEC);			

#ifdef	DEBUG
	Debug_Printf("ITEK:ITekTimerFunction() Return\n");
#endif
	return;
}

#endif	//ITEK_TIMER



VOID	NDIS_API
ITekAllocateSharedMemory(
		IN	NDIS_HANDLE	NdisAdapterHandle,
		IN	ULONG	Length,
		IN	ULONG	AlignMask,
		OUT	PVOID	*VirtualAddress,
		OUT	PNDIS_PHYSICAL_ADDRESS	PhysicalAddress
		)
{
	ULONG	nPages;
	PVOID	VirtualAddressLocal;	
	PVOID	PhysicalAddressLocal;

	nPages = (Length+4095)/4096;

	VirtualAddressLocal = (PVOID)_PageAllocate(
								nPages,					//nPages
								PG_SYS,					//nType
								(ULONG) 0,				//VM 
								AlignMask,				//AignMask
								(ULONG) 1,						//minPhys 
								(ULONG)0x0000FFFF,				//maxPhys
								(PVOID *)&PhysicalAddressLocal,		//
								(ULONG)(PAGECONTIG | PAGEFIXED | PAGEUSEALIGN)	//flags
								);

	*VirtualAddress = VirtualAddressLocal;
	*PhysicalAddress = (NDIS_PHYSICAL_ADDRESS)PhysicalAddressLocal;

	return;
}


VOID	NDIS_API
ITekFreeSharedMemory(
		IN	NDIS_HANDLE	NdisAdapterHandle,
		IN	PVOID	VirtualAddress
		)
{
	_PageFree(VirtualAddress, 0);
	return;
}


VOID	NDIS_API
ITekAllocateMemory(
		OUT	PVOID	*VirtualMemory,
		IN	ULONG	nBytes
		)
{
	PVOID	VirtualMemoryLocal;

	VirtualMemoryLocal = (PVOID)_HeapAllocate(
										nBytes,
										(ULONG)(HEAPLOCKEDIFDP|HEAPZEROINIT));

	*VirtualMemory = VirtualMemoryLocal;

	return;
}

VOID	NDIS_API
ITekFreeMemory(
		IN	PVOID	VirtualMemory
		)
{
	(void)_HeapFree(VirtualMemory, 0);

	return;
}

⌨️ 快捷键说明

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