示例#1
0
        public static int CollectSystemInfo()
        {
            if (IsRunningOnMono() == true)
            {
                FoxEventLog.WriteEventLog("Running on Mono is not supported!", EventLogEntryType.Error);
                Console.WriteLine("Running on Mono is not supported!");
                return(1);
            }

            if (GetWineVersion() != "")
            {
                FoxEventLog.WriteEventLog("Running on Wine/CrossOver is not supported!", EventLogEntryType.Error);
                Console.WriteLine("Running on Wine/CrossOver is not supported!");
                return(1);
            }

            SysInfo = new BaseSystemInfo();
            SysInfo.RunningInWindowsPE = WindowsPE.IsRunningInWindowsPE;
            SysInfo.ComputerModel      = GetComputerModel();
            SysInfo.ComputerName       = SystemInformation.ComputerName;
            SysInfo.CPU                 = GetCPU().ToString();
            SysInfo.MachineID           = RegistryData.MachineID;
            SysInfo.IsTSE               = IsSystemTSE();
            SysInfo.OSName              = SysInfo.RunningInWindowsPE == true ? "Windows PE / MiniNT" : GetWindowsProduct();
            SysInfo.OSSuite             = GetOSSuite().ToString();
            SysInfo.OSVerBuild          = Environment.OSVersion.Version.Build;
            SysInfo.OSVerMaj            = Environment.OSVersion.Version.Major;
            SysInfo.OSVerMin            = Environment.OSVersion.Version.Minor;
            SysInfo.Language            = CultureInfo.InstalledUICulture.Name;
            SysInfo.DisplayLanguage     = CultureInfo.InstalledUICulture.EnglishName;
            SysInfo.RunningInHypervisor = ProgramAgent.CPP.IsInHypervisor();
            SysInfo.BIOS                = GetBIOSData();
            SysInfo.BIOSType            = ProgramAgent.CPP.FoxGetFirmwareType();
            GetProcessorInfos(out SysInfo.NumberOfProcessors, out SysInfo.NumberOfLogicalProcessors, out SysInfo.TotalPhysicalMemory);
            SysInfo.CPUName         = GetProcessorName();
            SysInfo.SecureBootState = GetSecureBootState();
            SysInfo.SystemRoot      = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
            SysInfo.SUSID           = GetSUSID();

            try
            {
                SysInfo.IsMeteredConnection = MeteredConnection.IsMeteredConnection();
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                SysInfo.IsMeteredConnection = null;
            }

            OSVERSIONINFOEX os = new OSVERSIONINFOEX();

            os.dwOSVersionInfoSize = Marshal.SizeOf(os);
            GetVersionEx(ref os);
            SysInfo.OSVerType = os.wSuiteMask;

#if DEBUG
            SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " [DEBUG] " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
#else
            SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
#endif
            SysInfo.AgentVersionID = FoxVersion.Version;

            CPUType CPU = GetCPU();

            if (CPU != CPUType.Intel32 && CPU != CPUType.EM64T && CPU != CPUType.ARM64)
            {
                FoxEventLog.WriteEventLog("Only i386, AMD64 (EM64T) or ARM64 CPU are supported!", EventLogEntryType.Error);
                return(1);
            }

            if (CPU == CPUType.EM64T)
            {
                if (Is64Bit() == null)
                {
                    FoxEventLog.WriteEventLog("Cannot determine WOW state.", EventLogEntryType.Error);
                    return(1);
                }

                if (Is64Bit() == false && CPU == CPUType.EM64T)
                {
                    FoxEventLog.WriteEventLog("If you've a 64 bit CPU, then run this process as 64 bit!!!!", EventLogEntryType.Error);
                    return(1);
                }

                SysInfo.Is64Bit = Is64Bit().Value;
            }
            else
            {
                SysInfo.Is64Bit = false;
            }

            if (SysInfo.MachineID == "")
            {
                FoxEventLog.WriteEventLog("Cannot get machine ID.", EventLogEntryType.Error);
                return(1);
            }

            if (SysInfo.ComputerModel == null)
            {
                FoxEventLog.WriteEventLog("Cannot get Computer Model.", EventLogEntryType.Error);
                return(1);
            }

            PasswordID = RegistryData.MachinePassword;
            if (PasswordID == "")
            {
                FoxEventLog.WriteEventLog("Cannot get PassID.", EventLogEntryType.Error);
                return(1);
            }

            if (SysInfo.OSSuite == "Unknown")
            {
                FoxEventLog.WriteEventLog("Unknown OS Suite.", EventLogEntryType.Error);
                return(1);
            }

            if (RegistryData.UseOnPrem == true)
            {
                ServerURL = RegistryData.ServerURL;
            }
            else
            {
                ServerURL = ProgramAgent.VulpesURL;
            }

            if (ServerURL == "")
            {
                FoxEventLog.WriteEventLog("Cannot get Server URL.", EventLogEntryType.Error);
                return(1);
            }

            ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            if (ProgramData.EndsWith("\\") == false)
            {
                ProgramData += "\\";
            }
            ProgramData += "Fox\\SDC Agent\\";

            try
            {
                if (Directory.Exists(ProgramData) == false)
                {
                    Directory.CreateDirectory(ProgramData);
                }
            }
            catch
            {
                FoxEventLog.WriteEventLog("Error accessing " + ProgramData, EventLogEntryType.Error);
                return(1);
            }

            SysInfo.UCID       = UCID.GetUCID();
            SysInfo.LegacyUCID = UCID.GetUCIDLegacy();

            if (RegistryData.UCIDOverride != "")
            {
                string UUU = RegistryData.UCIDOverride.Trim().ToUpper();
                if (UUU.Length == 32)
                {
                    FoxEventLog.WriteEventLog("UCID Overriden from " + SysInfo.UCID + " to " + UUU, EventLogEntryType.Warning);
                    SysInfo.UCID = UUU;
                }
            }

            string SysInfoResumee = "";

            ContractID       = RegistryData.ContractID.Trim();
            ContractPassword = RegistryData.ContractPassword;

            SysInfoResumee += "System Info:\r\n";
            SysInfoResumee += "Agent:                 " + SysInfo.AgentVersion + "\r\n";
            SysInfoResumee += SysInfo.OSName + "\r\n";
            SysInfoResumee += "aka Windows NT         " + SysInfo.OSVerMaj.ToString() + "." + SysInfo.OSVerMin.ToString() + "." + SysInfo.OSVerBuild.ToString() + "\r\n";
            SysInfoResumee += "Suite:                 " + SysInfo.OSSuite + "\r\n";
            SysInfoResumee += "Language:              " + SysInfo.Language + " (" + SysInfo.DisplayLanguage + ")\r\n";
            SysInfoResumee += "Bits:                  " + (SysInfo.Is64Bit == true ? "64 bit" : "32 bit") + "\r\n";
            SysInfoResumee += "TSE:                   " + (SysInfo.IsTSE == false ? "no" : "yes") + "\r\n";
            SysInfoResumee += "OS Suite:              " + SysInfo.OSVerType + "\r\n";
            SysInfoResumee += "CPU:                   " + CPU.ToString() + "\r\n";
            SysInfoResumee += "Model:                 " + SysInfo.ComputerModel + "\r\n";
            SysInfoResumee += "BIOS:                  " + SysInfo.BIOS + "\r\n";
            SysInfoResumee += "Computername:          " + SysInfo.ComputerName + "\r\n";
            SysInfoResumee += "Machine ID:            " + SysInfo.MachineID + "\r\n";
            SysInfoResumee += "Server URL:            " + ServerURL + "\r\n";
            SysInfoResumee += "UCID:                  " + SysInfo.UCID + "\r\n";
            SysInfoResumee += "Program Data:          " + ProgramData + "\r\n";
            SysInfoResumee += "Running in Hypervisor: " + (SysInfo.RunningInHypervisor == false ? "no" : "yes") + "\r\n";

            FoxEventLog.WriteEventLog("Fox SDC Agent starting: " + SysInfoResumee, EventLogEntryType.Information);

            return(0);
        }
        static void DownloadThreadRunner()
        {
            try
            {
                int Direction = -1;
                lock (FileLock)
                {
                    if (FilesystemData.FileTransferStatus.ServerID == null)
                    {
                        return;
                    }
                    Direction = FilesystemData.FileTransferStatus.Direction;
                }

                #region Client to Server

                if (Direction == 1)
                {
                    string   LocalFilename = "";
                    string   MD5;
                    Int64    ServerID = 0;
                    Int64    CurrentSZ;
                    Int64    TotalSZ;
                    bool     OverrideMetered;
                    bool     ReqOnly;
                    DateTime LastModified;
                    try
                    {
                        lock (FileLock)
                        {
                            LocalFilename   = FilesystemData.FileTransferStatus.RemoteFileLocation;
                            ServerID        = FilesystemData.FileTransferStatus.ServerID.Value;
                            CurrentSZ       = FilesystemData.FileTransferStatus.ProgressSize;
                            TotalSZ         = FilesystemData.FileTransferStatus.Size;
                            MD5             = FilesystemData.FileTransferStatus.MD5CheckSum;
                            OverrideMetered = FilesystemData.FileTransferStatus.OverrideMeteredConnection;
                            ReqOnly         = FilesystemData.FileTransferStatus.RequestOnly;
                            LastModified    = FilesystemData.FileTransferStatus.LastModfied;
                        }

                        //won't start when in metered connection!
                        if (OverrideMetered == false)
                        {
                            try
                            {
                                if (MeteredConnection.IsMeteredConnection() == true)
                                {
                                    FoxEventLog.VerboseWriteEventLog("Upload paused = metered connection detected", System.Diagnostics.EventLogEntryType.Information);
                                    return;
                                }
                            }
                            catch
                            {
                            }
                        }

                        Int64 ReallyCurrentSZ = 0;

                        try
                        {
                            if (File.Exists(LocalFilename) == true)
                            {
                                FileInfo fi = new FileInfo(LocalFilename);
                                ReallyCurrentSZ = fi.Length;
                            }
                            else
                            {
                                FoxEventLog.WriteEventLog("File " + LocalFilename + " does not exist for upload.", System.Diagnostics.EventLogEntryType.Error);
                                return;
                            }
                        }
                        catch (Exception ee)
                        {
                            FoxEventLog.WriteEventLog("Checking upload file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                            return;
                        }

                        downloadnet = Utilities.ConnectNetwork(7);
                        if (downloadnet == null)
                        {
                            return;
                        }

                        if (ReqOnly == true)
                        {
                            Status.UpdateMessage(7, "Checking " + LocalFilename);
                            MD5 = MD5Utilities.CalcMD5File(LocalFilename);
                            FileInfo fi = new FileInfo(LocalFilename);
                            lock (FileLock)
                            {
                                FilesystemData.FileTransferStatus.MD5CheckSum = MD5;
                                FilesystemData.FileTransferStatus.LastModfied = fi.LastWriteTimeUtc;
                                FilesystemData.WriteFileTransferStatus();
                            }

                            Int64?NewID = downloadnet.File_Agent_NewUploadReq(LocalFilename, OverrideMetered, MD5);
                            if (NewID == null)
                            {
                                FoxEventLog.VerboseWriteEventLog("Cannot create a new upload req for " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                                return;
                            }

                            if (downloadnet.File_Agent_CancelUpload(ServerID) == false)
                            {
                                FoxEventLog.VerboseWriteEventLog("Cannot delete temp upload req for " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                return;
                            }

                            lock (FileLock)
                            {
                                //wait for the new upload req
                                ClearDataFSD();
                                FilesystemData.WriteFileTransferStatus();
                                UnlockTimer = true;
                                return;
                            }
                        }
                        else
                        {
                            FileStream fs = null;
                            do
                            {
                                try
                                {
                                    if (CancelAndDeleteDL == true)
                                    {
                                        return;
                                    }

                                    FileInfo fi = new FileInfo(LocalFilename);
                                    if (roughDT(fi.LastWriteTimeUtc, LastModified) == false || fi.Length != TotalSZ)
                                    {
                                        if (downloadnet.File_Agent_CancelUpload(ServerID) == false)
                                        {
                                            FoxEventLog.VerboseWriteEventLog("Cannot cancel upload req for " + LocalFilename + " ID: " + ServerID.ToString() + ", due file changes", System.Diagnostics.EventLogEntryType.Warning);
                                            lock (FileLock)
                                            {
                                                ClearDataFSD();
                                                FilesystemData.WriteFileTransferStatus();
                                            }
                                            return;
                                        }
                                        else
                                        {
                                            FoxEventLog.VerboseWriteEventLog("Cannot upload req for " + LocalFilename + " ID: " + ServerID.ToString() + ": File has been changed!", System.Diagnostics.EventLogEntryType.Warning);
                                        }
                                        return;
                                    }

                                    try
                                    {
                                        if (fs == null)
                                        {
                                            fs = File.Open(LocalFilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                                        }
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot upload file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    try
                                    {
                                        fs.Seek(CurrentSZ, SeekOrigin.Begin);
                                    }
                                    catch
                                    {
                                        FoxEventLog.WriteEventLog("Cannot properly seek in file " + LocalFilename + " ID: " + ServerID.ToString() + " Pos: 0x" + CurrentSZ.ToString("X"), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    byte[] data = null;

                                    try
                                    {
                                        int read = 1024 * 1024;
                                        data = new byte[read];
                                        read = fs.Read(data, 0, read);
                                        if (data.Length != read)
                                        {
                                            byte[] ddd = new byte[read];
                                            Array.Copy(data, ddd, read);
                                            data = ddd;
                                        }
                                    }
                                    catch
                                    {
                                        FoxEventLog.WriteEventLog("Cannot read file " + LocalFilename + " ID: " + ServerID.ToString() + " Pos: 0x" + CurrentSZ.ToString("X"), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    Status.UpdateMessage(7, "Uploading " + LocalFilename + "\r\n" + CommonUtilities.NiceSize(CurrentSZ) + " of " + CommonUtilities.NiceSize(TotalSZ));
                                    bool res = downloadnet.File_Agent_AppendUpload(ServerID, data);
                                    if (res == false)
                                    {
                                        FoxEventLog.VerboseWriteEventLog("Cannot upload append req for " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    CurrentSZ += data.Length;
                                    lock (FileLock)
                                    {
                                        FilesystemData.FileTransferStatus.ProgressSize = CurrentSZ;
                                        FilesystemData.WriteFileTransferStatus();
                                    }

                                    if (CurrentSZ == TotalSZ)
                                    {
                                        FoxEventLog.WriteEventLog("Upload file success " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Information);
                                        lock (FileLock)
                                        {
                                            ClearDataFSD();
                                            FilesystemData.WriteFileTransferStatus();
                                        }
                                        UnlockTimer = true;
                                        return;
                                    }
                                }
                                finally
                                {
                                    if (fs != null)
                                    {
                                        fs.Close();
                                        fs = null;
                                    }
                                }
                            } while (true);
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Downloading file " + LocalFilename + " ID: " + ServerID.ToString() + " crashed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }
                    finally
                    {
                        Status.UpdateMessage(7);
                    }
                }

                #endregion
                #region Server to Client

                if (Direction == 0)
                {
                    string LocalFilename;
                    string MD5;
                    Int64  ServerID;
                    Int64  CurrentSZ;
                    Int64  TotalSZ;
                    bool   OverrideMetered;
                    lock (FileLock)
                    {
                        LocalFilename   = FilesystemData.FileTransferStatus.RemoteFileLocation;
                        ServerID        = FilesystemData.FileTransferStatus.ServerID.Value;
                        CurrentSZ       = FilesystemData.FileTransferStatus.ProgressSize;
                        TotalSZ         = FilesystemData.FileTransferStatus.Size;
                        MD5             = FilesystemData.FileTransferStatus.MD5CheckSum;
                        OverrideMetered = FilesystemData.FileTransferStatus.OverrideMeteredConnection;
                    }

                    //won't start when in metered connection!
                    if (OverrideMetered == false)
                    {
                        try
                        {
                            if (MeteredConnection.IsMeteredConnection() == true)
                            {
                                FoxEventLog.VerboseWriteEventLog("Download paused = metered connection detected", System.Diagnostics.EventLogEntryType.Information);
                                return;
                            }
                        }
                        catch
                        {
                        }
                    }

                    Int64 ReallyCurrentSZ = 0;

                    try
                    {
                        string Dir = Path.GetDirectoryName(LocalFilename);
                        if (Directory.Exists(Dir) == false)
                        {
                            Directory.CreateDirectory(Dir);
                        }
                        if (File.Exists(LocalFilename) == true)
                        {
                            FileInfo fi = new FileInfo(LocalFilename);
                            ReallyCurrentSZ = fi.Length;
                        }
                        else
                        {
                            ReallyCurrentSZ = 0;
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Checking download file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }

                    if (ReallyCurrentSZ != CurrentSZ)
                    {
                        FoxEventLog.WriteEventLog("File Size does not match: deleting the file " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                        try
                        {
                            File.Delete(LocalFilename);
                        }
                        catch (Exception ee)
                        {
                            FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                        }
                        lock (FileLock)
                        {
                            ClearDataFSD();
                            FilesystemData.WriteFileTransferStatus();
                            return;
                        }
                    }

                    downloadnet = Utilities.ConnectNetwork(7);
                    if (downloadnet == null)
                    {
                        return;
                    }
                    try
                    {
                        downloadnet.DownloadNotify += Downloadnet_DownloadNotify;
                        if (downloadnet.DownloadFile("api/agent/filefiledownload/" + ServerID.ToString(), LocalFilename, TotalSZ) == false)
                        {
                            FileInfo fi = new FileInfo(LocalFilename);
                            lock (FileLock)
                            {
                                FilesystemData.FileTransferStatus.ProgressSize = fi.Length;
                                FilesystemData.WriteFileTransferStatus();
                            }
                        }
                        else
                        {
                            if (downloadnet.StopDownload == false)
                            {
                                Status.UpdateMessage(7, "Checking " + FilesystemData.FileTransferStatus.RemoteFileLocation + "...");
                                string CalcMD5 = MD5Utilities.CalcMD5File(LocalFilename);
                                if (MD5.ToLower() != CalcMD5.ToLower())
                                {
                                    FoxEventLog.WriteEventLog("File MD5 does not match: deleting the file " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                                    try
                                    {
                                        File.Delete(LocalFilename);
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                                    }
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                        return;
                                    }
                                }
                                else
                                {
                                    //success!
                                    FoxEventLog.WriteEventLog("File download success: " + LocalFilename, System.Diagnostics.EventLogEntryType.Information);
                                    downloadnet.File_Agent_CancelUpload(ServerID);
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                    }
                                    UnlockTimer = true;
                                    return;
                                }
                            }
                            else
                            {
                                if (CancelAndDeleteDL == true)
                                {
                                    FoxEventLog.VerboseWriteEventLog("File " + LocalFilename + " canceled by server req.", System.Diagnostics.EventLogEntryType.Information);
                                    try
                                    {
                                        File.Delete(LocalFilename);
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                                    }
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Downloading file " + LocalFilename + " ID: " + ServerID.ToString() + " crashed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }
                    finally
                    {
                        downloadnet.DownloadNotify -= Downloadnet_DownloadNotify;
                        Status.UpdateMessage(7);
                    }
                }

                #endregion
            }
            finally
            {
                try
                {
                    if (downloadnet != null)
                    {
                        downloadnet.CloseConnection();
                    }
                }
                catch
                {
                }
                downloadnet = null;
            }
        }
示例#3
0
        public static Network ConnectNetwork(int MessageChannel)
        {
            if (SystemInfos.ServerURL == ProgramAgent.VulpesURL)
            {
                if (SystemInfos.ContractID == "" || SystemInfos.ContractPassword == "")
                {
                    FoxEventLog.VerboseWriteEventLog("Missing contract data for Vulpes Server (" + ProgramAgent.VulpesURL + ")", System.Diagnostics.EventLogEntryType.Error);
                    return(null);
                }
            }

            Network net = new Network();

            if (MessageChannel > -1)
            {
                Status.UpdateMessage(MessageChannel, "Connecting to server " + SystemInfos.ServerURL);
            }
            FoxEventLog.VerboseWriteEventLog("Connecting to server " + SystemInfos.ServerURL, System.Diagnostics.EventLogEntryType.Information);
            try
            {
                ServerInfo = null;
                URL        = SystemInfos.ServerURL;
                if (net.Connect(SystemInfos.ServerURL) == false)
                {
                    if (MessageChannel > -1)
                    {
                        Status.UpdateMessage(MessageChannel, "Connecting to server " + SystemInfos.ServerURL + " failed");
                    }
                    FoxEventLog.VerboseWriteEventLog("Connecting to server " + SystemInfos.ServerURL + " failed", System.Diagnostics.EventLogEntryType.Information);
                    return(null);
                }

                try
                {
                    SystemInfos.SysInfo.IsMeteredConnection = MeteredConnection.IsMeteredConnection(); //always update this
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                    SystemInfos.SysInfo.IsMeteredConnection = null;
                }

                if (net.ComputerLogin(SystemInfos.SysInfo.MachineID, SystemInfos.PasswordID, SystemInfos.ContractID, SystemInfos.ContractPassword, SystemInfos.SysInfo) == false)
                {
                    if (net.LoginError == null)
                    {
                        if (MessageChannel > -1)
                        {
                            Status.UpdateMessage(MessageChannel, "Login failed: <no data> ( on server " + SystemInfos.ServerURL + ")");
                        }
                        FoxEventLog.VerboseWriteEventLog("Login failed: <no data> ( on server " + SystemInfos.ServerURL + ")", System.Diagnostics.EventLogEntryType.Information);
                    }
                    else
                    {
                        if (MessageChannel > -1)
                        {
                            Status.UpdateMessage(MessageChannel, "Login failed: " + net.LoginError.Error + " - " + net.LoginError.ErrorID.ToString() + " ( on server " + SystemInfos.ServerURL + ")");
                        }
                        FoxEventLog.VerboseWriteEventLog("Login failed: " + net.LoginError.Error + " - " + net.LoginError.ErrorID.ToString() + " ( on server " + SystemInfos.ServerURL + ")", System.Diagnostics.EventLogEntryType.Information);
                    }
                    net.CloseConnection();
                    return(null);
                }
                if (net.GetInfo() == true)
                {
                    ServerInfo = net.serverinfo;
                    URL        = SystemInfos.ServerURL;
                }
                if (MessageChannel > -1)
                {
                    Status.UpdateMessage(MessageChannel);
                }
            }
            catch
            {
                FoxEventLog.VerboseWriteEventLog("Login failed - something really has gone wrong: (" + SystemInfos.ServerURL + ")", System.Diagnostics.EventLogEntryType.Information);
                if (MessageChannel > -1)
                {
                    Status.UpdateMessage(MessageChannel);
                }
                return(null);
            }
            return(net);
        }