Proof of Concept: dwFindPattern TLS [C#] menu

User Tag List

Results 1 to 15 of 15
  1. #1
    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)

    Proof of Concept: dwFindPattern TLS [C#]

    Truth be told, ever since WoW!Sharp, I haven't hacked/disassembled/whatever WoW in any way, shape, or form (except for writing a teleporter for an EMU server, big whoop). I've never worked with TLS--nor am I even really sure what it stands for, to be honest--before today, but I've kinda decided that I want to try to catch up with the whole scene.

    I've read almost every thread I could get my hands on over the past 24-48 hours, and have compiled and run many, many different PoCs or examples. From what I can tell, the first step in making a bot--or anything, really--is to find the s_curMgr, which allows you to loop through loaded objects (including your character?). I've seen people left in the dust when their "TLS Pointer" is outdated due to client updates, so I set out to solve that problem--or, at the very least, make it easier to solve. Enter: dom1n1k's dwFindPattern (external C# version).

    (Source with highlighting HERE.)
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using MemoryLib;
    
    namespace ExternalFindPattern
    {
    	class Program
    	{
    		static void Main(string[] args)
    		{
    			DateTime now = DateTime.Now; //used for testing how long it takes to find the tls pointer
    			System.Diagnostics.Process.EnterDebugMode(); //gives our program debug permissions
    
    			//open wow for read/write
    			IntPtr hProcess = Memory.OpenProcess(Memory.GetProcessIdByProcessName("wow.exe"));
    			//if open process was successful
    			if (hProcess != IntPtr.Zero)
    			{
    				//search for the code pattern that we want (in this case, WoW TLS)
    				uint tlscode = dwFindPattern(hProcess, 0x410000, 0x400000,
    					"EB 02 33 00 64 8B 15 2C 00 00 00 8B 0D 00 00 00 00 8B 0C 8A",
    					"xxx?xxxxxxxxx????xxx");
    
    				//read Kynox's g_clientConnection from memory
    				uint g_clientConnection = Memory.ReadUInt(hProcess, Memory.ReadUInt(hProcess, (tlscode + 0x16)));
    				//first, the offset for the curMgr inside g_clientConnection is read,
    				//then s_curMgr is read from g_clientConnection + that offset (which may change version to version,
    				//I honestly don't know)
    				uint s_curMgr = Memory.ReadUInt(hProcess, (g_clientConnection + Memory.ReadInt(hProcess, tlscode + 0x22)));
    
    				//output to console
    				Console.WriteLine("TLS code: 0x{0:X08}ng_clientConnection: 0x{1:X08}ns_curMgr: 0x{2:X08}", tlscode, g_clientConnection, s_curMgr);
    
    				Memory.CloseHandle(hProcess);
    			}
    
    			//tell user how long it took to find and get what we wanted
    			TimeSpan timer = DateTime.Now.Subtract(now);
    			Console.WriteLine("nnTime taken: {0}msnnPlease press [ENTER] to continue...", timer.Milliseconds);
    			Console.ReadLine();
    		}
    
    		#region dwFindPattern
    		//blatantly adapted/copied from dom1n1k :)
    		static bool bDataCompare(byte[] data, int index, byte[] pattern, string mask)
    		{
    			if (pattern.Length != mask.Length) return false;
    
    			for (int i = 0; i < pattern.Length; i++)
    				if (mask[i] == 'x' && (data[index + i] != pattern[i]))
    					return false;
    
    			return true;
    		}
    
    		//blatantly adapted/copied from dom1n1k :)
    		static uint dwFindPattern(IntPtr hProcess, uint start, int length, string _pattern, string mask, char delimiter)
    		{
    			string[] p = _pattern.Split(delimiter);
    			byte[] pattern = new byte[p.Length];
    			for (int i = 0; i < p.Length; i++)
    				pattern[i] = Convert.ToByte(p[i], 16);
    
    			const int bytestoread = 1024;
    
    			int index = 0;
    			byte[] buf;
    
    			if (bytestoread > length)
    			{
    				buf = new byte[length];
    				Memory.ReadMemory(hProcess, start, ref buf);
    				for (int i = 0; i < (buf.Length - pattern.Length); i++)
    					if (bDataCompare(buf, i, pattern, mask))
    						return (uint)(start + i);
    			}
    			else
    			{
    				while (index < length)
    				{
    					buf = new byte[bytestoread + pattern.Length];
    					Memory.ReadMemory(hProcess, start + index, ref buf);
    					for (int i = 0; i < bytestoread; i++)
    						if (bDataCompare(buf, i, pattern, mask))
    							return (uint)(start + index + i);
    
    					index += bytestoread;
    				}
    			}
    
    			return uint.MaxValue;
    		}
    
    		static uint dwFindPattern(IntPtr hProcess, uint start, int length, string _pattern, string mask)
    		{
    			return dwFindPattern(hProcess, start, length, _pattern, mask, ' ');
    		}
    		#endregion
    	}
    }
    Now then, this serves two purposes:
    • Gives a program the ability to look for patterns (useful for making your program either update itself or completely ignore client version) without injecting anything into the client.
    • Finds Kynox's g_clientConnection and, subsequently, the s_curMgr externally, allowing the program to loop through loaded objects, regardless (hopefully?) of client version.


    In order to use this in the leechtastic, copy+paste way, you'll need my MemoryLib class library, located here. Source is included, though it's a bit rough around the edges and nowhere near finished (I've worked on it for a few hours here or there for nearly a year).



    Kynox, Bobbysing, UnknOwned: you guys have been doing this longer than I have, so, please, point out what I'm doing wrong, what I could be doing better, and/or any suggestions you might have, up to and including what should be my next step, in your opinion, towards a bot. I've got a few ideas of my own, but I'm really in over my head with information, at the moment. If you wouldn't mind helping me learn what it is I need to learn, I'd love the opportunity to pick your brain(s) about certain things. Let me know.



    Anyway, there's my first contribution with (hopefully) more to come as I learn and feel more comfortable. See the second post in this thread for a better explanation of what's going on in my code.




    CREDITS:
    dom1n1k
    Kynox
    bobbysing
    Anyone else that I forgot: I'm sorry. I've read a lot of threads and gleaned a lot of information from many different sources. Please, let me know if I've forgotten anyone.
    Last edited by Shynd; 05-31-2008 at 12:02 PM. Reason: added credits

    Proof of Concept: dwFindPattern TLS [C#]
  2. #2
    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)

    Further explanation...

    Okay, on line 21:
    Code:
    uint tlscode = dwFindPattern(hProcess, 0x410000, 0x400000,
    	"EB 02 33 00 64 8B 15 2C 00 00 00 8B 0D 00 00 00 00 8B 0C 8A",
    	"xxx?xxxxxxxxx????xxx");
    This searches for what I've determined to be the easiest portion of WoW game code from which to glean the largest amount of information. In 2.4.2, it looks a bit like this:
    Code:
    00778D1B  |. 6A 00              PUSH 0                                   ; /Arg1 = 00000000
    00778D1D  |. 8BC8               MOV ECX,EAX                              ; |
    00778D1F  |. E8 ECE8FFFF        CALL <Wow.CGCurMgr_C>                    ; Wow.00777610
    00778D24  |. EB 02              JMP SHORT Wow.00778D28
    00778D26     33C0               XOR EAX,EAX
    00778D28     64:8B15 2C000000   MOV EDX,DWORD PTR FS:[2C]
    00778D2F  |. 8B0D 84AAE800      MOV ECX,DWORD PTR DS:[E8AA84]
    00778D35  |. 8B0C8A             MOV ECX,DWORD PTR DS:[EDX+ECX*4]
    00778D38  |. 8B15 B095D400      MOV EDX,DWORD PTR DS:[D495B0]
    00778D3E  |. 8981 10000000      MOV DWORD PTR DS:[ECX+10],EAX
    00778D44  |. 8982 18220000      MOV DWORD PTR DS:[EDX+2218],EAX
    00778D4A  |. A1 B095D400        MOV EAX,DWORD PTR DS:[D495B0]
    Line 21 should find the pattern that starts at 0x00778D24, or JMP SHORT Wow.00778D28. That is where we will start gathering information.

    Line 26 has two memory reads on it. In simplistic terms, it looks more or less like so: [[0x00778D24 + 0x16]] = g_clientConnection. It reads from tlscode+0x16 (0x00778D3A), which contains 0x00D495B0, and then reads from 0xD495B0 to get the address of g_clientConnection. My hope is that the pointer to g_clientConnection will always be 0x16 bytes from where my pattern is found and, therefore, will update itself with each new client.

    Line 30 has two more memory reads on it. [g_clientConnection + [tlscode+0x22]] = s_curMgr. Basically, I'm not taking chances that the offset from g_clientConnection to the s_curMgr pointer will always stay the same, so I read the offset from memory at tlscode+0x22 (0x00778D46). Hopefully this will solve some client update issues, as well, though it's less likely. Never hurts to be safe, though.

    Seriously, I have no idea if any of this helps in any way, as I've never had things break during a client update (seeing as I'm starting from scratch with today as my first day). All I'm trying to do is fix problems I've had happen to me in other games when clients update and hope that WoW will act the same way. I'm sure someone will correct me if I'm wrong--in fact, I'm hoping for it .


    Afterthought: an image says a thousand words?

  3. #3
    kynox's Avatar Account not activated by Email
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice work dude!

  4. #4
    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)
    Nothing you would change?

  5. #5
    ShoniShilent's Avatar Member
    Reputation
    7
    Join Date
    May 2008
    Posts
    105
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    another location is here:


    0077624E CC INT3
    0077624F CC INT3
    00776250 55 PUSH EBP
    00776251 8BEC MOV EBP,ESP
    00776253 A1 84AAE800 MOV EAX,DWORD PTR DS:[E8AA84]
    00776258 64:8B0D 2C000000 MOV ECX,DWORD PTR FS:[2C]
    0077625F 53 PUSH EBX
    00776260 56 PUSH ESI
    00776261 8B3481 MOV ESI,DWORD PTR DS:[ECX+EAX*4]
    00776264 8B86 10000000 MOV EAX,DWORD PTR DS:[ESI+10]
    0077626A 05 A8000000 ADD EAX,0A8
    0077626F 8B40 04 MOV EAX,DWORD PTR DS:[EAX+4]
    00776272 A8 01 TEST AL,1
    00776274 57 PUSH EDI


    with the:

    00776253 A1 84AAE800 MOV EAX,DWORD PTR DS:[E8AA84]
    00776258 64:8B0D 2C000000 MOV ECX,DWORD PTR FS:[2C]

    being the most important location.

    theres a lot of stable (non-changing) code around that spot as well.

    best,
    Cal

  6. #6
    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)
    Here's a post I made on a website for a different game that may explain dwFindPattern usage better, for those of you who aren't already acquainted with it: dwFindPattern Proof of Concept [C#] - Dark Ages Underground. You shouldn't have to register to view it.

  7. #7
    DEMON_PK's Avatar Member
    Reputation
    2
    Join Date
    Mar 2009
    Posts
    15
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please, can someone compile this code to .exe?
    I downloaded many proggrams, but can't launch code..
    I'm trying to find pointers to ObjectManager in 1.12.1 patch, for a week, but can't figure this out...please any help..
    Last edited by DEMON_PK; 05-27-2010 at 07:36 AM.

  8. #8
    XTZGZoReX's Avatar Active Member
    Reputation
    32
    Join Date
    Apr 2008
    Posts
    173
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please, can someone compile this code to .exe?
    I downloaded many proggrams, but can't launch code..
    I'm trying to find pointers to ObjectManager in 1.12.1 patch, for a week, but can't figure this out...please any help..
    notepad.exe -> new file -> paste code -> save as Program.exe -> run it

  9. #9
    DEMON_PK's Avatar Member
    Reputation
    2
    Join Date
    Mar 2009
    Posts
    15
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by XTZGZoReX View Post
    notepad.exe -> new file -> paste code -> save as Program.exe -> run it
    Thank you, but this don't work..

  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)
    I lol'd .

  11. #11
    Danne206's Avatar Contributor
    Reputation
    183
    Join Date
    Jan 2008
    Posts
    717
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DEMON_PK View Post
    Thank you, but this don't work..
    He forgot the vital part, you must append
    Code:
    #Compile -r -i -f -k
    to the program.

    Good luck.
    Welcome to this section, please read the rules *cough*
    Dahnniel [DOT] s [AT] gmail [DOT] com

  12. #12
    fish2k's Avatar Member
    Reputation
    5
    Join Date
    Nov 2008
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DEMON_PK View Post
    Thank you, but this don't work..
    You have to convert the code first. To do so you have to reverse the complete text.

    For example:
    Code:
    return dwFindPattern(hProcess, start, length, _pattern, mask, ' ');
    ist going to be
    Code:
    ;)' ' ,ksam ,nrettap_ ,htgnel ,trats ,ssecorPh(nrettaPdniFwd nruter
    This is due the fact that the stack is growing downward.

    Have fun!

  13. #13
    Xarg0's Avatar Member
    Reputation
    61
    Join Date
    Jan 2008
    Posts
    389
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bumping in a necro thread?
    I hacked 127.0.0.1

  14. #14
    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)
    Originally Posted by fish2k View Post
    You have to convert the code first. To do so you have to reverse the complete text.

    For example:
    Code:
    return dwFindPattern(hProcess, start, length, _pattern, mask, ' ');
    ist going to be
    Code:
    ;)' ' ,ksam ,nrettap_ ,htgnel ,trats ,ssecorPh(nrettaPdniFwd nruter
    This is due the fact that the stack is growing downward.

    Have fun!
    you fool thats how they do it on linux!

    On windows they use linked lists that means you need to put the -> sign between all words
    Code:
    ->return-> ->dwFindPattern(->hProcess,-> start,-> length,-> _pattern,-> mask, '  ');->

  15. #15
    DEMON_PK's Avatar Member
    Reputation
    2
    Join Date
    Mar 2009
    Posts
    15
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, but i need this 2 old offsets, and i will find it))
    Founded them using CE and hand made memory scanner...

    Thanks
    Last edited by DEMON_PK; 06-10-2010 at 12:56 AM.

Similar Threads

  1. Behind target check (proof of concept)
    By Ultraviolence in forum WoW UI, Macros and Talent Specs
    Replies: 10
    Last Post: 02-07-2013, 03:34 AM
  2. Replies: 0
    Last Post: 10-20-2011, 09:20 PM
  3. [Proof of Concept] Anti Ban
    By ashleyww in forum World of Warcraft Bots and Programs
    Replies: 24
    Last Post: 05-18-2009, 07:21 PM
  4. [help]Proof of Concept: dwFindPattern TLS
    By babodx in forum WoW Memory Editing
    Replies: 1
    Last Post: 04-21-2009, 07:26 AM
  5. [Showoff][Proof-of-Concept]WMO-Editing+Maininterface
    By Tigurius in forum World of Warcraft Model Editing
    Replies: 26
    Last Post: 01-16-2009, 01:47 AM
All times are GMT -5. The time now is 02:21 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