void TargetPhrase::Save(OnDiskWrapper &onDiskWrapper) { // save in target ind size_t memUsed; char *mem = WriteToMemory(onDiskWrapper, memUsed); std::fstream &file = onDiskWrapper.GetFileTargetInd(); UINT64 startPos = file.tellp(); file.seekp(0, ios::end); file.write(mem, memUsed); UINT64 endPos = file.tellp(); CHECK(startPos + memUsed == endPos); m_filePos = startPos; free(mem); }
void __fastcall TMainForm::SGnewSetEditText(TObject *Sender, int ACol, int ARow, const AnsiString Value){ if (ACol == 3 && Value.Length()>=1){WriteToMemory(ARow-1, Value);} }
/** Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero. @param FileDescriptor Device to talk to. @param Buffer Buffer to hold Count bytes that were read @param Count Number of bytes to transfer. @retval -1 Error @retval {other} Number of bytes read. **/ INTN GdbRead ( IN INTN FileDescriptor, OUT VOID *Buffer, IN UINTN Count ) { CHAR8 Packet[128]; UINTN Size; INTN RetCode; UINTN ErrNo; BOOLEAN ReceiveDone = FALSE; // Send: // "Fread,XX,YYYYYYYY,XX // // XX - FileDescriptor in ASCII // YYYYYYYY - Buffer address in ASCII // XX - Count in ASCII // SS - check sum // Size = AsciiSPrint (Packet, sizeof (Packet), "Fread,%x,%x,%x", FileDescriptor, Buffer, Count); // Packet array is too small if you got this ASSERT ASSERT (Size < sizeof (Packet)); gProcessingFPacket = TRUE; SendPacket (Packet); Print ((CHAR16 *)L"Packet sent..\n"); do { // Reply: ReceivePacket (Packet, sizeof (Packet)); Print ((CHAR16 *)L"Command received..%c\n", Packet[0]); // Process GDB commands switch (Packet[0]) { //Write memory command. //M addr,length:XX... case 'M': WriteToMemory (Packet); break; //Fretcode, errno, Ctrl-C flag //retcode - Count read case 'F': //Once target receives F reply packet that means the previous //transactions are finished. ReceiveDone = TRUE; break; //Send empty buffer default : SendNotSupported(); break; } } while (ReceiveDone == FALSE); RetCode = GdbParseFReplyPacket (Packet, &ErrNo); Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo); if (ErrNo > 0) { //Send error to the host if there is any. SendError ((UINT8)ErrNo); } gProcessingFPacket = FALSE; return RetCode; }