|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbe.cardon.nativecall.LowLevelCalls
public class LowLevelCalls
Functions to allocate, delete, read or write some native types int
, boolean
, byte
,
UTF-8 String, etc.
This class uses the Java Native Interface.
Note :
In native object on Intel x386 processors, muliple byte values
are encoded in little endian (first byte is the least significant
byte) while Java use big endiang encoding (first byte is the most
significant byte). The functions in this class don't convert the byte arrays.
Use be.cardon.utils
to reverse small byte arrays (this function use a copy of the array, so
don't use it for big arrays).
Constructor Summary | |
---|---|
LowLevelCalls()
Creates a new instance of {code LowLevelCalls} The library nativecall is statically loaded when the first
instance of {code LowLevelCalls} is created. |
Method Summary | |
---|---|
int |
allocAndCopyBytes(byte[] data)
Allocates memory and copies the given byte array. |
int |
allocBytes(int numberOfBytes)
Allocates memory. |
void |
deleteAllocatedData(int firstByteAddress)
Delete the allocated data. |
boolean |
readBoolean(int BooleanAddress)
Read a boolean at the given address |
byte |
readByte(int ByteAddress)
Read one byte. |
byte[] |
readBytes(int firstByteAddress,
int numberOfBytes)
Read a byte array. |
int |
readInt(int IntAddress)
Read a signed integer (32 bits) at the given address |
short |
readShort(int IntAddress)
Read a signed short (16 bits) at the given address |
java.lang.String |
readUnicodeString(int StringAddress)
Read a MS UNICODE String at the given address |
java.lang.String |
readUTFString(int StringAddress)
Read a UTF-8 String at the given address |
void |
writeBoolean(int BooleanAddress,
boolean bool)
Write a boolean at the given address |
void |
writeBytes(int firstByteAddress,
byte[] bytes)
Write bytes. |
void |
writeBytesSecure(int firstByteAddress,
byte[] bytes,
int max)
Write maximal max bytes. |
void |
writeInt(int IntAddress,
int value)
Write a signed integer (32 bits) at the given address |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LowLevelCalls() throws NativeCallException
nativecall
is statically loaded when the first
instance of {code LowLevelCalls} is created.
NativeCallException
Method Detail |
---|
public int readInt(int IntAddress) throws NativeCallException
NativeCallException
public void writeInt(int IntAddress, int value) throws NativeCallException
NativeCallException
public short readShort(int IntAddress) throws NativeCallException
NativeCallException
public java.lang.String readUTFString(int StringAddress) throws NativeCallException
NativeCallException
public java.lang.String readUnicodeString(int StringAddress) throws NativeCallException
NativeCallException
public boolean readBoolean(int BooleanAddress) throws NativeCallException
NativeCallException
public void writeBoolean(int BooleanAddress, boolean bool) throws NativeCallException
NativeCallException
public byte[] readBytes(int firstByteAddress, int numberOfBytes) throws NativeCallException
NativeCallException
public byte readByte(int ByteAddress) throws NativeCallException
NativeCallException
public int allocAndCopyBytes(byte[] data) throws NativeCallException
NativeCallException
public int allocBytes(int numberOfBytes) throws NativeCallException
malloc
function of the standard C library.
numberOfBytes
- Size of the allocated memory in bytes.
NativeCallException
public void deleteAllocatedData(int firstByteAddress) throws NativeCallException
delete
function of the standard C library.
NativeCallException
public void writeBytesSecure(int firstByteAddress, byte[] bytes, int max) throws NativeCallException
max
bytes.
This is a secure version of writeBytes
.
NativeCallException
- if bytes.length > max
.public void writeBytes(int firstByteAddress, byte[] bytes) throws NativeCallException
NativeCallException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |