PWI GUI Mapper

09/16/2011 02:16 dumbfck#1
Hi folks,

Here's another tool that might prove useful for people who are just interested in disecting the game... If you just want to download bots and run them, you may as well leave now.

I'm currently working on a system to build custom in-game interfaces using the client's own mechanisms, so it was useful to me to investigate how the whole GUI system hangs together. Sometimes it's quicker to build a tool to investigate things for you than to spend weeks finding offsets, hence this little tool :P

In a nutshell, this tool will search the GUI base
Code:
[[[[baseCall]+0x1C]+0x18]+0x8]
for window objects, retrieving their offsets along with some information about them, plus information about their child objects, e.g., buttons, lists, labels, etc.

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

Run PWI, then launch this tool and it will list on the left all available GUI wndows in the client. Click on one of them and it will give you more information about the window. You can even open and close windows using the checkboxes next to the list of window objects hehe.
Be warned, trying to open some of them will crash the client... I'm not really too fussed about fixing that as it's only very few of them and they're windows that are not of interest to me.

That's about all there is to it - I won't go into details about how it works because it's fairly straightforward and you can just inspect the code if you're interested.
It's built with C# so you'll need Visual C# or Visual Studio to use it (Download [Only registered and activated users can see links. Click Here To Register...] or visual Studio 2010 Express - They're free and they kick AutoShit's arse ;))

I intend to build on it so that you can actually activate any control on any window via the tool's interface... Just not today lol.

Chances are the project might piss off your antivirus - I have crappy Avira on my Win7 box I tested this on and it kept telling me I had an infection even though I made the bloody thing - Hence I'm uploading the full source and not some dodgy .exe so you can inspect it. I was a little surprised as it only uses some process memory writes and doesn't even inject anything. I'm really not interested in stealing your precious facecock passwords and stuff, so if you don't trust it, don't download it. -(modified Swoosh quote... Thanks :P)

Oh... In another thread I kind of mentioned that it could open the console window. Well that was an inadvertant lie because I had accessed this during the building of this thing, but it's a slightly different approach to do that. As I'm generally a nice chap, I'll explain how to do that anyway lol.

If you want to play with the console stuff, you'll need [Only registered and activated users can see links. Click Here To Register...]
A utility to "send to command prompt" is quite useful too - I use [Only registered and activated users can see links. Click Here To Register...] for this (Crappy Avira even alerted this as an infection - It's safe)
So, download sPCK to a folder somewhere, then copy interfaces.pck from your perfect world element folder into the sPCK folder.

***IMPORTANT*** Make a backup of interfaces.pck in case you screw something up.

Right click sPCK.exe -> Send to command prompt.
Now, to extract the .pck file...
Code:
sPCK.exe -x interfaces.pck
This will generate a folder called interfaces.pck.files
Open interface.pck.files\interfaces\ingame-v1.dcf and find the line:
Code:
Version01\console.xml        0        0        0
and change it to
Code:
Version01\console.xml        0        0        1
Save the file and close it, then delete your interfaces.pck file (the one in your sPCK folder!!!) and run sPCK again
Code:
sPCK.exe -c interfaces.pck.files
This will repack the files into a .pck
Once that's completed, copy the interfaces.pck file back to your element folder and launch the client. Woohoo! You now have a console that you can play around with.

It will stay open and you can't unfocus it, so if you want to remove it, you need to reinstate your original interfaces.pck file. If I can be arsed, I might find the GUI offset to close it lol.... But I can't be arsed today.

The commands for the console are available in the configs.pck file (extract with sPCK again, look for console_cmd.txt) but for your pleasure, here is the list of commands: (don't include the quotes)
Code:
"d_cameramode"
"d_boundbox"
"d_rtdebug"
"d_npcid"
"d_runspeed"
"d_goto"
"d_fly"
"d_c2scmd"
"d_viewradius"
"d_relogin"
"d_skill"
"d_render_water"
"d_render_grass"
"d_render_forest"
"d_render_shadow"
"d_render_outline"
"d_turnaround"
"d_testdist"
"d_gfx"
"d_showpos"
"d_trnlayer"
"d_a3dstat"
"d_gamestat"
"d_treelod"
"d_fps"
"d_playerradius"
"d_showid"
"d_skipframe"
"d_modelupdate"
"d_minidump"
"d_settimeofday"
"d_getservertime"
"d_task"
"d_mipmapbias"
"d_trncull"
"d_gscmd"
"d_delcmd"
"d_title"
"d_namepos"
"d_createtime"
"d_lastlogintime"
"d_money"
"d_go"
"d_query"
"d_querynpc"
"d_theme"
"d_queryservice"
"d_uidebug"

// ========== GM commands ==========

"gm_kickout_role"
"gm_kickout_user"
"gm_list_user"
"gm_online_num"
"gm_restart_sev"
"gm_shutup_role"
"gm_shutup_user"
"gm_moveto_player"
"gm_callin_player"
"gm_broadcast"
"gm_showid"
"gm_forbid_role"
"gm_trigger_chat"
"gm_generate"
Obviously the GM ones wont work so don't bother trying them.
It's not particularly useful as such, but it's quite fun to play around with (d_boundbox looks quite cool ^^)
Well... I say it's not useful, but some of the commands there will display NPC / Player IDs above their heads - So that's very useful if you're looking for offsets etc.

Anyway - I hope someone finds it useful :)

Cheers.
09/16/2011 09:01 Interest07#2
Awesome, you 'finished' this project then :D

I'm quite curious about the adding your own windows to the gui thing. I'm not gonna continue with the d3d8 stuff for now if that proves possible, because it would be a much cleaner solution :)
09/16/2011 09:48 dumbfck#3
Quote:
Originally Posted by Interest07 View Post
Awesome, you 'finished' this project then :D

I'm quite curious about the adding your own windows to the gui thing. I'm not gonna continue with the d3d8 stuff for now if that proves possible, because it would be a much cleaner solution :)
Well... Don't give up on yours just yet lol - So far, I can add my own window into the client just by copy / pasta / editing one of the existing xml files in interfaces\version1. Once it's added, I have to search for it in memory in order to show it. As for actually displaying useful information in it and making buttons work, etc - Well I really have no idea yet how well that's gonna work out because it will require injecting some probably quite substantial code into the client, including code to add it to the guiBase1 windows table.
I wouldn't particularly fancy writing all of the handler code in asm, so I'm gonna need to find a way to somehow compile some other language into usable code that can be injected... I'm very open to suggestions here xD.
Considering this might not be a particularly easy task, I'm not sure how practical this will be in an environment where you typically have to tweak code -> compile it -> inject it -> test it -> rinse and repeat.
Your D3D8 hooking might still be a much more suitable solution ^^
09/16/2011 11:34 Interest07#4
Quote:
Originally Posted by dumbfck View Post
Well... Don't give up on yours just yet lol - So far, I can add my own window into the client just by copy / pasta / editing one of the existing xml files in interfaces\version1. Once it's added, I have to search for it in memory in order to show it. As for actually displaying useful information in it and making buttons work, etc - Well I really have no idea yet how well that's gonna work out because it will require injecting some probably quite substantial code into the client, including code to add it to the guiBase1 windows table.
I wouldn't particularly fancy writing all of the handler code in asm, so I'm gonna need to find a way to somehow compile some other language into usable code that can be injected... I'm very open to suggestions here xD.
Considering this might not be a particularly easy task, I'm not sure how practical this will be in an environment where you typically have to tweak code -> compile it -> inject it -> test it -> rinse and repeat.
Your D3D8 hooking might still be a much more suitable solution ^^
Instead of compiling some code to obtain the asm to inject, why not just inject a dll with the code you need? Should at least save you the horror of asm :p
09/16/2011 11:53 dumbfck#5
Good thinking... No idea how to do that, but hey - Something new to learn xD
09/17/2011 14:17 xoraxax#6
Looks cool. Trying to figure out how it works. Thank you.
I have an autoIt dll injector somewhere. I could try to find it if you wish.
09/17/2011 14:33 amineurin#7
Nice, but ower my understandings :(
At this time, im willed to learn.

i program in the moment a tool to seek for items in catshops, thx to Interest07 Info and posting over it.
not really finish yet, but i had a lucky day testing it.
found in a catshop a primeval stone for 100k, sold him minutes later for 33m *lol*

maybe one day i can use ur info to make some "plugins" for the game, like autopot or autoasisst :)
09/17/2011 18:39 dumbfck#8
Quote:
Originally Posted by xoraxax View Post
Looks cool. Trying to figure out how it works. Thank you.
I have an autoIt dll injector somewhere. I could try to find it if you wish.
Thanks, but I try to avoid using AutoIt wherever possible hehe.
I might ask Interest07 how he did it for his AutoPot thing, as that didn't even seem to trigger my AV - which is a particularly fussy AV lol. I'm assuming he codecaved it maybe?

Quote:
Originally Posted by amineurin View Post
not really finish yet, but i had a lucky day testing it.
found in a catshop a primeval stone for 100k, sold him minutes later for 33m *lol*
Niiiiice! Wish I was lucky like that xD
09/17/2011 21:16 Interest07#9
The code for the dll injector, taken from [Only registered and activated users can see links. Click Here To Register...]. This is all you need to compile it (C++ code). After compiling you would need to put the injector together with a PWdll.dll in your ../element folder. The dll will need to contain a function called "Initialize", as the injector will call this function from the dll after loading it inside the elementclient.exe (via a codecave indeed).

09/18/2011 13:18 xoraxax#10
[Only registered and activated users can see links. Click Here To Register...]

Working AutoIt injector. The thing i like with dll injection is that you do not have to use readProcessMemory or so on to get some data and you don't have to do any weird stuff to call some function
09/18/2011 16:12 dumbfck#11
Cool, thanks guys :D
09/18/2011 21:38 Interest07#12
here's the source for the dll
09/20/2011 23:54 amineurin#13
*erm* i really dont want do disturb you booth, since you are so silent im shure you work hard on the gui stuff [Only registered and activated users can see links. Click Here To Register...]
but would you be so nice to give me the number to send with the packet for refreshing the gold price ?

i dont get it with the mhs script to break the game from Interest07 :(
try to set a break at the auction hall base adress, press the refresh button, but no popup goes up.
like in the description from Interest07.

ur foolish padawan [Only registered and activated users can see links. Click Here To Register...]
09/26/2011 14:47 dumbfck#14
Sorry, I forgot to answer this post last time I saw it >.>
I never actually got the packet for refreshing gold listings - I assume Interest did though as (I believe) he did some stuff with graphing the gold trends etc.

On another note, I found a better base offset for searching the window offsets in the GUI mapper. It can now find all the dialogue boxes, consoles, etc too.
Just replace Form1.cs from the package in the first post with this:

Enjoy :)
I'll hopefully be releasing the custom in-game GUI development kit soon ;)
It's going rather nicely hehe.
04/21/2012 23:49 amineurin#15
erm is it possible to use own functions in this kind of menu ?
if yes, how would this work ?
build a dll and load it with the game or any other idea ?

its just a idea i have and im trying to get more info, before i start trying to realising.

im thinking of another hotkey bar in the game, like the two ones allready there.

the idea i have is:
make such a bar in game style
read icons from a ini file and use maybe png images
also read functions from ini file

like:
1 slot = health icon
1 function: send chat message to user xyz "heal me"
2 slot = another heal icon
2 function: send chat message to user xyz "heal selected $playername"
3 slot = buff icon
3 function: send chat message to user xyz "buff me"
and so on...

so u can command maybe a heal bot with chat commands and by using a ingame menu.

its just a idea and maybe here are ppl willed to discuss this :)