Skip to content

Commit

Permalink
Merge pull request #115 from ddvk/notifyonupdate
Browse files Browse the repository at this point in the history
hook the notify function for the screenshare #71
  • Loading branch information
ddvk authored Nov 17, 2022
2 parents 7228aa0 + b8f3816 commit 5f20bd6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Xochitl function name | Xochitl function role | Notes
`wait` | Waits until the update-handling threads have started. This function is replaced by the client shim with a no-op to avoid conflicting with the server. | Calls `usleep(1000)`.
`shutdown` | Stops the update-handling threads. This function is replaced by the client shim with a no-op to avoid conflicting with the server. | Uses the string `Shutting down...`.
`getInstance` | Retrieves the instance of the singleton SWTCON class. This function is used by the server to interact with the screen. | Calls a function that itself calls `create` and `wait`.
`notify` | Called when the framebuffer has been updated, used for the Qt signal/slot connections needed for ScreenShare to work |

The client and the server both ship the [hardcoded addresses](https://github.com/ddvk/remarkable2-framebuffer/blob/master/src/shared/config.cpp#L13) for these functions for various releases.
If you get a message saying `Missing address for function […]`, it means that the release you’re running is not yet supported. Please report this in [this dedicated thread](https://github.com/ddvk/remarkable2-framebuffer/issues/18).
Expand Down
17 changes: 16 additions & 1 deletion src/client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ bool _Z7qputenvPKcRK10QByteArray(const char *name, const QByteArray &val) {
return orig_fn(name, val);
}

void new_update_int4(void*, int x1, int y1, int x2, int y2, int waveform, int flags) {
// called when the framebuffer is updated
typedef uint32_t (*NotifyFunc)(void*, void*);
NotifyFunc f_notify = 0;
void new_update_int4(void* arg, int x1, int y1, int x2, int y2, int waveform, int flags) {
#ifdef DEBUG
std::cerr << "UPDATE HOOK CALLED" << std::endl;
std::cerr << "x " << x1 << " " << x2 << std::endl;
Expand All @@ -263,6 +266,11 @@ void new_update_int4(void*, int x1, int y1, int x2, int y2, int waveform, int fl
data.waveform = waveform;
data.flags = flags;
MSGQ.send(data);

if (f_notify != 0) {
QRect someRect(x1,y1, x2-x1, y2-y1) ;
f_notify(arg, &someRect);
}
}

void new_update_QRect(void* arg, QRect& rect, int waveform, bool flags) {
Expand Down Expand Up @@ -346,6 +354,13 @@ void intercept_xochitl(const Config& config) {
replace_func(interceptor, config, "create", (void*) new_create_threads);
replace_func(interceptor, config, "shutdown", (void*) new_shutdown);
replace_func(interceptor, config, "wait", (void*) new_wait);

auto search = config.find("notify");
if (search == config.end()) {
std::cerr << "missing notify function, screenshare won't work" << std::endl;
} else {
f_notify = (NotifyFunc) std::get<void*>(search->second);
}
}

__attribute__((visibility("default")))
Expand Down
1 change: 1 addition & 0 deletions src/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ create addr 0x4e7520
shutdown addr 0x4e74b8
wait addr 0x4e64c0
getInstance addr 0x4db484
notify addr 0x4d98a4
)CONF";

Expand Down
1 change: 1 addition & 0 deletions tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Before starting this tutorial, [download and install Ghidra](https://www.ghidra-
- ![Search Memory](images/05-search-memory.png)
- in "Search Value", put the *exact* search string with no typos. Partial search is okay, just be aware you might find partial string matches in other sections of code
- `update` search string: `Unable to complete update: invalid waveform (`
- `notify` is the second function in the switch, case 8 in the `update` function
- `create` search string: `Unable to start generator thread\n`
- `shutdown` search string: `Shutting down...`
- Click "Next". You should only find one result.
Expand Down

0 comments on commit 5f20bd6

Please sign in to comment.