Skip to content

Commit

Permalink
Fix for out-of-bounds access error with regionoffsets. Breaks compati…
Browse files Browse the repository at this point in the history
…bility.
  • Loading branch information
peterix committed Mar 31, 2010
1 parent 3313175 commit 35960db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions library/DFHackAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool API::InitMap()
/*
* --> SHM initialization (if possible) <--
*/
g_pProcess->getModuleIndex("Maps",2,d->maps_module);
g_pProcess->getModuleIndex("Maps",3,d->maps_module);

if(d->maps_module)
{
Expand Down Expand Up @@ -351,7 +351,7 @@ bool API::ReadTileTypes (uint32_t x, uint32_t y, uint32_t z, tiletypes40d *buffe
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->read (addr + d->tile_type_offset, 256 * sizeof (uint16_t), (uint8_t *) buffer);
g_pProcess->read (addr + d->tile_type_offset, sizeof (tiletypes40d), (uint8_t *) buffer);
return true;
}
return false;
Expand Down Expand Up @@ -413,7 +413,7 @@ bool API::ReadDesignations (uint32_t x, uint32_t y, uint32_t z, designations40d
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->read (addr + d->designation_offset, 256 * sizeof (uint32_t), (uint8_t *) buffer);
g_pProcess->read (addr + d->designation_offset, sizeof (designations40d), (uint8_t *) buffer);
return true;
}
return false;
Expand All @@ -426,7 +426,7 @@ bool API::ReadOccupancy (uint32_t x, uint32_t y, uint32_t z, occupancies40d *buf
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->read (addr + d->occupancy_offset, 256 * sizeof (uint32_t), (uint8_t *) buffer);
g_pProcess->read (addr + d->occupancy_offset, sizeof (occupancies40d), (uint8_t *) buffer);
return true;
}
return false;
Expand All @@ -439,7 +439,7 @@ bool API::WriteTileTypes (uint32_t x, uint32_t y, uint32_t z, tiletypes40d *buff
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->write (addr + d->tile_type_offset, 256 * sizeof (uint16_t), (uint8_t *) buffer);
g_pProcess->write (addr + d->tile_type_offset, sizeof (tiletypes40d), (uint8_t *) buffer);
return true;
}
return false;
Expand All @@ -457,7 +457,7 @@ bool API::WriteDesignations (uint32_t x, uint32_t y, uint32_t z, designations40d
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->write (addr + d->designation_offset, 256 * sizeof (uint32_t), (uint8_t *) buffer);
g_pProcess->write (addr + d->designation_offset, sizeof (designations40d), (uint8_t *) buffer);
return true;
}
return false;
Expand All @@ -469,7 +469,7 @@ bool API::WriteOccupancy (uint32_t x, uint32_t y, uint32_t z, occupancies40d *bu
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->write (addr + d->occupancy_offset, 256 * sizeof (uint32_t), (uint8_t *) buffer);
g_pProcess->write (addr + d->occupancy_offset, sizeof (occupancies40d), (uint8_t *) buffer);
return true;
}
return false;
Expand All @@ -483,7 +483,7 @@ bool API::ReadRegionOffsets (uint32_t x, uint32_t y, uint32_t z, biome_indices40
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
g_pProcess->read (addr + d->biome_stuffs, 16 * sizeof (uint8_t), (uint8_t *) buffer);
g_pProcess->read (addr + d->biome_stuffs, sizeof (biome_indices40d), (uint8_t *) buffer);
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/DFTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ union t_blockflags
typedef int16_t tiletypes40d [16][16];
typedef DFHack::t_designation designations40d [16][16];
typedef DFHack::t_occupancy occupancies40d [16][16];
typedef uint8_t biome_indices40d [8];
typedef uint8_t biome_indices40d [16];

typedef struct
{
Expand Down
2 changes: 1 addition & 1 deletion shmserver/mod-maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace DFHack
namespace Maps
{

#define MAPS_VERSION 2
#define MAPS_VERSION 3
typedef struct
{
uint32_t map_offset;// = d->offset_descriptor->getAddress ("map_data");
Expand Down

0 comments on commit 35960db

Please sign in to comment.