diff --git a/amex/ds.c b/amex/ds.c index 59c6254..4c69f69 100644 --- a/amex/ds.c +++ b/amex/ds.c @@ -149,26 +149,25 @@ static HRESULT ds_handle_ioctl(struct irp *irp) static HRESULT ds_ioctl_get_geometry(struct irp *irp) { - DISK_GEOMETRY *out; - - if (irp->read.nbytes < sizeof(*out)) { - dprintf("DS: Invalid ioctl response buffer size\n"); - - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } + DISK_GEOMETRY out; + HRESULT hr; dprintf("DS: Get geometry\n"); - out = (DISK_GEOMETRY *) irp->read.bytes; - out->Cylinders.QuadPart = 1; - out->MediaType = 0; - out->TracksPerCylinder = 1; - out->SectorsPerTrack = 2; - out->BytesPerSector = 32; + memset(&out, 0, sizeof(out)); + out.Cylinders.QuadPart = 1; + out.MediaType = 0; + out.TracksPerCylinder = 1; + out.SectorsPerTrack = 2; + out.BytesPerSector = 32; - irp->read.pos = sizeof(*out); + hr = iobuf_write(&irp->read, &out, sizeof(out)); - return S_OK; + if (FAILED(hr)) { + dprintf("DS: Get geometry failed: %08x\n", (int) hr); + } + + return hr; } static HRESULT ds_ioctl_setup(struct irp *irp) diff --git a/amex/eeprom.c b/amex/eeprom.c index 4c1d1d5..aa004f3 100644 --- a/amex/eeprom.c +++ b/amex/eeprom.c @@ -118,28 +118,27 @@ static HRESULT eeprom_handle_ioctl(struct irp *irp) static HRESULT eeprom_ioctl_get_geometry(struct irp *irp) { - DISK_GEOMETRY *out; - - if (irp->read.nbytes < sizeof(*out)) { - dprintf("EEPROM: Invalid ioctl response buffer size\n"); - - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } + DISK_GEOMETRY out; + HRESULT hr; dprintf("EEPROM: Get geometry\n"); /* Not the real values, just bullshitting something for now */ - out = (DISK_GEOMETRY *) irp->read.bytes; - out->Cylinders.QuadPart = 0x800; - out->MediaType = 0; - out->TracksPerCylinder = 1; - out->SectorsPerTrack = 2; - out->BytesPerSector = 4; + memset(&out, 0, sizeof(out)); + out.Cylinders.QuadPart = 0x800; + out.MediaType = 0; + out.TracksPerCylinder = 1; + out.SectorsPerTrack = 2; + out.BytesPerSector = 4; - irp->read.pos = sizeof(*out); + hr = iobuf_write(&irp->read, &out, sizeof(out)); - return S_OK; + if (FAILED(hr)) { + dprintf("EEPROM: Get geometry failed: %08x\n", (int) hr); + } + + return hr; } static HRESULT eeprom_handle_read(struct irp *irp) diff --git a/amex/gpio.c b/amex/gpio.c index 6f5c4da..cba3b7d 100644 --- a/amex/gpio.c +++ b/amex/gpio.c @@ -205,18 +205,17 @@ static HRESULT gpio_ioctl_get_psw(struct irp *irp) static HRESULT gpio_ioctl_describe(struct irp *irp) { + HRESULT hr; + dprintf("GPIO: Describe GPIO ports\n"); - if (irp->read.nbytes < sizeof(gpio_ports)) { - dprintf("GPIO: Descriptor read buffer too small\n"); + hr = iobuf_write(&irp->read, &gpio_ports, sizeof(gpio_ports)); - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + if (FAILED(hr)) { + dprintf("GPIO: Describe GPIO ports failed: %08x\n", (int) hr); } - memcpy(irp->read.bytes, &gpio_ports, sizeof(gpio_ports)); - irp->read.pos = sizeof(gpio_ports); - - return S_OK; + return hr; } static HRESULT gpio_ioctl_set_leds(struct irp *irp) diff --git a/amex/sram.c b/amex/sram.c index 790588b..1b8f81a 100644 --- a/amex/sram.c +++ b/amex/sram.c @@ -114,24 +114,23 @@ static HRESULT sram_handle_ioctl(struct irp *irp) static HRESULT sram_ioctl_get_geometry(struct irp *irp) { - DISK_GEOMETRY *out; - - if (irp->read.nbytes < sizeof(*out)) { - dprintf("SRAM: Invalid ioctl response buffer size\n"); - - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } + DISK_GEOMETRY out; + HRESULT hr; dprintf("SRAM: Get geometry\n"); - out = (DISK_GEOMETRY *) irp->read.bytes; - out->Cylinders.QuadPart = 0x20000; - out->MediaType = 0; - out->TracksPerCylinder = 1; - out->SectorsPerTrack = 1; - out->BytesPerSector = 4; + memset(&out, 0, sizeof(out)); + out.Cylinders.QuadPart = 0x20000; + out.MediaType = 0; + out.TracksPerCylinder = 1; + out.SectorsPerTrack = 1; + out.BytesPerSector = 4; - irp->read.pos = sizeof(*out); + hr = iobuf_write(&irp->read, &out, sizeof(out)); - return S_OK; + if (FAILED(hr)) { + dprintf("SRAM: Get geometry failed: %08x\n", (int) hr); + } + + return hr; }