Class IOStreamEmuUnixFileHandle

java.lang.Object
ghidra.pcode.emu.unix.AbstractStreamEmuUnixFileHandle<byte[]>
ghidra.pcode.emu.unix.IOStreamEmuUnixFileHandle
All Implemented Interfaces:
EmuUnixFileDescriptor<byte[]>

public class IOStreamEmuUnixFileHandle extends AbstractStreamEmuUnixFileHandle<byte[]>
A simulated file descriptor that proxies a host resource, typically a console/terminal
  • Field Details

  • Constructor Details

    • IOStreamEmuUnixFileHandle

      public IOStreamEmuUnixFileHandle(PcodeMachine<byte[]> machine, CompilerSpec cSpec, InputStream input, OutputStream output)
      Construct a proxy for a host resource

      WARNING: Think carefully before proxying any host resource to a temperamental target program.

      Parameters:
      machine - the machine emulating the hardware
      cSpec - the ABI of the target platform
      input - the stream representing the input side of the descriptor, if applicable
      output - the stream representing the output side of the descriptor, if applicable
  • Method Details

    • stdin

      public static IOStreamEmuUnixFileHandle stdin(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
      Construct a proxy for the host's standard input
      Parameters:
      machine - the machine emulating the hardware
      cSpec - the ABI of the target platform
      Returns:
      the proxy's handle
    • stdout

      public static IOStreamEmuUnixFileHandle stdout(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
      Construct a proxy for the host's standard output
      Parameters:
      machine - the machine emulating the hardware
      cSpec - the ABI of the target platform
      Returns:
      the proxy's handle
    • stderr

      public static IOStreamEmuUnixFileHandle stderr(PcodeMachine<byte[]> machine, CompilerSpec cSpec)
      Construct a proxy for the host's standard error output
      Parameters:
      machine - the machine emulating the hardware
      cSpec - the ABI of the target platform
      Returns:
      the proxy's handle
    • read

      public byte[] read(byte[] buf) throws EmuIOException
      Description copied from interface: EmuUnixFileDescriptor
      Read from the file opened by this handle
      Parameters:
      buf - the destination buffer
      Returns:
      the number of bytes read
      Throws:
      EmuIOException - if an error occurred
    • write

      public byte[] write(byte[] buf) throws EmuIOException
      Description copied from interface: EmuUnixFileDescriptor
      Read into the file opened by this handle
      Parameters:
      buf - the source buffer
      Returns:
      the number of bytes written
      Throws:
      EmuIOException - if an error occurred
    • close

      public void close()
      Description copied from interface: EmuUnixFileDescriptor
      Close this descriptor