private void ResetInit() { SteamClientDllHandle = IntPtr.Zero; ClientEngineInterfacePtr = IntPtr.Zero; ClientShortcutsInterfacePtr = IntPtr.Zero; _clientShortcuts = null; //ClientShortcutsVTable = IntPtr.Zero; //SteamClientInterface = IntPtr.Zero; _callCreateInterface = null; _callCreateSteamPipe = null; _callBReleaseSteamPipe = null; _callConnectToGlobalUser = null; _callReleaseUser = null; User = 0; Pipe = 0; }
private bool InitSteam() { if (SteamProcessInfo.SteamProcess == null) { Logger.Error("The Steam process could not be located or started. Aborting Steam initialization."); return(false); } if (IsLoaded(SteamClientDllHandle)) { Logger.Info("Steam is already initialized."); return(true); } Logger.Info("Beginning initialization of Steam..."); SysNative.SetDllDirectory(SteamProcessInfo.SteamInstallPath + ";" + Path.Combine(SteamProcessInfo.SteamInstallPath, "bin")); var clientDllHandle = SysNative.LoadLibraryEx(SteamProcessInfo.SteamClientDllPath, IntPtr.Zero, SysNative.LOAD_WITH_ALTERED_SEARCH_PATH); if (!IsLoaded(clientDllHandle)) { Logger.Error("Failed to load the Steam Client DLL. Aborting initialization.", 1); return(false); } _callCreateInterface = SysNative.GetExportFunction <SteamNative.CreateInterface>(clientDllHandle, "CreateInterface"); if (_callCreateInterface == null) { Logger.Error("Failed to retrieve the 'CreateInterface' export function. Aborting initialization.", 1); return(false); } _callCreateSteamPipe = SysNative.GetExportFunction <SteamNative.CreateSteamPipe>(clientDllHandle, "Steam_CreateSteamPipe"); if (_callCreateSteamPipe == null) { Logger.Error("Failed to retrieve the 'Steam_CreateSteamPipe' export function. Aborting initialization.", 1); return(false); } _callBReleaseSteamPipe = SysNative.GetExportFunction <SteamNative.BReleaseSteamPipe>(clientDllHandle, "Steam_BReleaseSteamPipe"); if (_callBReleaseSteamPipe == null) { Logger.Error("Failed to retrieve the 'Steam_BReleaseSteamPipe' export function. Aborting initialization.", 1); return(false); } _callConnectToGlobalUser = SysNative.GetExportFunction <SteamNative.ConnectToGlobalUser>(clientDllHandle, "Steam_ConnectToGlobalUser"); if (_callConnectToGlobalUser == null) { Logger.Error("Failed to retrieve the 'Steam_ConnectToGlobalUser' export function. Aborting initialization.", 1); return(false); } _callReleaseUser = SysNative.GetExportFunction <SteamNative.ReleaseUser>(clientDllHandle, "Steam_ReleaseUser"); if (_callReleaseUser == null) { Logger.Error("Failed to retrieve the 'Steam_ReleaseUser' export function. Aborting initialization.", 1); return(false); } Pipe = CreateSteamPipe(); if (!IsValidPipe(Pipe)) { Logger.Error("Failed to create a Steam pipe (IPC). Aborting initialization.", 1); return(false); } User = ConnectToGlobalUser(Pipe); if (!IsValidUser(User)) { Logger.Error("Failed to connect to Steam global user (IPC). Aborting initialization.", 1); return(false); } SteamClientDllHandle = clientDllHandle; Logger.Info("Steam initialization succeeded!", 1); return(true); }