Package ghidra.app.util.bin
Class ObfuscatedFileByteProvider
- java.lang.Object
-
- ghidra.app.util.bin.FileByteProvider
-
- ghidra.app.util.bin.ObfuscatedFileByteProvider
-
- All Implemented Interfaces:
ByteProvider
,MutableByteProvider
,java.io.Closeable
,java.lang.AutoCloseable
public class ObfuscatedFileByteProvider extends FileByteProvider
AByteProvider
that reads from an on-disk file, but obfuscates / de-obfuscates the contents of the file when reading / writing.
-
-
Field Summary
-
Fields inherited from interface ghidra.app.util.bin.ByteProvider
EMPTY_BYTEPROVIDER
-
-
Constructor Summary
Constructors Constructor Description ObfuscatedFileByteProvider(java.io.File file, FSRL fsrl, java.nio.file.AccessMode accessMode)
Creates an instance ofObfuscatedFileByteProvider
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
doReadBytes(long index, byte[] buffer)
Reads bytes from the file.protected void
doWriteBytes(long index, byte[] buffer, int offset, int length)
Writes the specified bytes to the file.java.io.File
getFile()
Returns the underlyingFile
for thisByteProvider
, or null if thisByteProvider
is not associated with aFile
.-
Methods inherited from class ghidra.app.util.bin.FileByteProvider
close, finalize, getAbsolutePath, getAccessMode, getFSRL, getName, isValidIndex, length, readByte, readBytes, readBytes, writeByte, writeBytes, writeBytes
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ghidra.app.util.bin.ByteProvider
getInputStream
-
-
-
-
Constructor Detail
-
ObfuscatedFileByteProvider
public ObfuscatedFileByteProvider(java.io.File file, FSRL fsrl, java.nio.file.AccessMode accessMode) throws java.io.IOException
Creates an instance ofObfuscatedFileByteProvider
.- Parameters:
file
-File
to read from / write tofsrl
-FSRL
identity of this fileaccessMode
-AccessMode.READ
orAccessMode.WRITE
- Throws:
java.io.IOException
- if error
-
-
Method Detail
-
getFile
public java.io.File getFile()
Description copied from interface:ByteProvider
Returns the underlyingFile
for thisByteProvider
, or null if thisByteProvider
is not associated with aFile
.- Specified by:
getFile
in interfaceByteProvider
- Overrides:
getFile
in classFileByteProvider
- Returns:
- the underlying file for this byte provider
-
doReadBytes
protected int doReadBytes(long index, byte[] buffer) throws java.io.IOException
Description copied from class:FileByteProvider
Reads bytes from the file.Protected by synchronized lock. (See
FileByteProvider.getBufferFor(long)
).- Overrides:
doReadBytes
in classFileByteProvider
- Parameters:
index
- file position of where to readbuffer
- byte array that will receive bytes- Returns:
- actual number of byte read
- Throws:
java.io.IOException
- if error
-
doWriteBytes
protected void doWriteBytes(long index, byte[] buffer, int offset, int length) throws java.io.IOException
Description copied from class:FileByteProvider
Writes the specified bytes to the file.Protected by synchronized lock (See
FileByteProvider.writeBytes(long, byte[], int, int)
)- Overrides:
doWriteBytes
in classFileByteProvider
- Parameters:
index
- file position of where to writebuffer
- byte array containing bytes to writeoffset
- offset inside of byte array to startlength
- number of bytes from buffer to write- Throws:
java.io.IOException
- if error
-
-