#ifndef __SIMULATEDHARDDISK_H__ #define __SIMULATEDHARDDISK_H__ #include // DWORD WINAPI /** @class SimulatedHardDisk @author Stan Birchfield (STB) */ class SimulatedHardDisk { public: // number of bytes in a sector enum { SHD_SECTOR_SIZE = 256 }; // parameter indicates whether write (true) or read (false) has finished typedef void (*InterruptHandler)(bool write); // create a file on the real hard disk to contain a simulated hard disk // 'real_filename': name of the real file // 'total_size': size of the file in bytes static void FormatHardDisk(const char* real_filename, int total_size); SimulatedHardDisk(); ~SimulatedHardDisk(); // set the device name // (i.e., the name of the real file that contains the simulated hard disk) bool SetDevice(const char* real_filename); // get the device name // (i.e., the name of the real file that contains the simulated hard disk) // returns the empty string if no device has been set const char* GetDevice() const; // set the function to be called whenever a read or write is complete void SetInterruptHandler(InterruptHandler interrupt_handler); public: // to read or write bytes, follow these steps: // 1. set 'sector' to the sector number // 2. set 'read' or 'write' to true // 3. the read or write will begin // 4. when the read or write is complete, the interrupt handler will be called (if set). // However, 'write' and 'read' will NOT be set to false automatically. You will need // to do this yourself in the interrupt handler, or another write/read will be initiated automatically. int sector; bool write, read; unsigned char buffer[ SHD_SECTOR_SIZE ]; // protected: // virtual void Interrupt(bool write) = 0; private: static DWORD WINAPI ThreadProc(LPVOID lpParameter); void MainLoop(); struct Data; Data* m_data; }; #endif // __SIMULATEDHARDDISK_H__