标题可能听起来令人困惑,但请允许我解释..我正在尝试使用C ++为游戏创建一个小dll hack。为了从类中调用非静态函数,您需要将类构造函数作为方法ID。我遇到的问题是我要调用方法的类的构造函数的参数是游戏中的其他字段......
这是一个例子,假设这是一个名为Minecraft的类......
public Minecraft(GameSetting setting, EntityPlayer player, Example example)
{
.....
}
我如何为类似的东西创建方法ID?有没有比创建更多jclasses(GameSetting等)更有效的方法,然后尝试为那些创建jobjects,但之后还必须为其构造函数找到参数?如果是这样的话,整个计划需要几个月的时间,为所有事情创造工作......
无论如何,这是我的实际dll,也许有一种方法可以将构造函数放在一起?我对java本机接口或C ++没有足够的经验来提出一个很好的解决方案......
Dll(我只是试着以clickMouse函数为例):
jclass Minecraft = env->FindClass("net.minecraft.client.Minecraft");
jmethodID constructor = env->GetStaticMethodID(Minecraft, "<init>", "()Minecraft");//In the () there are supposed to be a few variables from Minecraft.
jobject mcObj = env->NewObject(Minecraft, constructor); //Creates the object
jmethodID clickMouse = env->GetMethodID(Minecraft, "clickMouse", "()V"); //Creates the callable method
while (!GetAsyncKeyState(VK_END))
{
env->CallVoidMethod(mcObj, clickMouse); //End result what I want to do is call the method, but since it isn't static I need an object, which means I need to get the class constructor :/
}