Commit a2a4b486 authored by George Hotz's avatar George Hotz

ram of the lowest quality

parent da2f4d88
...@@ -90,6 +90,9 @@ type jsoncontract struct { ...@@ -90,6 +90,9 @@ type jsoncontract struct {
DeployedBytecode string `json:"deployedBytecode"` DeployedBytecode string `json:"deployedBytecode"`
} }
var ram []byte
var regs [4096]byte
func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeContext) ([]byte, error) { func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeContext) ([]byte, error) {
// Pop gas. The actual gas is in interpreter.evm.callGasTemp. // Pop gas. The actual gas is in interpreter.evm.callGasTemp.
stack := scope.Stack stack := scope.Stack
...@@ -102,15 +105,28 @@ func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeCon ...@@ -102,15 +105,28 @@ func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeCon
temp.SetOne() temp.SetOne()
stack.Push(&temp) stack.Push(&temp)
ret := common.Hash{}.Bytes()
// Get arguments from the memory. // Get arguments from the memory.
args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64())) args := scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))
addr := common.BytesToHash(args[4:]).Big().Uint64() addr := common.BytesToHash(args[4:]).Big().Uint64()
var nret int64
if addr >= 0xc0000000 {
addr -= 0xc0000000
nret = (int64(regs[addr]) << 24) |
(int64(regs[addr+1]) << 16) |
(int64(regs[addr+2]) << 8) |
(int64(regs[addr+3]) << 0)
addr += 0xc0000000
} else {
nret = (int64(ram[addr]) << 24) |
(int64(ram[addr+1]) << 16) |
(int64(ram[addr+2]) << 8) |
(int64(ram[addr+3]) << 0)
}
//scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64())) //scope.Memory.GetPtr(int64(inOffset.Uint64()), int64(inSize.Uint64()))
fmt.Println("HOOKED!", returnGas, fmt.Sprintf("%x", addr)) ret := common.BigToHash(big.NewInt(nret)).Bytes()
fmt.Println("HOOKED!", returnGas, fmt.Sprintf("%x = %x", addr, nret))
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
//scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) //scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
//return ret //return ret
...@@ -122,6 +138,8 @@ func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeCon ...@@ -122,6 +138,8 @@ func opStaticCall(pc *uint64, interpreter *vm.EVMInterpreter, scope *vm.ScopeCon
func main() { func main() {
fmt.Println("hello") fmt.Println("hello")
ram, _ = ioutil.ReadFile("test/add.bin")
/*var parent types.Header /*var parent types.Header
database := state.NewDatabase(parent) database := state.NewDatabase(parent)
statedb, _ := state.New(parent.Root, database, nil)*/ statedb, _ := state.New(parent.Root, database, nil)*/
......
...@@ -20,7 +20,8 @@ for d in os.listdir("test/"): ...@@ -20,7 +20,8 @@ for d in os.listdir("test/"):
#print(sec, sec.name, sec.data()) #print(sec, sec.name, sec.data())
if sec.name == ".test": if sec.name == ".test":
with open("test/"+(d.replace(".asm", ".bin")), "wb") as f: with open("test/"+(d.replace(".asm", ".bin")), "wb") as f:
data = sec.data() # jump to 0xdead0000 when done
data = b"\x24\x1f\xde\xad\x00\x1f\xfc\x00" + sec.data()
for dd in md.disasm(data, 0): for dd in md.disasm(data, 0):
print(dd) print(dd)
f.write(data) f.write(data)
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment