Class: SWD_MEM_AP
- Inherits:
-
Object
- Object
- SWD_MEM_AP
- Defined in:
- lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb
Overview
Hardsploit API - By Opale Security
www.opale-security.com || www.hardsploit.io
License: GNU General Public License v3
License URI: http://www.gnu.org/licenses/gpl.txt
Instance Method Summary collapse
- #csw(addrInc, size) ⇒ Object
- #idcode ⇒ Object
-
#initialize(dp, apsel) ⇒ SWD_MEM_AP
constructor
A new instance of SWD_MEM_AP.
-
#readBlock(address, size) ⇒ Object
1K boundaries and return 4K of data word alignement.
- #readWord(addr) ⇒ Object
-
#writeBlock(address, data) ⇒ Object
1K boundaries.
- #writeWord(addr, data) ⇒ Object
Constructor Details
#initialize(dp, apsel) ⇒ SWD_MEM_AP
Returns a new instance of SWD_MEM_AP.
11 12 13 14 15 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 11 def initialize( dp, apsel) @dp = dp @apsel = apsel csw(1,2) # 32-bit auto-incrementing addressing end |
Instance Method Details
#csw(addrInc, size) ⇒ Object
17 18 19 20 21 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 17 def csw ( addrInc, size) @dp.readAP(@apsel, 0x00) val = @dp.readRB() & 0xFFFFFF00 @dp.writeAP(@apsel, 0x00, val + (addrInc << 4) + size) end |
#idcode ⇒ Object
23 24 25 26 27 28 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 23 def idcode @dp.readAP(@apsel, 0xFC) id = @dp.readRB() @dp.select(0,0) return id end |
#readBlock(address, size) ⇒ Object
1K boundaries and return 4K of data word alignement
42 43 44 45 46 47 48 49 50 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 42 def readBlock ( address, size)#1K boundaries and return 4K of data word alignement if size < 1 then raise "readBlock error : count must be >= 1" end if size > 1024 then raise "readBlock error : size must be <= 1024 " end return @dp.getAPI.read_mem32(address,size) end |
#readWord(addr) ⇒ Object
30 31 32 33 34 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 30 def readWord (addr) @dp.writeAP(@apsel, 0x04, addr) @dp.readAP(@apsel, 0x0C) return @dp.readRB() end |
#writeBlock(address, data) ⇒ Object
1K boundaries
52 53 54 55 56 57 58 59 60 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 52 def writeBlock (address,data) #1K boundaries if data.length < 1 then raise "readBlock error : count must be >= 1" end if data.length > 1024 then raise "readBlock error : size must be <= 1024 " end @dp.getAPI.write_mem16Packed(address,data) end |
#writeWord(addr, data) ⇒ Object
36 37 38 39 40 |
# File 'lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb', line 36 def writeWord (addr, data) @dp.writeAP(@apsel, 0x04, addr) @dp.writeAP(@apsel, 0x0C, data) return @dp.readRB() end |