-
Contributor
I will appreciate if i get help on this one:
Code:
using (var font = new SlimDX.Direct3D9.Font(Device, new System.Drawing.Font("Consolas", 10)))
{
font.DrawString(null, text, x, y, color);
}
Why the drawn text appears or disappears when i move the mouse cursor depending if it points to a frame or not?
I noticed this behavior only on the vanilla client.
Last edited by tutrakan; 05-19-2016 at 04:39 PM.
-
Originally Posted by
tutrakan
I will appreciate if i get help on this one:
Code:
using (var font = new SlimDX.Direct3D9.Font(Device, new System.Drawing.Font("Consolas", 10)))
{
font.DrawString(null, text, x, y, color);
}
Why when i move the mouse cursor my text appears or disappears depending if i have pointed a frame or not?
I noticed this behavior only on the vanilla client.
For starters, stop creating and disposing a font every frame.
-
Contributor
I don't think that is the problem.
And i found that this is the best way to handle the font, otherwise it crashes when i resize the window or when in fullscreen: switching between the game and the desktop.
Creating it (and disposing it) takes ~10ms in fullscreen (in 3.3.5 client) which i find OK rather the risk of crashes at every alt-tab or WIN key press.
Even when i draw lines, they lose brightness when the cursor doesn't point to a frame.
Last edited by tutrakan; 05-19-2016 at 09:56 PM.
-
Active Member
Okay, i finally get something to happen, but not the right. I still try to inject LUA code into WoW 1.12.1 - but it will not work.
Atleast it shows me now an lua error ingame "[script " "]:1: unexpected symbol near `'"
Its not much but a little win. I still use the function i posted earlier, but slightly modified:
Code:
//Allocate Memory For Command
var DoStringArg_Codecave = _magic.AllocateMemory(Encoding.ASCII.GetBytes(Command).Length + 1);
//Execute Address
IntPtr FrameScript_Execute = new IntPtr(0x00704CD0);
//Write Command In Allocated Memory
_magic.Asm.Clear();
_magic.WriteASCIIString(DoStringArg_Codecave, Command);
_magic.Asm.AddLine("mov ecx, " + DoStringArg_Codecave);
_magic.Asm.AddLine("mov edx, " + DoStringArg_Codecave);
_magic.Asm.AddLine("call " + FrameScript_Execute);
_magic.Asm.AddLine("retn");
_magic.Asm.InjectAndExecute(DoStringArg_Codecave);
_magic.Asm.Clear();
_magic.FreeMemory(DoStringArg_Codecave);
Can someone help me to get this to work? Maybe even help me to get a return message (Like when i call "GuildInfo" that i get the information)
Thanks~
EDIT:
Also, someone postet this "0x4C9330 Script_GetGuildInfo" - That is the pointer to the function, right? But how would i call something like that? Also with asm, put in the parameters and inject it? And how would i get the data from that?
Sorry for all the noobie questions. I'm pretty new to all of this.
Last edited by SatyPardus; 05-20-2016 at 12:28 AM.
-
Contributor
Originally Posted by
SatyPardus
Okay, i finally get something to happen, but not the right. I still try to inject LUA code into WoW 1.12.1 - but it will not work.
Atleast it shows me now an lua error ingame "[script " "]:1: unexpected symbol near `'"
Its not much but a little win. I still use the function i posted earlier, but slightly modified:
Code:
//Allocate Memory For Command
var DoStringArg_Codecave = _magic.AllocateMemory(Encoding.ASCII.GetBytes(Command).Length + 1);
//Execute Address
IntPtr FrameScript_Execute = new IntPtr(0x00704CD0);
//Write Command In Allocated Memory
_magic.Asm.Clear();
_magic.WriteASCIIString(DoStringArg_Codecave, Command);
_magic.Asm.AddLine("mov ecx, " + DoStringArg_Codecave);
_magic.Asm.AddLine("mov edx, " + DoStringArg_Codecave);
_magic.Asm.AddLine("call " + FrameScript_Execute);
_magic.Asm.AddLine("retn");
_magic.Asm.InjectAndExecute(DoStringArg_Codecave);
_magic.Asm.Clear();
_magic.FreeMemory(DoStringArg_Codecave);
Can someone help me to get this to work? Maybe even help me to get a return message (Like when i call "GuildInfo" that i get the information)
Thanks~
EDIT:
Also, someone postet this "0x4C9330 Script_GetGuildInfo" - That is the pointer to the function, right? But how would i call something like that? Also with asm, put in the parameters and inject it? And how would i get the data from that?
Sorry for all the noobie questions. I'm pretty new to all of this.
Try calling it like this:
mov eax, 0
mov ecx, DoStringArg_CodeCave
mov edx, DoStringArg_CodeCave
call FrameScript_Execute
EDIT: (In regards to Script_GetGuildInfo) - You probably shouldn't be calling Lua functions directly if you don't know what you're doing as it's a pain to manage the lua stack manually. I'd recommend just reversing the function and calling whatever internal functions it's using directly.
Last edited by Saridormi; 05-20-2016 at 01:52 AM.
Reason: corrected code sample
-
Post Thanks / Like - 2 Thanks
-
Active Member
Originally Posted by
Saridormi
You probably shouldn't be calling Lua functions directly if you don't know what you're doing as it's a pain to manage the lua stack manually. I'd recommend just reversing the function and calling whatever internal functions it's using directly.
And how would i do that? In that way i'm doing it right now, or similar? Because this is currently pain to learn
I mean, i know how to read all player and object data, is there a way that i can read these functions also easy like that?
(Like "_magic.ReadUInt((LocalTarget.UnitFieldsAddress + (uint)WoWUnitFields.Health))")
Edit: With the little change its now this error "[script "?"]:1: unexpected symbol near `'" Just a questionmark more xD
Last edited by SatyPardus; 05-20-2016 at 01:13 AM.
-
Contributor
Originally Posted by
SatyPardus
And how would i do that? In that way i'm doing it right now, or similar? Because this is currently pain to learn
I mean, i know how to read all player and object data, is there a way that i can read these functions also easy like that?
(Like "_magic.ReadUInt((LocalTarget.UnitFieldsAddress + (uint)WoWUnitFields.Health))")
Do what, exactly?
You can call Lua functions directly by pushing your arguments onto the lua stack, calling the function with a pointer to the lua stack as a parameter, reading the number of arguments on the stack as a return value and then popping them off the stack (again, using internal lua functions).
It's much easier to just read the code and see what it's actually doing and then doing that :P
-
Active Member
-
Contributor
Originally Posted by
SatyPardus
OMG. That sounds way more complicated as everything else i ever did in the last 6 years
So how would i start with that? Any good tutorials on how to push stuff to the stack?
And do i have to do that with every little function i want to use?
Like castspell, attacktarget, get quetsobjectiveinfo etc xD That would be crazy
No, only if you want the return value of the function. For most things (like CastSpellByName) it's easier to just call FrameScript__Execute and let WoW deal with it.
For getting information out of lua functions, just reverse the actual functions, seriously. It's good practice and it'll get you a lot of extra information about WoW's internal data structures in the process.
-
Active Member
Okay, but the FrameScript_Execute still dont work (See edited post under your first tip).
I mean, that would already help a lot. But the most important thing is for me, to get information about quests and objectives (I mean, i already read out every quest that my character have, that works, but it's only the questID and no information about it)
"Reverse" ... you mean reverse enginering? Like IDA or something ? How would i do that with an entire function...and most important, how would i use that.
Some tutorial would be really nice, so i can read into that. Or some code examples with comments how it works. (It's really hard to find this kind of stuff, and as i am searching for stuff in this 1.12.1 version its even harder...lol )
-
Contributor
Originally Posted by
SatyPardus
Okay, but the FrameScript_Execute still dont work (See edited post under your first tip).
I mean, that would already help a lot. But the most important thing is for me, to get information about quests and objectives (I mean, i already read out every quest that my character have, that works, but it's only the questID and no information about it)
"Reverse" ... you mean reverse enginering? Like IDA or something ? How would i do that with an entire function...and most important, how would i use that.
Some tutorial would be really nice, so i can read into that. Or some code examples with comments how it works. (It's really hard to find this kind of stuff, and as i am searching for stuff in this 1.12.1 version its even harder...lol
)
Oops, my bad. It's
mov eax, 0
mov ecx, DoStringArg_Codecave
mov edx, DoStringArg_Codecave
call FrameScript__Execute
https://i.imgur.com/G51fGxo.png
Here's a POC if you're still struggling: https://gist.github.com/Evairfairy/d...aa1a325e9c8b16
Yes, reverse engineering. That's what this section is all about.
Open the function in IDA and start reading it, google any instructions you don't understand, use Cheat Engine to see the values of memory addresses that the function is using and try to figure out what they are. You figure out a small part of the function at a time, which gives you hints as to the rest of the function, until you end up with something like this: https://i.imgur.com/HniF0bx.png
-
Post Thanks / Like - 1 Thanks
SatyPardus (1 members gave Thanks to Saridormi for this useful post)
-
Active Member
-
Contributor
Originally Posted by
SatyPardus
Thank you! The DoLua works now with your code. My code with BlackMagic is exactly the same...but for some reason it doesnt work. Switching to memorysharp worked a lot better
Thanks again
And now! Lets look into IDA and stuff and get my head burning
MemorySharp is great, at least in my experience so far.
I haven't used BlackMagic so I can't comment on how good it is, but I know it's very popular here so I can only assume you were doing something wrong with it. As to what, I don't know, maybe one of the people who use BlackMagic regularly can tell you
-
Post Thanks / Like - 1 Thanks
tutrakan (1 members gave Thanks to Saridormi for this useful post)
-
Contributor
BlackMagic is very old and don't worth using it, when tools like MemorySharp exist nowdays. Thank you for pointing it out.
Last edited by tutrakan; 05-20-2016 at 08:11 AM.
-
Originally Posted by
tutrakan
I don't think that is the problem.
And i found that this is the best way to handle the font, otherwise it crashes when i resize the window or when in fullscreen: switching between the game and the desktop.
Creating it (and disposing it) takes ~10ms in fullscreen (in 3.3.5 client) which i find OK rather the risk of crashes at every alt-tab or WIN key press.
This is really bad practice with DirectX. The correct way is quite simple too - forward OnResetDevice and OnLostDevice from the D3D9 device to each ID3DXFont instance, and release the font when the device is destroyed and recreate it when the new device is created. You're going to have a REALLY bad time in the future unless you fix this.
Originally Posted by
tutrakan
Even when i draw lines, they lose brightness when the cursor doesn't point to a frame.
Most likely it's due to render states being set from the top-most drawing. This can be obviously be different for a number of reasons, even including what frame your cursor is hovering, highlighting, etc.
Try creating a state block and setting some more suitable render states before drawing. Don't forget to apply and release the state block after drawing, too.
-
Post Thanks / Like - 2 Thanks