You said;
The TROUBLE happens when the buffer itself contains a pointer. For
example, if that “shared_memory_addr” is returned to you in the output
buffer of an ioctl, then you have a problem. This is one reason why
shared memory is so often a bad answer.
like this;
BOOL create_process_shared_memory(struct my_driver_handle_structure_s *hDevice, unsigned short *fail_reason)
{
BOOL fInit;
USHORT i;
hDevice->driver_process_ram.driver_map_object_handle = CreateFileMapping(
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security attributes
PAGE_READWRITE, // read/write access
0, // size: high 32-bits
SHMEMSIZE, // size: low 32-bits
“MySharedMem”); // name of map object
I think IoIs32bitProcess is better too.
Son
Date: Tue, 12 Apr 2011 11:40:06 -0700
From: xxxxx@probo.com
To: xxxxx@lists.osr.com
Subject: Re: [ntdev] 32 bit app inf file for 64 bit systems
ilker alici wrote:
>
> You RIGHT;
> there is void * parameters you said as ;
> BOOL read_pci_config_space(HANDLE hDevice, *void *output_buffer*,
> unsigned long output_buffer_size, unsigned long *bytes_returned)
> or
> void *shared_memory_addr; // pointer to shared memory
> i should change them!!
Not necessarily. For example, I’m guessing that first call eventually
turns into:
DeviceIoControl( hDevice,
IOCTL_READ_MY_PCI_SPACE,
NULL, 0,
output_buffer, output_buffer_size,
bytes_returned,
NULL
);
That doesn’t need any changes at all. The I/O manager will handle the
addresses, so that the IRP contains a 64-bit pointer into the 32-bit
process.
The TROUBLE happens when the buffer itself contains a pointer. For
example, if that “shared_memory_addr” is returned to you in the output
buffer of an ioctl, then you have a problem. This is one reason why
shared memory is so often a bad answer.
> and you talked about two ways to handle, is there any documantation
> about how can i do this?
I described the two methods. The key is remembering that “void *” has a
different size in a 32-bit module and a 64-bit module. The first method
is to have two separate ioctls, like IOCTL_MY_GET_SHARED_MEMORY_32
(which return 4 bytes) and IOCTL_MY_GET_SHARED_MEMORY_64 (which returns
8 bytes). The second method is to keep one ioctl code, but use
IoIs32bitProcess within the driver to decide what to do. That may be
the better solution, because you don’t have to modify the application –
your existing application binaries will still work.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer