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
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]
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]]
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”
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”
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”
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."
This slices the last 2 chars.
Parameters
- string: is string to slice.
Examples
iex> Zeam.last2(“0123”) “23”
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.
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}) “”
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}”]
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}”]
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.
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
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} “
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} “
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.
This reverses a list.
Parameter
- list: is a list to reverse
Examples
iex> Zeam.reverseList([0, 1, 2]) [2, 1, 0]
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]
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]
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]
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]
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]
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}]
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]
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}]
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}]
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}]
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}]
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}]