winIDEA SDK
isys::CCodeStore Class Reference

Description

This class is a container of multiple memory items.

Each item is of type CCodeStoreItem

Note: This class has not been ported to Linux yet.

- Python example for saving memory to Motorola S format.

#include <CCodeStore.h>

Public Member Functions

 CCodeStore (const SPConnectionMgr &rspConnectionMgr)
 Creates a new instance. More...
 
void clear ()
 Clears all items.
 
void copy (const CCodeStore &rSrc)
 Copies from another code store instance. More...
 
void load (DWORD dwFlags, const std::string &rstrFileName, TCodeStoreAddress aOffset)
 Load from a file. More...
 
DWORD load1 (DWORD dwFlags, const std::string &rstrFileName, TCodeStoreAddress aOffset)
 Load from a file. More...
 
void save (DWORD dwFlags, const std::string &rstrFileName, TCodeStoreAddress aOffset)
 Save to file. More...
 
void insert (TCodeStoreAddress aAddress, const std::vector< BYTE > vBuffer)
 Inserts a new chunk of code. More...
 
void insertWithAccessInfo (TCodeStoreAddress aAddress, const std::vector< BYTE > vBuffer)
 Inserts a new chunk of code, but only bytes, which have valid access. More...
 
void exclude (TCodeStoreAddress aAddressExcl, TCodeStoreAddress aEndExcl)
 Excludes a range. More...
 
bool empty () const
 Returns true if container is empty. More...
 
int numItems () const
 Returns number of all items. More...
 
SPCodeStoreItem getItem (int nIndex) const
 Returns item at index nIndex. More...
 
int findItem (TCodeStoreAddress aAddress) const
 Finds an item in the requested range. More...
 
TCodeStoreAddress getBuffer (TCodeStoreAddress aAddress, std::vector< BYTE > &vBuffer) const
 Obtains the code from the specified region. More...
 
TCodeStoreAddress getTotal () const
 Returns total number of contained locations. More...
 
TCodeStoreAddress getRangeLo () const
 Returns lowest loaded location. More...
 
TCodeStoreAddress getRangeHi () const
 Returns highest loaded location. More...
 
bool report (const std::string &fileReport, bool append, const std::string &format, DWORD maxInLine) const
 Creates a report to file. More...
 
bool reportDif (const std::string &fileReport, bool append, const std::string &format, DWORD maxInLine, const CCodeStore &rCC1, const CCodeStore &rCC2) const
 Creates a difference report to file. More...
 

Constructor & Destructor Documentation

◆ CCodeStore()

isys::CCodeStore::CCodeStore ( const SPConnectionMgr &  rspConnectionMgr)

Creates a new instance.

Parameters
rspConnectionMgrConnectionMgr object

Member Function Documentation

◆ copy()

void isys::CCodeStore::copy ( const CCodeStore rSrc)

Copies from another code store instance.

Previous contents are cleared.

Parameters
rSrcCCodeStore object to copy from

◆ empty()

bool isys::CCodeStore::empty ( ) const

Returns true if container is empty.

Returns
  • true : container is empty
  • false: container is not empty

◆ exclude()

void isys::CCodeStore::exclude ( TCodeStoreAddress  aAddressExcl,
TCodeStoreAddress  aEndExcl 
)

Excludes a range.

Parameters
aAddressExclstart of range to exclude
aEndExcllast address of range to exclude

◆ findItem()

int isys::CCodeStore::findItem ( TCodeStoreAddress  aAddress) const

Finds an item in the requested range.

Parameters
aAddressaddress which the found item covers
Returns
  • Index of the item
  • -1 - no item in the range

◆ getBuffer()

TCodeStoreAddress isys::CCodeStore::getBuffer ( TCodeStoreAddress  aAddress,
std::vector< BYTE > &  vBuffer 
) const

Obtains the code from the specified region.

Parameters
aAddressaddress from which the code should be retrieved
vBufferbuffer which is filled with the code. Caller must preallocate vBuffer to the size that should be retrieved. For languages other than C++ use vBuffer = isystem.connect.VectorBYTE(size).
Returns
  • number of locations filled

◆ getItem()

SPCodeStoreItem isys::CCodeStore::getItem ( int  nIndex) const

Returns item at index nIndex.

Parameters
nIndexindex of the element. Must be in range 0 .. numItems()-1
Returns
  • Pointer to item

◆ getRangeHi()

TCodeStoreAddress isys::CCodeStore::getRangeHi ( ) const

Returns highest loaded location.

Returns
  • Highest loaded location. 0 if empty

◆ getRangeLo()

TCodeStoreAddress isys::CCodeStore::getRangeLo ( ) const

Returns lowest loaded location.

Returns
  • Lowest loaded location. 0 if empty

◆ getTotal()

TCodeStoreAddress isys::CCodeStore::getTotal ( ) const

Returns total number of contained locations.

Returns
  • Number of contained locations

◆ insert()

void isys::CCodeStore::insert ( TCodeStoreAddress  aAddress,
const std::vector< BYTE >  vBuffer 
)

Inserts a new chunk of code.

Parameters
aAddressaddress at which the new code is inserted
vBuffercode to insert

◆ insertWithAccessInfo()

void isys::CCodeStore::insertWithAccessInfo ( TCodeStoreAddress  aAddress,
const std::vector< BYTE >  vBuffer 
)

Inserts a new chunk of code, but only bytes, which have valid access.

Use this method if data was obtaind by method CDataController::readMemory(), because only bytes, which have ACCESS_OK may be inserted into code cache.

Parameters
aAddressaddress at which the new code is inserted
vBuffercode to insert in the first vBuffer.size() / 2 bytes, access info in the last half.

◆ load()

void isys::CCodeStore::load ( DWORD  dwFlags,
const std::string &  rstrFileName,
TCodeStoreAddress  aOffset 
)

Load from a file.

Parameters
dwFlagsfor default behavior specify 0 for dwFlags, otherwise use ICodeCache::ESaveLoadFlags
rstrFileNamepath to the file to load from
aOffsetoffset to add to the code loaded from the file

◆ load1()

DWORD isys::CCodeStore::load1 ( DWORD  dwFlags,
const std::string &  rstrFileName,
TCodeStoreAddress  aOffset 
)

Load from a file.

The same operation as load(), but this one returns format used in loading the file.

Parameters
dwFlagsfor default behavior specify 0 for dwFlags, otherwise use ICodeCache::ESaveLoadFlags
rstrFileNamepath to the file to load from
aOffsetoffset to add to the code loaded from the file
Returns
  • Format used in loading the file. See ICodeCache::ESaveLoadFlags, enums lFormat... for possible return values and associated format. In Python you can refer to them as ic.ICodeCache.lFormatELF, for example.

◆ numItems()

int isys::CCodeStore::numItems ( ) const

Returns number of all items.

Returns
  • Number of items

◆ report()

bool isys::CCodeStore::report ( const std::string &  fileReport,
bool  append,
const std::string &  format,
DWORD  maxInLine 
) const

Creates a report to file.

Parameters
fileReportpath to the report file
appendtrue to append, false to create a new file
formatfor every single item, using %ADDR%, %SIZE%, %EADDR% and %DATA% macros. If empty, the default "A:%ADDR% S:%SIZE% D:%DATA%" is used
maxInLinespecifies maximum number of addresses reported in a line. Use 0 to report contiguous ranges in one line
Returns
  • true on success

◆ reportDif()

bool isys::CCodeStore::reportDif ( const std::string &  fileReport,
bool  append,
const std::string &  format,
DWORD  maxInLine,
const CCodeStore rCC1,
const CCodeStore rCC2 
) const

Creates a difference report to file.

Parameters
fileReportpath to the report file
appendtrue to append, false to create a new file
formatfor every single item, using %ADDR%, %SIZE%, %EADDR%, %DIF% and %DATA1%, %DATA2% macros. If empty, the default "A:%ADDR% S:%SIZE%\n D1:%DATA1%\n D2:%DATA2%" is used
maxInLinespecifies maximum number of addresses reported in a line. Use 0 to report contiguous ranges in one line
rCC1is the first reference code store from which this difference object was created
rCC2is the second reference code store from which this difference object was created
Returns
  • true on success

◆ save()

void isys::CCodeStore::save ( DWORD  dwFlags,
const std::string &  rstrFileName,
TCodeStoreAddress  aOffset 
)

Save to file.

Parameters
dwFlagsuse ICodeCache::ESaveLoadFlags to specify format. Only lFormatMotorolaS and lFormatBinary are supported. Note: Gaps in the store are padded with 0h when saving to binary file.
rstrFileNamepath to the file to save to
aOffsetoffset to add to the code saved to the file. If format is binary, then the offset determines the position in the store from where the saving starts.