(size, address, data, hex=True)
This relies on windbg's default hex encoding being enforced
This relies on windbg's default hex encoding being enforced
This relies on windbg s default hex encoding being enforced
def eX(size, address, data, hex=True):
    """
    This relies on windbg's default hex encoding being enforced
    """
    if not data:
        print('Cannot write empty data into memory.')
        return

    if hex:
        # Early validation if all data is hex
        for string in data:
            if string.startswith('0x'):
                string = string[2:]

            if any(ch not in '0123456789abcdefABCDEF' for ch in string):
                print('Incorrect data format: it must all be a hex value (0x1234 or 1234, both interpreted as 0x1234)')
                return

    writes = 0
    for i, string in enumerate(data):
        if hex:
            if string.startswith('0x'):
                string = string[2:]

            string = string.rjust(size*2, '0')

            data    = codecs.decode(string, 'hex')
        else:
            data    = string

        if pwndbg.arch.endian == 'little':
            data = data[::-1]

        try:
            pwndbg.memory.write(address + (i * size), data)
            writes += 1
        except gdb.error:
            print('Cannot access memory at address %#x' % address)
            if writes > 0:
                print('(Made %d writes to memory; skipping further writes)' % writes)
            return
def eX ( size , address , data , hex = True ) : if not data : print ( 'Cannot write empty data into memory.' ) return if hex : # Early validation if all data is hex for string in data : if string . startswith ( '0x' ) : string = string [ 2 : ] if any ( ch not in '0123456789abcdefABCDEF' for ch in string ) : print ( 'Incorrect data format: it must all be a hex value (0x1234 or 1234, both interpreted as 0x1234)' ) return writes = 0 for i , string in enumerate ( data ) : if hex : if string . startswith ( '0x' ) : string = string [ 2 : ] string = string . rjust ( size * 2 , '0' ) data = codecs . decode ( string , 'hex' ) else : data = string if pwndbg . arch . endian == 'little' : data = data [ : : - 1 ] try : pwndbg . memory . write ( address + ( i * size ) , data ) writes += 1 except gdb . error : print ( 'Cannot access memory at address %#x' % address ) if writes > 0 : print ( '(Made %d writes to memory; skipping further writes)' % writes ) return