When C0deh4cker released libstubhook and I created my BigTNT mod, I started getting a lot of questions along the lines of: "How do I make mods with libstubhook? There isn't a tutorial." This post is the answer.
This tutorial is for people on Mac OS X 10.6.8 or later who want to develop mods in Xcode 4.x.
Table of Contents
- Install Necessary Tools
- Create Xcode Project
- Edit Mod
- Build Mod
- Create Package
- Upload Package
- Problems
Install Necessary Tools
Xcode - install from the app store. It is possible to create mods without Xcode. That is how C0deh4cker does it. I personally prefer to have an IDE so this tutorial will use Xcode.
iOSBrokenDev - download the repository from github:
Unzip the repository and navigate to that folder in Terminal. (I do that by typing "cd " and then dragging the folder into Terminal.) In Terminal run "sudo ./iOSBrokenDev.sh". You will need to enter your password.
MacPorts - I used macports to install dpkg. The installers for macports can be found here choose the one for your correct OS version.
dpkg - this is how you will build your package. I used macports to install dpkg. In terminal run "sudo port install dpkg". You will need to enter your password.
Create Xcode Project
Open Xcode.
Go to File->New->Project...
In the sidebar choose iOSBrokenDev and use the StubHook Mod template.
Click next, name your mod and turn off Automatic Reference Counting, click next, and save your project.
Change the build location. In the menu bar go to File->Project Settings. Choose advanced and then legacy.
Add libstubhook.dylib and stubhook.h to your project. In terminal run these commands. They will need your devices password. This is "alpine" (no quotes) unless you have changed it. Your "i-device ip address" can be found by going into Settings->Wi-Fi-><network name>(tap the blue arrow). The device ip address is the first in the list.
scp [email protected]<i-device ip address>:/usr/lib/libstubhook.dylib /path/to/project/folder/libstubhook.dylib
scp [email protected]<i-device ip address>:/usr/include/stubhook.h /path/to/project/folder/stubhook.h
After you run those commands, you will have libstubhook.dylib and stubhook.h in your project folder. Drag them to you project in Xcode. Edit Mod
You now have a Minecraft mod project. You need to edit your mod so it actually does something.
Put in addresses. You will need the addresses of the functions you want to hook or use. There are a few in C0deh4cker's mods on Github and TreeBl posted a list of them. You will probably want to find your own. That might be for another tutorial. You will notice the errors Xcode is giving me. That is because I haven't actually defined the Level$$explode function. I will do that in the next step.
In order to make the mod actually do something I will need to hook the Level$$explode function. That means that my mod says what the function does instead of the original one. Hooking the function also defines it which gets rid of the two errors in the last step.
Now that the function has a hook, I need to apply the hook in the constructor.
Build Mod
In the menu bar, go to Product->Build.
Make sure that the dylib in the Products in the sidebar turns from red to black. If not, make sure you are building for iOS device.
Create Package
In your project folder create a folder called <yourcompanyidentifier>.<yourmodname>. For my mod that will be called com.zcodemt.bigtnt. In that folder create the folder structure in the picture.
You will notice the file called control in the DEBIAN folder. Create that file and paste this in it. You will need to make sure it has no extension; the full name of that files is control.
You should now have a file structure similar to this one:
In terminal, navigate to your project folder and run "dpkg-deb -b <yourcompanyidentifier>.<yourmodname>"
Upload Package
You can upload your package to any Cydia repo you want. If you want your own repo use myrepospace. If you want me to host your package I will be happy to do that too. You can tweet to me on twitter or pm me.
Problems
Please tell me any problems you find. I will update the tutorial.
Please DO NOT quote this whole post (for obvious reasons).
1. DO NOT USE THAT TEMPLATE! That uses libstubhook as if it is a framework. If you try to use that mod on another device, it will not work.
2. You can't show a UIAlertView from SHConstructor because there's no UIWindow yet! That will just make it crash.
3. It is never a good idea to bug the user with an alert, especially EVERY TIME like will happen with this template.
4. You are claiming libstubhook to be your own. I don't care that you for some unknown reason decided to make libstubhook into a framework (which was a very bad idea), but you also have yourself listed as the author of stubhook. I do not tolerate when people steal credit for something I've done, and that's exactly what you are doing. You just wrapped my libstubhook into a framework (did I mention that was a bad idea?) and threw it on your repo for credit and more repo users.
Believe it or not, I have reasons for doing things the way I do them. For example, I made libstubhook be a LIBRARY, not a FRAMEWORK. Frameworks are HUGE projects of code. Libraries are for smaller pieces of code and are both easier to work with than frameworks and more common. Additionally, I put libstubhook on a default repository so mods using it could easily list it as a depend. You go off making people add some obscure repo (yours) and have mod makers list "com.zcodemt.something" (again, taking credit for MY libstubhook), which is a total mess.
Please either completely remove this so-called tutorial and your GitHub repository, or remake the tutorial from scratch (and still delete that GitHub repo). Also, remove stubhook from your repo.
I am sooooo sorry. I took stubhook out of my github repository. I don't have time to fix everything else right now, so for now, nobody use this tutorial.
1. DO NOT USE THAT TEMPLATE! That uses libstubhook as if it is a framework. If you try to use that mod on another device, it will not work.
2. You can't show a UIAlertView from SHConstructor because there's no UIWindow yet! That will just make it crash.
3. It is never a good idea to bug the user with an alert, especially EVERY TIME like will happen with this template.
4. You are claiming libstubhook to be your own. I don't care that you for some unknown reason decided to make libstubhook into a framework (which was a very bad idea), but you also have yourself listed as the author of stubhook. I do not tolerate when people steal credit for something I've done, and that's exactly what you are doing. You just wrapped my libstubhook into a framework (did I mention that was a bad idea?) and threw it on your repo for credit and more repo users.
Believe it or not, I have reasons for doing things the way I do them. For example, I made libstubhook be a LIBRARY, not a FRAMEWORK. Frameworks are HUGE projects of code. Libraries are for smaller pieces of code and are both easier to work with than frameworks and more common. Additionally, I put libstubhook on a default repository so mods using it could easily list it as a depend. You go off making people add some obscure repo (yours) and have mod makers list "com.zcodemt.something" (again, taking credit for MY libstubhook), which is a total mess.
Please either completely remove this so-called tutorial and your GitHub repository, or remake the tutorial from scratch (and still delete that GitHub repo). Also, remove stubhook from your repo.
I understand why you would be angry. I didn't mean it to be the way you are looking at it. Here are my answers:
1. I made a mistake while testing that made me think it worked.
2. I hadn't tested that yet. I guess I should have.
3. How would you suggest making it show only once?
4. I did not claim stubhook as my own. I understand that you put a lot of work in it and if you tell me where I claim it as my work, I will fix that. I put it on the github repository to make it easier for people. Since you obviously dissagree, I removed it from github and will change the tutorial to include instructions for getting it off of an i-device.
I absolutely believe you have reasons for doing things, just like I do. I know from experience that frameworks are a lot easier to work with in Xcode than libraries. After further testing today, I realized that the framework didn't work the way I wanted to.
I am not going to completely rewrite the tutorial from scratch because parts of it have no problems. As for the github repository, that is not just for stubhook, so I won't completely remove it. I removed the stubhook framework stuff and changed the template so that it does not use stubhook as a framework. If you still think it is unacceptable, I will remove it from github and use it for myself only.
I understand why you would be angry. I didn't mean it to be the way you are looking at it. Here are my answers:
1. I made a mistake while testing that made me think it worked.
2. I hadn't tested that yet. I guess I should have.
3. How would you suggest making it show only once?
4. I did not claim stubhook as my own. I understand that you put a lot of work in it and if you tell me where I claim it as my work, I will fix that. I put it on the github repository to make it easier for people. Since you obviously dissagree, I removed it from github and will change the tutorial to include instructions for getting it off of an i-device.
I absolutely believe you have reasons for doing things, just like I do. I know from experience that frameworks are a lot easier to work with in Xcode than libraries. After further testing today, I realized that the framework didn't work the way I wanted to.
I am not going to completely rewrite the tutorial from scratch because parts of it have no problems. As for the github repository, that is not just for stubhook, so I won't completely remove it. I removed the stubhook framework stuff and changed the template so that it does not use stubhook as a framework. If you still think it is unacceptable, I will remove it from github and use it for myself only.
Now . . . time to fix that tutorial!
2) Also, no Objective-C code at all should be run in SHConstructor unless you wrap it in @autorelease { }. Since there is no autorelease pool allocated when SHConstructor is run, any Objective-C code that either uses autoreleased objects directly or indirectly will create memory leaks, leading to crashes.
3) In my sprinting mod I did this:
If you use this code, DO NOT use the same key as I do.
Please note that a planned feature for libstubhook is to support version incompatibility reports, so your mod will basically just call SHIncompatible("mod name here"), and your mod's name will be displayed in a once-per-version update alert as a list with all other incompatible mods. Sample code will be up when this feature is added.
Thank you for being so quick to fix the issue with stubhook as a framework. I realize you did not intend to take credit for it, but that was the effect.
I don't have a Mac yet and therefore don't know how Xcode projects/templates work, but all you need to do is set the LDFLAGS to '-dynamiclib -lstubhook'.
I plan on making a libstubhook tutorial for iOS myself, so please don't try to do that. It will include a Theos template.
2) Also, no Objective-C code at all should be run in SHConstructor unless you wrap it in @autorelease { }. Since there is no autorelease pool allocated when SHConstructor is run, any Objective-C code that either uses autoreleased objects directly or indirectly will create memory leaks, leading to crashes.
3) In my sprinting mod I did this:
If you use this code, DO NOT use the same key as I do.
Please note that a planned feature for libstubhook is to support version incompatibility reports, so your mod will basically just call SHIncompatible("mod name here"), and your mod's name will be displayed in a once-per-version update alert as a list with all other incompatible mods. Sample code will be up when this feature is added.
Thank you for being so quick to fix the issue with stubhook as a framework. I realize you did not intend to take credit for it, but that was the effect.
I don't have a Mac yet and therefore don't know how Xcode projects/templates work, but all you need to do is set the LDFLAGS to '-dynamiclib -lstubhook'.
I plan on making a libstubhook tutorial for iOS myself, so please don't try to do that. It will include a Theos template.
Thanks for understanding what I did and for the tips. I know how to link with a dylib in Xcode, but I don't know how to do it in a template. I will see if I can get that figured out.
Also, could you give a yes or a no on the tutorial. Considering your first post on this topic, no one will use it unless you approve the changes I made.
Thanks for understanding what I did and for the tips. I know how to link with a dylib in Xcode, but I don't know how to do it in a template. I will see if I can get that figured out.
Also, could you give a yes or a no on the tutorial. Considering your first post on this topic, no one will use it unless you approve the changes I made.
The tutorial only tells how to setup Xcode to be able to use libstubhook. If that's what you were trying to do, then that's fine. Just reflect that in your title (something like "Using libstubhook from Xcode" would work).
Also, mods shouldnt use ARC. In general, ARC doesn't play well with mods/tweaks.
Plus, mods shouldn't depend on iOS 5+. Just remove that firmware dependency.
If that can all be changed, then I'll agree w/ this tutorial and even edit my posts to remove the initial criticism.
The tutorial only tells how to setup Xcode to be able to use libstubhook. If that's what you were trying to do, then that's fine. Just reflect that in your title (something like "Using libstubhook from Xcode" would work).
Also, mods shouldnt use ARC. In general, ARC doesn't play well with mods/tweaks.
Plus, mods shouldn't depend on iOS 5+. Just remove that firmware dependency.
If that can all be changed, then I'll agree w/ this tutorial and even edit my posts to remove the initial criticism.
- I would be happy to change the title of my post, but how do I do that?
- I can't remove the ARC option in a template (it is not a template option) but I added instruction to turn it off when creating a project.
- I removed that dependency.
- I would be happy to change the title of my post, but how do I do that?
- I can't remove the ARC option in a template (it is not a template option) but I added instruction to turn it off when creating a project.
- I removed that dependency.
You can change your title by clicking edit under you post. Then at the bottom, click use full editor.
Okay, this tutorial looks good now. One thing i'd like to point out:
SHStub just sets the address of a function. If you want to hook that function, you must first SHHook it and then SHApplyHook in SHConstructor. If you simply want to call that function from your own code, just declare it as a static function pointer and SHStub it.
Okay, this tutorial looks good now. One thing i'd like to point out:
SHStub just sets the address of a function. If you want to hook that function, you must first SHHook it and then SHApplyHook in SHConstructor. If you simply want to call that function from your own code, just declare it as a static function pointer and SHStub it.
This tutorial is for people on Mac OS X 10.6.8 or later who want to develop mods in Xcode 4.x.
Table of Contents
- Install Necessary Tools
- Create Xcode Project
- Edit Mod
- Build Mod
- Create Package
- Upload Package
- Problems
Install Necessary Tools
- Xcode - install from the app store. It is possible to create mods without Xcode. That is how C0deh4cker does it. I personally prefer to have an IDE so this tutorial will use Xcode.
- iOSBrokenDev - download the repository from github:

Unzip the repository and navigate to that folder in Terminal. (I do that by typing "cd " and then dragging the folder into Terminal.) In Terminal run "sudo ./iOSBrokenDev.sh". You will need to enter your password.
- MacPorts - I used macports to install dpkg. The installers for macports can be found here choose the one for your correct OS version.
- dpkg - this is how you will build your package. I used macports to install dpkg. In terminal run "sudo port install dpkg". You will need to enter your password.
Create Xcode Project- Open Xcode.
- Go to File->New->Project...

- In the sidebar choose iOSBrokenDev and use the StubHook Mod template.

- Click next, name your mod and turn off Automatic Reference Counting, click next, and save your project.

- Change the build location. In the menu bar go to File->Project Settings. Choose advanced and then legacy.

- Add libstubhook.dylib and stubhook.h to your project. In terminal run these commands. They will need your devices password. This is "alpine" (no quotes) unless you have changed it. Your "i-device ip address" can be found by going into Settings->Wi-Fi-><network name>(tap the blue arrow). The device ip address is the first in the list.
Edit ModAfter you run those commands, you will have libstubhook.dylib and stubhook.h in your project folder. Drag them to you project in Xcode.
You now have a Minecraft mod project. You need to edit your mod so it actually does something.
- Put in addresses. You will need the addresses of the functions you want to hook or use. There are a few in C0deh4cker's mods on Github and TreeBl posted a list of them. You will probably want to find your own. That might be for another tutorial. You will notice the errors Xcode is giving me. That is because I haven't actually defined the Level$$explode function. I will do that in the next step.

- In order to make the mod actually do something I will need to hook the Level$$explode function. That means that my mod says what the function does instead of the original one. Hooking the function also defines it which gets rid of the two errors in the last step.

- Now that the function has a hook, I need to apply the hook in the constructor.

Build Mod- In the menu bar, go to Product->Build.

- Make sure that the dylib in the Products in the sidebar turns from red to black. If not, make sure you are building for iOS device.

Create Package- In your project folder create a folder called <yourcompanyidentifier>.<yourmodname>. For my mod that will be called com.zcodemt.bigtnt. In that folder create the folder structure in the picture.

- You will notice the file called control in the DEBIAN folder. Create that file and paste this in it. You will need to make sure it has no extension; the full name of that files is control.
- Edit the control file to fit your mod. The only thing you shouldn't change is the Depends line.
- In your project folder open build/Debug-iphoneos copy the dylib file from there to the DynamicLibraries folder.
- Create a new file in textedit and save it with the same name as the dylib but with the extension plist. Paste this in the file:
- You should now have a file structure similar to this one:

- In terminal, navigate to your project folder and run "dpkg-deb -b <yourcompanyidentifier>.<yourmodname>"
Upload PackageYou can upload your package to any Cydia repo you want. If you want your own repo use myrepospace. If you want me to host your package I will be happy to do that too. You can tweet to me on twitter or pm me.
Problems
Please tell me any problems you find. I will update the tutorial.
Please DO NOT quote this whole post (for obvious reasons).
Sorry . . . Windows is totally out of the question. You can develop on ios or Mac. I think I will make an ios tutorial tomorrow.
Edit: actually, I think there is a way to develop on windows. I will look in to that tomorrow.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI would very much appreciate it if you made a tutorial soon for doing it on IOS.
A windows tutorial would be nice...
Check out my iOS Mods!
I am sooooo sorry. I took stubhook out of my github repository. I don't have time to fix everything else right now, so for now, nobody use this tutorial.
I understand why you would be angry. I didn't mean it to be the way you are looking at it. Here are my answers:
1. I made a mistake while testing that made me think it worked.
2. I hadn't tested that yet. I guess I should have.
3. How would you suggest making it show only once?
4. I did not claim stubhook as my own. I understand that you put a lot of work in it and if you tell me where I claim it as my work, I will fix that. I put it on the github repository to make it easier for people. Since you obviously dissagree, I removed it from github and will change the tutorial to include instructions for getting it off of an i-device.
I absolutely believe you have reasons for doing things, just like I do. I know from experience that frameworks are a lot easier to work with in Xcode than libraries. After further testing today, I realized that the framework didn't work the way I wanted to.
I am not going to completely rewrite the tutorial from scratch because parts of it have no problems. As for the github repository, that is not just for stubhook, so I won't completely remove it. I removed the stubhook framework stuff and changed the template so that it does not use stubhook as a framework. If you still think it is unacceptable, I will remove it from github and use it for myself only.
Now . . . time to fix that tutorial!
2) Also, no Objective-C code at all should be run in SHConstructor unless you wrap it in @autorelease { }. Since there is no autorelease pool allocated when SHConstructor is run, any Objective-C code that either uses autoreleased objects directly or indirectly will create memory leaks, leading to crashes.
3) In my sprinting mod I did this:
static void show_incompatible(NSString* version) { NSUserDefaults* settings = [NSUserDefaults standardUserDefaults]; NSString* key = [NSString stringWithFormat:@"incompatible_shown_%@", version]; if(![settings boolForKey:key]) { // Show alert popup // Set alert shown key [settings setBool:YES forKey:key]; [settings synchronize]; } }If you use this code, DO NOT use the same key as I do.
Please note that a planned feature for libstubhook is to support version incompatibility reports, so your mod will basically just call SHIncompatible("mod name here"), and your mod's name will be displayed in a once-per-version update alert as a list with all other incompatible mods. Sample code will be up when this feature is added.
Thank you for being so quick to fix the issue with stubhook as a framework. I realize you did not intend to take credit for it, but that was the effect.
I don't have a Mac yet and therefore don't know how Xcode projects/templates work, but all you need to do is set the LDFLAGS to '-dynamiclib -lstubhook'.
I plan on making a libstubhook tutorial for iOS myself, so please don't try to do that. It will include a Theos template.
Check out my iOS Mods!
Thanks for understanding what I did and for the tips. I know how to link with a dylib in Xcode, but I don't know how to do it in a template. I will see if I can get that figured out.
Also, could you give a yes or a no on the tutorial. Considering your first post on this topic, no one will use it unless you approve the changes I made.
The tutorial only tells how to setup Xcode to be able to use libstubhook. If that's what you were trying to do, then that's fine. Just reflect that in your title (something like "Using libstubhook from Xcode" would work).
Also, mods shouldnt use ARC. In general, ARC doesn't play well with mods/tweaks.
Plus, mods shouldn't depend on iOS 5+. Just remove that firmware dependency.
If that can all be changed, then I'll agree w/ this tutorial and even edit my posts to remove the initial criticism.
Check out my iOS Mods!
- I would be happy to change the title of my post, but how do I do that?
- I can't remove the ARC option in a template (it is not a template option) but I added instruction to turn it off when creating a project.
- I removed that dependency.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffYou can change your title by clicking edit under you post. Then at the bottom, click use full editor.
It will give you an option to change your title
Click on an image to view the section rules!









SHStub just sets the address of a function. If you want to hook that function, you must first SHHook it and then SHApplyHook in SHConstructor. If you simply want to call that function from your own code, just declare it as a static function pointer and SHStub it.
Check out my iOS Mods!
Oops, forgot to put that in the tutorial.