MCPcopy
hub / github.com/Gallopsled/pwntools / union

Method union

pwnlib/fmtstr.py:246–263  ·  view source on GitHub ↗

Combine adjacent writes into a single write. Example: >>> context.clear(endian = "little") >>> pwnlib.fmtstr.AtomWrite(0x0, 0x1, 0x1, 0xff).union(pwnlib.fmtstr.AtomWrite(0x1, 0x1, 0x2, 0x77)) AtomWrite(start=0, size=2, integer=0x201, mask=0x77ff

(self, other)

Source from the content-addressed store, hash-verified

244 return AtomWrite(start, size, integer, mask)
245
246 def union(self, other):
247 """
248 Combine adjacent writes into a single write.
249
250 Example:
251
252 >>> context.clear(endian = "little")
253 >>> pwnlib.fmtstr.AtomWrite(0x0, 0x1, 0x1, 0xff).union(pwnlib.fmtstr.AtomWrite(0x1, 0x1, 0x2, 0x77))
254 AtomWrite(start=0, size=2, integer=0x201, mask=0x77ff)
255 """
256 assert other.start == self.end, "writes to combine must be continous"
257 if context.endian == "little":
258 newinteger = (other.integer << self.bitsize) | self.integer
259 newmask = (other.mask << self.bitsize) | self.mask
260 elif context.endian == "big":
261 newinteger = (self.integer << other.bitsize) | other.integer
262 newmask = (self.mask << other.bitsize) | other.mask
263 return AtomWrite(self.start, self.size + other.size, newinteger, newmask)
264
265 def __getslice__(self, i, j):
266 return self.__getitem__(slice(i, j))

Callers 3

make_atoms_simpleFunction · 0.95
merge_atoms_overlappingFunction · 0.95
merge_atoms_writesizeFunction · 0.80

Calls 1

AtomWriteClass · 0.85

Tested by

no test coverage detected