Skip to content

Commit 7cce257

Browse files
committed
build libs
1 parent b99a685 commit 7cce257

File tree

7 files changed

+325
-3
lines changed

7 files changed

+325
-3
lines changed

app/src/main/cpp/CMakeLists.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ project("ModBNM")
2525
# Add the directory containing your local copy of dobby.h
2626
include_directories(
2727
${CMAKE_CURRENT_SOURCE_DIR}
28-
${CMAKE_CURRENT_SOURCE_DIR}/utils
28+
${CMAKE_CURRENT_SOURCE_DIR}/include
2929
${CMAKE_CURRENT_SOURCE_DIR}/Dobby
3030
)
3131
add_subdirectory(ByNameModding EXCLUDE_FROM_ALL)
@@ -47,6 +47,45 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
4747
# can link libraries from various origins, such as libraries defined in this
4848
# build script, prebuilt third-party libraries, or Android system libraries.
4949
target_link_libraries(${CMAKE_PROJECT_NAME}
50+
# List libraries link to the target library
51+
${LIBDOBBY_PATH}
52+
BNM
53+
android
54+
log)
55+
56+
# horny-villa
57+
set(LIB_NAME horny-villa)
58+
add_library(${LIB_NAME} SHARED
59+
utils/utils.cpp
60+
${LIB_NAME}.cpp)
61+
62+
target_link_libraries(${LIB_NAME}
63+
# List libraries link to the target library
64+
${LIBDOBBY_PATH}
65+
BNM
66+
android
67+
log)
68+
69+
# ark-recode
70+
set(LIB_NAME ark-recode)
71+
add_library(${LIB_NAME} SHARED
72+
utils/utils.cpp
73+
${LIB_NAME}.cpp)
74+
75+
target_link_libraries(${LIB_NAME}
76+
# List libraries link to the target library
77+
${LIBDOBBY_PATH}
78+
BNM
79+
android
80+
log)
81+
82+
# mafia-queens
83+
set(LIB_NAME mafia-queens)
84+
add_library(${LIB_NAME} SHARED
85+
utils/utils.cpp
86+
${LIB_NAME}.cpp)
87+
88+
target_link_libraries(${LIB_NAME}
5089
# List libraries link to the target library
5190
${LIBDOBBY_PATH}
5291
BNM

app/src/main/cpp/ark-recode.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include <jni.h>
2+
#include <string>
3+
#include <thread>
4+
5+
#include "logger.h"
6+
#include <BNM/Image.hpp>
7+
#include <BNM/Class.hpp>
8+
#include <BNM/Field.hpp>
9+
#include <BNM/Method.hpp>
10+
#include <BNM/Loading.hpp>
11+
#include "utils.h"
12+
13+
14+
void OnLoaded();
15+
16+
extern "C" JNIEXPORT jint JNICALL
17+
JNI_OnLoad(JavaVM *vm, void *reserved) {
18+
JNIEnv *env;
19+
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
20+
BNM::Loading::AddOnLoadedEvent(OnLoaded);
21+
BNM::Loading::TryLoadByJNI(env);
22+
return JNI_VERSION_1_6;
23+
}
24+
25+
// FeatureTypes: Toggle, Seekbar, Category
26+
// Examples:
27+
// Toggle:ToggleName:true
28+
// Seekbar:SeekbarName:1_20_10
29+
// Category:CategoryName
30+
extern "C" JNIEXPORT jobjectArray JNICALL
31+
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
32+
std::string featList[] = {
33+
"Seekbar:Attack:1_20",
34+
"Seekbar:Defence:1_20",
35+
};
36+
return toJobjectArray(env, featList, std::size(featList));
37+
}
38+
39+
int attack = 1;
40+
int defence = 1;
41+
extern "C" JNIEXPORT void JNICALL
42+
Java_com_android_support_Menu_valueChange(
43+
JNIEnv *env,
44+
jobject thiz,
45+
jint featIdx,
46+
jstring featName,
47+
jobject value
48+
) {
49+
// featIdx: index in feature list
50+
switch (featIdx) {
51+
case 0: {
52+
attack = toJint(env, value);
53+
break;
54+
}
55+
case 1: {
56+
defence = toJint(env, value);
57+
break;
58+
}
59+
default:
60+
break;
61+
}
62+
}
63+
64+
BNM::Field<int> Camp{};
65+
66+
float (*old_GetSkillConditionAttack)(void *instance, void *inSource,
67+
void *inSkillProcessContext,
68+
void *inSourceSkillFunctionInfos);
69+
70+
float new_GetSkillConditionAttack(void *instance, void *inSource,
71+
void *inSkillProcessContext,
72+
void *inSourceSkillFunctionInfos) {
73+
auto ret = old_GetSkillConditionAttack(instance, inSource, inSkillProcessContext,
74+
inSourceSkillFunctionInfos);
75+
auto camp = Camp[inSource]();
76+
if (camp == 1) {
77+
ret = ret * attack;
78+
}
79+
return ret;
80+
}
81+
82+
float (*old_GetDefenceRate)(void *instance, void *inSource,
83+
void *inSkillProcessContext,
84+
void *inSourceSkillFunctionInfos);
85+
86+
float new_GetDefenceRate(void *instance, void *inSource,
87+
void *inSkillProcessContext,
88+
void *inSourceSkillFunctionInfos) {
89+
auto ret = old_GetDefenceRate(instance, inSource, inSkillProcessContext,
90+
inSourceSkillFunctionInfos);
91+
auto camp = Camp[inSource]();
92+
if (camp == 2) {
93+
ret = ret * defence;
94+
}
95+
return ret;
96+
}
97+
98+
99+
// Example Game: [Ark Re:Code](https://www.nutaku.net/games/ark-recode/)
100+
void OnLoaded() {
101+
LOGI("OnLoaded");
102+
auto AssemblyCSharp = BNM::Image("Assembly-CSharp");
103+
auto BattleRoleData = BNM::Class("Game", "BattleRoleData", AssemblyCSharp);
104+
Camp = BattleRoleData.GetField("Camp");
105+
auto BattleCalculator = BNM::Class("Game", "BattleCalculator", AssemblyCSharp);
106+
auto GetSkillConditionAttack = BattleCalculator.GetMethod("GetSkillConditionAttack");
107+
auto GetDefenceRate = BattleCalculator.GetMethod("GetDefenceRate");
108+
BNM::BasicHook(GetSkillConditionAttack, new_GetSkillConditionAttack,
109+
old_GetSkillConditionAttack);
110+
BNM::BasicHook(GetDefenceRate, new_GetDefenceRate, old_GetDefenceRate);
111+
}

app/src/main/cpp/horny-villa.cpp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#include <jni.h>
2+
#include <string>
3+
#include <thread>
4+
5+
#include "logger.h"
6+
#include <BNM/Image.hpp>
7+
#include <BNM/Class.hpp>
8+
#include <BNM/Field.hpp>
9+
#include <BNM/Method.hpp>
10+
#include <BNM/Loading.hpp>
11+
#include "utils.h"
12+
13+
14+
void OnLoaded();
15+
16+
extern "C" JNIEXPORT jint JNICALL
17+
JNI_OnLoad(JavaVM *vm, void *reserved) {
18+
JNIEnv *env;
19+
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
20+
BNM::Loading::AddOnLoadedEvent(OnLoaded);
21+
BNM::Loading::TryLoadByJNI(env);
22+
return JNI_VERSION_1_6;
23+
}
24+
25+
// FeatureTypes: Toggle, Seekbar, Category
26+
// Examples:
27+
// Toggle:ToggleName:true
28+
// Seekbar:SeekbarName:1_20_10
29+
// Category:CategoryName
30+
extern "C" JNIEXPORT jobjectArray JNICALL
31+
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
32+
std::string featList[] = {
33+
"Toggle:Currencies",
34+
"Seekbar:Reward:1_10",
35+
};
36+
return toJobjectArray(env, featList, std::size(featList));
37+
}
38+
39+
bool currencies = false;
40+
int reward = 1;
41+
extern "C" JNIEXPORT void JNICALL
42+
Java_com_android_support_Menu_valueChange(
43+
JNIEnv *env,
44+
jobject thiz,
45+
jint featIdx,
46+
jstring featName,
47+
jobject value
48+
) {
49+
// featIdx: index in feature list
50+
switch (featIdx) {
51+
case 0: {
52+
currencies = toJboolean(env, value);
53+
break;
54+
}
55+
case 1: {
56+
reward = toJint(env, value);
57+
break;
58+
}
59+
default:
60+
break;
61+
}
62+
}
63+
64+
65+
bool (*old_CurrenciesTryAdd)(void *instance, int type, int amount, void *param);
66+
67+
bool CurrenciesTryAdd(void *instance, int type, int amount, void *param) {
68+
return old_CurrenciesTryAdd(instance, type, amount * reward, param);
69+
}
70+
71+
bool (*old_CurrenciesSpend)(void *instance, int type, int value, void *param);
72+
73+
bool CurrenciesSpend(void *instance, int type, int value, void *param) {
74+
if (instance != nullptr) {
75+
if (currencies) {
76+
CurrenciesTryAdd(instance, type, value, param);
77+
return true;
78+
}
79+
}
80+
return old_CurrenciesSpend(instance, type, value, param);
81+
}
82+
83+
84+
// Example Game: [Horny Villa](https://www.nutaku.net/games/horny-villa/)
85+
void OnLoaded() {
86+
LOGI("OnLoaded");
87+
auto AssemblyCSharp = BNM::Image("Assembly-CSharp");
88+
auto Currencies = BNM::Class("StripClub.Model", "Currencies", AssemblyCSharp);
89+
auto Spend = Currencies.GetMethod("Spend", 3);
90+
auto TryAdd = Currencies.GetMethod("TryAdd", 3);
91+
BNM::BasicHook(Spend, CurrenciesSpend, old_CurrenciesSpend);
92+
BNM::BasicHook(TryAdd, CurrenciesTryAdd, old_CurrenciesTryAdd);
93+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
#include <jni.h>
99
#include <string>
10-
#include <vector>
1110

1211
jboolean toJboolean(JNIEnv *env, jobject obj);
12+
1313
jint toJint(JNIEnv *env, jobject obj);
14+
1415
jobjectArray toJobjectArray(JNIEnv *env, std::string arr[], int size);
1516

1617
#endif //ANDROID_MOD_MENU_BNM_UTILS_H

app/src/main/cpp/mafia-queens.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include <jni.h>
2+
#include <string>
3+
#include <thread>
4+
5+
#include "logger.h"
6+
#include <BNM/Image.hpp>
7+
#include <BNM/Class.hpp>
8+
#include <BNM/Field.hpp>
9+
#include <BNM/Method.hpp>
10+
#include <BNM/Loading.hpp>
11+
#include "utils.h"
12+
13+
14+
void OnLoaded();
15+
16+
extern "C" JNIEXPORT jint JNICALL
17+
JNI_OnLoad(JavaVM *vm, void *reserved) {
18+
JNIEnv *env;
19+
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
20+
BNM::Loading::AddOnLoadedEvent(OnLoaded);
21+
BNM::Loading::TryLoadByJNI(env);
22+
return JNI_VERSION_1_6;
23+
}
24+
25+
// FeatureTypes: Toggle, Seekbar, Category
26+
// Examples:
27+
// Toggle:ToggleName:true
28+
// Seekbar:SeekbarName:1_20_10
29+
// Category:CategoryName
30+
extern "C" JNIEXPORT jobjectArray JNICALL
31+
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
32+
std::string featList[] = {
33+
"Toggle:Infinite Moves",
34+
};
35+
return toJobjectArray(env, featList, std::size(featList));
36+
}
37+
38+
bool moves = false;
39+
extern "C" JNIEXPORT void JNICALL
40+
Java_com_android_support_Menu_valueChange(
41+
JNIEnv *env,
42+
jobject thiz,
43+
jint featIdx,
44+
jstring featName,
45+
jobject value
46+
) {
47+
// featIdx: index in feature list
48+
switch (featIdx) {
49+
case 0: {
50+
moves = toJboolean(env, value);
51+
break;
52+
}
53+
default:
54+
break;
55+
}
56+
}
57+
58+
BNM::Method<void> AddMoves{};
59+
60+
float (*old_PlayerMove)();
61+
62+
float new_PlayerMove() {
63+
if (moves) {
64+
AddMoves(1);
65+
}
66+
return old_PlayerMove();
67+
}
68+
69+
70+
// Example Game: [Mafia Queens](https://www.nutaku.net/games/mafia-queens/)
71+
void OnLoaded() {
72+
LOGI("OnLoaded");
73+
auto AssemblyCSharp = BNM::Image("Assembly-CSharp");
74+
auto GameBoardGame = BNM::Class("BlmbM23SDK", "GameBoardGame", AssemblyCSharp);
75+
auto PlayerMove = GameBoardGame.GetMethod("PlayerMove");
76+
AddMoves = GameBoardGame.GetMethod("AddMoves");
77+
BNM::BasicHook(PlayerMove, new_PlayerMove, old_PlayerMove);
78+
}

app/src/main/java/com/android/support/Menu.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import androidx.core.graphics.toColorInt
3232
import androidx.core.view.setPadding
3333

3434
// setup
35-
const val TITLE = "Modded by (YourName)"
35+
const val TITLE = "Modded by Typh00n"
3636
const val SUB_TITLE = "whatever here"
3737

3838
@Suppress("SpellCheckingInspection")

0 commit comments

Comments
 (0)