create an aligned virtual address on already commited memory ?

Hi all,

My application need to move large buffers (512 KB) to a SCSI device using
predefined IOCTL_SCSI_xxx and DeviceIOControl calls. However, there is a
device-dependant constraint on the alignment of the buffer to provide with
the IOCTL. Unfortunatly, I have no control over the allocation of the data
buffer to be passed down to the device; so if it is not properly aligned, I
see two options to provide and aligned buffer with the IOCTL:

  1. copy the application data to a properly aligned, temporary buffer. I do
    not like this because it consumes time, CPU and memory.

  2. create a new aligned virtual address and, somehow, associate it to the
    provided buffer.
    Can this be done by a Win32 (NT) application ? VirtualAlloc() could be used
    to do half the job, which is to reserve 512KB of virtual memory in the
    process space. Then, we still need to “commit” this VA to the provided
    buffer.

Any ideas ?

Thanks,

Alain

> 2) create a new aligned virtual address and, somehow, associate it to the

provided buffer.

Impossible. The page offset (Va % PAGE_SIZE) cannot be changed by
remapping the physical pages. So, if you have the address with, say, 1KB
page offset, then any attempts to remap it will result in addresses with the
same page offset.
You can read the Intel’s documentation (the parts on the page table formats)
for details.

Max