DoString and getting values from it? menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DoString and getting values from it?

    Hi everyone,

    today I was trying to add lua calling to my bot but I was not even close. WoW is crashing all the time. I was trying the following with BlackMagic.

    Code:
     public void Lua_DoString(string command)
            {
                // command is something like "DoEmote(\"dance\")"
                uint codecave = magic.AllocateMemory();
                uint stringcave = magic.AllocateMemory();
    
                magic.Asm.AddLine("fs mov eax, [0x2C]");
                magic.Asm.AddLine("mov eax, [eax]");
                magic.Asm.AddLine("add eax, 0x10");
                magic.Asm.AddLine("mov dword [eax], {0}", com.getMgr());
    
                magic.Asm.AddLine("mov eax, 0");
                magic.Asm.AddLine("push eax");
                magic.Asm.AddLine("mov eax, {0}", stringcave);
                magic.Asm.AddLine("push eax");
                magic.Asm.AddLine("push eax");
                magic.Asm.AddLine("call {0}", 0x0049AAB0);
                magic.Asm.AddLine("add esp, 0xC");
                magic.Asm.AddLine("retn");
    
                magic.Asm.InjectAndExecute(codecave);
                magic.FreeMemory(codecave);
                magic.FreeMemory(stringcave);
                magic.ResumeThread();
            }
    After this WoW says goodbye.

    Does anybody here could provide examples of calling lua functions via BlackMagic and getting the results back into your code?
    Last edited by Viano; 07-11-2009 at 09:23 AM.
    Viano

    DoString and getting values from it?
  2. #2
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could write a wrapper that you inject that calls DoString and returns a pointer to the result in eax. You would just have to use ToString() in the wrapper and you'd be gold.

  3. #3
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by lanman92 View Post
    You could write a wrapper that you inject that calls DoString and returns a pointer to the result in eax. You would just have to use ToString() in the wrapper and you'd be gold.
    Sadly I am not able to do this. But I know some of you here managed to do it via BM. I don't understand assembler code that good, so I just have to trust copy&pasta currently.

    Now I have this.

    Code:
    public bool Lua_DoString(string command)
            {
                uint space = magic.AllocateMemory(0x2048);
                Magic bm = magic;
                bm.WriteASCIIString(space + 0x1024, command);
              
    
                bm.Asm.Clear();
                bm.Asm.AddLine("FS mov eax, [0x2C]");
                bm.Asm.AddLine("mov eax, [eax]");
                bm.Asm.AddLine("add eax, 0x10");
                bm.Asm.AddLine("mov dword [eax], {0}", com.getMgr());
                bm.Asm.AddLine("mov ecx, 0");
                bm.Asm.AddLine("mov eax, " + (space + 0x1024));
                bm.Asm.AddLine("push ecx");
                bm.Asm.AddLine("push eax");
                bm.Asm.AddLine("push eax");
                bm.Asm.AddLine("mov eax, " + 0x0049AAB0);
                bm.Asm.AddLine("call eax");
                bm.Asm.AddLine("add esp, 0xC");
                bm.Asm.AddLine("retn");
                bm.SuspendThread();
                bm.Asm.InjectAndExecute(space);
                bm.ResumeThread();
                bm.FreeMemory(space);
                return true;
            }
    However I am having a hard time putting together the code for other lua functions like GetLocalizedText, please help ;-) Anyone?
    Last edited by Viano; 07-11-2009 at 03:19 PM. Reason: Noobish question.
    Viano

  4. #4
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, now I was messing with Apoc's code, but it is just far beyond my tiny knowledge. I have questions to his code at http://www.mmowned.com/forums/wow-me...ected-clr.html.

    What is the content of "Utilities"?
    What is he doing at "Win32.MemoryOpen();"?
    Anyone having examples of how to use his code for lua functions?
    Viano

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Viano View Post
    Ok, now I was messing with Apoc's code, but it is just far beyond my tiny knowledge. I have questions to his code at http://www.mmowned.com/forums/wow-me...ected-clr.html.

    What is the content of "Utilities"?
    What is he doing at "Win32.MemoryOpen();"?
    Anyone having examples of how to use his code for lua functions?
    Uhhh... I already explained what was used from my Utilities class.

    Code:
            public static T RegisterDelegate<T>(IntPtr address) where T : class
            {
                return Marshal.GetDelegateForFunctionPointer(address, typeof(T)) as T;
            }
    As for the Win32.MemoryOpen()

    Code:
            [DllImport("kernel32.dll")]
            private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
    
            public static void MemoryOpen()
            {
                // WoW is our current proc. Flags: All = 0x001F0FFF
                _openProc = MemoryOpen(Process.GetProcessesByName("Wow")[0].Id, ProcessAccessFlags.All);
            }
    
            public static IntPtr MemoryOpen(int processID, ProcessAccessFlags desiredAccess)
            {
                Process myProc = Process.GetProcessById(processID);
                if (myProc.HandleCount > 0)
                {
                    return OpenProcess((uint) desiredAccess, true, processID);
                }
                return IntPtr.Zero;
            }
    _openProc is just used internally when we need to write memory. (As Marshal.WriteFoo seems to fail more often than not, while WriteProcessMemory works 100%)

    Nothing terribly special.

    As for example code; LEARN THE GOD DAMNED LANGUAGE BEFORE YOU TRY TO DO ADVANCED THINGS WITH IT!

    That is all.

  6. #6
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Apoc, do you not use pointers to avoid unsafe code? I don't really see any disadvantage to using the unsafe keyword :/

  7. #7
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    ...
    _openProc is just used internally when we need to write memory. (As Marshal.WriteFoo seems to fail more often than not, while WriteProcessMemory works 100%)
    ...
    A LEARN THE GOD DAMNED LANGUAGE BEFORE YOU TRY TO DO ADVANCED THINGS WITH IT!
    ...
    But you are not using _openProc in the code presented. Where internally do you use this?

    Are there any samples on the internet where I can see this beeing used with easyhook in C#?

    You are right about the learning part. But should I write my own yet another notepad? I guess not ;-) I am going to learn much more by looking at code from people like you (thanks for that). If I could only get this running ...
    Viano

  8. #8
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Viano View Post
    You are right about the learning part. But should I write my own yet another notepad? I guess not ;-) I am going to learn much more by looking at code from people like you (thanks for that). If I could only get this running ...
    You could read about the APIs you are using. For example.

  9. #9
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by lanman92 View Post
    Hey Apoc, do you not use pointers to avoid unsafe code? I don't really see any disadvantage to using the unsafe keyword :/
    I don't use the pointer arithmetic as it's not needed, and it creates fairly ugly code IMHO. Using delegates forces type-safety, and is also quite a bit more maintainable.

    Honestly, it's just preference. I think the delegated way is easier, as I can keep track of things *much* better. And if a certain function's prototype changes, I won't even need to open Olly or IDA to find out. (.NET will just throw errors concerning that delegate)

    If you have some tidbit of code that you think would be faster in the end, by all means, feel free to share. Until then though, I'll stick with my 'one time only' delegate assignment.

    Originally Posted by Viano View Post
    But you are not using _openProc in the code presented. Where internally do you use this?

    Are there any samples on the internet where I can see this beeing used with easyhook in C#?

    You are right about the learning part. But should I write my own yet another notepad? I guess not ;-) I am going to learn much more by looking at code from people like you (thanks for that). If I could only get this running ...
    Before you learn to program, learn to read.

    _openProc is just used internally when we need to write memory. (As Marshal.WriteFoo seems to fail more often than not, while WriteProcessMemory works 100%)
    Jesus christ. Seriously though, go program shit basic stuff before you come back here. The next 'beginner' question from you will get you infractions. Read the section rules, and be happy I'm warning you now.
    Last edited by Apoc; 07-11-2009 at 06:26 PM.

  10. #10
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mhm ... I will drop Apoc's approach since I am to stupid for it. Anyone a hint on why the following is crashing WoW?

    Code:
    public String Lua_GetLocalizedText(string variable)
            {
                magic.SuspendThread();
                BlackMagic wow = magic;
    
                String sResult = "null";
    
                uint codecave = wow.AllocateMemory();
                uint stringcave = wow.AllocateMemory(variable.Length + 1);
                wow.WriteASCIIString(stringcave, variable);
    
                wow.Asm.Clear();
                AsmUpdateCurMgr();
    
                wow.Asm.AddLine("mov ecx, {0}", Common.Instance.getObjectByGUID(magic.ReadUInt64(
                    Common.Instance.getMgr() + (uint)Descriptors.Offsets.localGuidOffset)));
                wow.Asm.AddLine("push {0}", -1);
                wow.Asm.AddLine("push {0}", stringcave);
                wow.Asm.AddLine("call {0}", Globals.Functions.Lua_GetLocalizedText);
    
                AsmSendResumeMessage();
                wow.Asm.AddLine("retn");
    
                try
                {
                    uint result = wow.Asm.InjectAndExecute(codecave);
                    Thread.Sleep(10);
    
                    if (result != 0)
                    {
                        sResult = wow.ReadASCIIString(result, 256);
                    }
                }
                catch (Exception e)
                {
                    magic.ResumeThread();
                    throw e;
                }
                finally
                {
                    wow.FreeMemory(codecave);
                    wow.FreeMemory(stringcave);
                }
    
                return sResult;
            }
    Viano

  11. #11
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hook EndScene and do your function calls from there

  12. #12
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    Hook EndScene and do your function calls from there
    Currently I am not capable of doing this (or show me how) and as I managed to call dostring that way I was hoping some of you can help here.
    Last edited by Viano; 07-12-2009 at 12:04 PM.
    Viano

  13. #13
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    God, this makes my mother ****ing brain hurt. You have a globally accessible BlackMagic object called 'magic' which you sometimes use but also create a reference to it called 'wow' which you ALSO sometimes use. Pick one or the other, holy christ.

    Anyway, it seems that you're only resuming WoW's main thread when catching an exception. That'd be my first and best guess as to why you're having issues. There's a bunch of other shit that stands out--namely that you use someone else's AsmSendResumeMessage(); but then ignore it and just do a static sleep of 10ms, which is completely useless, among other copypasta that you obviously don't understand--but I'm not going to waste my time sifting through crap like this.

    When I wrote and released BlackMagic with an ASM injection class, I didn't really think that this is the kind of shit it'd spawn. This is just getting pathetic.

  14. #14
    vulcanaoc's Avatar Member
    Reputation
    31
    Join Date
    Jul 2008
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Viano View Post
    Mhm ... I will drop Apoc's approach since I am to stupid for it. Anyone a hint on why the following is crashing WoW?

    Code:
                wow.Asm.AddLine("mov ecx, {0}", Common.Instance.getObjectByGUID(magic.ReadUInt64(
                    Common.Instance.getMgr() + (uint)Descriptors.Offsets.localGuidOffset)));
                wow.Asm.AddLine("push {0}", -1);
                wow.Asm.AddLine("push {0}", stringcave);
                wow.Asm.AddLine("call {0}", Globals.Functions.Lua_GetLocalizedText
    The fact that you have both Common.Instance AND Globals.Functions namespaces calling getObjectByGUID (what is this naming convention? java?) and Lua_GetLocalizedText, respectively, is deeply unsettling and confusing.

    I feel like you just *may* be cooking up some copy-pasta. Don't leave out the Common.Instance.Globals.Copypasta.AddAlfredoSauce() method!

  15. #15
    Viano's Avatar Active Member
    Reputation
    37
    Join Date
    May 2008
    Posts
    172
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Shynd View Post
    God, this makes my mother ****ing brain hurt.
    Your mom is reading code at mmwoned? You have to love her
    Originally Posted by Shynd View Post
    You have a globally accessible BlackMagic object called 'magic' which you sometimes use but also create a reference to it called 'wow' which you ALSO sometimes use. Pick one or the other, holy christ.
    Well that was just a very quick fix just to make it work as that was copy and pasted from this forum. I want to get things running and see how they work then and clean up the code afterwards. Even if this is not the way it should be done.

    Originally Posted by Shynd View Post
    Anyway, it seems that you're only resuming WoW's main thread when catching an exception. That'd be my first and best guess as to why you're having issues. There's a bunch of other shit that stands out--namely that you use someone else's AsmSendResumeMessage(); but then ignore it and just do a static sleep of 10ms, which is completely useless, among other copypasta that you obviously don't understand--but I'm not going to waste my time sifting through crap like this.
    True. I still don't understand IPC, ASM fully and C# syntax is still hard to read sometimes. Nevertheless thank you for the answer, BlackMagic and your help.

    Originally Posted by Shynd View Post
    When I wrote and released BlackMagic with an ASM injection class, I didn't really think that this is the kind of shit it'd spawn. This is just getting pathetic.
    I will try to spare you more shitty posts from me. I promise

    Originally Posted by vulcanaoc View Post
    The fact that you have both Common.Instance AND Globals.Functions namespaces calling getObjectByGUID (what is this naming convention? java?) and Lua_GetLocalizedText, respectively, is deeply unsettling and confusing.

    I feel like you just *may* be cooking up some copy-pasta. Don't leave out the Common.Instance.Globals.Copypasta.AddAlfredoSauce() method!
    Yes, at the beginning my naming convention was Java as I was coding some bullshit in Java for weeks and now can't get rid of it.

    I am copy and pasting ASM code from here as I simply have no idea about it at the moment. And I was just trying to get things work without thinking of design, patterns or organizing code.
    Last edited by Viano; 07-13-2009 at 02:54 AM.
    Viano

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2012, 08:45 AM
  2. [newbie guide] How to (not) get values from memory
    By zdud in forum Diablo 3 Memory Editing
    Replies: 0
    Last Post: 08-22-2012, 06:05 AM
  3. Replies: 18
    Last Post: 09-09-2007, 02:04 AM
  4. Level JC to 375 and How to get money from 2 ores
    By joshcan in forum World of Warcraft Guides
    Replies: 5
    Last Post: 08-31-2007, 02:36 PM
  5. Put fake auction up and get a shard from it
    By Destar in forum World of Warcraft Exploits
    Replies: 17
    Last Post: 12-05-2006, 09:44 PM
All times are GMT -5. The time now is 02:26 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search