MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides - Powered by vBulletin
Donate to remove ads, get special access and support the community!
+ Reply to Thread
Results 1 to 10 of 10
  1. #1

    Corporal
    Join Date: Jan 2008
    Location: Czech Republic
    Posts: 29
    Rep: 5
    Cash: 600

    Delphi source for TLS

    Donate to remove ads, get special forum and shoutbawx access
    My first attempt on TLS, based on WoW.DeV • View topic - Proof of concept code - WoW memory reading

    Hunt for TLS_INDEX by Chazvazza :
    Quote Originally Posted by Chazwazza
    Hunt it down every patch, but it's easy to find. Open up WoW with IDA and type in "TlsIndex" in the "Names" window. Double click the variable to follow it to its location, then copy the offset it's stored at. Takes a total of about 3 seconds.
    .. yes IDA is powerfull toy

    Code:
    unit MemoryReader;
    
    interface
    
    uses Windows,
         JwaNative, JwaWinBase,JwaWinType, JwaWinNT,
         PCex, tlhelp32;
    
    type TPlayerData = record
            HP, MaxHP : dword;
            SP, MaxSP : dword;
            x, y, z : single;
            HROT, VROT : single;
            Target : Int64;
         end;
    
    type  TPlayerInfo = record
             PlayerBase : dword;
             ptrPlayerX : dword;
             ptrPlayerY : dword;
             ptrPlayerZ : dword;
             ptrPLayerHROT : dword;
             ptrPLayerVROT : dword;
    
          end;
    
    var
        FWoWProcessHandle : THandle;
        FWoWWindowHandle : THandle;
        FWoWProcessID : THandle;
    
        FPtrObjectBase : dword;
        FPlayerGUID : Int64;
    
        FPlayerInfo : TPlayerInfo;
        FPlayerData : TPlayerData;
    
    function CaptureWow: boolean;
    function GetWoWBaseInfo : boolean;
    function GetPlayerInfo : boolean;
    function GetPlayerData : boolean;
    
    implementation
    
    
    type
          TWoWObject = record
              DontCare1: Integer;
              DontCare2: Integer;
              UnitData: Integer;
              DontCare4: Integer;
              DontCare5: Integer;
            ObjectType: Integer;
              DontCare7: Integer;
              DontCare8: Integer;
              DontCare9: Integer;
              DontCare10: Integer;
              DontCare11: Integer;
              DontCare12: Integer;
            GUID: Int64;
              DontCare13: Integer;
              NextPtr: Integer;
          end;
    
    function CaptureWow;
    begin
      Result := false;
      NTSetPrivilege(SE_DEBUG_NAME,True);
      FWoWWindowHandle := FindWindow(nil,'World of Warcraft');
    
      if isWindow(FWoWWindowHandle) then
      begin
        GetWindowThreadProcessID(FWoWWindowHandle, @FWoWProcessID);
        if FWoWProcessID = 0 then Exit
        else
        begin
          FWoWProcessHandle := OpenProcess(PROCESS_ALL_ACCESS,False, FWoWProcessID);
          if FWowProcessHandle = 0 then Exit;
          Result := true;
        end;
      end
      else Exit;
    end;
    
    
    
    function GetWoWBaseInfo: Boolean;
    const
      TLS_INDEX: Pointer = Pointer();
    
    var
      // TLS stuff
      TLS_Slot: DWord;
      TLS_Offset: DWord;
      TargetTLS_Slot: DWord;
    
      // Threads
      ThreadHandle: Integer;
      ThreadEntry: TThreadEntry32;
      ThreadQueryResult: DWord;
      BytesRead: DWord;
    
    
      SnapHandle: THandle;
    
    
      BasicInformation: TThreadBasicInformation;
      BaseObjectPtr: DWord;
      TmpPointer : Dword;
    
    
    
    
    
    begin
    
      FPtrObjectBase := 0;
      FPlayerGUID := 0;
      Result := false;
    
      // find TLS_Slot
      if not ReadProcessMemory(FWoWProcessHandle, TLS_INDEX, @TLS_Slot,
                               SizeOf(TLS_Slot), @BytesRead)
      then Exit;
    
    
      SnapHandle := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
    
      if (SnapHandle <> INVALID_HANDLE_VALUE) then
      begin
        ThreadEntry.dwSize := SizeOf(ThreadEntry);
    
        // Search all threads
        if (Thread32First(SnapHandle, ThreadEntry)) then
        repeat
          try
            // Choose WoW threads
            if ThreadEntry.th32OwnerProcessID = FWoWProcessID then
            begin
    
              ThreadHandle := OpenThread(THREAD_QUERY_INFORMATION, False, ThreadEntry.th32ThreadID);
              Sleep(100);
    
              if ThreadHandle <> 0 then
              try
                // Look for information about thread
                ThreadQueryResult := NtQueryInformationThread(ThreadHandle, THREADBASICINFORMATION,
                  @BasicInformation, SizeOf(BasicInformation), @BytesRead);
    
    
                if ThreadQueryResult = 0 then
                begin
    
                  TmpPointer := Cardinal(BasicInformation.TebBaseAddress);
                  TmpPointer := TmpPointer + $2C;
    
                  if not ReadProcessMemory(FWoWProcessHandle, Pointer(TmpPointer), @TLS_Offset,
                        SizeOf(TLS_Offset), @BytesRead) then
                    Continue;
    
                  if (TLS_Offset <> 0) then
                  begin
                    if not ReadProcessMemory(FWoWProcessHandle,
                            Pointer(TLS_Offset + (TLS_Slot * 4)), @TargetTLS_Slot,
                            SizeOf(TargetTLS_Slot), @BytesRead) then
                      Continue;
    
                    if not ReadProcessMemory(FWoWProcessHandle,
                              Pointer(TargetTLS_Slot + 8), @BaseObjectPtr,
                              SizeOf(BaseObjectPtr), @BytesRead) then
                      Continue;
    
                    if not ReadProcessMemory(FWoWProcessHandle,
                              Pointer(TargetTLS_Slot + 16), @FPlayerGUID, SizeOf(GUID),
                              @BytesRead) then
                      Continue;
    
                    if (BaseObjectPtr <> 0) then
                    begin
                      FPtrObjectBase := BaseObjectPtr;
                      Result := True;
                      Exit;
                    end;
                  end;
                end;
              finally
                CloseHandle(ThreadHandle);
              end;
            end;
          finally
           ThreadEntry.dwSize := SizeOf(ThreadEntry);
          end;
        until (not Thread32Next(SnapHandle, ThreadEntry));
      end;
    
      CloseHandle(SnapHandle);
      CloseHandle(FWoWProcessHandle);
    end;
    
    
    function GetPlayerInfo :boolean;
    var ObjectPointer : dword;
        CurrentObject : Dword;
        BytesRead : DWord;
        WoWObject : TWoWObject;
    
    begin
    
      Result := false;
      ObjectPointer := FPtrObjectBase + ;
    
      if not ReadProcessMemory(FWoWProcessHandle, Ptr(ObjectPointer), @CurrentObject,
                               SizeOf(CurrentObject), @BytesRead) then Exit;
    
    
      while (CurrentObject <> 0) and (Integer(CurrentObject) and 1 = 0) and (Integer(CurrentObject) <> $1c) do
      begin
    
        if not ReadProcessMemory(FWoWProcessHandle, Ptr(CurrentObject), @WoWObject,
                               SizeOf(TWowObject), @BytesRead) then Exit;
    
    
        if (WoWObject.GUID = FPlayerGUID) then
        begin
    
          with FPlayerInfo do
          begin
            PlayerBase := CurrentObject;
            ptrPlayerX := PlayerBase + ;
            ptrPlayerY := PlayerBase + ;
            ptrPlayerZ := PlayerBase + ;
    
            ptrPlayerHROT := PlayerBase + ;
            ptrPlayerVROT := PlayerBase + ;
          end;
    
        Result := true;
    
        end;
    
        CurrentObject := WoWObject.NextPtr;
      end;
    
    end;
    
    
    function GetPlayerData;
    var dword_var : dword;
        single_var : single;
        guid_var : int64;
        BytesRead : dword;
        ptrTmp : dword;
    
    begin
     Result := false;
    
     // coords
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.ptrPlayerX)  ,
                          @single_var, 4, @BytesRead)) then Exit;
    
     FPlayerData.X := single_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.ptrPlayerY)  ,
                          @single_var, 4, @BytesRead)) then Exit;
    
     FPlayerData.Y := single_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.ptrPlayerZ)  ,
                          @single_var, 4, @BytesRead)) then Exit;
    
     FPlayerData.Z := single_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.ptrPlayerHROT)  ,
                          @single_var, 4, @BytesRead)) then Exit;
    
     FPlayerData.HROT := single_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.ptrPlayerVROT)  ,
                          @single_var, 4, @BytesRead)) then Exit;
    
     FPlayerData.VROT := single_var;
    
      // staty
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(FPlayerInfo.PlayerBase + $08)  ,
                          @ptrTmp, 4, @BytesRead)) then Exit;
    
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(ptrTmp + $5C)  ,
                          @dword_var, 4, @BytesRead)) then Exit;
    
     FplayerData.SP := dword_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(ptrTmp + $74)  ,
                          @dword_var, 4, @BytesRead)) then Exit;
    
     FplayerData.MaxSP := dword_var;
    
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(ptrTmp + $58)  ,
                          @dword_var, 4, @BytesRead)) then Exit;
    
     FplayerData.HP := dword_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(ptrTmp + $70)  ,
                          @dword_var, 4, @BytesRead)) then Exit;
    
     FplayerData.MaxHP := dword_var;
    
     if not (ReadProcessMemory(FWoWProcessHandle, Ptr(ptrTmp + $40)  ,
                          @guid_var, SizeOf(Int64), @BytesRead)) then Exit;
    
     FplayerData.Target := guid_var;
    
     Result := true;
    end;
    
    end.
    To be continued ...
    Last edited by radegast; 02-09-2008 at 09:20 PM.

  2. #2

    Knight-Lieutenant

    Join Date: Jan 2008
    Location: South Pole
    Posts: 376
    Rep: 60
    Cash: 600
    I've got a question, why do you delphi guys always write data to buffers instead of building a function that returns a value?
    It's always better to have your function return some values than writing them to a buffer, because It'll make your functions easier to understand and it'll help other people to port the hole stuff into another programming language, since references and pointer symbols are different in every programming language.

    Ps: Delphi sucks please start using another language and this code looks alot like greymans proof of concept code, so I can't give you +rep sorry.
    I hacked 127.0.0.1

  3. #3

    Corporal
    Join Date: Jan 2008
    Location: Czech Republic
    Posts: 29
    Rep: 5
    Cash: 600
    heh ... your Delphi phobia is imba
    And yes, it's based on Greyman's code, as I wrote above. His code didn't work, it's only proof-of-concept .. try to compile it
    And +rep .. heh, I don't need your +rep

  4. #4

    Knight-Lieutenant

    Join Date: Jan 2008
    Location: South Pole
    Posts: 376
    Rep: 60
    Cash: 600
    I can't compile delphi code that's why I hate it so much :P
    I hacked 127.0.0.1

  5. #5

    Corporal
    Join Date: Jan 2008
    Location: Czech Republic
    Posts: 29
    Rep: 5
    Cash: 600
    I wrote the code in my first post again. Now it reads some info about player character .. all done from TLS, no static adresses excluding TLS slot ...

  6. #6

    Sergeant
    Join Date: Nov 2007
    Posts: 38
    Rep: 13
    Cash: 600
    ok, i must be an idiot, can`t get the example file to compile, can someone send me the file in a project(zip) or link a download location. i always have problems with copying code from the website.

    Thanks.

  7. #7

    Contributor

    Join Date: Apr 2006
    Posts: 1,608
    Rep: 232
    Cash: 90
    Quote Originally Posted by unknwon View Post
    ok, i must be an idiot, can`t get the example file to compile, can someone send me the file in a project(zip) or link a download location. i always have problems with copying code from the website.

    Thanks.
    probably because you arnt using a compiler for the actual launguage. There is no one compiler for everything (to my knowledge). Also, you may be missing some of the headers. Trying looking through them to see if they included any headers that arnt standard (which means they probably made or leeched them).

  8. #8

    Sergeant
    Join Date: Nov 2007
    Posts: 38
    Rep: 13
    Cash: 600
    found the problem, i was missing the jedi addon for delphi. After installing the jedi addon for delphi i was able to compile the source.

    Strange, it only works with 2.3.3 (live servers) 2.3.2 (private) loads but never shows any mobs. Both versions use the same TLS_SLOT. Very strange.

    does anyone have a complete list of the WOW Objects, trying to change my WoW Radar program from pointers/offsets to use TLS

  9. #9

    Corporal
    Join Date: Jan 2008
    Location: Czech Republic
    Posts: 29
    Rep: 5
    Cash: 600
    hm, i looked at my source code, and I saw the numbers with $ are missing, maybe it's impossible include it into code section here in forum... i'll try to fix it, when i come home ...
    BUT : if you use my code, it ONLY shows player's info !!! No mobs, no gameobjects ... because of
    Code:
     if (WoWObject.GUID = FPlayerGUID) then
        begin
    ...
    Read the code, don't Copy&Paste and compile ;-) Now you can simply modify my code and voila, it shows all gameobjects for you now ;-)
    Last edited by radegast; 03-21-2008 at 12:35 PM.

  10. #10

    Sergeant
    Join Date: Nov 2007
    Posts: 38
    Rep: 13
    Cash: 600
    ok, got it working..thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Go to the top of the page

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