How To Get Swtor To Work With Steam Overlay

Discussion in 'Gaming Discussion' started by Net, Nov 28, 2012.

  1. Net

    Net Achievement Hunter

    Posted from SWTOR Germany Forums. For those who really want to get STEAM overlay and UI to work on SWTOR, follow the instructions below. The reason he left the file uncompiled was so people could see the source and show he wasn't trying to design a logger or anything of that nature.

    OK. I think this will work for everyone...

    I still don't want to give out an exe as a matter of principle, so you are going to make it yourself. But don't worry, you don't have to download anything to make it, which is another of my self given requirements =)

    Step 1:
    - copy/paste this code into a text editor (ex. notepad) and save it as 'swtorsteam.txt'
    - I saved mine on the desktop
    - DO NOT NAME IT 'steamswtor.txt' OR THE SWTOR LAUNCHER WILL SEE PART OF THAT NAME LATER 'swtor.exe' AND WILL THINK THE REAL 'swtor.exe' IS RUNNING


    Code:
    using System;
    using System.Diagnostics;
    using System.IO;
    using System.IO.Pipes;
    using System.Management;
    using System.Threading;
    using System.Windows.Forms;
     
    namespace steamswtor
    {
    class Program
    {
    static bool IsPreVista()
    {
    //Vista or higher check
    if (System.Environment.OSVersion.Version.Major < 6)
    {
    MessageBox.Show("Windows Vista or higher is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return true;
    }
     
    return false;
    }
     
    static void Main(string[] args)
    {
    // If Operating System is before Vista, then exit
    if (IsPreVista())
    return;
     
    if (args.Length == 0)
    {
    string pipeName = "swtorsteam";
     
    // run ourself as admin
    try
    {
    Process admin = new Process();
    admin.StartInfo.FileName = System.Reflection.Assembly.GetEntryAssembly().Loca tion;
    admin.StartInfo.Arguments = pipeName;
    admin.StartInfo.Verb = "runas";
    admin.Start();
    }
    catch(Exception e)
    {
    string errmsg = e.Message + "\n";
    errmsg += "Failed to escalate. Program will now exit.";
    MessageBox.Show(errmsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
    }
     
    // run the swtor launcher
    try
    {
    Process launcher = new Process();
    launcher.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\launcher.exe";
    launcher.Start();
    }
    catch(Exception e)
    {
    string errmsg = e.Message + "\n";
    errmsg += "Launcher failed to begin. Is this exe in SWTOR's home directory? Program will now exit.";
    MessageBox.Show(errmsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
    }
     
    // loop waiting for our temp file to be filled with swtor's commandline arguments
    Console.WriteLine("Waiting for our other program to finish...");
     
    // grab data from the commandline arguments
    string exe, arguments, workingdirectory;
    try
    {
    NamedPipeServerStream server = new NamedPipeServerStream(pipeName);
    server.WaitForConnection();
     
    StreamReader sr = new StreamReader(server);
    string cmdline = sr.ReadLine();
    sr.Close();
    server.Close();
     
    // grab data from the commandline arguments
    exe = cmdline.Substring(1, cmdline.IndexOf('"', 1) - 1);
    arguments = cmdline.Substring(cmdline.IndexOf("\" ") + 2);
    workingdirectory = cmdline.Substring(1, cmdline.IndexOf("swtor.exe") - 1);
    }
    catch(Exception e)
    {
    string errmsg = e.Message + "\n";
    errmsg += "Failed to read command line arguments from other program. Program will now exit.";
    MessageBox.Show(errmsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
    }
     
    try
    {
    // start swtor's client
    Process swtor = new Process();
    swtor.StartInfo.FileName = exe;
    swtor.StartInfo.Arguments = arguments;
    swtor.StartInfo.WorkingDirectory = workingdirectory;
    swtor.Start();
    }
    catch(Exception e)
    {
    string errmsg = e.Message + "\n";
    errmsg += "swtor.exe failed to begin. Is this exe in SWTOR's home directory? Program will now exit.";
    MessageBox.Show(errmsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
    }
     
    // exit the program
    return;
    }
    else
    {
    // Connect to pipe server
    string pipeName = args[0];
    NamedPipeClientStream client = new NamedPipeClientStream(pipeName);
    client.Connect(10000);
     
    //Create the query
    ObjectQuery query = new ObjectQuery("Select * from Win32_Process Where Name =\"swtor.exe\"");
     
    // check once a second for swtor.exe that the launcher starts when the user hit's play in the launcher
    Console.WriteLine("Waiting for launcher to start swtor...");
    while (true)
    {
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
    ManagementObjectCollection processList = searcher.Get();
     
    foreach (ManagementObject obj in processList)
    {
    string cmdline = obj.GetPropertyValue("CommandLine").ToString();
     
    if (cmdline.Contains("username"))
    {
    // kill the process
    obj.InvokeMethod("Terminate", null);
     
    // write command line to the pipe
    try
    {
    StreamWriter sw = new StreamWriter(client);
    sw.WriteLine(cmdline);
    sw.Close();
    client.Close();
    }
    catch(Exception e)
    {
    string errmsg = e.Message + "\n";
    errmsg += "Failed to write commandline arguments to pipe. Program will now exit.";
    MessageBox.Show(errmsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return;
    }
     
    // exit the program
    return;
    }
    }
     
    Thread.Sleep(1000);
    }
    }
    }
    }
    }


    Step 2(the hard part):
    - Open a command prompt
    - Start Menu->All Programs->Accessories->Command Prompt
    - change the current directory to where you saved the above 'swtorsteam.txt' file
    - Since I saved mine on the desktop I just had to type "cd Desktop" without the quotes and hit enter
    - Enter the following into the command prompt and hit enter
    - For advanced users: you don't have to use v3.5, I just picked v3.5 because I think almost everyone will have that directory, you can use any that has a csc.exe in it

    Code:
    PATH %windir%\Microsoft.Net\Framework\v3.5


    - Now enter the following into the command prompt and hit enter

    Code:
    csc /platform:x86 swtorsteam.txt


    - csc is the c# compiler if you were wondering
    - There now should be a swtorsteam.exe in the same directory you are currently in
    - If you have done the same as me, that means swtorsteam.exe is on your desktop now
    - You can exit out of the command prompt now

    Step 3(the easy part):
    - Now that you have an exe, move it into your swtor's home directory. The home directory is the one with swtor's launcher.exe in it
    - An example swtor home directory is:

    Code:
    C:\Program Files (x86)\Electronic Arts\BioWare\Star Wars - The Old Republic


    - Go into steam and do the normal 'add non-steam game' and browse to the exe you just placed in swtor's home directory and add it

    Step 4(Optional):
    - Right click on the newly made game in steam's library and go to properties
    - Click Choose Icon and browse to swtor's launcher.exe and select it to get the swtor icon
    - Or you can change swtorsteam.exe's icon image by following a couple steps in a post of mine on the third page of this thread
    - Change the title from 'swtorsteam' to 'Star Wars - The Old Republic'

    You are done!

    If you try it and the steam overlay still doesn't work, then try exiting steam and running steam in admin-mode and try again. This is what my friend had to do.

    Thanks to all that posted on my previous thread. It helped seeing what problems people were having.

    If anyone has any problems, let me know. I will try and fix it.

    Enjoy!


    Source: STAR WARS: The Old Republic - Steam Overlay - Working on vista/win7
     
  2. CaptSpiffy

    CaptSpiffy Best Moderator NA

    yeah, you don't actually have to do all this anymore.
    just go to your Steam library, click "add non-steam game"
    select SWTOR.exe, and you're good to go.
    Now you can run SWTOR from your library and have the overlay.
     

Share This Page