worked more on set
git-svn-id: file:///home/svn/incoming/trunk@2609 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
bd8971130d
commit
0cfad842e6
|
@ -53,25 +53,43 @@ module X86
|
||||||
return opcodes[rand(opcodes.length)].chr + encode_modrm(reg, reg)
|
return opcodes[rand(opcodes.length)].chr + encode_modrm(reg, reg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# B004 mov al,0x4
|
||||||
def self.mov_byte(reg, val)
|
def self.mov_byte(reg, val)
|
||||||
_check_reg(reg)
|
_check_reg(reg)
|
||||||
# chr will raise RangeError if val not between 0 .. 255
|
# chr will raise RangeError if val not between 0 .. 255
|
||||||
return (0xb0 | reg).chr + val.chr
|
return (0xb0 | reg).chr + val.chr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 66B80400 mov ax,0x4
|
||||||
|
def self.mov_word(reg, val)
|
||||||
|
_check_reg(reg)
|
||||||
|
if val < 0 || val > 0xffff
|
||||||
|
raise RangeError, "Can only take unsigned word values!", caller()
|
||||||
|
end
|
||||||
|
return "\x66" + (0xb8 | reg).chr + [ val ].pack('v')
|
||||||
|
end
|
||||||
|
|
||||||
def self.set(dst, val, badchars = '')
|
def self.set(dst, val, badchars = '')
|
||||||
_check_reg(dst)
|
_check_reg(dst)
|
||||||
|
|
||||||
|
# try push BYTE val; pop dst
|
||||||
begin
|
begin
|
||||||
return _check_badchars(push_byte(val) + pop_dword(dst), badchars)
|
return _check_badchars(push_byte(val) + pop_dword(dst), badchars)
|
||||||
rescue RuntimeError, RangeError
|
rescue RuntimeError, RangeError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# try clear dst, mov BYTE dst
|
||||||
begin
|
begin
|
||||||
return _check_badchars(clear(dst, badchars) + mov_byte(dst, val), badchars)
|
return _check_badchars(clear(dst, badchars) + mov_byte(dst, val), badchars)
|
||||||
rescue RuntimeError, RangeError
|
rescue RuntimeError, RangeError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# try clear dst, mov WORD dst
|
||||||
|
begin
|
||||||
|
return _check_badchars(clear(dst, badchars) + mov_word(dst, val), badchars)
|
||||||
|
rescue RuntimeError, RangeError
|
||||||
|
end
|
||||||
|
|
||||||
raise RuntimeError, "No valid set instruction could be created!", caller()
|
raise RuntimeError, "No valid set instruction could be created!", caller()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue