Little Fighter Empire - Forums
LF2 Data Structures Reverse Engineered (C++ header) - Printable Version

+- Little Fighter Empire - Forums (https://lf-empire.de/forum)
+-- Forum: General Zone (https://lf-empire.de/forum/forumdisplay.php?fid=23)
+--- Forum: Programming (https://lf-empire.de/forum/forumdisplay.php?fid=50)
+--- Thread: LF2 Data Structures Reverse Engineered (C++ header) (/showthread.php?tid=8003)



LF2 Data Structures Reverse Engineered (C++ header) - Boop - 06-27-2012

    C-Code:
#ifndef CGAME_H
#define CGAME_H
 
 
struct sOpoint
{
	int kind;
	int x;
	int y;
	int action;
	int dvx;
	int dvy;
	int oid;
	int facing;
};
 
struct sBpoint
{
	int x;
	int y;
};
 
struct sCpoint
{
	int kind;
	int x;
	int y;
	int injury; //if its kind 2 this is fronthurtact
	int cover; // if its kind 2 this is backhurtact
	int vaction;
	int aaction;
	int jaction;
	int daction;
	int throwx;
	int throwy;
	int hurtable;
	int decrease;
	int dircontrol;
	int taction;
	int throwinjury;
	int throwz;
};
 
struct sWpoint
{
	int kind;
	int x;
	int y;
	int weaponact;
	int attacking;
	int cover;
	int dvx;
	int dvy;
	int dvz;
};
 
typedef struct 
{
	int kind;
	int x;
	int y;
	int w;
	int h;
	int dvx;
	int dvy;
	int fall;
	int arest;
	int vrest;
	int unknown1;
	int effect;
	int unknown2;
	int unknown3;
	int unknown4;
	int unknown5;
	int bdefend;
	int injury;
	int zwidth;
	int unknown6;
} sItr;
 
typedef struct 
{
	int kind;
	int x;
	int y;
	int w;
	int h;
	int unknown1;
	int unknown2;
	int unknown3;
	int unknown4;
	int unknown5;
} sBdy;
 
typedef struct
{
	int exists; 
	int pic; 
	int state; 
	int wait; 
	int next; 
	int dvx; 
	int dvy; 
	int dvz; 
	int unknown1; 
	int hit_a; 
	int hit_d; 
	int hit_j; 
	int hit_Fa; 
	int hit_Ua; 
	int hit_Da; 
	int hit_Fj; 
	int hit_Uj; 
	int hit_Dj;
	int hit_ja;
	int mp;	 
	int centerx; 
	int centery; 
	struct sOpoint opoint; 
	int unknown2; 
	int unknown3; 
	struct sBpoint bpoint; 
	struct sCpoint cpoint;
	int unknown4; 
	int unknown5; 
	int unknown6; 
	struct sWpoint wpoint;
	int unknown7; 
	int unknown8; 
	int unknown9; 
	int unknown10; 
	int unknown11; 
	int unknown12; 
	int unknown13; 
	int unknown14; 
	int unknown15; 
	int unknown16;
	int unknown17; 
	int numOfItr;
	int numOfBdy; 
	//vv these should be pointers to arrays or something... i dono
	sItr *pItr; 
	sBdy *pBdy; 
	//vv these values are deprecated i think
	int itr_x; 
	int itr_y; 
	int itr_w; 
	int itr_h; 
	int bdy_x;
	int bdy_y; 
	int bdy_w; 
	int bdy_h; 
	//----------------------------------------
	int unknown18;
	char fname[20];
	char (*pSoundFile)[20]; // maximum sound path is unknown actually
	int unknown20;
} sFrame;
 
class CDataFile
{
public:
	int walking_frame_rate;
	char unknwn1[16];
	double walking_speed;
	double walking_speedz;
	int running_frame_rate;
	double running_speed;
	double running_speedz;
	double heavy_walking_speed;
	double heavy_walking_speedz;
	double heavy_running_speed;
	double heavy_running_speedz;
	double jump_height;
	double jump_distance;
	double jump_distancez;
	double dash_height;
	double dash_distance;
	double dash_distancez;
	double rowing_height;
	double rowing_distance;
	int weapon_hp;
	int weapon_drop_hurt;
	char unkwn2[1612];
	int id;
	int type;
	int unkwn3;
	int head; //probably pointers
	char derp; // probably pointers
	char unkwn4[159];
	sFrame frames[400];
};
 
 
class CObject
{
public:
	int umkwn1;
	int unkwn2;
	int invincible;
	int unkwn3;
	int x;
	int y;
	int z;
	char unkwn4[12];
	double x_accel;
	double y_accel;
	double z_accel;
	double x_vel;
	double y_vel;
	double z_vel;
	double x_real;
	double y_real;
	double z_real;
	int frame;
	int frame2;
	int frame3;
	int frame4;
	char facing;
	char unkwn5[15];
	int cpoint_catcher;
	int cpoint_timer;
	int weapon_type;
	int weapon_held_num;
	int unknown6;
	int something;
	char unkwn7[12];
	int fall;
	int shaking;
	int bdefend;
	char unkwn8[10];
	char holding_up;
	char holding_down;
	char holding_left;
	char holding_right;
	char holding_A;
	char holding_J;
	char holding_D;
	char up;
	char down;
	char left;
	char right;
	char A;
	char J;
	char D;
	char DrA;
	char DlA;
	char DuA;
	char DdA;
	char DrJ;
	char DlJ;
	char DuJ;
	char DdJ;
	char DJA;
	char unkwn9[14];
	int arest;
	int vrest;
	char unkwn10[396];
	int attacked_object_num;
	char unkwn11[116];
	int clone;
	int unkwn12;
	int hp;
	int dark_hP;
	int max_hp;
	int mp;
	int reserve;
	int unkwn13;
	int unkwn14;
	int pic_gain;
	int bottle_hp;
	char unkwn15[24];
	int firzen_counter;
	int unkwn16;
	int armour_multiplier;
	int unkwn17;
	int total_attack;
	char unkwn18[24];
	int enemy;
	int team;
	CDataFile *dataFile;
};
 
class CBackground
{
public:
	int width; //0x0
	int zwidth1; //0x4
	int zwdith2; // 0x8
	int perspective1; //0xC
	int perspective2; //0x10
	int shadow1; //0x14
	int shadow2; //0x18
	int layerCount; //0x1c
	char layer_BMPs[30][30]; //0x20
	char shadowBMP[30]; //0x3a4
	char name[30]; //0x3c2
	int transparency[30]; //0x3e0
	int layer_width[30]; // 0x458
	int layer_x[30]; // 0x4d0
	int layer_y[30]; // 0x548
	int layer_height[30]; // 0x5c0
	char derp[856];
};
 
class CFileManager
{
public:
	CDataFile *dataFiles[500];
	char IDONTEVENOMGWHATISTHISAHHHHHHH[81024480];
	CBackground backgroudns[50];
};
 
class CGame
{
public:
	int state; // 0x4
	char exists[400]; // 0x194
	CObject *objects[400]; // 0x7d4
	CFileManager *manager; //FA4
};
 
#endif


I give you all the lf2 data structures! Just put
    C-Code:
CGame *game = (CGame*)0x458B00;
(that's for 2.0 not sure about others) and you have access to all the known lf2 objects etc.

You need to exist in lf2 memory space for this to work, so you either need to inject a dll with an injector(like the realtime data changer used), have an exe that is modified to load a dll (this is how the dll framework worked) or use a directdraw wrapper (like the AI dll worked).

This makes working with lf2 a lot easier. Instead of doing things like

    C-Code:
state = *(int*)(*(int*)(*(int*)(0x458C94+object_num*4)+0x368)+frame_num*0x178+0x7ac);


you can do

    C-Code:
game->objects[object_num]->dataFile->frames[frame_num].state;


Basically you don't need to know all these random numbers and stuff any more


RE: LF2 Data Structures Reverse Engineered (C++ header) - blow_fly98 - 06-28-2012

More info >>here<<. (Click on "Go to spreadsheet view" at the top if you have stuff to contribute.)


RE: LF2 Data Structures Reverse Engineered (C++ header) - Boop - 07-03-2012

    C-Code:
#include "stdafx.h"
#include "lf2.h"
 
using namespace std;
 
template <class tType> tType __fastcall ReadMemoryType(HANDLE hProcess, void* pLocaton)
{
	tType pType = {0};
	ReadProcessMemory(hProcess,pLocaton,&pType,sizeof(tType),NULL);
	return pType;
}
 
template <class tType> BOOL __fastcall WriteMemoryType(HANDLE hProcess,tType* pType ,void* pLocaton)
{
	return WriteProcessMemory(hProcess,pLocaton,pType,sizeof(tType),NULL);
}
 
BOOL __fastcall GetProcessID(char* szWndName, unsigned long* pPID)
{
	HWND hWnd = FindWindowA(szWndName,NULL);
	if(hWnd != NULL) 
		if(GetWindowThreadProcessId(hWnd,pPID)) 
			return TRUE;
 
	return FALSE;
}
 
HANDLE __fastcall GetLF2Process()
{
	DWORD dwPID;
	if(!GetProcessID("Marti",&dwPID))
	{
		cerr << "DERP" << endl;
		return NULL;
	}
 
	HANDLE hToken;
	LUID pLUID;
	TOKEN_PRIVILEGES pTokenPrivileges;
	if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
		return NULL;
 
	if(LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&pLUID))
	{
		pTokenPrivileges.PrivilegeCount = 1;
		pTokenPrivileges.Privileges[0].Luid = pLUID;
		pTokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
		AdjustTokenPrivileges(hToken,FALSE,&pTokenPrivileges,sizeof(pTokenPrivileges),NULL,NULL);
	}
 
	CloseHandle(hToken);   
	return OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_QUERY_INFORMATION|PROCESS_VM_WRITE,FALSE,dwPID);   
}
 
int main(int argc, char* argv[])
{
	HANDLE hProcess = GetLF2Process();
	if(hProcess == NULL)
	{
		system("pause");
		return 0;      
	}
 
	void* pDataFiles = ReadMemoryType<void*>(hProcess,(void*)0x4592D4);
 
	cout << hex << pDataFiles << endl;
	if(pDataFiles == NULL)
	{
		cerr << "LF2 Not Loaded" << endl;
		system("pause");
		return 0;      
	}
 
	void* pDataFile = ReadMemoryType<void*>(hProcess,(void*)pDataFiles); // + 0x4 * datafileNum
	CDataFile dataFile = ReadMemoryType<CDataFile>(hProcess,(void*)pDataFile);
 
	cout << dataFile.walking_frame_rate <<endl;
	dataFile.walking_frame_rate = 5;
 
	//Stupid testing yaybecaus
 
	WriteMemoryType<CDataFile>(hProcess,&dataFile,(void*)pDataFile);
	dataFile = ReadMemoryType<CDataFile>(hProcess,(void*)pDataFile);
	cout << dataFile.walking_frame_rate <<endl;
 
	system("pause");
	return EXIT_SUCCESS;
}


Some external frame data reading ;) (as in you don't have to exist in lf2's memory).