public MBXGVars(MBXFile self) { List <MBXProcVar> temp_list = new List <MBXProcVar>(); uint offset = self.procs.GetLaspProcDataEnd(); if (self.procs.GetLaspProcDataEnd() < self.header.GetGlobalVarsOffset()) { while (offset < self.header.GetGlobalVarsOffset()) { MBXProcVar tmpVar = new MBXProcVar(); tmpVar.dataType = (MBXDataType)self.mbxFileBinaryData.readWord(offset); offset += 2; tmpVar.arraySize = self.mbxFileBinaryData.readWord(offset); offset += 2; tmpVar.typeNum = self.mbxFileBinaryData.readWord(offset); offset += 2; tmpVar.zero = self.mbxFileBinaryData.readWord(offset); offset += 2; temp_list.Add(tmpVar); } } this.uglobalVars = new MBXProcVar[temp_list.Count]; temp_list.CopyTo(this.uglobalVars); this.globalVars = new MBXProcVar[self.header.GetGlobalVarsCount()]; offset = self.header.GetGlobalVarsOffset(); for (int i = 0; i < this.globalVars.Length; i++) { this.globalVars[i].dataType = (MBXDataType)self.mbxFileBinaryData.readWord(offset); offset += 2; this.globalVars[i].arraySize = self.mbxFileBinaryData.readWord(offset); offset += 2; this.globalVars[i].typeNum = self.mbxFileBinaryData.readWord(offset); offset += 2; this.globalVars[i].zero = self.mbxFileBinaryData.readWord(offset); offset += 2; } }
public MBXProcs(MBXFile self) { this.procList = new MBXProc[self.header.GetProcCount()]; for (int i = 0; i < this.procList.Length; i++) { this.procList[i] = new MBXProc(self, i); } }
private void readProcList(MBXFile self) { this.proclist = new MBXProcInfo[this.header.procsCount]; uint curroffset = this.header.procsNamesOffset; for (int i = 0; i < this.header.procsCount; i++) { this.proclist[i].procOffset = self.mbxFileBinaryData.readDWord(curroffset); curroffset += 4; this.proclist[i].procName = self.mbxFileBinaryData.readMBXString(curroffset); curroffset += (uint)this.proclist[i].procName.GetLength() + 1; } }
public MBXTypes(MBXFile self) { this.self = self; this.types = new MBXType[self.header.GetTypeCount()]; uint offset = self.header.GetTypesOffset(); for (int i = 0; i < this.types.Length; i++) { this.types[i].fieldsCount = self.mbxFileBinaryData.readWord(offset); offset += 2; this.types[i].fields = new MBXProcVar[this.types[i].fieldsCount]; for (int ii = 0; ii < this.types[i].fieldsCount; ii++) { this.types[i].fields[ii].dataType = (MBXDataType)self.mbxFileBinaryData.readWord(offset); offset += 2; this.types[i].fields[ii].arraySize = self.mbxFileBinaryData.readWord(offset); offset += 2; this.types[i].fields[ii].typeNum = self.mbxFileBinaryData.readWord(offset); offset += 2; this.types[i].fields[ii].zero = self.mbxFileBinaryData.readWord(offset); offset += 2; } } }
public MBXHeader(MBXFile self) { this.signature = self.mbxFileBinaryData.readByteArray(0, 0x100); this.version = System.Text.Encoding.ASCII.GetString(signature).Split('\n')[1].Split(' ')[1]; this.iVersion = int.Parse(this.version); this.isMoreThen850Version = this.iVersion > 850; this.header.zero = self.mbxFileBinaryData.readDWord(0x100); this.header.globalVarsOffset = self.mbxFileBinaryData.readDWord(0x104); this.header.procsNamesOffset = self.mbxFileBinaryData.readDWord(0x108); this.header.typesOffset = self.mbxFileBinaryData.readDWord(0x10C); this.header.procsVarNamesOffset = self.mbxFileBinaryData.readDWord(0x110); this.header.dllTable = self.mbxFileBinaryData.readDWord(0x114); this.header.globalVarsCount = self.mbxFileBinaryData.readWord(0x118); this.header.procsCount = self.mbxFileBinaryData.readWord(0x11A); this.header.typesCount = self.mbxFileBinaryData.readWord(0x11C); this.header.dllsCount = self.mbxFileBinaryData.readWord(0x11E); this.header.unknown = self.mbxFileBinaryData.readWord(0x120); readProcList(self); }
public MBXProc(MBXFile self, int index) { this.selfIndex = index; this.selfName = self.header.GetProcName(index); uint offset = self.header.GetProcffset(index); this.procHeader.SelfBase = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.CodeStart = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.DataStart = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.DataEnd = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.C1 = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.LocConstCnt = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.LocVarCnt = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.ArgCnt = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.ResType = (MBXDataType)self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.C6 = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procHeader.X1 = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.Z2 = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procHeader.Size = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.binCode = self.mbxFileBinaryData.readByteArray(this.procHeader.CodeStart + this.procHeader.SelfBase, this.procHeader.DataStart - this.procHeader.CodeStart); this.binData = self.mbxFileBinaryData.readByteArray(this.procHeader.DataStart + this.procHeader.SelfBase, this.procHeader.DataEnd - this.procHeader.DataStart); this.procVars = new MBXProcVar[this.procHeader.LocVarCnt]; offset = this.procHeader.SelfBase + this.procHeader.DataEnd; for (int i = 0; i < this.procVars.Length; i++) { this.procVars[i].dataType = (MBXDataType)self.mbxFileBinaryData.readWord(offset); offset += 2; this.procVars[i].arraySize = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procVars[i].typeNum = self.mbxFileBinaryData.readWord(offset); offset += 2; this.procVars[i].zero = self.mbxFileBinaryData.readWord(offset); offset += 2; } }
public MBXNames(MBXFile self) { this.self = self; uint offset = self.header.GetVarNamesOffset(); this.namesHeader.globalVarsStart = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.namesHeader.typesStart = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.namesHeader.localVarsStart = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.namesHeader.LocalVarsEnd = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.namesHeader.C1 = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procVarNames = new MBXProcVarNames[self.header.GetProcCount()]; offset = this.namesHeader.localVarsStart; for (int i = 0; i < this.procVarNames.Length; i++) { this.procVarNames[i].parrentProcOffset = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procVarNames[i].dataEnd = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procVarNames[i].varsCount = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.procVarNames[i].names = new MBXString[this.procVarNames[i].varsCount]; if (self.procs.GetProcVarCount(i) == 0) { continue; } for (int ii = 0; ii < this.procVarNames[i].varsCount; ii++) { this.procVarNames[i].names[ii] = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)1 + this.procVarNames[i].names[ii].GetLength(); } } this.globalVarNames = new MBXString[self.header.GetGlobalVarsCount()]; offset = this.namesHeader.globalVarsStart; for (int i = 0; i < this.globalVarNames.Length; i++) { this.globalVarNames[i] = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)0x1 + this.globalVarNames[i].GetLength(); } offset = this.namesHeader.typesStart; this.typeNames = new MBXTypeName[self.header.GetTypeCount()]; for (int i = 0; i < this.typeNames.Length; i++) { offset += 4;//skip addr of next type names uint itemCount = self.mbxFileBinaryData.readDWord(offset); offset += 4; this.typeNames[i].itemNames = new MBXString[itemCount - 1]; this.typeNames[i].typeName = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)1 + this.typeNames[i].typeName.GetLength(); for (int ii = 0; ii < this.typeNames[i].itemNames.Length; ii++) { this.typeNames[i].itemNames[ii] = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)1 + this.typeNames[i].itemNames[ii].GetLength(); } } this.dllNames = new MBXDllNames[self.header.GetDllCount()]; offset = self.header.GetDllOffset(); for (int i = 0; i < this.dllNames.Length; i++) { ushort namesCount = self.mbxFileBinaryData.readWord(offset); offset += 2; this.dllNames[i].functionNames = new MBXString[namesCount]; this.dllNames[i].dllName = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)1 + this.dllNames[i].dllName.GetLength(); if (self.header.isNewVersion()) { offset += 2; } for (int ii = 0; ii < namesCount; ii++) { this.dllNames[i].functionNames[ii] = self.mbxFileBinaryData.readMBXString(offset); offset += (uint)1 + this.dllNames[i].functionNames[ii].GetLength(); } } }
public MBXDisassembler(MBXFile d) { this.self = d; }