Log in

View Full Version : Hook a console DLL


settoken
December 8th, 2010, 12:07
Hi there,

I have a game and a dev console DLL. Using dependancy walker gave me the list of all the functions of the console DLL and which ones are exported to the game.
So the console is used by the game but there's no way to show it using commands or special keys.

What I want is to create a wrapper between both so I can launch the console using "~" or (if there's no interface integrated) just redirect I/O to my own.

I suspect the console used by the dev to be Lua5.1 command prompt as there's also a lua DLL in the main folder and I know for sure that the UI and debugging functions are coded in Lua 5.1.

If someone could help me with it, it would be great as I really don't know where to begin.

THX

Woodmann
December 8th, 2010, 21:34
Howdy,

I have a question or two before we proceed.

Is this an online game?
If not, is it a windows based PC game?

There is a ton of documentation regarding lua.
A lot depends on which platform you are using.

Woodmann

settoken
December 8th, 2010, 21:54
thx

it is locally installed in a steam folder on my PC. It's a windows based game.

I've searched a lot on the subject before asking for help. I've tried to launch the game via lua with the io.popen function without success, I've tried several cmd lines at startup, debugged an unpacked version to collect some information etc... so I have some clues on how it works.
Now I'm to the point where I need some help. I think that having the game into several separate dlls can help to identify the flow and eventually hook the functions related to the console. I easily get a list of each using dependancy walker but I don't know how to use that information now.

Woodmann
December 9th, 2010, 21:34
I have no idea.

If the game is pc based and comes with a console.dll,
I dont understand why you cant fire it up.

I suppose you can try getconsolewindow() but that is
platform dependent, so I dont think it works in win7.

Lua is open source so ask them.

Woodmann

Hang on, A steam folder is linux/wine based.
Is this true for your app?

Upon further review, Lua is not the problem.
Steam is the problem.
Their support shows ~ as the correct command to bring up the console.
If this is not working then perhaps you have a platform problem.
Maybe you have a game that runs in win7 but was meant to
run in XP or some other platform with full support?

I'm just guessing here as I read what I can find.

BanMe
December 9th, 2010, 21:53
Have you tried using GetCommandLine() to see what is passed in? and used that to launch a process with CreateProcess?

How does a 'console' dll differ from any other dll, other then it exports a console for input? IE dump the exports of interesting dlls or fire up olly and look threw them,
and hook away.

Now if you're saying that the console is a separate process that is launched and services the 'game' as some sorta interpreter then im lost.. :]

regards BanMe

settoken
December 10th, 2010, 16:22
@Woodman The game is distributed by Steam but it's not Source engine based. The version of the game that has the console DLL is a demo. I suppose the devs just released a limited house build as a demo because the full release doesn't have these libs as separated DLLs but compiled in the exe instead. It makes sense as during developpment it is more efficient to have finished parts of the game precompiled so they would just have to compile the small parts of the code they are working on.

My opinion is that the console is purposely not activated. It's not a malfunction or compatibility issue that prevent the end user from using it. There are lots of debugging functions that you can activate with it and as the game is build using Lua (execept for the engine), it would allow modders to make major overhauls.

From what I've read on the subject, lua is embedded in C++. So there is the engine, a set of functions for communication with lua, lua's main implementation, parallel lua states each managing parts of the game (UI, AI, Diplomacy etc) and external compiled lua scripts. The interface should be between the external scripts and the managers IMHO.
I've tried to launch the game via the lua interpreter with io.popen wich I supposed could hook the Virtual Machine ingame and give me an output of what is processed.
If you launch the game in IDA pro, you get messages from the debuggee about what is processed.

@BanMe thx for your input unfortunatly I don't know how to do this or I would try. I'm a noob. Never hooked anything you know.