Example #1
0
		private void playButton_Click(object sender, EventArgs e)
		{
			IPAddress server = IPAddress.Parse("169.254.169.254");
			var dialog = new OpenFileDialog();
			dialog.Filter = "*.exe|*.exe";
			dialog.InitialDirectory = string.Format("{0}\\KRU\\Dark Ages", ProgramFilesx86());
			dialog.FileName = "Darkages.exe";
			dialog.Title = "Which Darkages.exe shall I use?";

            try
            {
                switch (comboBox1.SelectedIndex)
                {
                    case 0:
                        // production
                        server = Dns.GetHostAddresses("production.hybrasyl.com")[0];
                        break;
                    case 1:
                        // testing
                        server = Dns.GetHostAddresses("staging.hybrasyl.com")[0];
                        break;
                    case 2:
                        // localhost (FOR 1337 H4X0RZ)
                        server = Dns.GetHostAddresses("127.0.0.1")[0];
                        break;
                }
            }
            catch (Exception exc)
            {
                // We naively assume any error is due to a resolution failure
                MessageBox.Show("There was an error resolving the hostname of the Hybrasyl servers.", "Hybrasyl Launcher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				ProcessInformation information;
				StartupInfo startupInfo = new StartupInfo();
				startupInfo.Size = Marshal.SizeOf(startupInfo);
				Kernel32.CreateProcess(dialog.FileName, null, IntPtr.Zero, IntPtr.Zero, false, ProcessCreationFlags.Suspended,
					IntPtr.Zero, null, ref startupInfo, out information);

				using (ProcessMemoryStream stream = new ProcessMemoryStream(information.ProcessId,
					ProcessAccess.VmWrite | ProcessAccess.VmRead | ProcessAccess.VmOperation))
				{
					stream.Position = 0x4341FAL;
					var bytes = server.GetAddressBytes();
					stream.WriteByte(0x6A);
					stream.WriteByte(bytes[3]);
					stream.WriteByte(0x6A);
					stream.WriteByte(bytes[2]);
					stream.WriteByte(0x6A);
					stream.WriteByte(bytes[1]);
					stream.WriteByte(0x6A);
					stream.WriteByte(bytes[0]);

					stream.Position = 0x434224L;
					stream.WriteByte((byte)(2610 % 256));
					stream.WriteByte((byte)(2610 / 256));
					stream.Position = 0x5911B9L;
					stream.WriteByte(0xEB);

					stream.Position = 0x42F495L;
					stream.WriteByte(0x90);
					stream.WriteByte(0x90);
					stream.WriteByte(0x90);
					stream.WriteByte(0x90);
					stream.WriteByte(0x90);
					stream.WriteByte(0x90);

					Kernel32.ResumeThread(information.ThreadHandle);
				}
			}
		}
Example #2
0
 public static extern bool CreateProcess(string applicationName, string commandLine, IntPtr processAttributes, IntPtr threadAttributes, bool inheritHandles, ProcessCreationFlags creationFlags, IntPtr environment, string currentDirectory, ref StartupInfo startupInfo, out ProcessInformation processInfo);