gxPatchBuffer(string sDocument, string sBuffer, string sFileName, int flag);

Partially overwrites a document's buffer from an external file. The original buffer content is preserved at the addresses that are not overwritten by the file.

Parameters:

sDocument - document ID.
sBuffer - name of the buffer.
sFileName - file name
flag - gxBFAuto, determines the file type from its extension.

Remarks:

Buffer content can be directly accessed through the cVMMPhysModel object:
// This example dumps buffer data.

cVMMPhysModel buffer = thisDocument.Buffer.getModel("physicalBuffer");

int iStartAddr = 0x13;
int iEndAddr = 0x200;

// Display address, then buffer data.
for (int iAddr = iStartAddr; iAddr < iEndAddr; ++iAddr)
  print(MTR("%iAddr% %data%") << iAddr << buffer.getByte(iAddr));

// One byte per line - data only.
for (int iAddr = iStartAddr; iAddr < iEndAddr; ++iAddr)
print(buffer.getByte(iAddr));
// Display chunks of 16 bytes as hex dump.
for (int iAddr = iStartAddr; iAddr < iEndAddr;)
{
string s = MTR("%addr") << iAddr;
for (int i = 0; i < 16; ++i)
{
if (iAddr >= iEndAddr)
break;
s += " ";
s += message("%d%") << buffer.getByte(iAddr++);
}
print (s);
}

Example:

string sDocument = "document0";
string sBuffer = "physicalBuffer";
string sFileName = "test.hex"; gxPatchBuffer(sDocument, sBuffer, sFileName, gxBFAuto);

See also:

gxImportProject, gxExportProject, gxLoadBuffer

► latest version online