Jump to content

PyObject crashing the game


Recommended Posts

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

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

  • Developer

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

  • Forum Moderator
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 by VegaS™
  • Angry 1
  • Love 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.