Skip to content

Commit

Permalink
Added support for per-process (LocalOnly) userspace patches
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Nov 21, 2019
1 parent 45abdb9 commit 414c974
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Lilu Changelog
#### v1.4.0
- Fixed mishandling user patches process list after processKernel API call
- Fixed extra I/O in user patcher even when no patches were needed
- Added support for per-process (LocalOnly) userspace patches

#### v1.3.9
- Added QEMU/KVM vendor compatibility to device detection logic
Expand Down
13 changes: 13 additions & 0 deletions Lilu/Headers/kern_user.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,22 @@ class UserPatcher {
"__common"
};

/**
* Binary modification patches flags
*/
enum BinaryModPatchFlags {
/*
* Only applies to one process, not globally.
*/
LocalOnly = 1
};

/**
* Structure holding lookup-style binary patches
*/
struct BinaryModPatch {
cpu_type_t cpu;
uint32_t flags;
const uint8_t *find;
const uint8_t *replace;
size_t size;
Expand All @@ -102,6 +113,8 @@ class UserPatcher {
uint32_t section;
};

static_assert(sizeof(BinaryModPatch) == 56, "BinaryModPatch ABI compatibility failure");

/**
* Structure describing the modifications for the binary
*/
Expand Down
4 changes: 4 additions & 0 deletions Lilu/Sources/kern_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ void UserPatcher::performPagePatch(const void *data_ptr, size_t data_size) {
auto &rpatch = storage->mod->patches[ref->i];
sz = ref->pageOffs.size();

// Skip patches that are meant to apply only to select processes.
if (rpatch.flags & LocalOnly) {
continue;
}

DBGLOG("user", "found what we are looking for %X %X %X %X %X %X %X %X", rpatch.find[0],
rpatch.size > 1 ? rpatch.find[1] : 0xff,
Expand Down

0 comments on commit 414c974

Please sign in to comment.