[C#][Source][Copy/Pasta] Getting started with out of process botting menu

User Tag List

Page 1 of 4 1234 LastLast
Results 1 to 15 of 48
  1. #1
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C#][Source][Copy/Pasta] Getting started with out of process botting

    Because I just had to mimic the other thread, I wrote up a quick 'basic' COMPLETELY PASSIVE bot setup. It can be used to 'write' to the process as well, but none of that code is being used. (Preprocessor defines are added as well, to allow it to work in process too)

    It's a simple implementation of an ObjectManager, and the basic WoWObject class, and a few things from WoWUnit.

    There is nothing advanced in this little project whatsoever. It's only a basis for the nubs to copy/paste to get them started. I'm tired of seeing thread after thread about how to read the object list.

    So here you go, a full helping of copy/pasta.

    Note: this is VERY basic code, for the exception of the Memory class. (The Memory class touches on some workarounds for interacting with other process' memory via .NET including reading/writing full structs to memory.)

    It shows some very simple ways to implement the 'basic' framework part of a WoW wrapper.

    Again; this is by no means advanced, and you probably won't learn C# by reading any of this code.

    http://dl.dropbox.com/u/2068143/WoWStarter.7z

    [C#][Source][Copy/Pasta] Getting started with out of process botting
  2. #2
    asbest0s's Avatar Active Member CoreCoins Purchaser
    Reputation
    34
    Join Date
    Jan 2008
    Posts
    372
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot, it might help me a bit

  3. #3
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your internal reader still uses Marshal.Read* as its base reading method... Not very out of process? :P

    Also, your Point struct, correct me if I'm wrong but won't using FieldOffset(0), FieldOffset(1), FieldOffset(2) cause overlap? Shouldn't it be 0, 4, 8?

  4. #4
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by adaephon View Post
    Your internal reader still uses Marshal.Read* as its base reading method... Not very out of process? :P

    Also, your Point struct, correct me if I'm wrong but won't using FieldOffset(0), FieldOffset(1), FieldOffset(2) cause overlap? Shouldn't it be 0, 4, 8?


    At least you read the code.

    And yes, they should be fixed.

  5. #5
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice and clean. As always or most of the time
    Little to late for me but I would have loved you a year ago for releasing this

    Anyways it is great that people like you actually share this stuff and help people to get into this matter.

    Keep it up and maybe add some stuff about Aigroups and Areatriggers. I'd be very happy to see how those are handled. I don't use them atm so I don't care but I guess it would be interesting.

    +rep :P

  6. #6
    abuckau907's Avatar Active Member
    Reputation
    49
    Join Date
    May 2009
    Posts
    225
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like how you get object properties...gave me some ideas, thanks.

  7. #7
    EmilyStrange's Avatar Active Member
    Reputation
    34
    Join Date
    Jul 2009
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice contribution.

    Not sure if Apoc was just trying to trip up the copy/pasta people with the field offset bug, or wanting more endless questions along the lines of "It doesn't work! You said it would work! You owe me!"

    With just three floats specified in the structure, Sequential would also have worked just fine too, or even no LayoutKind decorator at all. The compiler won't rearrange anything based on float packing type if that is all that is in the structure.

    If you have DirectX SDK installed, you can also use the Vector3 directly from that library.

    Or even the XNA Vector3, which has a few more utility functions. Contains free code for calculating distance, angles, etc.

  8. #8
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    throw new Exception("There's no current process handle... are you sure you did everything right?");
    I like ya style to pwn noobs
    (inb4 bad joke about me getting pwned, i merly read through the code to get ideas)

    Anyway nice way of doing things especially how you read your object properties, wich reminds me that i should read a book or 2 about c# instead of just using what i've learned by trail and error and reading source codes...

  9. #9
    Mr.Zunz's Avatar Contributor
    Reputation
    92
    Join Date
    Mar 2007
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *goes back to model view presenter shit again*


  10. #10
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by EmilyStrange View Post
    Nice contribution.

    Not sure if Apoc was just trying to trip up the copy/pasta people with the field offset bug, or wanting more endless questions along the lines of "It doesn't work! You said it would work! You owe me!"

    With just three floats specified in the structure, Sequential would also have worked just fine too, or even no LayoutKind decorator at all. The compiler won't rearrange anything based on float packing type if that is all that is in the structure.

    If you have DirectX SDK installed, you can also use the Vector3 directly from that library.

    Or even the XNA Vector3, which has a few more utility functions. Contains free code for calculating distance, angles, etc.
    Very true; but when you include other fields, they're also packed into the struct. The code was originally a Sequential, then I added some stuff that required it to be Explicit. Then as always, went back to just 3 fields. (I wrote the entire thing in ~20min so not much 'proof reading' was done.)

    And yes, the two Vector3 structs are awesome alternatives. But some people don't like having the extra dependency.

    Also, me and the .NET Marshaler have a hate-hate relationship. I don't trust it to 'assume' things. So I specify things whenever possible if it's going to go through the Marshaler. (Ask amadmonk, it's got some really screwy behavior at times)

  11. #11
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by EmilyStrange View Post
    If you have DirectX SDK installed, you can also use the Vector3 directly from that library.

    Or even the XNA Vector3, which has a few more utility functions. Contains free code for calculating distance, angles, etc.
    This, I did not know.

    Thanks for the help. I hate dealing with vectors "correctly," it's nice to know that someone's already done the work.
    Don't believe everything you think.

  12. #12
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    Also, me and the .NET Marshaler have a hate-hate relationship. I don't trust it to 'assume' things. So I specify things whenever possible if it's going to go through the Marshaler. (Ask amadmonk, it's got some really screwy behavior at times)
    Amen, brother. I've learned to really hate the default marshaller. It works correctly often enough to lull me into complacency, and then BAM... things like my cf with the Point struct for traceline pop up...
    Don't believe everything you think.

  13. #13
    GliderPro's Avatar Member
    Reputation
    -1
    Join Date
    Mar 2009
    Posts
    93
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    It works correctly often enough to lull me into complacency, and then BAM...
    That is pretty much the reason why I've been avoiding a deep dive into C#. When I have a problem I like being able to look at assembly and hardware registers. Although, after viewing your code I'm more motivated to mess with C# again.

    Thanks for the sample Apoc. It is much appreciated.

  14. #14
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, don't diss C#... in truth, marshalling (correctly -- not just one time for a known structure, but for arbitrary structures, in all cases) is *hard*, so the default marshaller does a pretty good job. It's just that the exception cases really, really suck to debug
    Don't believe everything you think.

  15. #15
    EmilyStrange's Avatar Active Member
    Reputation
    34
    Join Date
    Jul 2009
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    The code was originally a Sequential, then I added some stuff that required it to be Explicit.
    Understood.

    And yes, the two Vector3 structs are awesome alternatives. But some people don't like having the extra dependency.
    People are crazy and insist on re-inventing the wheel. Re-invent to understand, re-invent because you will do a better job. Re-invent just because? That's (mostly) crazy talk.

    Also, me and the .NET Marshaler have a hate-hate relationship. I don't trust it to 'assume' things.
    And that I can understand too. When it screws up, it screws up royally! The simple cases, such as three floats, is usually pretty safe though.

    Browsing your code did cause me to go back and re-examine the assumptions about my own object enumeration though. We do it almost the same way.

    The main difference is that I don't pulse my objects. I keep a TimeSpan and enumerate again if the last time the object list was enumerated is greater than the desired TimeSpan, in this case 30 millseconds.

    My Enumerate went from about 50 lines to the code below. I was over-complicating my tests in the dictionary for valid objects. Making sure the object type was valid, the memory address had not changed, etc.

    Code:
            private void EnumerateVisibleObjects()
            {
                Dictionary<GameGUID, WowObject> newObjectCache = new Dictionary<GameGUID, WowObject>();
                ObjectMemoryAddresses objectMemory = new ObjectMemoryAddresses(m_gameClient);
                foreach (uint memoryAddress in objectMemory)
                {
                    GameGUID clientGUID = GetGUID(memoryAddress);
                    Descriptor.WoWObjectType clientObjectType = GetType(memoryAddress);
                    WowObject obj = null;
                    try
                    {
                        obj = m_objectCache[clientGUID];
                        obj.BaseAddress = memoryAddress;
                    }
    
                    catch
                    {
                        obj = GetGameObject(memoryAddress);
                    }
    
                    if (obj != null)
                    {
                        newObjectCache.Add(clientGUID, obj);
                    }
    
    
                }
    
                m_objectCache = newObjectCache;
                m_lastEnumerationTime = DateTime.Now;
            }
    Last edited by EmilyStrange; 01-30-2010 at 01:56 AM. Reason: Added the last thought about refactoring.

Page 1 of 4 1234 LastLast

Similar Threads

  1. Getting started with pathing?
    By miceiken in forum WoW Memory Editing
    Replies: 9
    Last Post: 01-08-2011, 05:41 AM
  2. Getting started with c++
    By EnergyForce in forum Programming
    Replies: 2
    Last Post: 12-07-2010, 07:38 PM
  3. [C++][Source] How to get started
    By Flowerew in forum WoW Memory Editing
    Replies: 16
    Last Post: 01-28-2010, 03:03 AM
  4. [Need Help] get started with C#
    By 96engvall in forum Programming
    Replies: 6
    Last Post: 07-22-2009, 10:09 PM
  5. [Question] Getting started with modelediting?
    By Ezelaap in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 04-03-2009, 12:37 PM
All times are GMT -5. The time now is 03:08 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search