Re: data exchange betwen driver and gui aplication

Tech-Archive recommends: Fix windows errors by optimizing your registry



there is absolutely no need to call MmIsAddressValid on Irp->UserBuffer, it
will be a valid address. you can trust the i/o manager. you cannot trust
any METHOD_NEITHER buffers or embedded pointers though. for that case,
MmIsAddressValid is not the right API to call anyways, you need to probe
and lock the buffer.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<euacela@xxxxxxxxx> wrote in message
news:1154186758.373038.247700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
typedef struct _pEvent
{
char test[100];
HANDLE hEvent;
}PEVENT;
PEVENT *test;


case IOCTL_SEND_HANDLE:

DbgPrint("TRying to receive handle");

if
(IrpStack->Parameters.DeviceIoControl.InputBufferLength>=sizeof(PEVENT))
{


//test=Irp->AssociatedIrp.SystemBuffer;
test=Irp->UserBuffer;


if (!MmIsAddressValid(test))
{
DbgPrint("Could not import handle");
return STATUS_ACCESS_VIOLATION;
}

UserProcessHandleEvent=test->hEvent;
try {
ProbeForWrite( UserProcessHandleEvent,sizeof( HANDLE ), 4);
}

except( EXCEPTION_EXECUTE_HANDLER )
{
DbgPrint("Could not receive handle");
ExRaiseAccessViolation();
return STATUS_ACCESS_VIOLATION;
}
DbgPrint("%s",test->test);


rc =ObReferenceObjectByHandle
(
UserProcessHandleEvent,
GENERIC_ALL,
NULL,
KernelMode,
(PVOID *)&ProcessEvent,
0
);
if (!NT_SUCCESS(rc))
DbgPrint("Could not reference object corectly" );
else
DbgPrint("Referenced object corectly");
}
break;




and the user mode aplication is like this
the ctl_code is method buffered


PEVENT test;
strcpy(test.test,"test");
test.hEvent=CreateEvent();
DeviceIoControl(hFile,0,0,&test,sizeof(test),&ret,NULL);






Don Burn wrote:
Show the group the code fragment of the application and the
DeviceIoControl
code for the driver. At this point there is not enough data.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply



<euacela@xxxxxxxxx> wrote in message
news:1154185232.666047.95350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes I know I must reference it but I dont't even get it.
I never get to use the handle.
But instead if I define a structure sometthing like
typedef struct _data
{
char stuff[100];
}DATA;
and I send this to kernel the "stuff " variable arrives OK but if I
define it like this

typedef struct _data
{
char stuff[100];
HANDLE hEvent;
}DATA;

I get the error:
I mean the Irp->UserBuffer is not a valid address.



Don Burn wrote:
When you say you send a handle and then get memory invalid, is this on
saving the handle or using it? If it is on using the handle it is
probably
because you are no longer in the context of the process for the
handle,
you
should be using ObReferenceObjectByHandle in the DeviceIoControl
routine
to
get the event. If you haven't done so take a look at the event sample
in
the current ddk under src\general\event


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply



<euacela@xxxxxxxxx> wrote in message
news:1154176326.304975.192930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I want to know how can it be done corectly.
I can't seem to find any documentation on this.
For example how can I tell if the buffer was sent to the driver in
the
Type3InputBuffer variable or Irp->UserBuffer.
I know it depends on how you define your control codes.
I mean: METHOD bufered => the buffer will come in Irp->UserBuffer
for
example.
Can someone clear this out for me a little or tell me where I can
find
documentation.
I am trying to send a handle of an event in kernel mode and it
always
tells me that the memory is not valid but if I am sending a string
it
works.
Please help me.
Thanks in advance





.



Relevant Pages

  • Re: how to accessed paged memory at DISPATCH_LEVEL
    ... passive, after copying the buffer. ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... accessed paged memory: KsStreamHeader->Data, i have not way or ideas to ...
    (microsoft.public.development.device.drivers)
  • Re: Device Initialization File
    ... Don Burn ... SetupDiGetDeviceRegistryProperty with>> the same DeviceInfoData argument will allow you to get the UI number (i.e.>> the PCI slot and bus number) for this device. ... >> Don Burn (MVP, Windows DDK) ... >> Windows 2k/XP/2k3 Filesystem and Driver Consulting ...
    (microsoft.public.development.device.drivers)
  • Re: DeviceIoControl Usage
    ... Don Burn ... >> If the buffer is small METHOD_BUFFERED is best. ... >> Don Burn (MVP, Windows DDK) ... >> Windows 2k/XP/2k3 Filesystem and Driver Consulting ...
    (microsoft.public.development.device.drivers)
  • Re: __rdtsc() intrinsic function in Windows server 2003 sp1 DDK
    ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... what do we need to do additionally for x86 build to compile correctly? ...
    (microsoft.public.development.device.drivers)
  • Re: Question about firewall
    ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... get in the hook code isn't always the process ID of whoever established ...
    (microsoft.public.win32.programmer.kernel)