Jump to content
  • 1

PyObject crashing the game


ledi12

Question

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 post

7 answers to this question

Recommended Posts

  • 0
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 post
  • 0
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 post
  • 0

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 post
  • 0
  • 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™ (see edit history)
  • Love 2
  • Angry 1
Link to post
Guest
This topic is now closed to further replies.


×
×
  • 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.