Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmrp针对windows优化 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@




13 changes: 9 additions & 4 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
"${workspaceFolder}/**",
"${workspaceFolder}/windows/SDL2-2.0.10/x86_64-w64-mingw32/include/SDL2/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
Expand All @@ -14,15 +15,19 @@
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
"${workspaceFolder}/**",
"${workspaceFolder}\\windows\\SDL2-2.0.10\\x86_64-w64-mingw32\\include\\SDL2\\**",
"${workspaceFolder}\\windows\\SDL2-2.0.10\\x86_64-w64-mingw32\\include\\**"
],
"defines": [
"_DEBUG",
"DEBUG",
"UNICODE",
"_UNICODE"
"_UNICODE",
"NETWORK",
"WIN32"
],
"compilerPath": "C:/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0/mingw64/bin/gcc.exe",
"compilerPath": "D:\\app\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
Expand Down
34 changes: 7 additions & 27 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,31 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "win debug current file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "win build current file",
},

{
"name": "debug win",
"type": "cppdbg",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/main.exe",
"args": [
"ems.mrp",
"cfunction.ext",
// "vmrp.mrp",
// "cfunction.ext",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/",
"cwd": "${workspaceFolder}\\bin\\",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
// "miDebuggerPath": "C:/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0/mingw64/bin/gdb.exe",
"miDebuggerPath": "C:/msys64/mingw32/bin/gdb.exe",
"miDebuggerPath": "D:\\app\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
// "preLaunchTask": "make",
"preLaunchTask": "make",
},
{
"name": "debug linux",
Expand Down
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files.associations": {
"dsm.h": "c",
"*.idl": "c",
"pthread.h": "c",
"fcntl.h": "c",
"ws2tcpip.h": "c",
"types.h": "c",
"iconv.h": "c",
"mem.h": "c",
"tables.h": "c",
"encode.h": "c"
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"label": "make",
"command": "make",
"args": [
// "-g",
// "DEBUG=1",
// "${file}",
// "-o",
// "${fileDirname}/${fileBasenameNoExtension}"
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ else
CFLAGS := -Wall
endif

OBJS = network.o fileLib.o font16_st.o gb2unicode.o vmrp.o tsf_font.o utils.o debug.o \
rbtree.o bridge.o memory.o baseLib_cfunction.ext.o main.o
OBJS = net.o fileLib.o font16_st.o gb2unicode.o vmrp.o tsf_font.o utils.o debug.o \
rbtree.o bridge.o memory.o baseLib_cfunction.ext.o main.o sound.o encode.c

UNICORN = -lunicorn
CAPSTONE = -lcapstone
Expand All @@ -17,12 +17,14 @@ ifeq ($(OS),Windows_NT)
endif

SDL2 = ./windows/SDL2-2.0.10/i686-w64-mingw32
UNIPATH = ./windows/unicorn-1.0.2-win32/include/unicorn/


# -Wl,-subsystem,windows gets rid of the console window
# gcc -o main.exe main.c -lmingw32 -Wl,-subsystem,windows -L./lib -lSDL2main -lSDL2
# gcc -o main.exe main.c -lmingw32 -Wl,-subsystem,windows -L./lib -lSDL2main -lSDL2 -fexec-charset=GBK -finput-charset=GBK
main: $(OBJS)
$(CC) $(CFLAGS) -m32 -o ./bin/$@ $^ $(UNICORN) $(CAPSTONE) -lpthread -lm -lz \
-lws2_32 -lmingw32 -L$(SDL2)/lib/ -lSDL2main -lSDL2
$(CC) $(CFLAGS) -m32 -DEXT_CALL -o ./bin/$@ $^ $(UNICORN) $(CAPSTONE) -lpthread -lm -lz \
-lws2_32 -lmingw32 -L$(SDL2)/lib/ -I$(UNIPATH) -lSDL2main -lSDL2 -lwinmm -liconv

ifeq (,$(wildcard ./bin/capstone.dll))
cp $(CAPSTONE) ./bin/
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu" /></a> 反对996是每个软件工程师的义务

# PC版本下载地址

https://github.com/zengming00/vmrp/releases/download/1.0.0/vmrp_win32_20201107.zip

# web网页版体验地址

https://zengming00.github.io/vmrp_v1.0/main.html

# vmrp

由于mrpoid模拟器受限于安卓系统,于是决定开发一款真正的模拟器
Expand All @@ -18,7 +10,7 @@ https://zengming00.github.io/vmrp_v1.0/main.html

按键: 上下左右或wsad键控制方向,回车键是ok, q键是左功能键, e键是右功能键

初始版本实现的函数
目前实现的函数
| | | | |
|-----------------|-----------------|----------------|--------------------|
| mrc_malloc() | mrc_free() | mrc_memcpy() | mrc_memmove() |
Expand Down Expand Up @@ -46,6 +38,10 @@ vmrp实现原理与mrpoid基本相同,参考了mrpoid早期的实现原理,

因为ext中的mr_c_function_load()函数是第一个函数,在mythroad层调用此函数其实相当于仍然在mythroad层调用mythroad层的东西,它会回调_mr_c_function_new()将mr_extHelper()或mr_helper()函数的地址传回mythroad,所有的事件传递都是通过这个helper函数,helper函数进去的第一件事就是备份r9寄存到r10,然后设置r9寄存器的值,在ext内的所有全局变量的读写都是基于这个寄存器提供的基地址,而在ext内调用mythroad层的函数时,r9和r10寄存器的值并没有恢复,这可能导致严重的问题,这可能就是安卓上mrpoid运行不稳定的原因,从反编译的结果来看,插件化mrp内的ext之间是有恢复r9寄存器的功能,但是没有恢复r10寄存器的功能,在目前能获得的mythroad层代码中没有看到任何恢复r9和r10的操作。


# 下载地址
https://github.com/zengming00/vmrp/releases/

# 编译方法

目前使用到的工具和库:
Expand Down
Loading