Hello everyone.
I´m struggling to understand this concept: I have a fixed size definition:
(from http://msdn.microsoft.com/pt-br/library/aa931918.aspx)
typedef struct _FlashRegion {
REGION_TYPE regionType;
DWORD dwStartPhysBlock;
DWORD dwNumPhysBlocks;
DWORD dwNumLogicalBlocks;
DWORD dwSectorsPerBlock;
DWORD dwBytesPerBlock;
DWORD dwCompactBlocks;
} FlashRegion, *PFlashRegion;
this FlashRegion struct, is used in this another struct: (from: http://msdn.microsoft.com/pt-br/library/aa932688.aspx)
typedef struct _FlashInfoEx {
DWORD cbSize;
FLASH_TYPEflashType;
DWORD dwNumBlocks;
WORD dwDataBytesPerSector;
DWORD dwNumRegions;
FlashRegion region[1];
} FlashInfoEx, *PFlashInfoEx;
The problem is, I can have a variable number of FlashRegions inside a FlashInfoEx. The function that I´m debugging does this somewhere in the code:
memcpy (pFlashInfoEx->region, g_pStorageDesc->pRegionTable,
g_pStorageDesc->dwNumRegions * sizeof(FlashRegion));
That means that it copies an amount of regions to pFlashInfoEx (that I pass in the call of the function);
So, the code will overwrite memory if dwNumRegions is bigger than one. If that is the case, Should I create a FlashRegion [FIXED_SIZE] in my code and somehow place/overwrite in FlashInfoEx->region? How do I do that?
Thanks, Marcelo