HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

World Editor specs - internals disassembled

03-08-2010, 03:29 AM#1
midiway
I'm releasing here a particular header file which contains spec information of the internal data structures formats plus some functions offsets used inside World Editor binary.

It is incomplete and badly formated, I just want to see if it might be of someone interest so I could expand and give it a better look.

My interest was in reading each triggers of the currently open map, so with this header and knowing how to read a process memory you can have access to the triggers content found in the Trigger Editor.


What follows is a c++ header file compiled with disassembling technics against we.exe:

Code:
#pragma once
#pragma warning(disable : 4200)


#define DWORD_FILL(byte_size)								\
	struct {												\
		JOIN(DWORD fill_gap, __LINE__)						\
		[(byte_size)/sizeof(DWORD)];						\
	};

// File/folders
const TCHAR cDLL_LOCALSTORM[]		= L"Storm.dll";
const TCHAR cDLL_LOCALGAME[]		= L"game.dll";


// Patch version
enum ePatchVersion { v_21, v_24 };
const TCHAR cPATCH_QUERY_21[]		= L"";  //newgen version is not the same from game.dll so this check is useless
const TCHAR cPATCH_QUERY_24[]		= L"1, 24, 2, 6378";


// Internal definitions
const TCHAR cEDITOR_WNDPROP[]		= L"OsGuiPointer";


// Internal structs
struct sEditorState;
struct sMapScript;
struct sMapInfo;
struct sTriggerTable;
struct sICATable;
struct sStub;


//// Trigger content

struct sICAData
{
	DWORD_FILL(0x20);
};

struct sCategData
{
	UINT ncateg;
	CHAR categname[0x100];

	DWORD_FILL(0x8);
	sStub* stub;
	BOOL needsave;
	DWORD d1;
	BOOL type;
	DWORD_FILL(0x10);

	BOOL trgtablegrow;
	BOOL nchieldtrgs;
	sTriggerTable* trgtableoff;
	DWORD_FILL(0x8);
};

struct sTriggerData
{
	sStub* vtable;
	BOOL b0;			//always 0?

	UINT ICAtablesize;	//grow in multiple of 2 (1..2..4..8..)
	UINT numICA;
	sICATable* ICAs;	//guessed

	BOOL b1;			//always 0?
	BOOL type;			//TRUE - trigger is comment		FALSE - not comment
	UINT u1;			//big value or 0
	BOOL enabled;
	BOOL inimode;		//GUI only		FALSE - Initialy on   TRUE - Initialy off
	BOOL customtxt;		//TRUE - has custom text	FALSE - GUI trigger
	BOOL initrun;		//JASS only		so doesnt apply to GUI triggers when it has "Map Initialization" event

	UINT scriptbuffsize;//grows in a strange manner
	UINT scripttextsize;
	CHAR* scripttext;

	UINT u2;	//0 or 256
	INT i1;		//0xFF or 0x282
	INT i2;		//0xFF or 0x282

	sMapScript* mapscript;
	CHAR triggername[0x100 + 0x4];
	sCategData* categ;

	CHAR desc[0x800];
};

struct sICATable
{
	sICAData* entry[0];
};

struct sCategTable
{
	sCategData* entry[0];
};

struct sTriggerTable
{
	sTriggerData* entry[0];
};

struct sMapScript
{
	DWORD trgtablesize;		//when numtriggers is > trgtablesize, tablesize will be increased in chunks of 64 to acomodate this new trigger, or multiplied by 2 if it doesnt pass 64. When map is loaded tablesize==numtriggers and so is its valid size
	DWORD numtriggers;
	sTriggerTable* trigs;
	DWORD trgtablegrow;		//when table growing should start growing in chuncks, so not in multiple of 2, this will be 64

	DWORD categtablesize;	//same growing behavior as trgtablesize
	DWORD numcateg;
	sCategTable* categs;
	DWORD categtablegrow;	//same behavior as trgtablegrow

	sStub* stub1;
	sStub* stub2;
	sStub* stub3;
	sMapInfo* mapinfo;
	DWORD zero2;
	CHAR customcomment[0x800];

	DWORD customscriptbuffsize;
	DWORD customscripttextsize;
	CHAR* customscript;
};


//// Map loaded

struct sMapInfo
{
	UINT mapversion;
	UINT editorversion;
	CHAR details[0x400];	//1Kb

	DWORD_FILL(0x38F0 - 0x400 - 0x8);
	sMapScript* script;
};

struct sMapData
{
	CHAR path[MAX_PATH];
	DWORD_FILL(0x14);
	sMapInfo** info;		//probably a table

	DWORD_FILL(0x12BC);
	DWORD unk1;
	DWORD unk2;
	HANDLE hMpq;
	DWORD unk3;
};


//// State
struct sToolState
{
	DWORD unk1;	//0x00
	sEditorState* state;
	DWORD unk3;	//0x08
	DWORD unk4;	//0x0C

	DWORD fillgap[0x13];
	BOOL bObjectSel;
};

struct sMapTable
{
	sMapData* entry[0];
};

struct sEditorState
{
	DWORD_FILL(0x1A4);							// 0x0
	UINT nopenmaps;								// 0x1A4
	sMapTable* maptable;						// 0x1A8
	DWORD unk1;									// 0x1AC
	INT openmap; //0 based	//-1==no map open	// 0x1B0
	DWORD unk2;									// 0x1B4
	DWORD unk3;									// 0x1B8
	sToolState* tool;							// 0x1BC

	DWORD_FILL(0xC4);
	CHAR wndtitle[MAX_PATH]; //title shown
};


//// Information
struct sStub
{
	DWORD fillgap[20];
};

struct sInfoMain		// pointed by OsGuiPointer of main wnd
{
	sStub* stub;
	DWORD info1;
	DWORD info2;
	DWORD info3;
	sEditorState* state;
};


// Offsets
const DWORD cADDR_GLOBAL_PMAIN_21	= 0x0080A108;
const DWORD cADDR_GLOBAL_PMAIN_24	= 0x00862C7C;

typedef char* (sEditorState::*fEDITOR_MAPNAME)(void);
const DWORD cADDR_FUNC_MAPPRI_24	= 0x004D1610;
const DWORD cADDR_FUNC_MAPSEC_24	= 0x004CF770;

typedef UINT (*fEDITOR_VERSION)(void);
const DWORD cADDR_FUNC_EDIVER_21	= 0x004D0AA0;	// Get editor version
const DWORD cADDR_FUNC_EDIVER_24	= 0x004B85E0;
const BYTE cASM_FEDIVER_FIRST		= 0xB8;			// MOV EAX, CONST
const BYTE cASM_FEDIVER_SECOND		= 0xC3;			// RETN