Network: WoW Gold | WoW Accounts | MPS Games | FPSowned
MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides
Homepage »      Register »      Hall of Fame »      Ranks And Awards »      Advertise »      Marketplace »
 
Sign up



Do you like this excellent information? Then Donate HERE to remove ads and support the MMOwned community.


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > World of Warcraft > Bots and Programs > WoW Memory Editing

WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post

Reply
 
LinkBack Thread Tools
  #1  
Old 09-19-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 2,263
Nominated 8 Times in 4 Posts
Reputation: 1087
Points: 28,359, Level: 24
Points: 28,359, Level: 24 Points: 28,359, Level: 24 Points: 28,359, Level: 24
Level up: 69%, 541 Points needed
Level up: 69% Level up: 69% Level up: 69%
Activity: 30.9%
Activity: 30.9% Activity: 30.9% Activity: 30.9%

[Release][C#]WhiteMagic - Injected .NET Helper Library

Well, since Shynd released his BlackMagic library for out of process work, I figured I'd release my own little library, for in process work.

Aptly named: WhiteMagic. (My creativity is awesome isn't it?)

Anyhow... this library is aimed towards users who inject their .NET applications into processes. It provides ways to hook/detour functions, create memory patches, find patterns (via my FindPatternSharp stuff), as well as read/write memory (basic datatypes, structs, etc).

It's released under the GPLv3 license (so you silly commercial people can't just go stealing code all willy nilly like).

The API is fairly well rounded, with only 1 class instantiation required (or omitted if you choose), and you can do pretty much everything from there.

Anyhow, I'm not releasing an example with this, because... if you don't know how to use it properly... you shouldn't be using it at all.

HOWEVER, I will answer questions based on API troubles and the like. Other than that, it's up to you to figure out.

The code is commented, and will throw more than enough exceptions to make sure you code is kept in line of requirements. (Eg; proper attributes, etc)

You can grab it here: http://dl.getdropbox.com/u/2068143/WhiteMagic.rar

Edit: Since I got a few PMs about how to actually use the Detour API, here's a quick example.
Please note, the addresses used, are from WoW. Using the proper addresses to your DXDevice should produce the same results.

Code:
using System;
using System.Runtime.InteropServices;

using WhiteMagic;

namespace ConsoleApplication1
{
    internal class Program
    {
        #region Delegates

        [UnmanagedFunctionPointer(CallingConvention.WinApi)]
        public delegate int EndSceneDelegate(IntPtr instance);

        #endregion

        private static readonly EndSceneDelegate EndSceneHandler = EndScene;

        private static readonly Magic m = new Magic();

        private static int EndScene(IntPtr instance)
        {
            // Pulse();

            return (int)m.Detours["EndScene"].CallOriginal(instance);
        }

        private static void Main(string[] args)
        {
            IntPtr endSceneAddr = m.GetObjectVtableFunction(m.Read<IntPtr>(0x0123E908, 0x397C), 42);
            m.Detours.CreateAndApply(m.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
        }
    }
}
Changes:

9/20/2009 (v0.0.1.1)
- Added x64 support. Simply build with X64 as a define.
- Added support to turn off most exceptions. Simply build with NOEXCEPTIONS as a define.
- Cleaned up some code.
- Added more documentation, etc.
- Fixed a bug in the Detour class that caused it to crash. (Forgot to set the _win32 var)
- Minor other fixes

Credits:

Major credit to Shynd, who's name I pretty much stole (from his BlackMagic lib, aimed towards out of proc editors)
kynox; being an awesome ausfag
Cypher: being a portability nazi kiwi (yes, this lib is mainly for x86, no x64 support is implied)
jjaa; a good bit of his code is used in this library, however, I've changed/rewritten a good chunk of it.
Shynd; the BlackMagic library that I used as a basis of.. well... even writing this one...
Everyone at GD; just plain awesome people.
MMOwned; 95% retarded dimwits, but some of you are awesome.
__________________
[Only registered and activated users can see links. ]

Last edited by Apoc; 09-20-2009 at 12:22 AM.
Reply With Quote


Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.

  #2  
Old 09-19-2009
~OddBall~'s Avatar
~OddBall~ is offline.
Contributor
  
 
Join Date: Jan 2008
Posts: 851
Nominated 1 Times in 1 Post
Reputation: 107
Points: 4,350, Level: 6
Points: 4,350, Level: 6 Points: 4,350, Level: 6 Points: 4,350, Level: 6
Level up: 84%, 150 Points needed
Level up: 84% Level up: 84% Level up: 84%
Activity: 8.3%
Activity: 8.3% Activity: 8.3% Activity: 8.3%

O gawd, every commercial bot is no longer safe O.o
__________________
Reply With Quote
  #3  
Old 09-19-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 2,263
Nominated 8 Times in 4 Posts
Reputation: 1087
Points: 28,359, Level: 24
Points: 28,359, Level: 24 Points: 28,359, Level: 24 Points: 28,359, Level: 24
Level up: 69%, 541 Points needed
Level up: 69% Level up: 69% Level up: 69%
Activity: 30.9%
Activity: 30.9% Activity: 30.9% Activity: 30.9%

An example since MaiN had some issues with the detour API.

This is how you can easily hook EndScene using the library:

Code:
using System;
using System.Runtime.InteropServices;

using WhiteMagic;

namespace ConsoleApplication1
{
    internal class Program
    {
        #region Delegates

        [UnmanagedFunctionPointer(CallingConvention.WinApi)]
        public delegate int EndSceneDelegate(IntPtr instance);

        #endregion

        private static readonly EndSceneDelegate EndSceneHandler = EndScene;

        private static readonly Magic m = new Magic();

        private static int EndScene(IntPtr instance)
        {
            // Pulse();

            return (int)m.Detours["EndScene"].CallOriginal(instance);
        }

        private static void Main(string[] args)
        {
            IntPtr endSceneAddr = m.GetObjectVtableFunction(m.Read<IntPtr>(0x0123E908, 0x397C), 42);
            m.Detours.CreateAndApply(m.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
        }
    }
}
__________________
[Only registered and activated users can see links. ]

Last edited by Apoc; 09-19-2009 at 04:31 AM.
Reply With Quote
  #4  
Old 09-19-2009
Nesox's Avatar
Nesox is offline.
MaiN's Biatch
Legendary User
  
 
Join Date: Mar 2007
Location: Managed Heap
Posts: 1,245
Nominated 47 Times in 4 Posts
Nominated TOTM/W Award(s): 2
Reputation: 767
Points: 48,301, Level: 33
Points: 48,301, Level: 33 Points: 48,301, Level: 33 Points: 48,301, Level: 33
Level up: 9%, 3,099 Points needed
Level up: 9% Level up: 9% Level up: 9%
Activity: 5.0%
Activity: 5.0% Activity: 5.0% Activity: 5.0%

very kewl apoc
__________________
[Only registered and activated users can see links. ]

Warrior 60 | Druid 60 | Shaman 67 | Rogue 68 | Warlock 80 | Mage 80 | Hunter 80 | Death-knight 80 | Priest 80 | Paladin 80
Reply With Quote
  #5  
Old 09-19-2009
The-Eradicator's Avatar
The-Eradicator is offline.
Contributor
  
 
Join Date: May 2007
Posts: 498
Reputation: 98
Points: 2,381, Level: 4
Points: 2,381, Level: 4 Points: 2,381, Level: 4 Points: 2,381, Level: 4
Level up: 41%, 419 Points needed
Level up: 41% Level up: 41% Level up: 41%
Activity: 25.5%
Activity: 25.5% Activity: 25.5% Activity: 25.5%

Very awesome.
__________________
Reply With Quote
  #6  
Old 09-19-2009
Viano's Avatar
Viano is offline.
Master Sergeant
  
 
Join Date: May 2008
Posts: 119
Reputation: 17
Points: 1,424, Level: 3
Points: 1,424, Level: 3 Points: 1,424, Level: 3 Points: 1,424, Level: 3
Level up: 4%, 676 Points needed
Level up: 4% Level up: 4% Level up: 4%
Activity: 4.3%
Activity: 4.3% Activity: 4.3% Activity: 4.3%

Quote:
Originally Posted by Apoc View Post
...
It's released under the GPLv3 license (so you silly commercial people can't just go stealing code all willy nilly like).
...
Thanks for this

But is the license even valid? Since there is no author or application name in there?

Code:
<program>  Copyright (C) <year>  <name of author>
__________________
Viano
Reply With Quote
  #7  
Old 09-19-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 2,263
Nominated 8 Times in 4 Posts
Reputation: 1087
Points: 28,359, Level: 24
Points: 28,359, Level: 24 Points: 28,359, Level: 24 Points: 28,359, Level: 24
Level up: 69%, 541 Points needed
Level up: 69% Level up: 69% Level up: 69%
Activity: 30.9%
Activity: 30.9% Activity: 30.9% Activity: 30.9%

Quote:
Originally Posted by Viano View Post
Thanks for this

But is the license even valid? Since there is no author or application name in there?

Code:
<program>  Copyright (C) <year>  <name of author>
The full license doesn't require those filled out. (Everything after the TOS can be omitted from the full license, I left it in for obvious reasons)

Each piece of source code has the proper license/copyright header.

Nice try though!

Also; the bit you're referring to is for terminal applications. Not a library.
__________________
[Only registered and activated users can see links. ]
Reply With Quote
  #8  
Old 09-19-2009
CimSlunt's Avatar
CimSlunt is offline.
Knight-Captain
  
 
Join Date: Nov 2008
Location: Under Your Bed!
Posts: 436
Nominated 3 Times in 1 Post
Reputation: 54
Points: 2,760, Level: 4
Points: 2,760, Level: 4 Points: 2,760, Level: 4 Points: 2,760, Level: 4
Level up: 95%, 40 Points needed
Level up: 95% Level up: 95% Level up: 95%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%


Very nice!!

i bet im one of that 5% of MMOwned thats awesome

Btw, Anyone know how to start an exe from buttonclick in vb??

Sorry to hijack Apoc
__________________
Reply With Quote
  #9  
Old 09-19-2009
FenixTX2's Avatar
FenixTX2 is offline.
Master Sergeant
  
 
Join Date: Mar 2009
Location: /
Posts: 87
Reputation: 15
Points: 750, Level: 1
Points: 750, Level: 1 Points: 750, Level: 1 Points: 750, Level: 1
Level up: 70%, 150 Points needed
Level up: 70% Level up: 70% Level up: 70%
Activity: 0.7%
Activity: 0.7% Activity: 0.7% Activity: 0.7%

Quote:
i bet im one of that 5% of MMOwned thats awesome

Btw, Anyone know how to start an exe from buttonclick in vb??
You are not awesome.
Edit: Sorry meant to add an answer. Have you tried 'shellexecute(<filename>)'?
or is that not exactly the functionality you were looking for?
__________________

Last edited by FenixTX2; 09-19-2009 at 01:35 PM.
Reply With Quote
  #10  
Old 09-19-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 2,263
Nominated 8 Times in 4 Posts
Reputation: 1087
Points: 28,359, Level: 24
Points: 28,359, Level: 24 Points: 28,359, Level: 24 Points: 28,359, Level: 24
Level up: 69%, 541 Points needed
Level up: 69% Level up: 69% Level up: 69%
Activity: 30.9%
Activity: 30.9% Activity: 30.9% Activity: 30.9%

Quote:
Originally Posted by FenixTX2 View Post


You are not awesome.
Troll: Successful.
__________________
[Only registered and activated users can see links. ]
Reply With Quote
  #11  
Old 09-19-2009
CimSlunt's Avatar
CimSlunt is offline.
Knight-Captain
  
 
Join Date: Nov 2008
Location: Under Your Bed!
Posts: 436
Nominated 3 Times in 1 Post
Reputation: 54
Points: 2,760, Level: 4
Points: 2,760, Level: 4 Points: 2,760, Level: 4 Points: 2,760, Level: 4
Level up: 95%, 40 Points needed
Level up: 95% Level up: 95% Level up: 95%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%

Quote:
Originally Posted by FenixTX2 View Post


You are not awesome.
Ok well thanks for clearing that up for me xD

One day i will be awesome!!!
__________________
Reply With Quote
  #12  
Old 09-19-2009
Robske's Avatar
Robske is offline.
Contributor
  
 
Join Date: May 2007
Location: Dragon Shores
Posts: 773
Reputation: 180
Points: 4,156, Level: 6
Points: 4,156, Level: 6 Points: 4,156, Level: 6 Points: 4,156, Level: 6
Level up: 62%, 344 Points needed
Level up: 62% Level up: 62% Level up: 62%
Activity: 6.1%
Activity: 6.1% Activity: 6.1% Activity: 6.1%

Amazing lib.

I have a design question though, seeing as every instance of the Magic class will be identical (as in, it will interact with the same process, namely itself) then why not make the entire class static? Is there a specific drawback to static classes?

"Robske, you are a moron and should gtfo and read some programming books" is a valid answer.



Also, 360 awesome people on mmowned ? (5% of 7219)
__________________
“First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack.” -(George Carrette)
Reply With Quote
  #13  
Old 09-19-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 2,263
Nominated 8 Times in 4 Posts
Reputation: 1087
Points: 28,359, Level: 24
Points: 28,359, Level: 24 Points: 28,359, Level: 24 Points: 28,359, Level: 24
Level up: 69%, 541 Points needed
Level up: 69% Level up: 69% Level up: 69%
Activity: 30.9%
Activity: 30.9% Activity: 30.9% Activity: 30.9%

Quote:
Originally Posted by Robske View Post
Amazing lib.

I have a design question though, seeing as every instance of the Magic class will be identical (as in, it will interact with the same process, namely itself) then why not make the entire class static? Is there a specific drawback to static classes?

"Robske, you are a moron and should gtfo and read some programming books" is a valid answer.



Also, 360 awesome people on mmowned ? (5% of 7219)
What happens when you inject two different applications in the same AppDomain, that use this library? You end up with 'bad' shit in memory. (Each app conflicting with eachother, etc)

You could always just use the Magic.Instance property if you so choose.

There's no specific reason to use a class instance over static classes; other than avoidance of possible bugs.
__________________
[Only registered and activated users can see links. ]
Reply With Quote
  #14  
Old 09-19-2009
MaiN is offline.
Contributor
  
 
Join Date: Sep 2006
Location: Jaedenar O.o
Posts: 645
Reputation: 171
Points: 3,537, Level: 5
Points: 3,537, Level: 5 Points: 3,537, Level: 5 Points: 3,537, Level: 5
Level up: 93%, 63 Points needed
Level up: 93% Level up: 93% Level up: 93%
Activity: 12.9%
Activity: 12.9% Activity: 12.9% Activity: 12.9%

Freaking awesome library!
__________________
Reply With Quote
  #15  
Old 09-19-2009
oliman is offline.
Private
  
 
Join Date: Jul 2009
Posts: 1
Reputation: 1
Points: 97, Level: 1
Points: 97, Level: 1 Points: 97, Level: 1 Points: 97, Level: 1
Level up: 25%, 303 Points needed
Level up: 25% Level up: 25% Level up: 25%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%

WOW, I was hoping to figure out how to hook endScene today and now I have this kick ass library to play with.

plus it's C#, holy crap!

Thanks Apoc
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



All times are GMT -4. The time now is 01:30 AM.




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523