Skip to content

Commit

Permalink
libkrw bug fixes, bump version of it to 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Jun 11, 2024
1 parent 0bff46c commit b3f8bdb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Application/Dopamine/Jailbreak/DOBootstrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import <dlfcn.h>
#import <sys/stat.h>

#define LIBKRW_DOPAMINE_BUNDLED_VERSION @"2.0.1"
#define LIBKRW_DOPAMINE_BUNDLED_VERSION @"2.0.2"
#define LIBROOT_DOPAMINE_BUNDLED_VERSION @"1.0.1"
#define BASEBIN_LINK_BUNDLED_VERSION @"1.0.0"

Expand Down
2 changes: 1 addition & 1 deletion Packages/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libkrw-provider/libkrw-plugin.*
libkrw-provider/libkrw-dopamine.*
libroot/libroot.*
basebin-link/basebin-link.*
12 changes: 6 additions & 6 deletions Packages/libkrw-provider/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
TARGET = libkrw-plugin.dylib
TARGET = libkrw-dopamine.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../../BaseBin/.build -ljailbreak
LDFLAGS = -dynamiclib -rpath /var/jb/usr/lib -L../../BaseBin/.build -ljailbreak

all: $(TARGET) sign

Expand All @@ -11,16 +11,16 @@ sign: $(TARGET)

$(TARGET): $(wildcard src/*.c)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
install_name_tool -change "@loader_path/libjailbreak.dylib" "@rpath/usr/lib/libjailbreak.dylib" $@
install_name_tool -change "@loader_path/libjailbreak.dylib" "@rpath/libjailbreak.dylib" $@

clean:
@rm -f $(TARGET)
@rm -f libkrw-plugin.deb
@rm -f libkrw-dopamine.deb

package: all
@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
@cp libkrw-dopamine.dylib .package/var/jb/usr/lib/libkrw/libkrw-dopamine.dylib
@dpkg-deb --root-owner-group -Zzstd -b .package ./libkrw-dopamine.deb
@rm -rf .package
2 changes: 1 addition & 1 deletion Packages/libkrw-provider/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Name: libkrw Plug-in (Dopamine)
Author: opa334 <[email protected]>
Maintainer: opa334 <[email protected]>
Architecture: iphoneos-arm64
Version: 2.0.1
Version: 2.0.2
Provides: libkrw0-plugin
Depends: libiosexec1 (>= 1.3.1), libkrw0
Section: Libraries
Expand Down
27 changes: 14 additions & 13 deletions Packages/libkrw-provider/src/main.c
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
#include <libjailbreak/libjailbreak.h>
#include <libkrw/libkrw_plugin.h>
#include <dispatch/dispatch.h>
#include <errno.h>

void load_primitives_once(void)
static void load_primitives_once(void)
{
static dispatch_once_t onceToken;
dispatch_once (&onceToken, ^{
jbclient_initialize_primitives();
});
}

int kwritebuf_wrapper(void *from, uint64_t to, size_t len)
static int kwritebuf_wrapper(void *from, uint64_t to, size_t len)
{
return kwritebuf(to, from, len);
}

int kcall_wrapper(uint64_t func, size_t argc, const uint64_t *argv, uint64_t *ret)
static int kcall_wrapper(uint64_t func, size_t argc, const uint64_t *argv, uint64_t *ret)
{
return kcall(ret, func, argc, argv);
if (jbinfo(usesPACBypass)) {
return kcall(ret, func, argc, argv);
}
return ENOTSUP;
}

int physreadbuf_wrapper(uint64_t from, void *to, size_t len, uint8_t granule)
static int physreadbuf_wrapper(uint64_t from, void *to, size_t len, uint8_t granule)
{
return physreadbuf(from, to, len);
}

int physwritebuf_wrapper(void *from, uint64_t to, size_t len, uint8_t granule)
static int physwritebuf_wrapper(void *from, uint64_t to, size_t len, uint8_t granule)
{
return physwritebuf(to, from, len);
}

int kbase_wrapper(uint64_t *kbase)
static int kbase_wrapper(uint64_t *kbase)
{
*kbase = kconstant(base);
return 0;
}

__attribute__((used)) krw_plugin_initializer_t krw_initializer(krw_handlers_t handlers)
__attribute__((used)) int krw_initializer(krw_handlers_t handlers)
{
load_primitives_once();

Expand All @@ -48,14 +52,11 @@ __attribute__((used)) krw_plugin_initializer_t krw_initializer(krw_handlers_t ha
return 0;
}

__attribute__((used)) krw_plugin_initializer_t kcall_initializer(krw_handlers_t handlers)
__attribute__((used)) int kcall_initializer(krw_handlers_t handlers)
{
load_primitives_once();

if (jbinfo(usesPACBypass)) {
handlers->kcall = kcall_wrapper;
}

handlers->kcall = kcall_wrapper;
handlers->physread = physreadbuf_wrapper;
handlers->physwrite = physwritebuf_wrapper;
return 0;
Expand Down

0 comments on commit b3f8bdb

Please sign in to comment.