Skip to content

Commit

Permalink
Merge pull request #14 from M1nxy/main
Browse files Browse the repository at this point in the history
Added nice frontend (thanks to @M1nxy)
  • Loading branch information
NightwindDev authored Nov 24, 2023
2 parents d0085f6 + 17f03cb commit c8da27e
Show file tree
Hide file tree
Showing 45 changed files with 1,064 additions and 598 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

env:
# Hosted GitHub runners have 7 GB of memory available, let's use 6 GB
NODE_OPTIONS: --max-old-space-size=6144

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn install --non-interactive
- name: Build
run: yarn build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: build
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
.DS_Store
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

pnpm-lock.yaml
yarn.lock
package-lock.json
bun.lock
28 changes: 0 additions & 28 deletions Solutions/Challenge_1.x

This file was deleted.

3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
3 changes: 3 additions & 0 deletions docs/challenges/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
label: "Challenges"
collapsible: true # make the category collapsible
collapsed: false # keep the category open by default
33 changes: 33 additions & 0 deletions docs/challenges/example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: example
title: Example Challenge
unlisted: true
---

{/* remove the unlisted, increment the ids above and provided a sensible title */}

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

{/* Short description of the challenge goes here */}

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

<Tabs>
<TabItem value="challenge" label="Challenge">
{/* challenge code goes here (do not indent)*/}

```objc
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

</TabItem>
<TabItem value="solution" label="Solution">
{/* solution code goes here (do not indent)*/}

```objc
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

</TabItem>
</Tabs>
85 changes: 85 additions & 0 deletions docs/challenges/p14_challenges.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
id: challenge_1
title: Challenge 1
sidebar_position: 1
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

<p>Convert the following piece of Substrate code to Logos.</p>
<Tabs>
<TabItem value="challenge" label="Challenge">
```objc
#import <UIKit/UIKit.h>
#import <substrate.h>

@interface SBIconImageView : UIView
@end

@interface SBHomeScreenBackdropView : UIView
@end

void orig_SBIconImageView_didMoveToWindow(SBIconImageView *self, SEL _cmd);

void new_SBIconImageView_didMoveToWindow(SBIconImageView *self, SEL _cmd) {
self.alpha = 0.5;
orig_didMoveToWindow(self, _cmd);
}

void orig_SBHomeScreenBackdropView_didMoveToSuperview(SBHomeScreenBackdropView *self, SEL _cmd);

void new_SBHomeScreenBackdropView_didMoveToSuperview(SBHomeScreenBackdropView *self, SEL _cmd) {
self.hidden = true;
orig_SBHomeScreenBackdropView_didMoveToSuperview(self, _cmd);
}

__attribute__((constructor)) static void initialize() {
MSHookMessageEx(
NSClassFromString(@"SBIconImageView"),
@selector(didMoveToWindow),
(IMP) &new_SBIconImageView_didMoveToWindow,
(IMP *) &orig_SBIconImageView_didMoveToWindow
);
MSHookMessageEx(
NSClassFromString(@"SBHomeScreenBackdropView"),
@selector(didMoveToSuperview),
(IMP) &new_SBHomeScreenBackdropView_didMoveToSuperview,
(IMP *) &orig_SBHomeScreenBackdropView_didMoveToSuperview
);
}
```
</TabItem>
<TabItem value="solution" label="Solution">
```objc
#import <UIKit/UIKit.h>

@interface SBIconImageView : UIView
@end

@interface SBHomeScreenBackdropView : UIView
@end


%hook SBIconImageView

-(void)didMoveToWindow {
self.alpha = 0.5;
%orig;
}

%end


%hook SBHomeScreenBackdropView

-(void)didMoveToWindow {
self.hidden = true;
%orig;
}

%end
```
</TabItem>

</Tabs>
11 changes: 11 additions & 0 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: example
title: Example Lesson
sidebar_position: 0
unlisted: true
---

{/* remove the unlisted, increment the ids above and provided a sensible title */}


{/* Lesson content goes here */}
23 changes: 23 additions & 0 deletions docs/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: intro
title: Introduction
sidebar_position: -1
tags: []
---

## Prerequisites

- Basic [Object-Orientated Programming (OOP)](https://en.wikipedia.org/wiki/Object-oriented_programming) knowledge.
- Either [Theos](https://theos.dev) or [Dragon](https://dragon.cynder.me/en/latest/) installed.
- A text editor or IDE of your choice.
- A jailbroken device or the Xcode Simulator on macOS paired with [Simject](https://github.com/akemin-dayo/simject)

### Credits:

- [@Luki120](https://github.com/Luki120) for helping out with some of the issues regarding Substrate + important & valuable contributions.
- [@L1ghtmann](https://github.com/L1ghtmann) for helping out with some issues regarding the tutorial as well as helping make the tutorial more beginner friendly.

### Support:

- [iOSJBN Discord Server](https://discord.gg/K3wGBBhPqp)
- [r/jailbreakdevelopers](https://reddit.com/r/jailbreakdevelopers)
37 changes: 37 additions & 0 deletions docs/p0_starting_off.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: getting_started
title: Getting Started
sidebar_position: 0
---

## Setting Up The Tweak

1. Assure that you have [**Theos**](https://theos.dev) set up. The instructions to set up Theos can be found [here](https://theos.dev/docs/installation). Please choose the appropriate operating system in the wiki and install it.

2. Assure you have some kind of text editor, some good ones being [Visual Studio Code](https://code.visualstudio.com), [Sublime Text](https://www.sublimetext.com), and more! Feel free to use your preferred text editor, however note that **Visual Studio Code** has an **extension** for **Logos**, which can be found [here](https://marketplace.visualstudio.com/items?itemName=tale.logos-vscode).

3. For easier "view-finding," download a flipboard explorer such as FLEXing ([rootful version](https://github.com/NSExceptional/FLEXing/releases/tag/1.2.0)/[rootless version](https://github.com/PoomSmart/FLEXing/releases/tag/1.5.0)) or [FLEXall](https://DGh0st.github.io/) (rootful only).

4. To begin run the following command:

```bash
$THEOS/bin/nic.pl
```

:::danger Warning
If this does not work, you have probably set up Theos incorrectly. Please go back to step 1 and fix your installation.
:::

- This should show different options, one of them being `iphone/tweak`. This option will have a number next to it, which you type in to select that option.

- After that, the terminal will prompt you with `Project Name (required):`, meaning "what is going to be the name of your tweak?" Please type the name that you want to call the tweak in this space.

- After _that_, the terminal will prompt you with `Package Name [com.yourcompany.testtweak]:`, meaning "what is going to be the [Bundle ID](https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids) of your tweak?" Most likely it will be `com.yourname.yourtweakname`. Note that it cannot contain any uppercase letters.

- Next, it will ask you `Author/Maintainer Name [yourname]:`. Please put whatever you want your "developer name" to be if/when you publish the tweak.

- Furthermore, the terminal will ask you `[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]:`. This essentially means "what do you want your tweak to hook?" (Examples: Twitter tweak: `com.atebits.Tweetie2`, Settings tweak: `com.apple.Preferences`, SpringBoard: `com.apple.springboard`). We will hook SpringBoard for our example tweak, so use `com.apple.springboard`.

- Then, it will ask `[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]:`, just press enter for now on this one.

- After this, Theos will create a folder with the tweak files inside of it.
16 changes: 11 additions & 5 deletions p10_rootless.md → docs/p10_rootless.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
---
id: rootless
title: Rootless tweaks
sidebar_position: 10
---

# Adapting for Rootless

### What is rootless?

- "rootless" is the term used for jailbreaks which do not have access to the root filesystem. This means that anything outside of `/var/` and `/private/preboot/` is not writable. However, the root **user** is still accessibly on a rootless jailbreak.

### How does this affect my tweak?

- Existing tweaks which do not support rootless will need some changes in order to work on a rootless jailbreak. For instance, preference bundles are stored in `/Library/PreferenceBundles/` on a traditional ("rootful") jailbreak. However, since a rootless jailbreak does not have the ability to write to outside of the aforementioned directories, there needs to be a change made to the path in order to work properly. On rootless jailbreaks, the jailbreak files are stored in `/var/jb/`. Thus, the path becomes `/var/jb/Library/PreferenceBundles/`. This is the main difference between "rootless" and "rootful" jailbreaks.

---
Expand All @@ -13,11 +21,12 @@
Firsrly, it is best to always use the most up-to-date version of Theos. Make sure to update it if you installed Theos a while ago.

Theos includes convenient macros for you to use in order to adapt for rootless. They are stored in a header file called [rootless.h](https://github.com/theos/headers/blob/4c7409e29260a7c47a27d52531a0ebc4bc034e72/rootless.h) which is bundled in recent versions. Say we have a file path that needs to be adapted stored within an `NSString` like so:

```objc
NSString *filePath = @"/Library/Application Support/";
```

This particular directory *does* exist in non-jailbroken iOS. On "rootful" jailbreaks, tweaks can write to this directory to store files. However, on "rootless" jailbreaks, there is no ability to do that. So, rootless jailbreaks write to `/var/jb/Library/Application Support/`. So how can we include the `/var/jb/` part of the path when compiling for "rootless" but not "rootful?" Well, the macros make that process quite simple. In order to utilize the macros, you need to `#import <rootless.h>` at in your file. That will give you the ability to access the macros. Then, you can just wrap the path in the `ROOT_PATH_NS()` macro in order to adapt for "rootless" jailbreaks. So, it can be done as easily as this:
This particular directory _does_ exist in non-jailbroken iOS. On "rootful" jailbreaks, tweaks can write to this directory to store files. However, on "rootless" jailbreaks, there is no ability to do that. So, rootless jailbreaks write to `/var/jb/Library/Application Support/`. So how can we include the `/var/jb/` part of the path when compiling for "rootless" but not "rootful?" Well, the macros make that process quite simple. In order to utilize the macros, you need to `#import <rootless.h>` at in your file. That will give you the ability to access the macros. Then, you can just wrap the path in the `ROOT_PATH_NS()` macro in order to adapt for "rootless" jailbreaks. So, it can be done as easily as this:

```objc
#import <rootless.h>
Expand All @@ -28,6 +37,7 @@ NSString *filePath = ROOT_PATH_NS(@"/Library/Application Support/");
```

The value of this string will be like so:

- "rootful": `/Library/Application Support/`
- "rootless": `/var/jb/Library/Application Support/`

Expand All @@ -40,7 +50,3 @@ Do note that some libraries also need to be updated for rootless, so that is som
More information about adapting for rootless can be found [here](https://theos.dev/docs/rootless).

---

[Previous Page (FLEX Explained)](./p9_advanced_flex.md)

[Next Page (`%hookf`)](./p11_hookf.md)
16 changes: 8 additions & 8 deletions p11_hookf.md → docs/p11_hookf.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# How Do You Create a Tweak?
---
id: hookf
title: Hookf
sidebar_position: 11
---

`%hookf` can be confusing at first, but it is pretty easy to understand once you get into it.

Expand All @@ -12,9 +16,9 @@ While `%hook` is used to hook Objective-C classes, `%hookf` is used to hook C fu
%hookf(return_type, symbol_name, arguments...) {...}
```
* `return_type` - The return type of the function.
* `symbol_name` - This is the name of the function being hooked.
* `arguments` - These are the arguments that are passed into the function.
- `return_type` - The return type of the function.
- `symbol_name` - This is the name of the function being hooked.
- `arguments` - These are the arguments that are passed into the function.
## Example
Expand All @@ -41,7 +45,3 @@ __attribute__((constructor)) static void initialize() {
```
For further information about `%hookf`, please go [here](https://theos.dev/docs/logos-syntax).
[Previous Page (Adapting for rootless)](./p10_rootless.md)
[Next Page (`%subclass` Wrapper)](./p12_subclassWrapper.md)
Loading

0 comments on commit c8da27e

Please sign in to comment.