From: Gary Li on
Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
the different processes ?

-Gary

From: soviet_bloke on
> Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> the different processes ?

Of course you cannot do it - *ANY* handle is valid only in the context
of a process that has opened it, unless it has been duplicated with
DuplicateHandle()

Anton Bassov

Gary Li wrote:
> Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> the different processes ?
>
> -Gary

From: Gary Li on
Thanks for the feeback.

My problem actually is:
I need to access a big file in the workitem routine (kernel thread created
by driver and running in the PASSIVE_LEVEL). However, ZwCreateSection() will
report STATUS_SECTION_TOO_BIG if called in the routines other than
DriverEntry() or AddDevice().
Therefore, I am planing to create the file and section in AddDevice(), and
to map the view in the workitem routines. Now sure whether they are legal.
NtCurrentProcess() will be used to get process handle during mapping the view.
If AddDevice() and workitem are in different processes, how to use this
mechanism ? or is there any other mechanism to try for the same purpose ?

Thanks

-Gary

"soviet_bloke(a)hotmail.com" wrote:

> > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> > the different processes ?
>
> Of course you cannot do it - *ANY* handle is valid only in the context
> of a process that has opened it, unless it has been duplicated with
> DuplicateHandle()
>
> Anton Bassov
>
> Gary Li wrote:
> > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> > the different processes ?
> >
> > -Gary
>
>
From: Gary Li on
Accroding to DDK, the workitems are in system thread context, which should be
in the same process of AddDevice().
Does it mean the workitem can use the section handle created in AddDevice()
to map the view. Otherwise, ZwOpenSection() may have to be be used to get the
handle.

"Gary Li" wrote:

> Thanks for the feeback.
>
> My problem actually is:
> I need to access a big file in the workitem routine (kernel thread created
> by driver and running in the PASSIVE_LEVEL). However, ZwCreateSection() will
> report STATUS_SECTION_TOO_BIG if called in the routines other than
> DriverEntry() or AddDevice().
> Therefore, I am planing to create the file and section in AddDevice(), and
> to map the view in the workitem routines. Now sure whether they are legal.
> NtCurrentProcess() will be used to get process handle during mapping the view.
> If AddDevice() and workitem are in different processes, how to use this
> mechanism ? or is there any other mechanism to try for the same purpose ?
>
> Thanks
>
> -Gary
>
> "soviet_bloke(a)hotmail.com" wrote:
>
> > > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> > > the different processes ?
> >
> > Of course you cannot do it - *ANY* handle is valid only in the context
> > of a process that has opened it, unless it has been duplicated with
> > DuplicateHandle()
> >
> > Anton Bassov
> >
> > Gary Li wrote:
> > > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same handle in
> > > the different processes ?
> > >
> > > -Gary
> >
> >
From: David J. Craig on
Which WorkItems? Your own? If so, it is easy. Just open the file in the
work item initialization code before the worker thread begins its loop
waiting on new items to process. You can use a special 'work item' to let
your system thread know that it should exit. OSR has some nice code from a
NT Insider several years ago. It uses its own worker thread(s) to process
work items because during NT4 the number of system worker threads was
limited and generally reserved for file systems.

"Gary Li" <garyli(a)verizon.net> wrote in message
news:33F28EC5-3D38-4788-A634-E0FEF0B26F40(a)microsoft.com...
> Accroding to DDK, the workitems are in system thread context, which should
> be
> in the same process of AddDevice().
> Does it mean the workitem can use the section handle created in
> AddDevice()
> to map the view. Otherwise, ZwOpenSection() may have to be be used to get
> the
> handle.
>
> "Gary Li" wrote:
>
>> Thanks for the feeback.
>>
>> My problem actually is:
>> I need to access a big file in the workitem routine (kernel thread
>> created
>> by driver and running in the PASSIVE_LEVEL). However, ZwCreateSection()
>> will
>> report STATUS_SECTION_TOO_BIG if called in the routines other than
>> DriverEntry() or AddDevice().
>> Therefore, I am planing to create the file and section in AddDevice(),
>> and
>> to map the view in the workitem routines. Now sure whether they are
>> legal.
>> NtCurrentProcess() will be used to get process handle during mapping the
>> view.
>> If AddDevice() and workitem are in different processes, how to use this
>> mechanism ? or is there any other mechanism to try for the same purpose ?
>>
>> Thanks
>>
>> -Gary
>>
>> "soviet_bloke(a)hotmail.com" wrote:
>>
>> > > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same
>> > > handle in
>> > > the different processes ?
>> >
>> > Of course you cannot do it - *ANY* handle is valid only in the context
>> > of a process that has opened it, unless it has been duplicated with
>> > DuplicateHandle()
>> >
>> > Anton Bassov
>> >
>> > Gary Li wrote:
>> > > Can I call ZwCreateSection() and ZwMapViewOfSection() with the same
>> > > handle in
>> > > the different processes ?
>> > >
>> > > -Gary
>> >
>> >