BOOL YGFSMonSaveRegData(UCHAR ucDrive,PCHAR pRegPath,PCHAR pValue,DWORD dwType,UCHAR *pData,DWORD dwDataLen) { char szPath[MAX_PATH],szFile[MAX_PATH]; DWORD hFile,dwAction; REGDATAHEAD RegHead; RegHead.dwType = dwType; RegHead.dwDataLen = dwDataLen; _lstrcpyn(szPath, "C:\\YGReg\\",_lstrlen("C:\\YGReg\\")+1); szPath[0] = ucDrive; YGFSMonConvertRegPath(pRegPath,TRUE); strcat(szPath,pRegPath); if (CreateDirAnsi(szPath)) { strcat(szPath,"\\"); _lstrcpyn(szFile,(pValue&&pValue[0])?pValue:"(default)",_lstrlen((pValue&&pValue[0])?pValue:"(default)")+1); YGFSMonConvertRegPath(szFile,FALSE); strcat(szPath,szFile); if (!R0_OpenCreateFile(FALSE, ACCESS_READWRITE | SHARE_COMPATIBILITY, 0,ACTION_OPENALWAYS, 0, szPath, &hFile,&dwAction)) { R0_WriteFile(FALSE,hFile,sizeof(REGDATAHEAD),0,(UCHAR *)&RegHead,&dwAction); R0_WriteFile(FALSE,hFile,dwDataLen,sizeof(REGDATAHEAD),pData,&dwAction); R0_CloseFile(hFile); } else _asm int 3 } else _asm int 3
/**************************************************************************** REMARKS: VxD implementation of the ANSI C fwrite function. Note that the VxD file I/O functions are layered on DOS, so can only read up to 64K at a time. Since we are expected to handle much larger chunks than this, we handle larger blocks automatically in here. ****************************************************************************/ size_t fwrite( const void *ptr, size_t size, size_t n, FILE *f) { const char *buf = ptr; WORD error; int bytes,writtenbytes,totalbytes = 0; /* Flush anything already in the buffer */ if (!f->writemode) return 0; fflush(f); bytes = size * n; while (bytes > 0x10000) { if (initComplete) { writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); writtenbytes += R0_WriteFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); } else { writtenbytes = i_write(f->handle,buf,0x8000); writtenbytes += i_write(f->handle,buf+0x8000,0x8000); } totalbytes += writtenbytes; f->offset += writtenbytes; buf += 0x10000; bytes -= 0x10000; } if (initComplete) writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); else writtenbytes = i_write(f->handle,buf,bytes); totalbytes += writtenbytes; f->offset += writtenbytes; if (f->offset > f->filesize) f->filesize = f->offset; return totalbytes / size; }
/**************************************************************************** REMARKS: VxD implementation of the ANSI C fflush function. ****************************************************************************/ int fflush( FILE *f) { WORD error; int bytes; /* First copy any data already written into our buffer */ if (f->writemode && (bytes = (f->curp - f->startp)) > 0) { if (initComplete) bytes = R0_WriteFile(false,(HANDLE)f->handle,f->startp,bytes,f->offset,&error); else bytes = i_write(f->handle,f->startp,bytes); f->offset += bytes; if (f->offset > f->filesize) f->filesize = f->offset; f->startp = f->curp = f->buf; } return 0; }