PyLoader (Python 2.7)

05/22/2016 17:50 maximus780#1
Simple python loader for metin2 client(or any game) that uses Python 2.7 so that you can load your scripts and import modules offered by the game that means you can use functions the game exposed to it's scripting system(bindings).

I couldn't find working loader for 2.7 so here it is.

[Only registered and activated users can see links. Click Here To Register...]

USAGE: Place PyLoader.mix in metin2 client directory, if you want to use it as .dll then just rename it.

There is no support for compiled python(*.pyc) files and no autoload function but I'm giving you the source code so you can add this yourself! :bandit:

SCAN: [Only registered and activated users can see links. Click Here To Register...]
05/22/2016 19:44 noahrmal#2
it works with small scripts but when I try to execute longer scripts the client crashes. Any idea for a solution? the other public pyloader (v2.7) have the same problem.
05/22/2016 20:16 yig123it123#3
I playing on Tr pvp servers there is loyein hackshield please help meeee ::
05/22/2016 20:39 KaMeR1337#4
Quote:
Originally Posted by 123klo View Post
it works with small scripts but when I try to execute longer scripts the client crashes. Any idea for a solution? the other public pyloader (v2.7) have the same problem.
try pyrun_simplefile
05/22/2016 20:59 maximus780#5
Quote:
Originally Posted by 123klo View Post
it works with small scripts but when I try to execute longer scripts the client crashes. Any idea for a solution? the other public pyloader (v2.7) have the same problem.
How many lines has your script that crashes the client?

I haven't experienced this issue yet. This could be either problem with python library or metin2 client.

700-1000 lines load just fine to me.

Quote:
Originally Posted by KaMeR1337 View Post
try pyrun_simplefile
PyRun_SimpleFile is missing in most of clients like it's not exported

dumpbin output:
Quote:
568 237 00115240 PyRun_AnyFile
569 238 00115260 PyRun_AnyFileEx
570 239 001144D0 PyRun_AnyFileExFlags
571 23A 00115280 PyRun_AnyFileFlags
572 23B 00115D00 PyRun_File
573 23C 00115D30 PyRun_FileEx
574 23D 00115B80 PyRun_FileExFlags
575 23E 00115D60 PyRun_FileFlags
576 23F 00116890 PyRun_InteractiveLoop
577 240 001167D0 PyRun_InteractiveLoopFlags
578 241 00116070 PyRun_InteractiveOne
579 242 00115E20 PyRun_InteractiveOneFlags
580 243 00116000 PyRun_SimpleStringFlags
581 244 00115D90 PyRun_String
582 245 00115B10 PyRun_StringFlags
05/22/2016 21:25 noahrmal#6
Quote:
Originally Posted by maximus780 View Post
How many lines has your script that crashes the client?

I haven't experienced this issue yet. This could be either problem with python library or metin2 client.

700-1000 lines load just fine to me.



PyRun_SimpleFile is missing in most of clients like it's not exported

dumpbin output:
I want to load [Only registered and activated users can see links. Click Here To Register...], I have a file which just imports the main script (hackbar). But this one imports about 20 other scripts. All in all there are thousands lines of code which have to be imported.

The Pythonloader from musicinstructor for python version 2.2 works fine:
-> [Only registered and activated users can see links. Click Here To Register...]
05/23/2016 00:09 maximus780#7
I haven't checked your mod yet but I've checked pythonloader you mentioned and it uses PyRun_SimpleFile and PyRunSimpleString. Those functions are high level functions to low level python PyRun_File(more specifically PyRun_FileExFlags, PyParser_ASTFromFile) and PyRun_String(deeper PyRun_StringFlags and very low-level PyParser_ASTFromString) you can find them [Only registered and activated users can see links. Click Here To Register...]

Metin2 client bundles custom version of python27.dll which replaces PyModule_GetDict with PyForModule_GetActualDictionary and some Py_ForProgramAddActualName, this is just for confusion but it's exactly the same.

I've tried replacing PyRun_SimpleStringFlags with PyRun_File but the game closes, maybe memory is protected? I will let you know if I find more clues but I rarely find time for playing with games.

The logic behind loading python scripts from file:
[Only registered and activated users can see links. Click Here To Register...]

Quote:
m = PyImport_AddModule("__main__");
if (m == NULL)
return -1;
d = PyModule_GetDict(m);
.....
v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d,
closeit, flags);
Attached my messy code lol with few different options.

Have fun :bandit:
05/23/2016 08:44 KaMeR1337#8
Quote:
Originally Posted by maximus780 View Post
Metin2 client bundles custom version of python27.dll which replaces PyModule_GetDict with PyForModule_GetActualDictionary and some Py_ForProgramAddActualName, this is just for confusion but it's exactly the same.
thats why my multihack crashes on some pserver i suppose
05/23/2016 15:53 maximus780#9
123klo: please check this version if it crashes to you. I'm trying to mimic here m2 way of loading python scripts.

also check this script and run it with loader and see what happens:

Quote:
filename = 'yourscript.py'

f = open(filename, 'r')
content = f.read()
# or exec(compile(content, filename, 'exec'));
exec(content);
05/23/2016 16:07 MasterGamer1#10
I can't load Klo's multihack on Tsuyoshi2

Even not with the new experimental version

[Only registered and activated users can see links. Click Here To Register...]
05/23/2016 17:11 maximus780#11
Quote:
Originally Posted by MasterGamer1 View Post
I can't load Klo's multihack on Tsuyoshi2

Even not with the new experimental version

[Only registered and activated users can see links. Click Here To Register...]
Please try updated one. It looks like in your client this function is not renamed. I have added a fallback for old one.
05/23/2016 17:40 MasterGamer1#12
how do I type in the filename?

[Only registered and activated users can see links. Click Here To Register...]

I swear to God, you're my hero if you can make Klo123's bot work on that. :D
05/23/2016 19:10 maximus780#13
Fixes crashes on 123klo's mod and probably in other scripts too. I will include the source code as soon as I refactor the code.

EDIT: I've got report, there was some problem where you couldn't insert commands for example on Metin2.SG. That's fixed already. See first post for an update.

Quote:
Originally Posted by MasterGamer1 View Post
how do I type in the filename?

[Only registered and activated users can see links. Click Here To Register...]
You can type in the filename now. Download updated dll.
05/23/2016 23:16 MasterGamer1#14
Still doesn't work on Tsuyoshi2 :(

[Only registered and activated users can see links. Click Here To Register...]

Edit: Maybe Klo123 could help on this as well. Would be AMAZING to see his great hack working again
05/24/2016 12:40 noahrmal#15
Quote:
Originally Posted by MasterGamer1 View Post
Still doesn't work on Tsuyoshi2 :(

[Only registered and activated users can see links. Click Here To Register...]

Edit: Maybe Klo123 could help on this as well. Would be AMAZING to see his great hack working again
try to open the file "syser.txt" of your metin2 client and post the content here. Anyway the latest m2kmod version wont work for 2.7 clients at the moment because they are only compiled for 2.2 client. But on 01.06 I will release an update for 2.7 and some other features.

the latest version of maximus780 works with m2kmod now (wait for the update next week)