forked from roothide/Dopamine2-roothide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new libkrw plugin, add libroot, ensure these are installed every …
…jailbreak
- Loading branch information
Showing
20 changed files
with
647 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#ifndef LIBKRW_PLUGIN_H | ||
#define LIBKRW_PLUGIN_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
/** | ||
* libkrw - Library for kernel read/write | ||
* | ||
* The purpose of this library is to provide a standard interface for common | ||
* kernel memory operations. Subsets of those have historically been exported | ||
* by most jailbreaks, but the provided interfaces are increasingly shifting, | ||
* thus calling for a standard interface. | ||
* | ||
* It is understood that hardly any jailbreak provides the necessary primitives | ||
* to implement ALL of the below functions. Thus, an implementer of this API | ||
* is free to implement any subset of their choosing, even an empty one, and | ||
* simply "stub" the remaining functions to return `ENOTSUP` unconditionally. | ||
* | ||
* All functions imported by this library are expected to return an `int` status | ||
* code, where: | ||
* - The value `0` indicates success. | ||
* - The values `1` through `255` indicate failure and correspond to their | ||
* definitions in <errno.h> (or are reserved, if no such definition exists). | ||
* - All other return values are implementation-defined, but indicate failure. | ||
* | ||
* Notable conditions where values from <errno.h> should be used include: | ||
* - `EPERM` The requested operation requires root, an entitlement, or some | ||
* other form of elevated privileges. | ||
* - `EINVAL` An invalid argument was provided to the function. | ||
* - `EDEVERR` The requested operation is supported in this implementation, but | ||
* could not be completed for some reason. | ||
* - `ENOTSUP` The requested operation is not supported in this implementation. | ||
* | ||
* Further shall be noted that due to the inherently unsafe nature of direct | ||
* kernel memory accesses, functions that take kernel addresses as arguments | ||
* from the caller may panic the kernel, and implementers of this interface may | ||
* choose to defend against that, but are not expected to do so. They ARE | ||
* however expected to defend against causing kernel panics in functions that do | ||
* NOT take kernel addresses as arguments. | ||
**/ | ||
|
||
typedef int (*krw_kbase_func_t)(uint64_t *addr); | ||
typedef int (*krw_kread_func_t)(uint64_t from, void *to, size_t len); | ||
typedef int (*krw_kwrite_func_t)(void *from, uint64_t to, size_t len); | ||
typedef int (*krw_kmalloc_func_t)(uint64_t *addr, size_t size); | ||
typedef int (*krw_kdealloc_func_t)(uint64_t addr, size_t size); | ||
typedef int (*krw_kcall_func_t)(uint64_t func, size_t argc, const uint64_t *argv, uint64_t *ret); | ||
typedef int (*krw_physread_func_t)(uint64_t from, void *to, size_t len, uint8_t granule); | ||
typedef int (*krw_physwrite_func_t)(void *from, uint64_t to, size_t len, uint8_t granule); | ||
|
||
// This struct must only be extended so that old plugins can still load | ||
#define LIBKRW_HANDLERS_VERSION 0 | ||
struct krw_handlers_s { | ||
uint64_t version; | ||
krw_kbase_func_t kbase; | ||
krw_kread_func_t kread; | ||
krw_kwrite_func_t kwrite; | ||
krw_kmalloc_func_t kmalloc; | ||
krw_kdealloc_func_t kdealloc; | ||
krw_kcall_func_t kcall; | ||
krw_physread_func_t physread; | ||
krw_physwrite_func_t physwrite; | ||
}; | ||
|
||
typedef struct krw_handlers_s* krw_handlers_t; | ||
|
||
/** | ||
* krw_initializer_t - plugin initialization prototype | ||
* | ||
* Called krw_initializer_t krw_initializer is called when a plugin is opened to | ||
* determine if read/write primitives are available | ||
* | ||
* krw_initializer should set as many of handlers->kread, handlers->kwrite, handlers->kbase, | ||
* handlers->kmalloc, and handlers->kdealloc as possible on success - any not set will | ||
* return unsupported. | ||
* | ||
* Called krw_initializer_t kcall_initializer is called when a plugin is opened to | ||
* determine if read/write primitives are available. It is passed a structure containing | ||
* populated kread/kwrite functions | ||
* | ||
* kcall_initializer should set as many of handlers->kcall, handlers->physread, and | ||
* handlers->physwrite as possible on success. any not set will return unsupported. | ||
* | ||
* Retuns 0 if read/write are supported by this plugin | ||
**/ | ||
typedef int (*krw_plugin_initializer_t)(krw_handlers_t handlers); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
libkrw-provider/libkrw-plugin.* | ||
libroot/libroot.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
all: | ||
@$(MAKE) -C libkrw-provider package | ||
@$(MAKE) -C libroot package | ||
|
||
clean: | ||
@$(MAKE) -C libkrw-provider clean | ||
@$(MAKE) -C libroot clean | ||
|
||
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
TARGET = libkrw-plugin.dylib | ||
CC = clang | ||
|
||
CFLAGS = -I../../BaseBin/.include -Isrc -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -arch arm64e -miphoneos-version-min=15.0 -fobjc-arc -O2 | ||
LDFLAGS = -dynamiclib -rpath /var/jb -L. -ljailbreak | ||
|
||
all: $(TARGET) sign | ||
|
||
sign: $(TARGET) | ||
@ldid -S $^ | ||
|
||
$(TARGET): $(wildcard src/*.c) | ||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | ||
|
||
clean: | ||
@rm -f $(TARGET) | ||
@rm -f libkrw-plugin.deb | ||
|
||
package: $(TARGET) | ||
@mkdir -p .package/DEBIAN | ||
@mkdir -p .package/var/jb/usr/lib/libkrw | ||
@cp control .package/DEBIAN/control | ||
@cp libkrw-plugin.dylib .package/var/jb/usr/lib/libkrw/libkrw-plugin.dylib | ||
@dpkg-deb --root-owner-group -Zzstd -b .package ./libkrw-plugin.deb | ||
@rm -rf .package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Package: libkrw0-dopamine | ||
Name: libkrw Plug-in (Dopamine) | ||
Author: opa334 <opa334@protonmail.com> | ||
Maintainer: opa334 <opa334@protonmail.com> | ||
Architecture: iphoneos-arm64 | ||
Version: 2.0.0 | ||
Provides: libkrw0-plugin | ||
Depends: libiosexec1 (>= 1.3.1), libkrw0 | ||
Section: Libraries | ||
Priority: standard | ||
Homepage: https://github.com/opa334/Dopamine/tree/main/Packages/libkrw-provider | ||
Description: libkrw Plug-in for Dopamine (Shared Library) |
Oops, something went wrong.