This is an simple code wich makes lighthack .
This code is not created by me.
Updated to 8.00
This code is not created by me.
Updated to 8.00
Code:
#include <windows.h>
#include <iostream> // ONLY needed if you for some reason would want to use the std::cout inside main()
// Tibia 8.00
#define Battlelist 0x0060EB30 // Id first
#define BL_ENTRYSIZE 160
#define BL_ARRAYSIZE 150
#define PlayerID 0x0060EAD0
HANDLE hProcess;
HWND T_hWnd;
// If a tibia client is running this function will return true
bool IsTibiaRunning()
{
T_hWnd = FindWindow( "tibiaclient", NULL ); // Retrieves a handle to Tibia.exe
DWORD procid;
GetWindowThreadProcessId( T_hWnd, &procid ); // We use the Tibia.exe handle to get the process id
hProcess = OpenProcess( PROCESS_ALL_ACCESS, false, procid ); // We use the process id to open a handle in our program which will give us access to edit Tibias memory
if ( !hProcess || !T_hWnd )
return false;
return true;
}
// Reads x bytes from the memory and return it as an integer
int ReadMemoryByte( int Address, int iByte )
{
int iValue = 0;
// We use our process handle (hProcess) to make sure we read from the correct process
ReadProcessMemory( hProcess, (LPVOID)Address, &iValue, iByte, NULL ); // We will read iByte amount of bytes and store the bytes in iValue and then return it
return iValue;
}
// Function writes x amount of bytes in Tibias memory at the given address and returns the amount of bytes successfully written. An error will return 0
int WriteMemoryInt( int Address, int nValue, int nByte )
{
return WriteProcessMemory( hProcess, (LPVOID)Address, &nValue, nByte, NULL );
}
int LocatePlayer()
{
int nPlayerID = ReadMemoryByte( PlayerID, 4 ); // Read our player id from tibias memory
for ( int i = 0; i < BL_ARRAYSIZE; i++ ) { // Loop through the entire battle list (150 structs in the array)
int nSearchID = Battlelist + (i*BL_ENTRYSIZE); // Simple mathematics, we take the address to the battle list and adds i (i goes from 0-149 as there are only 150 structs in the array) and multiplies it with the number of bytes there are in the array and we will have jumped exactly 160 bytes further in the memory
int nID = ReadMemoryByte( nSearchID, 4 ); // We then read the current player/monster id from the battle list
if ( nPlayerID == nID ) // We compare if the id we just read compare with our player id
return i; // If it success we will return the position (0-149) that we found ourselves
}
return -1; // If we couldn't find ourselves we return -1 as an error statement
}
// This function will return true if it successfully changes the light of the tibia client
bool DoLight( int nPos, int Size, int Color ) // The function takes 3 parameters, battle list position, light size and light color
{
int nSizeDist = 120; // Battlelist + ( i * BL_ENTRYSIZE ) + 120 equals the address of the light size
int nColorDist = 124; // Another 4 bytes after that we can find the light color
if ( WriteMemoryInt( nPos + nSizeDist, Size, 1 ) != 0 ) // First we change the size to whatever was requested
if ( WriteMemoryInt( nPos + nColorDist, Color, 1 ) != 0 ) // Then we change the color
return true; // And if everything went well, we return true
return false;
}
int main()
{
if ( IsTibiaRunning() ) { // First we make sure tibia is running and set T_hWnd and hProcess to what's needed
int nTemp = LocatePlayer(); // Secondly we locate ourself and store our position in the battle list in nTemp
if ( nTemp != -1 ) { // We make sure that we were actually found
int BL_Position = Battlelist + (nTemp*BL_ENTRYSIZE); // Basic mathematics again, Battlelist address + (our_bl_position*number_of_bytes_per_creature_in_battlelist)
if ( DoLight( BL_Position, 20, 206 ) ) // Here we actually change the light, 20 will give full light (I think some lower such as 15 also will but I can't say what does what atm) and I think 206 is the default color in tibia
std::cout << "Full light activated."; // If you'd actually want to use this row you must include <iostream>
}
}
CloseHandle( hProcess ); // Last but not least we close the handle our program created to Tibia.exe
}