Jump to content

Getting offsets/opcodes


Pudge

Recommended Posts

Hello how can i get offsets from wow memory?
I need a methods which will return NetClient connection state, num characters in charselect menu, get characters names from characterselect menu or charractercreate functions for different wow versions, but i can't get returned value from Lua.DoStiring, while bot is not in game. The only way is reading data from wow memory? If is true, how i can get this offsets?
 

Link to comment
Share on other sites

  • Pudge changed the title to Getting offsets/opcodes

You need to use GetText to read if you are not ingame. here is the c++ code : 

 

note GetLocalizedText uses active client player object, but GetText doesnt.

 

image.thumb.png.260b34bbb59dea4102ca61b4508918a5.png

Link to comment
Share on other sites

21 hours ago, Nax said:

You need to use GetText to read if you are not ingame. here is the c++ code : 

 

note GetLocalizedText uses active client player object, but GetText doesnt.

 

image.thumb.png.260b34bbb59dea4102ca61b4508918a5.png

But how i can return value to variable?

Link to comment
Share on other sites

So LuaDoString is FrameScriptExecute, and it casts the results of your code to a variable, then GetLocalizedText reads that veriable (@druids) just has LuaDoString return info. instead of two functions, he combinded both together. 

 

you need to write the asm for GetText Offset = 0x0819d40, Sample Asm code : https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/407197-getlocalizedtext-problem.html

 

not gonna lie, its kinda funny that GetLocalizedText uses GetText, 

 

image.png.74ec12e1e2fd5742687620fffc412062.png

Link to comment
Share on other sites

public static string GetText(string commandline)
    {
        try
        {
            string s = commandline;
            if (s.Replace(" ", "").Length <= 0)
                return "";
            uint address = wManager.Wow.Memory.WowMemory.Memory.AllocateMemory(Encoding.UTF8.GetBytes(s).Length + 1);
            if (address <= 0U)
                return "";
            
            //uint ClntObjMgrGetActivePlayerObj = 0x4038F0; 
            //uint FrameScript__GetLocalizedText = 0x7225E0;
            uint FrameScript_GetText = 0x0819d40;
            wManager.Wow.Memory.WowMemory.Memory.WriteBytes(address, Encoding.UTF8.GetBytes(s));
            string[] asm = new string[]
        {
                "push 0",
                "push -1",
                "mov edx, " + address,
                "push edx",
                "call " + (FrameScript_GetText + wManager.Wow.Memory.WowMemory.Memory.MainModuleAddress) ,
                "add esp, 0Ch",
                "retn"
        };
            
            string _Text = Encoding.UTF8.GetString(wManager.Wow.Memory.WowMemory.InjectAndExecute(asm,true));
            wManager.Wow.Memory.WowMemory.Memory.FreeMemory(address);
            return _Text;
        }
        catch (Exception ex)
        {
            Logging.WriteError("[GetText]: error " + ex);
        }
        return "";
    }

 

This code just kills the client wow, I don't understand what's wrong with it, it's very similar to the code from the forum link you posted on

Link to comment
Share on other sites

Hi, the correct code is :

    public static string GetTextFixed(string commandline)
    {
        uint FrameScript_GetText = 0x0819d40;

        var commandByte = System.Text.Encoding.UTF8.GetBytes(commandline + "\0");
        var luaGetLocalizedTextSpace = wManager.Wow.Memory.WowMemory.AllocData.Get(commandByte.Length);
        var rCodecave = wManager.Wow.Memory.WowMemory.AllocData.Get(IntPtr.Size);

        if (luaGetLocalizedTextSpace <= 0)
            return "";

        wManager.Wow.Memory.WowMemory.Memory.WriteBytes(luaGetLocalizedTextSpace, commandByte);
        wManager.Wow.Memory.WowMemory.Memory.WritePtr(rCodecave, 0);

        var asm = new[]
        {
            wManager.Wow.Memory.WowMemory.CallWrapperCodeRebaseEsp(FrameScript_GetText, 0x0C, luaGetLocalizedTextSpace, -1, 0),
            "mov ecx, " + rCodecave,
            "mov [ecx], eax",
            wManager.Wow.Memory.WowMemory.RetnToHookCode
        };

        wManager.Wow.Memory.WowMemory.InjectAndExecute(asm);
        var sResult = string.Empty;
        var a = wManager.Wow.Memory.WowMemory.Memory.ReadPtr(rCodecave);
        if (a > 0)
            sResult = wManager.Wow.Memory.WowMemory.Memory.ReadStringUTF8(a);
        if (string.IsNullOrEmpty(sResult))
            sResult = string.Empty;

        wManager.Wow.Memory.WowMemory.AllocData.Free(luaGetLocalizedTextSpace);
        wManager.Wow.Memory.WowMemory.AllocData.Free(rCodecave);

        return sResult;
    }

 

Link to comment
Share on other sites

@Droidz thank you for this snippet, it works and will be very useful for me.
But old wrobot versions, like "WRobot_7.3.5_26365_final" does not have such class like "AllocData". 
Which method from the old libraries can replace the missing one?
 

Spoiler

image.png.c8a741c4a7f9b0cff40966531b97aff4.png

 

Link to comment
Share on other sites

@Pudgeto be honest, that code might not work with patch 7.3.5, the code above is for wotlk. May need to use Ida and see what GetText asm is as they might of changed it.

Link to comment
Share on other sites

On 3/26/2023 at 8:52 AM, Nax said:

@Pudgeto be honest, that code might not work with patch 7.3.5, the code above is for wotlk. May need to use Ida and see what GetText asm is as they might of changed it.

Hey, i understand it, but i cannot check new offsets because this snippet doesnot work on old wrobot legion

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...