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

Add support for running xochitl using the client. #29

Merged
merged 13 commits into from
Dec 7, 2020

Conversation

timower
Copy link
Collaborator

@timower timower commented Dec 7, 2020

This uses frida gum to hook some function if the client detects it's running in xochitl.
The hooked update function sends the update to the message queue.
The other hooked functions do nothing, they prevent the creation of the swtcon threads.

Resolves #24

Copy link
Collaborator

@raisjn raisjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, nice work!

i'm fine with checking libfrida-gum.a in to repo, wonder if its standard to do so though

src/client/main.cpp Outdated Show resolved Hide resolved
bool FIRST_ALLOC = true;
void _ZN6QImageC1EiiNS_6FormatE(void *that, int x, int y, int f) {
if (IN_XOCHITL && x == swtfb::WIDTH && y == swtfb::HEIGHT && FIRST_ALLOC) {
fprintf(stderr, "REPLACING THE IMAGE with /dev/shm/xofb \n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right path? isn't it placed in /dev/shm/swtfb.01 or something? you can probably delete this line print line if the info is printed elsewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, copied :)

src/client/main.cpp Show resolved Hide resolved
Comment on lines 235 to 249
auto *update_fn = swtfb::locate_signature(
argv[0], "\x10\xd0\x4d\xe2\x7b\xc5\x00\xe3", 8) +
4;
auto *create_threads_fn =
swtfb::locate_signature(
argv[0], "\xc0\x64\x11\x00\x70\x40\x2d\xe9\x00\x40\xa0\xe1", 12) +
8;

auto *wait_fn = swtfb::locate_signature(
argv[0], "\x40\x6c\x11\x00\x10\x40\x2d\xe9", 8) +
8;

auto *shutdown_fn = swtfb::locate_signature(
argv[0], "\x70\x57\x16\x00\x70\x40\x2d\xe9", 8) +
8;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should verify these are robust. if finding signature fails, it should error and print out the binary name and its hash (sha256sum or md5sum) with a message telling the user to look at github issues #18

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked with an older xochitl version and updated them. But they'll need to be maintained for future updates as this is fragile. I'll think about a better way to get these.

src/server/main.cpp Outdated Show resolved Hide resolved
src/server/main.cpp Show resolved Hide resolved
src/shared/ipc.cpp Show resolved Hide resolved
src/shared/swtfb.cpp Outdated Show resolved Hide resolved
Comment on lines +179 to +181
if (strcmp(name, "QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS") == 0) {
return orig_fn(name, touchArgs);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

src/server/main.cpp Show resolved Hide resolved
Copy link

@danshick danshick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some minor fixes for log strings

auto *create_threads_fn = swtfb::locate_signature(
argv[0], "\x00\x40\xa0\xe1\x10\x52\x9f\xe5\x6b\x0d\xa0\xe3", 12);
if (create_threads_fn == nullptr) {
std::cerr << "Unable to find update fn" << std::endl;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad copy/paste here

auto *shutdown_fn =
swtfb::locate_signature(argv[0], "\x01\x50\xa0\xe3\x44\x40\x9f\xe5", 8);
if (shutdown_fn == nullptr) {
std::cerr << "Unable to find update fn" << std::endl;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

auto *wait_fn =
swtfb::locate_signature(argv[0], "\x01\x30\xa0\xe3\x30\x40\x9f\xe5", 8);
if (wait_fn == nullptr) {
std::cerr << "Unable to find update fn" << std::endl;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@timower
Copy link
Collaborator Author

timower commented Dec 7, 2020

i'm fine with checking libfrida-gum.a in to repo, wonder if its standard to do so though
Frida is difficult to build, so checking in the static lib is easiest.

argv[0], "\xc0\x64\x11\x00\x70\x40\x2d\xe9\x00\x40\xa0\xe1", 12) +
8;
auto *update_fn =
swtfb::locate_signature(argv[0], "\x54\x40\x8d\xe2\x10\x50\x8d\xe2", 8);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the signature isn't found, it should point people to issue #18

@raisjn
Copy link
Collaborator

raisjn commented Dec 7, 2020

I tested this with the following apps and things work quite well!

  • KOReader
  • harmony
  • mines
  • retris <--- has an issue
  • chessmarkable
  • calculator <--- touch input fixed automatically!
  • draft <--- doesn't accept pen input
  • xochitl
  • remux <--- no go, doesn't screenshot or render properly

with retris, there is one problem which is retris sends over waveform 4 which gets thrown away. i think if an app sends over waveform > 3 inside the mxcfb_update struct, we need to snap it down to 2 or 3 (like in the previous version).

@Eeems
Copy link
Collaborator

Eeems commented Dec 7, 2020

Any chance you could test with oxide? v2.0.1 is in toltec's testing branch and has input support.

@timower
Copy link
Collaborator Author

timower commented Dec 7, 2020

Any chance you could test with oxide? v2.0.1 is in toltec's testing branch and has input support.

I tried yesterday but I wasn't able to get it to work reliably. It seems that the LD_PRELOAD didn't get propagated to xochitl by the process manager . But I was able to run oxide though but it overdrew xochitl on start. I also don't like how it stops the wifi on start so I lose ssh access 😄

@Eeems
Copy link
Collaborator

Eeems commented Dec 7, 2020

Any chance you could test with oxide? v2.0.1 is in toltec's testing branch and has input support.

I tried yesterday but I wasn't able to get it to work reliably. It seems that the LD_PRELOAD didn't get propagated to xochitl by the process manager . But I was able to run oxide though but it overdrew xochitl on start. I also don't like how it stops the wifi on start so I lose ssh access 😄

You should be able to fix the pass through here https://github.com/Eeems/oxide/blob/master/applications/system-service/application.h#L53-L69 (Since I don't have an rM2 I can't do this myself). I'm also surprised to hear that it stops wifi on start, it shouldn't do so. Could you open an issue.

Copy link
Collaborator

@raisjn raisjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just this one last change for clamping waveform > 3 for waveforms in mxcfb_update. (if waveform > 3, it should be clamped to 2 or 3)

@raisjn raisjn merged commit 706f4cb into ddvk:master Dec 7, 2020
@mgsoloway
Copy link

I tested this with the following apps and things work quite well!

...

  • draft <--- doesn't accept pen input
    ...

Hi raisjn! Thank you for your continued work on this!

Does your post above mean that draft will effectively not work at all on an rm2 or is there some form of input that actually works and allows a user to select the app to run?

Thanks!

@Eeems
Copy link
Collaborator

Eeems commented Dec 8, 2020

Does your post above mean that draft will effectively not work at all on an rm2 or is there some form of input that actually works and allows a user to select the app to run?

Thanks!

I believe that pen input never worked in draft, even on the rM1. Touch input works though.

@mgsoloway
Copy link

Thank you for the quick reply! I'm a brand new user of the reMarkable devices (got an rm2 a week ago) and have been trying out hacks. I definitely want to try out rm2fb with draft initially and then later try oxide when v2.0.2-beta (or whatever release is next that deals with the toolchain mismatch) is released.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integrate against xochitl
5 participants