is it possible to inject ingame not allowed lua code ?

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
Micke
Posts: 46
Joined: Sun Aug 15, 2010 10:07 am
Location: Germany

is it possible to inject ingame not allowed lua code ?

#1 Post by Micke » Sun Aug 15, 2010 11:42 am

Hi,

i hope i've read it correct - it's not possible/allowed to use the "require" function inside the lua VM in runes of magic.
But i need this, cause i want include a luapackage into my addon which give me access to non-lua-written-libraries.

Most likely i cant inject forbidden code, but who knows ....

thanx in advance
Micke

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: is it possible to inject ingame not allowed lua code ?

#2 Post by Administrator » Sun Aug 15, 2010 7:42 pm

You could hook the luaL_openlibs() and luaL_register() Lua functions. Your openlibs would be something like this:

Code: Select all

static int myLuaFunction(lua_State *lstate)
{
  return 0;
}

LUAL_OPENLIBS hook_luaL_openlibs(lua_State *lstate)
{
  int success = real_luaL_openlibs(lstate); -- Install standard libraries

  static const lua_reg regMap[] = {
    {"myLuaFunction", myLuaFunction},
    {NULL, NULL}
  };

  real_luaL_register(lstate, "myLibraryName", regMap); -- Install custom library

  -- You can now call myLuaFunction() from within the Lua VM

  return success;
}

Micke
Posts: 46
Joined: Sun Aug 15, 2010 10:07 am
Location: Germany

Re: is it possible to inject ingame not allowed lua code ?

#3 Post by Micke » Tue Aug 17, 2010 4:41 pm

puuh, wow, big thnx .... didn't knew that i can catch a foreign VM and use her as if i have initiated her, can't i ?

understand, but if it is so easy, i wonder why so many guys writing their addons in LUA, instead of reduce the lua code to a minimum and handle the logic in a less primitive language.
ok ok ....

thanx a lot admin
( even if i know i will spent some hours with your example, finishing with 2 new questions ;-) )

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: is it possible to inject ingame not allowed lua code ?

#4 Post by Administrator » Tue Aug 17, 2010 9:54 pm

understand, but if it is so easy, i wonder why so many guys writing their addons in LUA, instead of reduce the lua code to a minimum and handle the logic in a less primitive language.
You've got it backwards. Lua is a high-level scripting language while C is a (relatively) low-level programming language. It's almost like comparing apples and oranges.

One (Lua) is quick and simple, while the other (C) is dirty, hackish, and requires a lot of knowledge and experience because it works by exploiting how a portable executable works.

Micke
Posts: 46
Joined: Sun Aug 15, 2010 10:07 am
Location: Germany

Re: is it possible to inject ingame not allowed lua code ?

#5 Post by Micke » Wed Aug 18, 2010 1:11 am

using the attribute primitive i won't affront someone,
i miss the advantages of the object oriented aspect.
anyway ...


do u have pls some keywords to find posts how to catch the Lua VM hosted in ROM ?

I would complete your example with
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
lua_State *lstate = luaL_newstate();

But how do i know what class/type/lib ROM is using for that ?

thnx in advance
Micke

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: is it possible to inject ingame not allowed lua code ?

#6 Post by Administrator » Wed Aug 18, 2010 2:22 am

You don't need to worry about that. You're looking at function hooking.

Include the attached files in your project. Read the readme. You'll use DetourFunc() to hook the two functions I stated earlier (and those are the only ones you need for now).


Here's an example of it:
http://forum.gamedeception.net/threads/ ... bix-detour.

Micke
Posts: 46
Joined: Sun Aug 15, 2010 10:07 am
Location: Germany

Re: is it possible to inject ingame not allowed lua code ?

#7 Post by Micke » Sun Aug 22, 2010 2:58 pm

oha, thnx admin, very helpful, really.

pls excuse when i dont answered immidiately, but its a very new topic for me and i first have to spent some time with your references - that as a small feedback that i've read all.

Micke
Posts: 46
Joined: Sun Aug 15, 2010 10:07 am
Location: Germany

Re: is it possible to inject ingame not allowed lua code ?

#8 Post by Micke » Sun Oct 24, 2010 4:00 pm


Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests