Delphi和驱动通信的问题
时间:2011-10-12
来源:互联网
用户层如何接受R0的缓冲区字符串类型的数据呢?
KdPrint(("[Irp->AssociatedIrp.SystemBuffer_Data]: %s\n", *(ULONG*)ioBuffer));
-----
WinDbg输出:
[Irp->AssociatedIrp.SystemBuffer_Data]: C:\Documents and Settings\Administrator\桌面\Project1.exe
-----------
ReadFile或者DeviceIoControl
我在DP这样写不行
我已经在R0将字符串传递给了缓冲区。
procedure TForm1.btn3Click(Sender: TObject);
var
BytesReturned : DWORD;
ret : Boolean;
SendData: DWORD;
RecoyData: String;
begin
SendData:=0;
ret := DeviceIoControl(
m_hCommDevice,
IOCTL_EXTNDDRV_GET_STARTING_SERVICEID, //dwIoControlCode
@SendData,
0,
@RecoyData, //接受的数据
sizeof(RecoyData), //缓冲区大小设置
BytesReturned, //实际接受到的数据大小
nil);
//BytesReturned:= sizeof(RecoyData);
label1.Caption:= 'DeviceIoControl Run Over';
label1.Caption:= IntToStr(BytesReturned);
if ret = False then label1.Caption:= 'Operation failed';
if (ret = True) then
begin
//if (BytesReturned <> sizeof(RecoyData)) then
// begin
// label1.Caption:= 'Buffer Space Error,or Buffer Size Too short';
// ret := FALSE;
// end
// else
//begin
// label1.Caption:= 'Operation success!';
//edt2.Text := IntToStr(RecoyData);
edt2.Text := RecoyData;
ret := TRUE;
end;
end;
end;
-------
KdPrint(("[Irp->AssociatedIrp.SystemBuffer_Data]: %s\n", *(ULONG*)ioBuffer));
-----
WinDbg输出:
[Irp->AssociatedIrp.SystemBuffer_Data]: C:\Documents and Settings\Administrator\桌面\Project1.exe
-----------
ReadFile或者DeviceIoControl
我在DP这样写不行
我已经在R0将字符串传递给了缓冲区。
procedure TForm1.btn3Click(Sender: TObject);
var
BytesReturned : DWORD;
ret : Boolean;
SendData: DWORD;
RecoyData: String;
begin
SendData:=0;
ret := DeviceIoControl(
m_hCommDevice,
IOCTL_EXTNDDRV_GET_STARTING_SERVICEID, //dwIoControlCode
@SendData,
0,
@RecoyData, //接受的数据
sizeof(RecoyData), //缓冲区大小设置
BytesReturned, //实际接受到的数据大小
nil);
//BytesReturned:= sizeof(RecoyData);
label1.Caption:= 'DeviceIoControl Run Over';
label1.Caption:= IntToStr(BytesReturned);
if ret = False then label1.Caption:= 'Operation failed';
if (ret = True) then
begin
//if (BytesReturned <> sizeof(RecoyData)) then
// begin
// label1.Caption:= 'Buffer Space Error,or Buffer Size Too short';
// ret := FALSE;
// end
// else
//begin
// label1.Caption:= 'Operation success!';
//edt2.Text := IntToStr(RecoyData);
edt2.Text := RecoyData;
ret := TRUE;
end;
end;
end;
-------
作者: xedazss 发布时间: 2011-10-12
第一,你的接收使用了阻塞式,第二、在主线程就收。
建议不要这样做,可以借鉴spcomm控件的手法,使用线程循环监控、异步通讯(非阻塞式),用事件驱动。
建议不要这样做,可以借鉴spcomm控件的手法,使用线程循环监控、异步通讯(非阻塞式),用事件驱动。
作者: gzzai 发布时间: 2011-10-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28