Exemple #1
0
			public PlatformInterface(string output_dir, string path, Platform pv) : base(pv)
			{
				if (!ValidateExe(path))
					throw new BlamLib.Debug.ExceptionLog("{0} is not a supported {1} exe", path, pv.ToString());

				string dir = string.IsNullOrEmpty(output_dir) ? Path.GetDirectoryName(path) : output_dir;
				string name = Path.GetFileName(path);
				name = Path.Combine(dir, "OS_" + name);
				File.Copy(path, name, true);
				output = new BlamLib.IO.EndianWriter(name);
				output.BaseAddress = Program.PeAddressMask;
			}
Exemple #2
0
		private MemoryStream PrepareStrings()
		{
			MemoryStream ms = new MemoryStream(StringPoolSize + ((MaxCount * 2) * sizeof(int)));
			IO.EndianWriter s = new BlamLib.IO.EndianWriter(ms);
			//int offset = 0;

			//NameOffsets = new List<int>(Names.Count);
			//foreach (string str in Names)
			//{
			//    offset = (int)ms.Position;
			//    NameOffsets.Add(offset);
			//    s.Write(str, true);
			//}

			//ScenarioOffsets = new List<int>(Scenarios.Count);
			//foreach (string str in Scenarios)
			//{
			//    offset = (int)ms.Position;
			//    ScenarioOffsets.Add(offset);
			//    s.Write(str, true);
			//}

			foreach (string str in Scenarios)
				s.Write(str, true);
			int len = StringPoolSize - (int)ms.Position;
			if (len > 0)
				for (int x = 0; x < len; x++)
					s.Write(byte.MinValue);

			len = MaxCount - ScenarioOffsets.Count;

			foreach (int i in ScenarioOffsets)
				s.Write(i);

			if(len > 0)
				for (int x = 0; x < len; x++)
					s.Write(0);

			foreach (int i in NameOffsets)
				s.Write(i);

			if (len > 0)
				for (int x = 0; x < len; x++)
					s.Write(0);

			return ms;
		}
Exemple #3
0
		public void Build(string path)
		{
			IO.EndianWriter file = new BlamLib.IO.EndianWriter(path, BlamLib.IO.EndianState.Little, this, true);

			MemoryStream ms = PrepareStrings();

			file.Write(Names.Count);
			//file.Write(ms.GetBuffer().Length);

			//foreach (int offset in NameOffsets)
			//    file.Write(offset);

			//foreach (int offset in ScenarioOffsets)
			//    file.Write(offset);

			file.Write(ms.GetBuffer());

			ms.Close();
			file.Close();
		}
Exemple #4
0
        public override void Write(BlamLib.IO.EndianWriter s)
        {
            CacheFile cf = s.Owner as CacheFile;

            if (cf.EngineVersion == BlamVersion.Halo2_PC)
            {
                return;
            }
            if (cf.EngineVersion == BlamVersion.Halo2_Alpha)
            {
                return;
            }

            s.WriteTag((char[])MiscGroups.head);
            s.Write(8);
            s.Write(fileLength);
            s.Write(0);
            s.Write(offsetToIndex);
            s.Write(indexStreamSize);
            s.Write(tagBufferSize);
            s.Write(0);             // needs to be calc'd

            s.Write(new byte[256]);
            s.Write("02.09.27.09809", false);
            s.Write((int)cacheType);
            s.Write(0);             // needs to be calc'd
            s.Write(0);             // needs to be calc'd
            s.Write(0); s.Write(0);

            s.Write(0);             // needs to be calc'd

            s.Write(0);             // needs to be calc'd
            s.Write(0);             // needs to be calc'd

            s.Write(/*stringIdsBufferAlignedOffset*/ 0);
            s.Write(stringIdsCount);

            s.Write(stringIdsBufferSize);
            s.Write(stringIdIndicesOffset);
            s.Write(stringIdsBufferOffset);

            s.Write(0);             // 4 bools

            s.Write(Filetime.dwHighDateTime);                       s.Write(Filetime.dwHighDateTime);

            // mainmenu
            s.Write(SharedFiletimes[0].dwHighDateTime);     s.Write(SharedFiletimes[0].dwHighDateTime);
            // shared
            s.Write(SharedFiletimes[1].dwHighDateTime);     s.Write(SharedFiletimes[1].dwHighDateTime);
            // shared sp
            s.Write(SharedFiletimes[2].dwHighDateTime);     s.Write(SharedFiletimes[2].dwHighDateTime);

            s.Write(name, false);
            s.Write(0);
            s.Write(scenarioPath, 256);
            s.Write(Convert.ToInt32(needsShared));

            s.Write(tagNamesCount);
            s.Write(tagNamesBufferOffset);
            s.Write(tagNamesBufferSize);
            s.Write(tagNameIndicesOffset);

            s.Write(0);             // checksum

            s.Write(new byte[1320]);

            s.WriteTag((char[])MiscGroups.foot);
        }
Exemple #5
0
		public CacheFile(string map_name)
		{
			if (!SharableReferenceXbox(map_name) && !SharableReferencePc(map_name))
			{
				InputStream = new BlamLib.IO.EndianReader(map_name, BlamLib.IO.EndianState.Little, this);
				if(!CacheIsReadonly(map_name))
					OutputStream = new BlamLib.IO.EndianWriter(map_name, BlamLib.IO.EndianState.Little, this);
			}

			cacheHeader = new CacheHeader();
			cacheIndex = new CacheIndex();
		}
Exemple #6
0
 public void Write(BlamLib.IO.EndianWriter s)
 {
     s.Write(Start);
     s.Write(Count);
 }
Exemple #7
0
			public XnaNative(string output_dir, string path)
			{
				if (!ValidateExe(path))
					throw new BlamLib.Debug.ExceptionLog("{0} is not a supported {1} dll", path, "XnaNative");

				string dir = string.IsNullOrEmpty(output_dir) ? Path.GetDirectoryName(path) : output_dir;
				string name = Path.GetFileName(path);
				name = Path.Combine(dir, "OS_" + name);
				File.Copy(path, name, true);
				output = new BlamLib.IO.EndianWriter(name);
				output.BaseAddress = Program.PeAddressMask;
			}
Exemple #8
0
 /// <summary>
 /// Does nothing.
 /// </summary>
 /// <param name="s"></param>
 public override void Write(BlamLib.IO.EndianWriter s)
 {
 }
 public override void Write(BlamLib.IO.EndianWriter s)
 {
     WritePreprocess(s);
     base.Write(s);
     // TODO: write entry data
 }
 public void Write(BlamLib.IO.EndianWriter s)
 {
     s.Write((byte)type);
     s.Write(flags);
 }