Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - luamage

Pages: [1]
1
UO Client Modifications/Tools / Enhanced Client Lua hooking
« on: February 10, 2015, 05:22:45 AM »
Hello everybody,

I didnt find a better place to post this, so I hope suo forums will be the most appropriate place to have this at the moment.

As most of you might know, the Enhanced Client (EC) comes basically in two parts: a binary core client and a lua UI system (which is basically 95% open to modding). Pinco'sUI pretty much shows how much automating things is possible with plain legal mods (move items between containers, harvest plant gumps, etc.). So it's actually only a couple of minor issues left to providing a fully scriptable client right from within the native lua environment. What I personally like the most: you got to write scripts in the same environment as you do the UI elements, so it feels as natural as the EC gets writing custom UIs for each script. The lua environment also provides basic information as position, helath, mana, armor, mobs, etc.

Some things noted on the EC:
- The core client seems to be written in C++ (oh suprise)
- The UOSA.exe incorporates a full Lua 5.2 library (C source +binaries available on lua.org)
- They don't use native lua (as mentioned above), but use LuaPlus C++ wrapper (source + binary on http://luaplus.org/)

From there on it's a pretty easy target to identify the core lua functions in the UOSA.exe (though it is a hugh beast to me). Actually it's not as easy to comparing luaplus.lib with uosa.exe, as they compiled it on their own with heavy optimizations (register parameter passing, inline functions, etc). So it's not as easy as builing luaplus.lib flair signatures (for IDA Pro) and applying them onto uosa.exe :/ But it's still easy by referencing strings in the the source and the assembly. I found it interesting to look for lua_openlib() and lua_newstate().

Maybe a bit on lua now: Lua is a pretty lightweight scripting language. On of the things that make it easy to hook is the fact it encapsulates all data it operates on into a lua_State data structure and basically only passes refenreces to this global lua_State along it's APIs.

Inside this lua_State it's guaranteed to met binary compability among different lua builds of the same major version. So despite not knowing all the lua functions inside uosa.exe which would be needed to modifiy the lua_State properly, one might just link their own lua library (build from open source codes mentioned above) to a dll inserted, and work on the full spectrum of the lua API.

One example would be to load external lua libraries, which maybe this site gives a good overview what can be built with them: https://code.google.com/p/luaforwindows/
This LuaCOM thing looks also interesting (as I once saw some CC tool implenting a COM interface from within uo.exe to interact with it in whatever binding was preferred :D). However this is something I'm working on. I linked my own lua.lib and succesfully registred libraries. But it seems there is one more bit I'm missing as the functions are registred in lua (can verify) but don't trigger their callbacks. Anyway, not wanna to get lost in the details here!

But what about finding the lua_State? Well, I didn't found a better way yet as to spawn UOSA.exe as debugee of my tool. So i can set breakpoints on some internal lua APIs and record the lua_State memory address. It kinds of uses the same notation as IDA flair to identify a couple of core functions like lua_newstate() (see official Lua docs for more).

So atm i registered functions for things that can't be triggered through Lua: I added a function to emulate a ctrl-shift (which results in getting all object ids on screen in lua), and a couple of functions to emulate character moving (just by emulating keypress through win API atm). It is enough to run the trade quests automatically or run a automated IDOC scanner, reproting IDOCs just as you play and move along in game.

I'm pretty unfamiliar with C++ and windows so I'm learning all along the way :D I felt it was about to maybe share my findings in case someone else find it interesting or useful. Please don't hesitate to point me on anything i might be missing out big.

Other things I'm appreciating any input on:
 - UOSA uses Gamebryo (*eek*). I have a hard time getting into that, with identifiying vtables and stuff. No success at all tbh.
 - There seem to be relicts from some EASTL (EA Standard Template Libary). Couldn't find anything public available though.

I also found that UOSpy tool for loggin packet streams and tried it within my tool. Fun stuff but i really have no interest in tampering with the servers :D I'm also more into attended scripting, as in the end I don't intend to make a living out of UO or stuff ;P

Please let me know if you any interesting infos to add or want to know more! It's a shame no good scripting is available for EC  :P

2
.NET Programming / Re: Beginner's guide to memory reading/writing
« on: February 09, 2015, 02:37:28 AM »
Indeed, using C# to invoke low level win32 APIs has it benefits. If you want to save yourself the pain of assembling all this method stubs and data structures, you should have a look at http://www.pinvoke.net/ as well :)

3
New member introductions / New on the block
« on: January 20, 2015, 02:57:37 AM »
Hello everybody,

I just registered to the board and would like to throw out a quick introduction. I'm playing UO (OSI) for not that long but for a solid 2.5 yrs now and still enjoying it.

When I'm bored with gameplay I usually hack on the EC. I'm not sure if people here are into EC as well, as the flagship tools seem to targeted CC exclusively. However I was never much into using complex scripting but more into the tricks of the trade. So it was never a big problem for me to not use any stuff. Actually I am not looking for the script ressources here but rather for technical discussions :D

Getting my brain melt down on UOSA in IDA has more or less become a pet peeve of mine by now. Most of my time so far I spent on hooking the lua core, which I can now register new functions to (e.g. MouseClick(x,y), CtrlShift()) and also load some lua default libraries Mythic choose to not include (file, os libraries). It only needs some more effort but basically it's game over for the lua engine as there is bare access to the lua_State.

I was looking to get into other areas of the client now, to hook more useful functionality to the lua core, like getting all itemIds on screen, hiding looted corpses, etc. Just at the beginning here though.

I really hope you guys don't just tell me go to hell with your EC crap :D

Cheers,
luamage

P.S. Im really impressed with the work on Stealth. Keep it up guys, really neat stuff!

Pages: [1]