Skip to content

Commit 84abff8

Browse files
committed
amlmod.h
1 parent 594e1c7 commit 84abff8

2 files changed

Lines changed: 28 additions & 36 deletions

File tree

mod/amlmod.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include <stdlib.h>
88
#include <signal.h>
99

10-
#ifdef __arm__
10+
#if defined(__arm__) || defined(_WIN32)
1111
#define AML32
1212
#define BYBIT(__32val, __64val) (__32val)
13-
#elif defined __aarch64__
13+
#elif defined(__aarch64__) || defined(_WIN64)
1414
#define AML64
1515
#define BYBIT(__32val, __64val) (__64val)
1616
#else
@@ -24,16 +24,15 @@
2424

2525
#ifdef __GNUC__
2626
#define ASM_NAKED __attribute__((naked))
27-
#define EXPORT __attribute__((visibility("default")))
2827
#else
2928
#define ASM_NAKED __declspec(naked)
30-
#define EXPORT
3129
#endif
30+
#define EXPORT JNIEXPORT
3231

3332
#define MYMOD(_guid, _name, _version, _author) \
3433
static ModInfo modinfoLocal(#_guid, #_name, #_version, #_author); \
3534
ModInfo* modinfo = &modinfoLocal; \
36-
extern "C" ModInfo* __GetModInfo() { return modinfo; } \
35+
extern "C" JNIEXPORT ModInfo* __GetModInfo() { return modinfo; } \
3736
IAML* aml = (IAML*)GetInterface("AMLInterface");
3837

3938
#define MYMODCFG(_guid, _name, _version, _author) \
@@ -47,10 +46,7 @@
4746
Config* cfg = &cfgLocal;
4847

4948
#define NEEDGAME(_pkg_name) \
50-
extern "C" const char* __INeedASpecificGame() {return #_pkg_name;}
51-
52-
#define MYMODDECL() \
53-
extern ModInfo* modinfo; // Just in case if you need to use that somewhere else in your mod
49+
extern "C" JNIEXPORT const char* __INeedASpecificGame() { return #_pkg_name; }
5450

5551
/* Dependencies! */
5652
#define BEGIN_DEPLIST() \
@@ -64,29 +60,29 @@
6460

6561
#define END_DEPLIST() \
6662
{"", ""} }; \
67-
extern "C" ModInfoDependency* __GetDepsList() { return &g_listDependencies[0]; }
63+
extern "C" JNIEXPORT ModInfoDependency* __GetDepsList() { return &g_listDependencies[0]; }
6864

6965
/* Macros to stop forgetting stuff! */
7066
#define ON_MOD_PRELOAD() \
71-
extern "C" void OnModPreLoad()
67+
extern "C" JNIEXPORT void OnModPreLoad()
7268

7369
#define ON_MOD_LOAD() \
74-
extern "C" void OnModLoad()
70+
extern "C" JNIEXPORT void OnModLoad()
7571

7672
#define ON_ALL_MODS_LOAD() \
77-
extern "C" void OnAllModsLoaded()
73+
extern "C" JNIEXPORT void OnAllModsLoaded()
7874

7975
#define ON_MOD_UNLOAD() \
80-
extern "C" void OnModUnload() /*Not guaranteed*/
76+
extern "C" JNIEXPORT void OnModUnload() /*Not guaranteed*/
8177

8278
#define ON_GAME_CRASH() \
83-
extern "C" void OnGameCrash(const char* library, int sig, int code, uintptr_t libaddr, mcontext_t* mcontext) /*Not guaranteed*/
79+
extern "C" JNIEXPORT void OnGameCrash(const char* library, int sig, int code, uintptr_t libaddr, mcontext_t* mcontext) /*Not guaranteed*/
8480

8581
#define UPDATER_URL() \
86-
extern "C" const char* OnUpdaterURLRequested()
82+
extern "C" JNIEXPORT const char* OnUpdaterURLRequested()
8783

8884
#define ON_NEW_INTERFACE() \
89-
extern "C" void OnInterfaceAdded(const char* name, const void* ptr)
85+
extern "C" JNIEXPORT void OnInterfaceAdded(const char* name, const void* ptr)
9086

9187

9288

@@ -203,7 +199,7 @@ class ModInfo
203199
};
204200

205201
typedef ModInfo* (*GetModInfoFn)();
206-
202+
extern ModInfo* modinfo;
207203

208204

209205
#include "iaml.h"

template_of_mod/mod/amlmod.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include <stdlib.h>
88
#include <signal.h>
99

10-
#ifdef __arm__
10+
#if defined(__arm__) || defined(_WIN32)
1111
#define AML32
1212
#define BYBIT(__32val, __64val) (__32val)
13-
#elif defined __aarch64__
13+
#elif defined(__aarch64__) || defined(_WIN64)
1414
#define AML64
1515
#define BYBIT(__32val, __64val) (__64val)
1616
#else
@@ -24,16 +24,15 @@
2424

2525
#ifdef __GNUC__
2626
#define ASM_NAKED __attribute__((naked))
27-
#define EXPORT __attribute__((visibility("default")))
2827
#else
2928
#define ASM_NAKED __declspec(naked)
30-
#define EXPORT
3129
#endif
30+
#define EXPORT JNIEXPORT
3231

3332
#define MYMOD(_guid, _name, _version, _author) \
3433
static ModInfo modinfoLocal(#_guid, #_name, #_version, #_author); \
3534
ModInfo* modinfo = &modinfoLocal; \
36-
extern "C" ModInfo* __GetModInfo() { return modinfo; } \
35+
extern "C" JNIEXPORT ModInfo* __GetModInfo() { return modinfo; } \
3736
IAML* aml = (IAML*)GetInterface("AMLInterface");
3837

3938
#define MYMODCFG(_guid, _name, _version, _author) \
@@ -47,10 +46,7 @@
4746
Config* cfg = &cfgLocal;
4847

4948
#define NEEDGAME(_pkg_name) \
50-
extern "C" const char* __INeedASpecificGame() {return #_pkg_name;}
51-
52-
#define MYMODDECL() \
53-
extern ModInfo* modinfo; // Just in case if you need to use that somewhere else in your mod
49+
extern "C" JNIEXPORT const char* __INeedASpecificGame() { return #_pkg_name; }
5450

5551
/* Dependencies! */
5652
#define BEGIN_DEPLIST() \
@@ -64,29 +60,29 @@
6460

6561
#define END_DEPLIST() \
6662
{"", ""} }; \
67-
extern "C" ModInfoDependency* __GetDepsList() { return &g_listDependencies[0]; }
63+
extern "C" JNIEXPORT ModInfoDependency* __GetDepsList() { return &g_listDependencies[0]; }
6864

6965
/* Macros to stop forgetting stuff! */
7066
#define ON_MOD_PRELOAD() \
71-
extern "C" void OnModPreLoad()
67+
extern "C" JNIEXPORT void OnModPreLoad()
7268

7369
#define ON_MOD_LOAD() \
74-
extern "C" void OnModLoad()
70+
extern "C" JNIEXPORT void OnModLoad()
7571

7672
#define ON_ALL_MODS_LOAD() \
77-
extern "C" void OnAllModsLoaded()
73+
extern "C" JNIEXPORT void OnAllModsLoaded()
7874

7975
#define ON_MOD_UNLOAD() \
80-
extern "C" void OnModUnload() /*Not guaranteed*/
76+
extern "C" JNIEXPORT void OnModUnload() /*Not guaranteed*/
8177

8278
#define ON_GAME_CRASH() \
83-
extern "C" void OnGameCrash(const char* library, int sig, int code, uintptr_t libaddr, mcontext_t* mcontext) /*Not guaranteed*/
79+
extern "C" JNIEXPORT void OnGameCrash(const char* library, int sig, int code, uintptr_t libaddr, mcontext_t* mcontext) /*Not guaranteed*/
8480

8581
#define UPDATER_URL() \
86-
extern "C" const char* OnUpdaterURLRequested()
82+
extern "C" JNIEXPORT const char* OnUpdaterURLRequested()
8783

8884
#define ON_NEW_INTERFACE() \
89-
extern "C" void OnInterfaceAdded(const char* name, const void* ptr)
85+
extern "C" JNIEXPORT void OnInterfaceAdded(const char* name, const void* ptr)
9086

9187

9288

@@ -203,7 +199,7 @@ class ModInfo
203199
};
204200

205201
typedef ModInfo* (*GetModInfoFn)();
206-
202+
extern ModInfo* modinfo;
207203

208204

209205
#include "iaml.h"

0 commit comments

Comments
 (0)