1

For some reason on my application when running on some configuration of hard disk (RAID, random partitions, through a separate IDE controller, not on the operating systems partition), VirtualAlloc returns null with the GetLastError code of ERROR_INVALID_PARAMETER.

The only parameter apart from the flags (MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE) passed in is the size calculated as a multiple of the sector size obtained from the disk geometry (unfortunately I cant post code due to NDA etc).

Just wondering if anyone has any experience of this? or if anyone knows any reason why windows might treat page sizes differently on disks that are part of a raid or partitioned?, any help is greatly appreciated thanks!

Stu Thompson
  • 38,370
  • 19
  • 110
  • 156
Stowelly
  • 1,260
  • 2
  • 12
  • 31
  • 1
    As you are attempting to commit an already reserved block, are you checking that when you reserved the block whether the address was rounded down to a multiple of the allocation granularity? In your calculation of the size requested do you have any protection against requesting unusually large amounts of memory? – CB Bailey Jun 30 '09 at 10:53
  • the offset is rounded down to granularity of the sector size, and is checks in to guard against any errors with this, although it doesnt look like were guarding against large amounts of memory being requested, although im putting in some extra logging to output the length when it fails – Stowelly Jun 30 '09 at 11:20
  • the problem seems to lie in DeviceIoControl, for any disk that isnt the primary hard drive it doesnt return valid drive geometry, any ideas? – Stowelly Jun 30 '09 at 15:45
  • Perhaps you should ask a separate question. Your question about VirtualAlloc now has nothing to do with your real problem which is actually about DeviceIoControl. Anybody who can help won't know that they can from the question title or description. – CB Bailey Jun 30 '09 at 18:13

1 Answers1

0

Issue was to do with DeviceIoControl when trying to return IOCTL_DISK_GET_DRIVE_GEOMETRY seemed to be returning complete garbage when using anything other than the primary hdd, I solved this by using GetDiskFreeSpace instead to get the sector information and is all working fine

obviously finding out why IOCTL_DISK_GET_DRIVE_GEOMETRY is garbage would be ideal, but im happy that it works!

Stowelly
  • 1,260
  • 2
  • 12
  • 31