Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2
You last visited: Today at 22:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[help] Understading Mt2 function calls

Discussion on [help] Understading Mt2 function calls within the Metin2 forum part of the Popular Games category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2023
Posts: 2
Received Thanks: 0
[help] Understading Mt2 function calls

Hello pvpers,


I've been investigating this for a while now and I feel that I've come to a brick wall therefore I'd like to request your help.

I've done a cpp DLL that calls a python script as soon as it is injected into the metin2 client.

I've successfully printed some messages in the chat with using the chat import.

But I've not been successful with any other function.

This is a basic example that print in the chat a message but blows up afterwards:

Code:
chat = __import__("XXsRHxy")
chr = __import__("chr")

chat.AppendChat(7, "test")

for i in xrange(100000):
    if(chr.HasInstance(i) != 0):
        if(chr.GetInstanceType(i) == 6):
            chr.SelectInstance(i);
            chat.AppendChat(7, str(i));
I get a "test" written to the chat, but then it blows up, before anyone asks, there are no printed logs I've tried to catch the error on the cpp side and check for

Code:
    
if (PyErr_Occurred())
        PyErr_Print();
but I have nothing printed out in the logs, if there is a python error usually it prints out something.

I wanted to do a simple scan for other players and in the future interact with them. Any suggestion is appreciated

I think it's not relevant but here is the cpp code:

Code:
#include "pch.h"
#include <Python.h>
#include <thread>
#include <iostream>
#include <vector>


bool executePythonFile(const char* file) {
    int result = 0;
    char path[256] = { 0 };
    strcat_s(path, file);
    printf("Executing Python file: %s\n", path);

    PyObject* PyFileObject = PyFile_FromString(path, (char*)"r");
    if (PyFileObject == NULL) {
        printf("%s  is not a File!\n", path);
        goto error_code;
    }
    result = PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), "MyFile", 1);
    if (result == -1) {
        printf("Error executing python script!\n");
        goto error_code;
    }
    else {
        printf("Python script execution complete!\n");
        Py_DECREF(PyFileObject);
        return true;
    }

    if (PyErr_Occurred())
        PyErr_Print();

error_code:
    PyErr_Print();
    Py_DECREF(PyFileObject);
    return 0;
}


void init() {

    AllocConsole();
    freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
    std::cout << "### START ###" << std::endl;
    
    executePythonFile("C:\\code\\testing.py");
 
    FreeConsole();
}

BOOL APIENTRY DllMain(HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved
)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH: {
        // sdk::utilities::h_module = (HMODULE)hDllHandle;
        init();
        FreeLibraryAndExitThread(hModule, 0);
    }break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
Nawky is offline  
Old 02/18/2024, 23:42   #2
 
MrCrisp's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 747
Received Thanks: 184
Hey Nawky,

it could be a failing function call from the chr module. I don't remember the function signature of those functions, but I would check them individually.

Maybe a tip: Get a pointer to the VID map in memory instead of running over a million VIDs and check each individually.
MrCrisp is offline  
Old 02/21/2024, 23:17   #3
 
dave_m's Avatar
 
elite*gold: 0
Join Date: May 2023
Posts: 65
Received Thanks: 11
What @ says and in addition, you can call python functions directly using c++ with certain python commands like "PyObject_CallObject"
dave_m is offline  
Old 03/01/2024, 11:46   #4
 
elite*gold: 0
Join Date: Feb 2024
Posts: 8
Received Thanks: 0
try dave's, it can work
Godalike is offline  
Reply

Tags
function call metin2, metin2, python


Similar Threads Similar Threads
std::function of a function returning an std::function
11/11/2013 - C/C++ - 19 Replies
Nun muss ich nach langer Zeit auch mal wieder einen Thread erstellen, weil mir Google nicht mehr weiterhelfen kann. Ich verzweifle an Folgendem Vorhaben: #include <Windows.h> #include <string> #include <iostream> using namespace std;
Running Function 2 after Function 1 finished
09/15/2013 - AutoIt - 3 Replies
Hey, its me again. Im stuck on a problem since yesterday and as much as i hate to ask for help, i really dont know what else to try. I want Function 2 to run after Function 1 has finished. I tried GuiCtrlSetOnEvent and MsgLoop, but i dont really understand it. I tried to read tutorials but they didnt help at all. The line that are underline is what im talking about. I want gamestart() to run first and when its finished, i want iniviteteam() to run. #AutoIt3Wrapper_UseX64=n...
detect in game function calls
07/25/2011 - General Coding - 3 Replies
Hello i need to know what is de best way to detect when a funciton gets called inside the game client is there a better way than using detour, hope for answers thanks
[VIP-function] ToxicSYS [VIP-function]
08/14/2010 - WarRock Hacks, Bots, Cheats & Exploits - 1 Replies
heeeey E-pvpers :pimp: this is a new hack by TSYS Status : UNDETECTED Functions (VIDEO) : YouTube - WarRock - Bikini event VIP hack
Search a VoIP Programm which records calls
03/04/2006 - Technical Support - 3 Replies
Hi, i have a big problem, my mobile phone provider did shit with my account and the payment. So i want to call the Support Line. A friend sad to me I should record the call. I use VoIP and so i searched a programm which record my stream. But i just found Sipps and it doesn't record my call. It create a data but in it is nothing (0kb)^^ So i started again to google... But i doesn't found any other programm, only a Buissnes Solution, where they use Hardware and it's cost very much ;) ...



All times are GMT +1. The time now is 22:10.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.