Skip to content

Commit

Permalink
Client Start Finally Works but needs a whole rewrite to add more feat…
Browse files Browse the repository at this point in the history
…ures and qol features + error codes handling is being developed ok ok ok
  • Loading branch information
BeRightBack0 committed Dec 7, 2024
1 parent 7365e67 commit a576411
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 103 deletions.
14 changes: 12 additions & 2 deletions Assets/ClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public class ClientManager

private static string versionsdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher/versions.json";

private const string FORTNITE_EXECUTABLE = "D:\\Builds\\7.40\\7.40\\FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe";
private const string FORTNITE_EXECUTABLE = "D:\\Builds\\Fortnite 8.51\\FortniteGame\\Binaries\\Win64\\FortniteClient-Win64-Shipping.exe";



private static Process _fnProcess;
private static Patcher _fnPatcher;

public static void Test(string[] args)
{
string joinedArgs = string.Join(" ", args);
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XybLauncher";

// Check if -FORCECONSOLE exists in args (regardless of case) to force console (due to Epic Games Launcher by default hiding it)
if (joinedArgs.ToUpper().Contains("-FORCECONSOLE"))
Expand Down Expand Up @@ -58,20 +61,27 @@ public static void Test(string[] args)
// Setup a process exit event handler
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);

var accountParser = new AccountParser();
string email = accountParser.GetAccountInfo("email");
string password = accountParser.GetAccountInfo("password");


// Initialize Fortnite process with start info
_fnProcess = new Process
{
StartInfo =
{
FileName = FORTNITE_EXECUTABLE,
Arguments = $"{joinedArgs} -NOSSLPINNING -epicapp=Fortnite -epicenv=Prod -epiclocale=en-us -epicportal -skippatchcheck -nobe -fromfl=eac -fltoken=3db3ba5dcbd2e16703f3978d -caldera=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiYmU5ZGE1YzJmYmVhNDQwN2IyZjQwZWJhYWQ4NTlhZDQiLCJnZW5lcmF0ZWQiOjE2Mzg3MTcyNzgsImNhbGRlcmFHdWlkIjoiMzgxMGI4NjMtMmE2NS00NDU3LTliNTgtNGRhYjNiNDgyYTg2IiwiYWNQcm92aWRlciI6IkVhc3lBbnRpQ2hlYXQiLCJub3RlcyI6IiIsImZhbGxiYWNrIjpmYWxzZX0.VAWQB67RTxhiWOxx7DBjnzDnXyyEnX7OljJm-j2d88G_WgwQ9wrE6lwMEHZHjBd1ISJdUO1UVUqkfLdU5nofBQ -AUTH_LOGIN=[email protected] -AUTH_PASSWORD=12345678 -AUTH_TYPE=epic",
Arguments = $"{joinedArgs} -NOSSLPINNING -epicapp=Fortnite -epicenv=Prod -epiclocale=en-us -epicportal -skippatchcheck -nobe -fromfl=eac -fltoken=3db3ba5dcbd2e16703f3978d -caldera=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiYmU5ZGE1YzJmYmVhNDQwN2IyZjQwZWJhYWQ4NTlhZDQiLCJnZW5lcmF0ZWQiOjE2Mzg3MTcyNzgsImNhbGRlcmFHdWlkIjoiMzgxMGI4NjMtMmE2NS00NDU3LTliNTgtNGRhYjNiNDgyYTg2IiwiYWNQcm92aWRlciI6IkVhc3lBbnRpQ2hlYXQiLCJub3RlcyI6IiIsImZhbGxiYWNrIjpmYWxzZX0.VAWQB67RTxhiWOxx7DBjnzDnXyyEnX7OljJm-j2d88G_WgwQ9wrE6lwMEHZHjBd1ISJdUO1UVUqkfLdU5nofBQ -AUTH_LOGIN={email} -AUTH_PASSWORD={password} -AUTH_TYPE=epic",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
}
};

_fnProcess.Start(); // Start Fortnite client process
XybLauncher.Injector.Inject(_fnProcess.Id, appdata + "\\Cobalt.dll");


// Set up our async readers
AsyncStreamReader asyncOutputReader = new AsyncStreamReader(_fnProcess.StandardOutput);
Expand Down
3 changes: 3 additions & 0 deletions Assets/FilesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,7 @@ public class ChoiceContainer






}
126 changes: 126 additions & 0 deletions Assets/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,132 @@ namespace XybLauncher.Assets
{
internal class Functions
{
public static class ErrorCodes
{
// General Errors (1-99)
public const int SUCCESS = 0;
public const int UNKNOWN_ERROR = 1;
public const int INVALID_INPUT = 2;
public const int NOT_INITIALIZED = 3;
public const int OPERATION_FAILED = 4;

// File Operations (100-199)
public const int FILE_NOT_FOUND = 100;
public const int FILE_ACCESS_DENIED = 101;
public const int FILE_ALREADY_EXISTS = 102;
public const int INVALID_FILE_FORMAT = 103;
public const int FILE_READ_ERROR = 104;
public const int FILE_WRITE_ERROR = 105;

// Database Operations (200-299)
public const int DB_CONNECTION_FAILED = 200;
public const int DB_QUERY_FAILED = 201;
public const int DB_RECORD_NOT_FOUND = 202;
public const int DB_DUPLICATE_ENTRY = 203;
public const int DB_TRANSACTION_FAILED = 204;

// Network Operations (300-399)
public const int NETWORK_CONNECTION_FAILED = 300;
public const int REQUEST_TIMEOUT = 301;
public const int INVALID_RESPONSE = 302;
public const int SERVER_ERROR = 303;
// HTTP Status Related (310-329)
public const int HTTP_BAD_REQUEST = 310; // 400
public const int HTTP_UNAUTHORIZED = 311; // 401
public const int HTTP_FORBIDDEN = 312; // 403
public const int HTTP_NOT_FOUND = 313; // 404
public const int HTTP_SERVER_ERROR = 314; // 500
public const int HTTP_SERVICE_UNAVAILABLE = 315; // 503
// Connection Issues (330-349)
public const int DNS_RESOLUTION_FAILED = 330;
public const int HOST_UNREACHABLE = 331;
public const int PORT_UNREACHABLE = 332;
public const int CONNECTION_REFUSED = 333;
public const int SSL_CERTIFICATE_ERROR = 334;
public const int PROXY_CONNECTION_FAILED = 335;
// Data Transfer (350-369)
public const int UPLOAD_FAILED = 350;
public const int DOWNLOAD_FAILED = 351;
public const int INCOMPLETE_RESPONSE = 352;
public const int DATA_TRANSFER_INTERRUPTED = 353;
public const int BANDWIDTH_LIMIT_EXCEEDED = 354;
// Protocol Errors (370-389)
public const int PROTOCOL_ERROR = 370;
public const int INVALID_URL = 371;
public const int UNSUPPORTED_PROTOCOL = 372;
public const int TOO_MANY_REDIRECTS = 373;
public const int WEBSOCKET_ERROR = 374;

// Authentication & Authorization (400-499)
public const int INVALID_CREDENTIALS = 400;
public const int SESSION_EXPIRED = 401;
public const int UNAUTHORIZED_ACCESS = 402;
public const int ACCOUNT_LOCKED = 403;

// Helper method to get error message
public static string GetErrorMessage(int errorCode)
{
return errorCode switch
{
SUCCESS => "Operation completed successfully",
UNKNOWN_ERROR => "An unknown error occurred",
INVALID_INPUT => "Invalid input provided",
NOT_INITIALIZED => "System not properly initialized",
OPERATION_FAILED => "Operation failed to complete",
FILE_NOT_FOUND => "Specified file could not be found",
FILE_ACCESS_DENIED => "Access to the file was denied",
FILE_ALREADY_EXISTS => "File already exists",
INVALID_FILE_FORMAT => "Invalid file format",
FILE_READ_ERROR => "Error reading from file",
FILE_WRITE_ERROR => "Error writing to file",
DB_CONNECTION_FAILED => "Database connection failed",
DB_QUERY_FAILED => "Database query execution failed",
DB_RECORD_NOT_FOUND => "Database record not found",
DB_DUPLICATE_ENTRY => "Duplicate database entry",
DB_TRANSACTION_FAILED => "Database transaction failed",

// Network Errors
NETWORK_CONNECTION_FAILED => "Network connection failed",
REQUEST_TIMEOUT => "Request timed out",
INVALID_RESPONSE => "Invalid response received",
SERVER_ERROR => "Server error occurred",
// HTTP Status
HTTP_BAD_REQUEST => "Bad request - The server cannot process the request",
HTTP_UNAUTHORIZED => "Unauthorized - Authentication is required",
HTTP_FORBIDDEN => "Forbidden - Server refuses to authorize",
HTTP_NOT_FOUND => "Resource not found on the server",
HTTP_SERVER_ERROR => "Internal server error occurred",
HTTP_SERVICE_UNAVAILABLE => "Service temporarily unavailable",
// Connection Issues
DNS_RESOLUTION_FAILED => "Failed to resolve domain name",
HOST_UNREACHABLE => "Host is unreachable",
PORT_UNREACHABLE => "Network port is unreachable",
CONNECTION_REFUSED => "Connection was refused by the server",
SSL_CERTIFICATE_ERROR => "SSL/TLS certificate validation failed",
PROXY_CONNECTION_FAILED => "Failed to connect through proxy",
// Data Transfer
UPLOAD_FAILED => "Failed to upload data to server",
DOWNLOAD_FAILED => "Failed to download data from server",
INCOMPLETE_RESPONSE => "Received incomplete response from server",
DATA_TRANSFER_INTERRUPTED => "Data transfer was interrupted",
BANDWIDTH_LIMIT_EXCEEDED => "Bandwidth limit has been exceeded",
// Protocol Errors
PROTOCOL_ERROR => "Network protocol error occurred",
INVALID_URL => "Invalid URL format or structure",
UNSUPPORTED_PROTOCOL => "Unsupported network protocol",
TOO_MANY_REDIRECTS => "Too many redirects encountered",
WEBSOCKET_ERROR => "WebSocket connection error",

INVALID_CREDENTIALS => "Invalid credentials provided",
SESSION_EXPIRED => "Session has expired",
UNAUTHORIZED_ACCESS => "Unauthorized access attempt",
ACCOUNT_LOCKED => "Account is locked",
_ => $"Undefined error code: {errorCode}"
};
}
}





Expand Down
100 changes: 0 additions & 100 deletions Assets/StartHandler.cs

This file was deleted.

68 changes: 68 additions & 0 deletions Other/AccountParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.Json;

namespace XybLauncher
{
public class AccountParser
{

public class Account
{
public int Index { get; set; }
public string DisplayName { get; set; }
public string Email { get; set; }
public string Password { get; set; }
}

public class LauncherData
{
public int Selected { get; set; }
public Account[] Accounts { get; set; }
}

private LauncherData _data;

// Constructor with hardcoded file path
public AccountParser()
{
string filePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"XybLauncher", // Hardcoded folder name
"accounts.json" // Hardcoded file name
);

if (!File.Exists(filePath))
throw new FileNotFoundException($"The file {filePath} was not found.");

string json = File.ReadAllText(filePath);
_data = JsonSerializer.Deserialize<LauncherData>(json)
?? throw new InvalidOperationException("Failed to parse JSON data.");
}

// Method to get account information based on the argument ('email' or 'password')
public string GetAccountInfo(string argument)
{
var selectedAccount = _data.Accounts.FirstOrDefault(a => a.Index == _data.Selected);
if (selectedAccount == null)
throw new InvalidOperationException("No account found with the selected index.");

return argument.ToLower() switch
{
"email" => selectedAccount.Email,
"password" => selectedAccount.Password,
_ => throw new ArgumentException("Invalid argument. Use 'email' or 'password'.")
};
}



}

}


1 change: 0 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using static Terminal.Gui.Graphs.PathAnnotation;
using static XybLauncher.FilesManager;
using static XybLauncher.StartHandler;
using static XybLauncher.AccountHandler;
using System.Net.Http;
using System.Text.Json.Serialization;
Expand Down

0 comments on commit a576411

Please sign in to comment.