Beispiel #1
0
static int readwrite_pio(int devno, uint64_t sect, void *buf, void (*rwdata)(struct device*, void*))
{
	int use_irq, cmd, st, res = -1;
	uint32_t sect_low, sect_high;
	struct device *dev = devices + devno;

	if(dev->id == -1) {
		return -1;
	}
	use_irq = get_current_proc() != 0;

	if(use_irq) {
		/* wait for the interface to become available */
		mutex_lock(&pending);
	}

	select_dev(dev);

	/* LBA48 requires the high-order bits first */
	if(sect >= dev->nsect_lba) {
		sect_high = (uint32_t)(sect >> 24);
		sect_low = (uint32_t)sect & 0xffffff;

		if(sect >= dev->nsect_lba48) {
			goto end;
		}
		cmd = CMD_READ48;

		write_reg8(dev, REG_COUNT, 0);
		write_reg8(dev, REG_LBA0, sect_high & 0xff);
		write_reg8(dev, REG_LBA1, (sect_high >> 8) & 0xff);
		write_reg8(dev, REG_LBA2, (sect_high >> 16) & 0xff);
	} else {
Beispiel #2
0
void windows_read_enter(CPUState *cpu, target_ulong pc, uint32_t FileHandle, uint32_t Event, uint32_t UserApcRoutine, uint32_t UserApcContext, uint32_t IoStatusBlock, uint32_t Buffer, uint32_t BufferLength, uint32_t ByteOffset, uint32_t Key) {
    int64_t offset = -1;
    if (ByteOffset != 0) {
        // Byte offset into file is specified (pointer to LARGE_INTEGER). Read and interpret.
        panda_virtual_memory_rw(cpu, ByteOffset, (uint8_t *)&offset, sizeof(offset), 0);
        //printf("NtReadFile: %lu[%ld]\n", (unsigned long)FileHandle, offset);
    } else {
        //printf("NtReadFile: %lu[]\n", (unsigned long)FileHandle);
    }

    char *filename = get_handle_name(cpu, get_current_proc(cpu), FileHandle);
    if (ByteOffset && (offset >= 0 && offset < (1L << 48))) {
        read_enter(cpu, pc, filename, offset, Buffer, BufferLength);
    }
    else {
        offset = get_file_handle_pos(cpu, get_current_proc(cpu), FileHandle);
        if (offset != -1)
            read_enter(cpu, pc, filename, offset, Buffer, BufferLength);
        else // last resort. just assume last_pos.
            read_enter(cpu, pc, filename, last_pos, Buffer, BufferLength);
    }
}