PsWriteIo

Writes data to an I/O port.

Syntax

PULSE_STATUS PsWriteIo(
 [in] PPS_ENGINE pEngine,
 [in] uint16_t Port,
 [in] uint16_t AccessSize,
 [in] void* pBuffer,
 [in] uint64_t cbToWrite,
 [out, optional] uint64_t* pcbWritten
);

Parameters

PPS_ENGINE pEngine

An opaque handle to an engine created by the EngCreateEngine function.

uint16_t Port

The I/O port number to write to.

uint16_t AccessSize

I/O port write width in bytes. Valid values are 1, 2, and 4.

void* pBuffer

The buffer with the data to write.

uint64_t cbToWrite

Specifies how many bytes to write.

uint64_t* pcbWritten

Returns the number of bytes that were actually written.

Return value

If the function succeeds, the return value is PULSE_STATUS_SUCCESS.

If it fails, it returns one of the PULSE_STATUS values. Possible return codes include, but are not limited to, the following:

PULSE_STATUS_PARTIAL_WRITE
0x00000002
Only a portion of the data was written. Check the *pcbWritten parameter value to determine how many bytes were written.
PULSE_STATUS_INSUFFICIENT_RESOURCES
0xC0000002
One of the memory allocations failed during initialization.
PULSE_STATUS_READ_FAILED
0xC0000003
Transport communication failed during a read operation.
PULSE_STATUS_WRITE_FAILED
0xC0000004
Transport communication failed during a write operation.
PULSE_STATUS_NOT_ALIGNED
0xC0000006
Buffer size is not aligned to the access size.
PULSE_STATUS_TIMEOUT
0xC0000007
Might happen if
  • Transport I/O timed out.
  • No response was received from the debuggee within the request timeout period.
PULSE_STATUS_INVALID_ACCESS_SIZE
0xC000000A
I/O port access size is not 1, 2 or 4 bytes.
PULSE_STATUS_INVALID_PARAMETER
0xC0000010
Might happen if
  • The pEngine parameter is NULL.
  • The pBuffer parameter is NULL.
PULSE_STATUS_INVALID_PACKET
0xC0000031
An invalid or unexpected packet was received in response.
PULSE_STATUS_DEVICE_CONNECTION_LOST
0xC0000308
The connection to the transport was lost. Try restarting the engine or the transport.

Remarks

The maximum number of bytes that can be written in a single request can be determined using the PsRequestGetMaxWriteIoBufferSize function. If a larger amount is specified, this function performs multiple requests to the debug target.