

![]() |
![]() |
|
|||||||
![]() |
![]() |
| Code Snippets and Tutorials The place for open source releases, great information, and tutorials written by other members. |
![]() |
|
|
LinkBack | Thread Tools |
![]() |
![]() |
|
|
#21 (permalink) | |
![]() ![]() ![]() ![]() Enlightened |
So it is, I stand corrected.
__________________
Ultimate Guide/Resource/Tutorial/Book Thread
Technobabble! - My Blog About All Things Technological Quote:
|
|
|
|
|
![]() |
![]() |
| Sponsored links | |
|
Advertisement
|
|
![]() |
![]() |
|
|
#22 (permalink) |
|
Mortal
Join Date: Jun 2008
Posts: 9
![]() |
As I discovered today this is not real game state checking. The real game state checking in warcraft is stored in a class or structure that is obtained through TLS. It can tell you things like 0 - nowhere 1 - in game lobby waiting for players 3 - loading screen 4 - ingame, these are the values i've encountered so far there maybe more :P
|
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#24 (permalink) |
|
Mortal
Join Date: Jun 2008
Posts: 9
![]() |
Yes, yes I can. Basically Warcraft III 's game processing threads use a pointer in their TLS (Thread Local Storage) records at index 0x1F. Of course this pointer is 0 for your thread because TLS records are unique for each thread and this is why when you call a W3 function even with perfect parameters and stack it may crash because it won't find the needed pointer when it tries to retrieve it from your thread's TLS records at index 0x1F. There are ways ( I won't mention here but there a few ) to retrieve another thread's tls value for a given index. After you've done that you can call any function in w3 you like and also check the current game state which is stored there.
|
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#26 (permalink) |
|
Mortal
Join Date: Jun 2008
Posts: 9
![]() |
Well I couldn't figure it out either until I saw this thread -> Problems with Commanding Units which made me look into it and realise why my function calls were crashing and when I was trying to find the gamestate change function I saw where it changed the current gamestate. So it's basically Sheppard's credit that I found this in the first place :P
EDIT: Oh and it seems that TLS was introduced into warcraft III in patch 1.22 Last edited by kolkoo : 09-20-2008 at 04:33 PM. |
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#27 (permalink) | |
|
Banned
![]() ![]() Deviant Join Date: Oct 2005
Location: www.w3jsp.com
Posts: 49
![]() |
Quote:
/EDIT: You can access other Threads Local Storage with this code: Code:
__declspec(naked) DWORD GetCurrentTEB()
{
__asm
{
mov eax,fs:[0x18]
retn
}
}
DWORD WINAPI TestThread(LPVOID pParam)
{
printf("TEB of this Thread 0x%x\n", GetCurrentTEB());
bPrinted = TRUE;
while(TRUE)
Sleep(1000);
return TRUE;
}
INT main()
{
CreateThread(NULL, NULL, TestThread, 0,0,0);
while(!bPrinted)
Sleep(1);
// Enumerate all Threads in this Process ..!
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetCurrentProcessId());
THREADENTRY32 tEntry;
tEntry.dwSize = sizeof(tEntry);
if(Thread32First(hSnap, &tEntry))
do {
if(tEntry.th32OwnerProcessID != GetCurrentProcessId())
continue;
HANDLE hThreadHandle = OpenThread(THREAD_ALL_ACCESS, FALSE, tEntry.th32ThreadID);
if(hThreadHandle == INVALID_HANDLE_VALUE)
continue;
printf("Thread-Id 0x%x, TEB 0x%x\n", tEntry.th32ThreadID, GetTEBFromThread(hThreadHandle));
} while(Thread32Next(hSnap, &tEntry));
CloseHandle(hSnap);
return NULL;
}
TEB* GetTEBFromThread(HANDLE hThread)
{
pfnNtQueryInformationThread NtQueryInformationThread = (pfnNtQueryInformationThread) GetProcAddress(LoadLibrary("ntdll.dll"), "NtQueryInformationThread");
THREAD_BASIC_INFORMATION tbi;
THREAD_INFORMATION_CLASS tic = ThreadBasicInformation;
if (NtQueryInformationThread == NULL)
return NULL;
if (NtQueryInformationThread(hThread, tic, &tbi, sizeof(tbi), NULL) == NULL)
return (TEB*)tbi.TebBaseAddress;
return NULL;
}
Last edited by Sheppard : 09-24-2008 at 03:40 PM. |
|
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#28 (permalink) |
|
Mortal
Join Date: Jun 2008
Posts: 9
![]() |
Well this is how I get the TLS Index and Value from W3.
Code:
DWORD GetIndex()
{
return *(DWORD*)(0x6FAA45E4);
}
DWORD GetW3TlsForIndex(DWORD index)
{
DWORD pid = GetCurrentProcessId();
THREADENTRY32 te32;
HANDLE hSnap=CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, pid );
te32.dwSize = sizeof(THREADENTRY32);
if ( Thread32First( hSnap, &te32 ) )
{
do
{
if ( te32.th32OwnerProcessID == pid )
{
HANDLE hThread = OpenThread( THREAD_ALL_ACCESS, false, te32.th32ThreadID );
CONTEXT ctx = { CONTEXT_SEGMENTS };
LDT_ENTRY ldt;
GetThreadContext( hThread, &ctx );
GetThreadSelectorEntry( hThread, ctx.SegFs, &ldt );
DWORD dwThreadBase = ldt.BaseLow|(ldt.HighWord.Bytes.BaseMid<<16)|(ldt.HighWord.Bytes.BaseHi<<24);
CloseHandle( hThread );
if ( dwThreadBase == NULL )
continue;
DWORD *dwTLS = *(DWORD**)(dwThreadBase+0xE10+4*index);
printf("Thread: %X , TLS for index %X : %X\n",te32.th32ThreadID,index,(DWORD)dwTLS);
if ( dwTLS == NULL )
continue;
return (DWORD)dwTLS;
}
} while( Thread32Next( hSnap, &te32 ) );
}
return NULL;
}
Code:
DWORD GetGameStateValue()
{
DWORD rt;
__asm
{
MOV ESI,0x0D;
MOV EAX,TlsValue;
MOV EAX, DWORD PTR DS:[EAX+ESI*4];
MOV EAX,DWORD PTR DS:[EAX+0x10]
MOV ECX,DWORD PTR DS:[EAX+0x8]
MOV EAX, DWORD PTR DS:[ECX+0x278];
MOV rt,EAX;
}
return rt;
}
And what made me think it wasn't used prior to patch 1.22 is that I didn't find any calls to TlsGetValue/TlsSetValue in 1.21b game.dll intermodular calls. |
|
|
|
![]() |
![]() |
![]() |
![]() |
|
|
#29 (permalink) | |
![]() Heretic Join Date: Aug 2008
Posts: 21
![]() |
If anyone is interested, here is a simple program (c++) I wrote to check if you're in game or not using Rufus' offset:
Quote:
Last edited by GayPimp : 11-29-2008 at 06:54 AM. |
|
|
|
|
![]() |
![]() |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Game State Checking in mASM | Perma | Starcraft Hacking Related | 32 | 06-08-2005 12:45 PM |
| Gameboy Advance, agian. | Element | General Gaming | 1 | 05-18-2005 07:26 AM |
| Lobby Ops Address....... | ~*^CuLo^*~ | Starcraft Hacking Related | 22 | 12-18-2004 08:46 PM |
| D2 Rollbacking | Dr. Silence | General Chat | 6 | 10-01-2004 07:42 AM |
| All times are GMT. The time now is 01:55 AM. |

