Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a2a4b486
Commit
a2a4b486
authored
Sep 26, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ram of the lowest quality
parent
da2f4d88
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
main.go
mipsevm/main.go
+21
-3
maketests.py
mipsevm/maketests.py
+2
-1
add.bin
mipsevm/test/add.bin
+0
-0
addiu.bin
mipsevm/test/addiu.bin
+0
-0
No files found.
mipsevm/main.go
View file @
a2a4b486
...
@@ -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)*/
...
...
mipsevm/maketests.py
View file @
a2a4b486
...
@@ -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
)
...
...
mipsevm/test/add.bin
View file @
a2a4b486
No preview for this file type
mipsevm/test/addiu.bin
View file @
a2a4b486
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment