ledi12 2 Posted July 13, 2020 Share Posted July 13, 2020 Version of Files : XXX Hey yo, I'm injecting python modules via c++ api and after executing it my games crashes (client shuts down). My VS uses python 2.7 libs int GetInstanceType(long vid) { PyObject* args = PyTuple_New(1); PyTuple_SetItem(args, 0, PyInt_FromLong(vid)); PyObject* ret = PyObject_Call(PyObject_GetAttrString(PyImport_ImportModule("chr"), "GetInstanceType"), args, NULL); int result = PyInt_AsLong(ret); Py_DECREF(ret); Py_XDECREF(args); return result; } Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4880 Posted July 14, 2020 Bot Share Posted July 14, 2020 Attach logs. Link to comment Share on other sites More sharing options...
ledi12 2 Posted July 14, 2020 Author Share Posted July 14, 2020 3 minutes ago, Chyuae said: Attach logs. This is my current code which works if the loop isn;t that long (max 10k) std::vector<int> mobList() { std::vector<int> list; PyObject* mod = PyObject_GetAttrString(PyImport_AddModule("player"), "GetCharacterDistance"); PyObject* mod2 = PyObject_GetAttrString(PyImport_AddModule("chr"), "GetInstanceType"); PyObject* args = PyTuple_New(1); std::vector<int> mobs; for (int i = 0; i < 100000; i++) { PyTuple_SetItem(args, 0, PyInt_FromLong(i)); PyObject* mob = PyObject_CallObject(mod, args); if (!mob) { Py_DECREF(mob); Py_XDECREF(args); } else { PyObject* enemy = PyObject_CallObject(mod2, args); if (!enemy) { Py_DECREF(enemy); Py_XDECREF(args); } else { if (PyInt_AsLong(mob) > 0 && PyInt_AsLong(mob) < 1000 && PyInt_AsLong(enemy) == 0) { mobs.push_back(i); } } } } return mobs; } 100k still crashes it I've found out that 0xC0000409 causes it. My client simply closes and I do not receive any logs except CrashDumps. Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4880 Posted July 14, 2020 Bot Share Posted July 14, 2020 (edited) So you should be able to debug it by using crash dump, no? Edited July 14, 2020 by Chyuae Typo Link to comment Share on other sites More sharing options...
ledi12 2 Posted July 14, 2020 Author Share Posted July 14, 2020 49 minutes ago, Chyuae said: So you should be able to debug it by using crash dump, no? Exception thrown at 0x1E0AF9E0 (python27.dll) in Soria2.pl.exe: 0xC0000005: Access violation reading location 0x00000045. occurred Link to comment Share on other sites More sharing options...
ledi12 2 Posted July 14, 2020 Author Share Posted July 14, 2020 3 hours ago, Chyuae said: So you should be able to debug it by using crash dump, no? Variable is optimized away and not available this is the main problem Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2426 Posted July 15, 2020 Developer Share Posted July 15, 2020 are you trying to freeze the game? xd what is this check ? 0 to 100k for vid it's a slow way to check the nearest characters. you could make a new method in CPythonCharacterManager to get what you need, rather than use your way. you could iterate all the character instances rather than iterate a number from 0 to 100.000 using the GetInstancePtr 100.000 times (which is a find into a map, which is slower than iterating the directly the map) My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10273 Posted July 15, 2020 Forum Moderator Share Posted July 15, 2020 (edited) 6 minutes ago, Ikarus_ said: are you trying to freeze the game? xd He's trying to call some API functions for making a DLL injectable to metin2 client = cheat/hack. @ledi12 We don't support this here, topic closed. Edited July 15, 2020 by VegaS™ 1 2 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now