Re: data exchange betwen driver and gui aplication
- From: "euacela@xxxxxxxxx" <euacela@xxxxxxxxx>
- Date: 29 Jul 2006 08:25:58 -0700
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
.
- Follow-Ups:
- Re: data exchange betwen driver and gui aplication
- From: Maxim S. Shatskih
- Re: data exchange betwen driver and gui aplication
- From: Doron Holan [MS]
- Re: data exchange betwen driver and gui aplication
- References:
- data exchange betwen driver and gui aplication
- From: euacela
- Re: data exchange betwen driver and gui aplication
- From: Don Burn
- Re: data exchange betwen driver and gui aplication
- From: euacela@xxxxxxxxx
- Re: data exchange betwen driver and gui aplication
- From: Don Burn
- data exchange betwen driver and gui aplication
- Prev by Date: Re: data exchange betwen driver and gui aplication
- Next by Date: Converting kernel-mode print drivers to user mode
- Previous by thread: Re: data exchange betwen driver and gui aplication
- Next by thread: Re: data exchange betwen driver and gui aplication
- Index(es):
Relevant Pages
|