Re: determining process context



You have to create a thread with the correct process context, i.e get the
process handle of the current process in the DISPATCH routine, and then
create a thread to perform the request.

Obviously, there are optimizations here depending on known use patterns, for
instance I suspect that most requests will come from one, or a limited
number of processes, so you have a thread for each process to do the
mapping. Also, you need to handle the case where the process goes away.


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




"David" <know_devig@xxxxxxxxxxx> wrote in message
news:1122130783.339225.155920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi Don,
> In one of the discussions on such topic you had suggested alternative
> approach to IFS kit. I am trying to implement that, i.e. Sending IOCTL
> from application and performing wait in Kernel in a thread created
> using PsCreateSystemThread (In dispatch routine)
> But if PsCreateSystemThread doesnt put u in User context then is there
> any other way to wait in kernel, without blocking other IOCTL
> operations.
> Your help is really appreciated.
>
> - David
> Don Burn wrote:
>> "David" <know_devig@xxxxxxxxxxx> wrote in message
>> news:1122099525.124179.295440@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> > Does that mean, when it runs under system process context it is
>> > essentially same "Application" process context by which this dispatch
>> > routine is called?
>> > Reason of this question is, I need to access buffer pointer from IRP
>> > which has User virtual address and in order to access that, i need to
>> > be in same process context else i will corrupt some memory.
>> > So am i doing it correctly by running PsCreateSystemThread in system
>> > process context ? if not, what do I need to do to achieve this?
>> >
>> > - David
>> >
>> David,
>>
>> You sre going to have to change process contexts, for this you are
>> going to need KeStackAttachProcess to change to the correct process and
>> KeUnstackDetachProcess to revert back. Unfortunately, these routines and
>> their associated data structures are only defined in the IFS kit which
>> you
>> will have to buy from Microsoft.
>>
>> As Doron pointed out, this is complex code to get right. Validating
>> the buffer is not an easy task. If at all possible, don't do things this
>> way.
>>
>>
>> --
>> Don Burn (MVP, Windows DDK)
>> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>> Remove StopSpam from the email to reply
>


.



Relevant Pages

  • Re: determining process context
    ... PsGetCurrentProcess, PsCreateSystemThread fails. ... Is it possible to create thread from Dispatch routine, ... Mark Roddy wrote: ... >> So how do I create thread in Current Process context? ...
    (microsoft.public.development.device.drivers)
  • Re: determining process context
    ... I tried to get the Process context in dispatch routine using ... So how do I create thread in Current Process context? ... > you can create a transaction object and add buffers to it with individual ... >> kernel so I cannot use buffered or direct method because it will be ...
    (microsoft.public.development.device.drivers)
  • Re: determining process context
    ... I tried to get the Process context in dispatch routine using PsGetCurrentProcess and tried to supply this argument to my PsCreateSystemThread but when I do this, it DOESNT create Thread AT ALL. ... My application requirement is passing multiple buffers to the kernel so I cannot use buffered or direct method because it will be locked, we want to lock the buffers only when device requests it for DMA. ...
    (microsoft.public.development.device.drivers)
  • determining process context
    ... I am developing WDM driver and curious about process context. ... My Driver's Dispatch routine gets invoked, ... wakes up and start processing pending IRP. ... Is my Thread running in the same process context where Irp buffer ...
    (microsoft.public.development.device.drivers)
  • Re: determining process context
    ... >> Is my Thread running in the same process context where Irp buffer belongs ... PsCreateSystemThread has nothing to do with IRPs. ...
    (microsoft.public.development.device.drivers)

Loading