コード例 #1
0
ファイル: memory.py プロジェクト: hepteract/misc
 def read(self, addr=None):
     if not self.__read:
         raise MemoryProtectionError(
             'Attempted to read from protected memory space: %s' % addr)
     if addr is not None:
         self.__check_addr(addr)
         return ord(self.mem[addr])
     return ord(self.mem.read(1))
コード例 #2
0
ファイル: memory.py プロジェクト: hepteract/misc
 def write(self, addr, byte=None):
     if not self.__write:
         raise MemoryProtectionError(
             'Attempted to write to protected memory space: %s' % addr)
     if byte is not None:
         self.__check_addr(addr)
         if isinstance(byte, int):
             byte = chr(byte)
         self.mem[addr] = byte
     else:
         if isinstance(addr, int):
             addr = chr(addr)
         self.mem.write(addr)
コード例 #3
0
ファイル: memory.py プロジェクト: hepteract/misc
 def clearblock(self, addr, size):
     raise MemoryProtectionError('Unsupported operation by I/O map.')
コード例 #4
0
ファイル: memory.py プロジェクト: hepteract/misc
 def writeblock(self, addr, block):
     raise MemoryProtectionError('Unsupported operation by I/O map.')
コード例 #5
0
ファイル: memory.py プロジェクト: hepteract/misc
 def fetch(self):
     if not self.__execute:
         raise MemoryProtectionError(
             'Attempted to execute code from protected memory space!')
     return ord(self.mem.read(1))
コード例 #6
0
 def mem_write(self, addr, byte):
     raise MemoryProtectionError('Unable to write to memory address.')
コード例 #7
0
 def mem_read(self, addr):
     try:
         return ord(self.mem[addr])
     except IndexError:
         raise MemoryProtectionError('Unable to read from memory address.')