zeam v0.0.5 Zeam

Zeam is a module of ZEAM. ZEAM is ZACKY’s Elixir Abstract Machine, which is aimed at being BEAM compatible. Zeam now provides bytecode analyzing functions.

Link to this section Summary

Functions

This converts a binary into a list

This bundles three values away from each value of a list

This concats a list of integer in the manner of big endian

This concats a list of integer in the manner of little endian

This dumps binary files to stdard output

This dumps binary data to String

This dumps binary files to String

This dumps binary files to String

Hello world

This slices the last 2 chars

This opens the file of a path and calls a function

This prints a tuple of addresses of the origin and the target

This prints a sorted list of addresses in big endian of the origin and target from a binary

This prints a sorted list of addresses in little endian of the origin and target from a binary

This calls a function with a binary, obtains a list of tuples, and prints it

This calls a function with a path, and puts to IO

This puts a sorted list of addresses in big endian of the origin and the target from the binary read from the file of a path

This puts a sorted list of addresses in little endian of the origin and the target from the binary read from the file of a path

This dumps binary files to String

This reverses a list

This returns list of absolute addresses

This returns list of absolute addresses in big endian

This returns list of absolute addresses in little endian

This provides Template Method of toAddress{Little/Big}Endian/1

This reads binary (a sequence of bytes) and generates a list of integers that each value is regarded as a 24 bits (3 bytes) in big endian

This returns a list of tupples of absolute addresses in big endian of the origin and the target

This reads binary (a sequence of bytes) and generates a list of integers that each value is regarded as a 24 bits (3 bytes) in little endian

This returns a list of tupples of absolute addresses in little endian of the origin and the target

This returns a list of tupples of absolute addresses of the origin and the target

This returns a sorted list of tupples of absolute addresses in big endian of the origin and the target in order of the target address

This returns a sorted list of tupples of absolute addresses in little endian of the origin and the target in order of the target address

This returns a sorted list of tupples of absolute addresses of the origin and the target in order of the target address

Link to this section Functions

Link to this function bin2list(binary)
bin2list(binary()) :: list()

This converts a binary into a list.

Parameter

  • binary: is a binary to convert into a list.

Examples

iex> Zeam.bin2list(<<0, 1, 2, 3>>) [0, 1, 2, 3]

Link to this function bundle3Values(list)
bundle3Values(list()) :: list()

This bundles three values away from each value of a list.

Parameter

  • list: is a list to bundle.

Examples

iex> Zeam.bundle3Values([0, 1, 2, 3]) [[0, 1, 2], [1, 2, 3]]

Link to this function concatBigEndian(list)
concatBigEndian(list()) :: integer()

This concats a list of integer in the manner of big endian.

Parameter

  • list: is a list of integer to concat

Examples

iex> Integer.to_string(Zeam.concatBigEndian([0, 1, 2]), 16) “102”

Link to this function concatLittleEndian(list)
concatLittleEndian(list()) :: integer()

This concats a list of integer in the manner of little endian.

Parameter

  • list: is a list of integer to concat

Examples

iex> Integer.to_string(Zeam.concatLittleEndian([0, 1, 2]), 16) “20100”

Link to this function dump(path)
dump(Path.t()) :: String.t()

This dumps binary files to stdard output.

Parameter

  • path: is data or a binary file path to dump.
Link to this function dump_d(data)
dump_d(binary()) :: String.t()

This dumps binary data to String.

Parameters

  • data: is binary data to dump.

Examples

iex> Zeam.dump_d(<<0, 1, 2, 3>>) “00 01 02 03”

Link to this function dump_f(file)
dump_f(File.t()) :: String.t()

This dumps binary files to String.

Parameter

  • file: is data or a binary file path to dump.
Link to this function dump_p(path)
dump_p(Path.t()) :: String.t()

This dumps binary files to String.

Parameter

  • path: is data or a binary file path to dump.

Examples

iex> Zeam.dump_p(“./test/sample”) “41 42 43 44 45 46 47 48\n49 4A 4B 4C 4D 4E\n\n”

Hello world.

Examples

iex> Zeam.hello
"ZEAM is ZACKY's Elixir Abstract Machine, which is aimed at being BEAM compatible."
Link to this function last2(string)
last2(String.t()) :: String.t()

This slices the last 2 chars.

Parameters

  • string: is string to slice.

Examples

iex> Zeam.last2(“0123”) “23”

Link to this function openAndCall(function, path)
openAndCall(function(), Path.t()) :: String.t()

This opens the file of a path and calls a function.

Parameter

  • function: is a function that receives the path
  • path: is data or a binary file path to dump.
Link to this function printElem(x)
printElem(tuple()) :: String.t()

This prints a tuple of addresses of the origin and the target

Parameter

  • x: is a tuple including addresses of the origin and the target.

Examples

iex> Zeam.printElem({0, 0}) “{0, 0}”

iex> Zeam.printElem({0, -1}) “”

Link to this function printSortedListInBigEndian(binary)
printSortedListInBigEndian(binary()) :: String.t()

This prints a sorted list of addresses in big endian of the origin and target from a binary.

Parameter

  • binary: is a binary to print the list.

Examples

iex> Zeam.printSortedListInBigEndian(<<0, 0, 0, 0>>) [“{0, 0}”, “{1, 1}”]

iex> Zeam.printSortedListInBigEndian(<<0, 0, 1, 0>>) [“{0, 1}”, “{1, 101}”]

Link to this function printSortedListInLittleEndian(binary)
printSortedListInLittleEndian(binary()) :: String.t()

This prints a sorted list of addresses in little endian of the origin and target from a binary.

Parameter

  • binary: is a binary to print the list.

Examples

iex> Zeam.printSortedListInLittleEndian(<<0, 0, 0, 0>>) [“{0, 0}”, “{1, 1}”]

iex> Zeam.printSortedListInLittleEndian(<<1, 0, 0, 0>>) [“{1, 1}”, “{0, 1}”]

Link to this function printTupleList(function, binary)
printTupleList(function(), binary()) :: String.t()

This calls a function with a binary, obtains a list of tuples, and prints it.

Parameter

  • function: is a function to call with a binary.
  • binary: is a binary to be converted by the function.
Link to this function put(function, path)
put(function(), Path.t()) :: String.t()

This calls a function with a path, and puts to IO.

Parameter

  • function: is a function that receives the path
  • path: is data or a binary file path
Link to this function putAddressInBigEndian(path)
putAddressInBigEndian(Path.t()) :: String.t()

This puts a sorted list of addresses in big endian of the origin and the target from the binary read from the file of a path.

Parameter

  • path: is data or a binary file path to put.

Examples

iex> Zeam.putAddressInBigEndian(“./test/sample”) “{0, 414243}{1, 424345}{2, 434447}{3, 444549}{4, 45464B}{5, 46474D}{6, 47484F}{7, 484951}{8, 494A53}{9, 4A4B55}{A, 4B4C57}{B, 4C4D59} “

Link to this function putAddressInLittleEndian(path)
putAddressInLittleEndian(Path.t()) :: String.t()

This puts a sorted list of addresses in little endian of the origin and the target from the binary read from the file of a path.

Parameter

  • path: is data or a binary file path to put.

Examples

iex> Zeam.putAddressInLittleEndian(“./test/sample”) “{0, 434241}{1, 444343}{2, 454445}{3, 464547}{4, 474649}{5, 48474B}{6, 49484D}{7, 4A494F}{8, 4B4A51}{9, 4C4B53}{A, 4D4C55}{B, 4E4D57} “

Link to this function readFile(function, file)
readFile(function(), File.t()) :: String.t()

This dumps binary files to String.

Parameter

  • function: is a function that receives the path
  • file: is data or a binary file path to dump.
Link to this function reverseList(list)
reverseList(list()) :: list()

This reverses a list.

Parameter

  • list: is a list to reverse

Examples

iex> Zeam.reverseList([0, 1, 2]) [2, 1, 0]

Link to this function toAbsoluteAddress(function, binary)
toAbsoluteAddress(function(), binary()) :: list()

This returns list of absolute addresses.

Parameter

  • function: is one of concat{Little/Big}Endian/1.
  • binary: is a binary to read.

Examples

iex> Zeam.toAbsoluteAddress(&Zeam.concatLittleEndian/1, <<0, 1, 2, 3>>) [131328, 197122]

iex> Zeam.toAbsoluteAddress(&Zeam.concatBigEndian/1, <<0, 1, 2, 3>>) [258, 66052]

Link to this function toAbsoluteAddressInBigEndian(binary)
toAbsoluteAddressInBigEndian(binary()) :: list()

This returns list of absolute addresses in big endian.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toAbsoluteAddressInBigEndian(<<0, 1, 2, 3>>) [258, 66052]

Link to this function toAbsoluteAddressInLittleEndian(binary)
toAbsoluteAddressInLittleEndian(binary()) :: list()

This returns list of absolute addresses in little endian.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toAbsoluteAddressInLittleEndian(<<0, 1, 2, 3>>) [131328, 197122]

Link to this function toAddress(function, binary)
toAddress(function(), binary()) :: list()

This provides Template Method of toAddress{Little/Big}Endian/1.

Parameter

  • function: is one of concat{Little/Big}Endian/1.
  • binary: is a binary to read.

Examples

iex> Zeam.toAddress(&Zeam.concatLittleEndian/1, <<0, 1, 2, 3>>)
[131328, 197121]

iex> Zeam.toAddress(&Zeam.concatBigEndian/1, <<0, 1, 2, 3>>)
[258, 66051]
Link to this function toAddressInBigEndian(binary)
toAddressInBigEndian(binary()) :: list()

This reads binary (a sequence of bytes) and generates a list of integers that each value is regarded as a 24 bits (3 bytes) in big endian.

Parameter

  • binary: is a binary to read

Examples

iex> Zeam.toAddressInBigEndian(<<0, 1, 2, 3>>) [258, 66051]

iex> Zeam.toAddressInBigEndian(<<255, 255, 255>>) [-1]

iex> Zeam.toAddressInBigEndian(<<255, 255, 254>>) [-2]

Link to this function toAddressInBigEndianOfOriginAndTarget(binary)
toAddressInBigEndianOfOriginAndTarget(binary()) :: list()

This returns a list of tupples of absolute addresses in big endian of the origin and the target.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toAddressInBigEndianOfOriginAndTarget(<<0, 0, 0>>) [{0, 0}]

iex> Zeam.toAddressInBigEndianOfOriginAndTarget(<<0, 0, 1, 0>>) [{0, 1}, {1, 257}]

Link to this function toAddressInLittleEndian(binary)
toAddressInLittleEndian(binary()) :: list()

This reads binary (a sequence of bytes) and generates a list of integers that each value is regarded as a 24 bits (3 bytes) in little endian.

Parameter

  • binary: is a binary to read

Examples

iex> Zeam.toAddressInLittleEndian(<<0, 1, 2, 3>>) [131328, 197121]

iex> Zeam.toAddressInLittleEndian(<<255, 255, 255>>) [-1]

iex> Zeam.toAddressInLittleEndian(<<254, 255, 255>>) [-2]

Link to this function toAddressInLittleEndianOfOriginAndTarget(binary)
toAddressInLittleEndianOfOriginAndTarget(binary()) :: list()

This returns a list of tupples of absolute addresses in little endian of the origin and the target.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toAddressInLittleEndianOfOriginAndTarget(<<0, 0, 0>>) [{0, 0}]

iex> Zeam.toAddressInLittleEndianOfOriginAndTarget(<<1, 0, 0, 0>>) [{0, 1}, {1, 1}]

Link to this function toAddressOfOriginAndTarget(function, binary)
toAddressOfOriginAndTarget(function(), binary()) :: list()

This returns a list of tupples of absolute addresses of the origin and the target.

Parameter

  • function: is one of concat{Little/Big}Endian/1.
  • binary: is a binary to read.

Examples

iex> Zeam.toAddressOfOriginAndTarget(&Zeam.concatLittleEndian/1, <<0, 0, 0>>) [{0, 0}]

iex> Zeam.toAddressOfOriginAndTarget(&Zeam.concatLittleEndian/1, <<1, 0, 0, 0>>) [{0, 1}, {1, 1}]

iex> Zeam.toAddressOfOriginAndTarget(&Zeam.concatBigEndian/1, <<0, 0, 0>>) [{0, 0}]

iex> Zeam.toAddressOfOriginAndTarget(&Zeam.concatBigEndian/1, <<0, 0, 1, 0>>) [{0, 1}, {1, 257}]

Link to this function toSortedListOfAddressInBigEndianOfOriginAndTarget(binary)
toSortedListOfAddressInBigEndianOfOriginAndTarget(binary()) :: list()

This returns a sorted list of tupples of absolute addresses in big endian of the origin and the target in order of the target address.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toSortedListOfAddressInBigEndianOfOriginAndTarget(<<0, 0, 0>>)
[{0, 0}]

iex> Zeam.toSortedListOfAddressInBigEndianOfOriginAndTarget(<<0, 0, 1, 0>>)
[{0, 1}, {1, 257}]
Link to this function toSortedListOfAddressInLittleEndianOfOriginAndTarget(binary)
toSortedListOfAddressInLittleEndianOfOriginAndTarget(binary()) :: list()

This returns a sorted list of tupples of absolute addresses in little endian of the origin and the target in order of the target address.

Parameter

  • binary: is a binary to read.

Examples

iex> Zeam.toSortedListOfAddressInLittleEndianOfOriginAndTarget(<<0, 0, 0>>)
[{0, 0}]

iex> Zeam.toSortedListOfAddressInLittleEndianOfOriginAndTarget(<<1, 0, 0, 0>>)
[{1, 1}, {0, 1}]
Link to this function toSortedListOfAddressOfOriginAndTarget(function, binary)
toSortedListOfAddressOfOriginAndTarget(function(), binary()) :: list()

This returns a sorted list of tupples of absolute addresses of the origin and the target in order of the target address.

Parameter

  • function: is one of concat{Little/Big}Endian/1.
  • binary: is a binary to read.

Examples

iex> Zeam.toSortedListOfAddressOfOriginAndTarget(&Zeam.concatLittleEndian/1, <<0, 0, 0>>)
[{0, 0}]

iex> Zeam.toSortedListOfAddressOfOriginAndTarget(&Zeam.concatLittleEndian/1, <<1, 0, 0, 0>>)
[{1, 1}, {0, 1}]

iex> Zeam.toSortedListOfAddressOfOriginAndTarget(&Zeam.concatBigEndian/1, <<0, 0, 0>>)
[{0, 0}]

iex> Zeam.toSortedListOfAddressOfOriginAndTarget(&Zeam.concatBigEndian/1, <<0, 0, 1, 0>>)
[{0, 1}, {1, 257}]