I'm including the routines that we modified. I hate to send the whole file around the entire list. The ppdbuffer and ppdbuffersize are set initially when the database is opened and closed. The current implementation may not be threadsafe, but we are single threaded.


extern int ppdbuffersize; extern void *ppdbuffer;

int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
  DWORD got;
  int i;

  assert( id->isOpen );
  SimulateIOError(SQLITE_IOERR);
  TRACE3("READ %d lock=%d\n", id->h, id->locktype);
  if( !ReadFile(id->h, pBuf, amt, &got, 0) ){
    got = 0;
  }

// PPD - XOR the buffer with a pattern so the disk file contents are not in plain text
for (i = 0; i < got/4; i++)
{
*((DWORD *)((DWORD *)pBuf + i)) = (*((DWORD *)((DWORD *)pBuf + i)))^0xA5A5A5A5;
}


  // XOR the buffer with a pattern - any leftover bytes
  for (i = 0; i < got%4; i++)
  {
    *((BYTE *)((BYTE *)pBuf + i)) = (*((BYTE *)((BYTE *)pBuf + i)))^0xA5;
  }


if( got==(DWORD)amt ){ return SQLITE_OK; }else{ return SQLITE_IOERR; } }

int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
  int rc;
  DWORD wrote;
  int i;

  if (ppdbuffersize < amt)
  {
    ppdbuffersize = amt + 1024;
    ppdbuffer = realloc(ppdbuffer, ppdbuffersize);
  }

// PPD - XOR the buffer with a pattern so the disk file contents are not in plain text
for (i = 0; i < amt/4; i++)
{
*((DWORD *)((DWORD *)ppdbuffer + i)) = (*((DWORD *)((DWORD *)pBuf + i)))^0xA5A5A5A5;
}


  // XOR the buffer with a pattern - any leftover bytes
  for (i = 0; i < amt%4; i++)
  {
    *((BYTE *)((BYTE *)ppdbuffer + i)) = (*((BYTE *)((BYTE *)pBuf + i)))^0xA5;
  }

  pBuf = ppdbuffer;

assert( id->isOpen );
SimulateIOError(SQLITE_IOERR);
TRACE3("WRITE %d lock=%d\n", id->h, id->locktype);
while( amt>0 && (rc = WriteFile(id->h, pBuf, amt, &wrote, 0))!=0 && wrote>0 ){
amt -= wrote;
pBuf = &((char*)pBuf)[wrote];
}


  if( !rc || amt>(int)wrote ){
    return SQLITE_FULL;
  }
  return SQLITE_OK;
}


At 03:03 PM 9/10/2004, you wrote:
Joey,

Would you mind sharing the modifications you made to the os_win.c file?
I would be interested in using such a modification, unfortunately, c++
isn't my strongest language.

Thanks!

Bob



Reply via email to