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

📄 mapmem.cpp

📁 DS编写基于ISA插槽的,数据采集卡驱动程序,包含基本的中断,I/O读写
💻 CPP
字号:
// mapmem.cpp -  example driver
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060  USA
//
// Copyright (c) 1998 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================

// This driver maps a range of physical memory on the ISA bus.
// The address and size of the range have default values, but
// can be taken from the Parameters subkey of the driver's
// registry key at initialization. 
//
// The driver does not map the memory to kernel space. Rather,
// it waits until a process sends a DeviceIoControl call, and
// then it maps the address into that process. Later, the process
// calls back to undo the mapping.

#define VDW_MAIN
#include <vdw.h>
#include "function.h"
#include "mmioctl.h"
#include "mmdevice.h"
#include "mapmem.h"


//KDebugOnlyTrace	T("BasicPci");	// Global driver trace object

#pragma code_seg("INIT")

DECLARE_DRIVER_CLASS(MapMemDriver, NULL) 

//////////////////////////////////////////////////////////////////////////
// DriverEntry
//
// Retrieve parameters and create device object
//
NTSTATUS MapMemDriver::DriverEntry(PUNICODE_STRING RegistryPath)
{
	MapMemDevice* pDevice;

//	ULONG DeviceMemoryAddress = DEFAULT_DEVMEMORY_ADDRESS;
//	ULONG DeviceMemorySize = DEFAULT_DEVMEMORY_SIZE;
 /*   ULONG shouldBreak = FALSE;
	KRegistryKey Params(RegistryPath, L"Parameters");
	if ( NT_SUCCESS (Params.LastError()) )
	{
		Params.QueryValue(L"BreakOnEntry", &shouldBreak);
//		Params.QueryValue(L"DEVICE_SIZE", &DeviceMemorySize);
	}
    T << "In DriverEntry\n";

	if (shouldBreak) DbgBreakPoint();
*/
	pDevice = new (NonPagedPool) MapMemDevice();

	if ( pDevice == NULL )
		return STATUS_INSUFFICIENT_RESOURCES;
	else
	{
		NTSTATUS status = pDevice->ConstructorStatus();
		if ( !NT_SUCCESS(status) )
			delete pDevice;
		return status;
	}
}

#pragma code_seg()

⌨️ 快捷键说明

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