xuanyuan14
驱动中牛
驱动中牛
  • 注册日期2002-03-07
  • 最后登录2003-01-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1280回复:5

求助地址问题

楼主#
更多 发布于:2002-12-15 22:06
已知物理地址,有没有什么函数可以把它转换成虚拟地址,然后可以在VC中对其进行操作?各位高手,帮帮忙吧,谢谢了!
好好学习,天天时尚!
Gong_XG
驱动太牛
驱动太牛
  • 注册日期2002-10-01
  • 最后登录2010-11-25
  • 粉丝0
  • 关注0
  • 积分313分
  • 威望46点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-12-15 22:10
估计编写驱动程序;
然后调用一个函数(自己查查),得到一个指针;
用deviceiocontrol()将指针传递到应用程序。

我以前用vxd做过。
Tom.Cat
禁止发言
禁止发言
  • 注册日期2001-10-10
  • 最后登录2019-07-29
  • 粉丝1
  • 关注0
  • 积分-53792分
  • 威望197411点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2002-12-16 09:46
用户被禁言,该主题自动屏蔽!
Dragon2008
驱动中牛
驱动中牛
  • 注册日期2002-04-01
  • 最后登录2006-03-13
  • 粉丝0
  • 关注0
  • 积分31分
  • 威望5点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-12-16 10:09
估计编写驱动程序;
然后调用一个函数(自己查查),得到一个指针;
用deviceiocontrol()将指针传递到应用程序。

我以前用vxd做过。


是的。这是一个类似问题的例程:

NTSTATUS SX5933Device::IOCTL_MEM_Handler(KIrp I)
{
NTSTATUS status = STATUS_SUCCESS;

t << \"Entering SX5933Device::IOCTL_MEM_Handler, \" << I << EOL;
// TODO: Verify that the input parameters are correct
// If not, return STATUS_INVALID_PARAMETER

// TODO: Handle the the IOCTL_MEM request, or
// defer the processing of the IRP (i.e. by queuing) and set
// status to STATUS_PENDING.
ULONG Address=Phy_Address.LowPart;

MemRegion = new (NonPagedPool) KMemoryToProcessMap(Address,    // peripheral memory address
 mem_length,  // number of bytes
 (HANDLE)-1,  // current process
 FALSE,       // don\'t do kernel mapping
 NULL,        // any address
 ViewShare);  // view inherit
if ( !MemRegion||!NT_SUCCESS( MemRegion->ConstructorStatus() ) )
{
  // insufficient memory
  I.Information() = 0;
  return FALSE;
}
((Mem_Param*)I.IoctlBuffer())->mdr_PhysicalAddress=Address;
((Mem_Param*)I.IoctlBuffer())->mdr_LinearAddress=MemRegion->ProcessAddress();
// TODO: Assuming that the request was handled here. Set I.Information
// to indicate how much data to copy back to the user.
I.Information() = sizeof(ULONGLONG);

return status;
}

NTSTATUS SX5933Device::IOCTL_UNMEM_Handler(KIrp I)
{
NTSTATUS status = STATUS_SUCCESS;

t << \"Entering SX5933Device::IOCTL_UNMEM_Handler, \" << I << EOL;
// TODO: Verify that the input parameters are correct
// If not, return STATUS_INVALID_PARAMETER

// TODO: Handle the the IOCTL_UNMEM request, or
// defer the processing of the IRP (i.e. by queuing) and set
// status to STATUS_PENDING.
delete MemRegion;
// TODO: Assuming that the request was handled here. Set I.Information
// to indicate how much data to copy back to the user.
I.Information() = 0;

return status;
}
我姓龙,我属龙,我叫龙。。。
xuanyuan14
驱动中牛
驱动中牛
  • 注册日期2002-03-07
  • 最后登录2003-01-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-12-16 11:16
谢谢各位大虾!我就是要编驱动,但不能用VXD,只能用C、VC++或汇编。我想可能会有相应的函数吧,可是我找了很久还没找到,急!!!!高手们帮帮忙吧!
好好学习,天天时尚!
Dragon2008
驱动中牛
驱动中牛
  • 注册日期2002-04-01
  • 最后登录2006-03-13
  • 粉丝0
  • 关注0
  • 积分31分
  • 威望5点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-12-16 12:47
如用DriverWorks,你可用这个函数:
KMemoryToProcessMap()
具体用法可查帮助,我上面的贴子就是一个应用的例子。
我姓龙,我属龙,我叫龙。。。
游客

返回顶部