Common bitwise operations

Rotate left/right

malduck.bits.rol(value: int, count: int, bits: int = 32) int[source]

Bitwise rotate left

Parameters:
  • value – Value to rotate

  • count – Number of bits to rotate

  • bits – Bit-length of rotated value (default: 32-bit, DWORD)

malduck.bits.ror(value: int, count: int, bits: int = 32) int[source]

Bitwise rotate right

Parameters:
  • value – Value to rotate

  • count – Number of bits to rotate

  • bits – Bit-length of rotated value (default: 32-bit, DWORD)

Align up/down

malduck.bits.align(value: int, round_to: int) int[source]

Rounds value up to provided alignment

malduck.bits.align_down(value: int, round_to: int) int[source]

Rounds value down to provided alignment