Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.3 KiB

4 years ago
  1. #ifndef _CSTREAM_INCLUDED
  2. #define _CSTREAM_INCLUDED
  3. static const UINT INPUT_BUF_SIZE = (64 * 1024);
  4. static const UINT HFILE_NOTREAD = ((UINT) -2);
  5. static const UINT DUAL_INPUT_BUF_SIZE = (8 * 1024);
  6. #define chEOF ((unsigned char) 255)
  7. class CStream
  8. {
  9. public:
  10. CStream(PCSTR pszFileName);
  11. ~CStream(void);
  12. int STDCALL seek(int pos, SEEK_TYPE seek = SK_SET);
  13. int Remaining() { return pEndBuf - pCurBuf; };
  14. #ifndef _DEBUG
  15. char cget() {
  16. if (pCurBuf < pEndBuf)
  17. return (char) *pCurBuf++;
  18. else if (pEndBuf < pbuf + cbBuf)
  19. return chEOF;
  20. else
  21. return ReadBuf();
  22. }
  23. #else
  24. char cget();
  25. #endif
  26. int tell(void) { return lFileBuf + (pCurBuf - pbuf); };
  27. BOOL STDCALL read(PBYTE pbDst, int cbBytes);
  28. char ReadBuf(void);
  29. friend DWORD WINAPI ReadAhead(LPVOID pv);
  30. void Cleanup(void);
  31. BOOL fInitialized;
  32. PBYTE pCurBuf; // current position in the buffer
  33. PBYTE pEndBuf; // last position in buffer
  34. protected:
  35. void WaitForReadAhead(void);
  36. int lFilePos; // position in the file
  37. int lFileBuf; // file position at first of buffer
  38. HFILE hfile; // file handle
  39. PBYTE pbuf; // address of allocated buffer
  40. PSTR pszFile; // copy of the filename
  41. int cbBuf; // buffer size
  42. int cThrdRead; // result from read-ahead thread
  43. HANDLE hthrd;
  44. DWORD idThrd;
  45. BOOL fDualCPU;
  46. };
  47. #endif // _CSTREAM_INCLUDED