//Write to our Sram file void DmaToSram(BYTE * Source, int StartOffset, int len) { DWORD dwWritten; //See if we have a sram file loaded if (hSramFile == NULL) { //If we dont, try to load it if (!LoadSram()) return; } SetFilePointer(hSramFile,StartOffset,NULL,FILE_BEGIN); WriteFile(hSramFile,Source,len,&dwWritten,NULL); }
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) { DWORD dwRead; if (m_hFile == NULL) { if (!LoadSram()) { return; } } SetFilePointer(m_hFile,StartOffset,NULL,FILE_BEGIN); ReadFile(m_hFile,dest,len,&dwRead,NULL); }
//Read the DMA from our Sram file void DmaFromSram(BYTE * dest, int StartOffset, int len) { DWORD dwRead; //See if we have a sram file loaded if (hSramFile == NULL) { //If we dont try and load it if (!LoadSram()) return; } SetFilePointer(hSramFile,StartOffset,NULL,FILE_BEGIN); ReadFile(hSramFile,dest,len,&dwRead,NULL); }
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len) { if (m_ReadOnly) { return; } if (m_hFile == NULL) { if (!LoadSram()) { return; } } DWORD dwWritten; SetFilePointer(m_hFile,StartOffset,NULL,FILE_BEGIN); WriteFile(m_hFile,Source,len,&dwWritten,NULL); FlushFileBuffers(m_hFile); }
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) { DWORD dwRead; DWORD i; BYTE tmp[4]; if (m_hFile == NULL) { if (!LoadSram()) { return; } } DWORD Offset = StartOffset & 3; if (Offset == 0) { SetFilePointer(m_hFile, StartOffset, NULL, FILE_BEGIN); ReadFile(m_hFile, dest, len, &dwRead, NULL); } else { SetFilePointer(m_hFile, StartOffset - Offset, NULL, FILE_BEGIN); ReadFile(m_hFile, tmp, 4, &dwRead, NULL); for (i = 0; i < (4 - Offset); i++) { dest[i + Offset] = tmp[i]; } for (i = 4 - Offset; i < len - Offset; i += 4) { ReadFile(m_hFile, tmp, 4, &dwRead, NULL); switch (Offset) { case 1: dest[i + 2] = tmp[0]; dest[i + 3] = tmp[1]; dest[i + 4] = tmp[2]; dest[i - 3] = tmp[3]; break; case 2: dest[i + 4] = tmp[0]; dest[i + 5] = tmp[1]; dest[i - 2] = tmp[2]; dest[i - 1] = tmp[3]; break; case 3: dest[i + 6] = tmp[0]; dest[i - 1] = tmp[1]; dest[i] = tmp[2]; dest[i + 1] = tmp[3]; break; default: break; } } ReadFile(m_hFile, tmp, 4, &dwRead, NULL); switch (Offset) { case 1: dest[i - 3] = tmp[3]; break; case 2: dest[i - 2] = tmp[2]; dest[i - 1] = tmp[3]; break; case 3: dest[i - 1] = tmp[1]; dest[i] = tmp[2]; dest[i + 1] = tmp[3]; break; default: break; } } }
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len) { DWORD dwWritten; DWORD i; BYTE tmp[4]; if (m_ReadOnly) { return; } if (m_hFile == NULL) { if (!LoadSram()) { return; } } DWORD Offset = StartOffset & 3; if (Offset == 0) { SetFilePointer(m_hFile, StartOffset, NULL, FILE_BEGIN); WriteFile(m_hFile, Source, len, &dwWritten, NULL); } else { for (i = 0; i < (4 - Offset); i++) { tmp[i] = Source[i + Offset]; } SetFilePointer(m_hFile, StartOffset - Offset, NULL, FILE_BEGIN); WriteFile(m_hFile, tmp, (4 - Offset), &dwWritten, NULL); SetFilePointer(m_hFile, Offset, NULL, FILE_CURRENT); for (i = 4 - Offset; i < len - Offset; i += 4) { switch (Offset) { case 1: tmp[0] = Source[i + 2]; tmp[1] = Source[i + 3]; tmp[2] = Source[i + 4]; tmp[3] = Source[i - 3]; break; case 2: tmp[0] = Source[i + 4]; tmp[1] = Source[i + 5]; tmp[2] = Source[i - 2]; tmp[3] = Source[i - 1]; break; case 3: tmp[0] = Source[i + 6]; tmp[1] = Source[i - 1]; tmp[2] = Source[i]; tmp[3] = Source[i + 1]; break; default: break; } WriteFile(m_hFile, tmp, 4, &dwWritten, NULL); } switch (Offset) { case 1: tmp[0] = Source[i - 3]; break; case 2: tmp[0] = Source[i - 2]; tmp[0] = Source[i - 1]; break; case 3: tmp[0] = Source[i - 1]; tmp[0] = Source[i]; tmp[0] = Source[i + 1]; break; default: break; } SetFilePointer(m_hFile, 4 - Offset, NULL, FILE_CURRENT); WriteFile(m_hFile, tmp, Offset, &dwWritten, NULL); } FlushFileBuffers(m_hFile); }