Пример #1
0
        public Server()
        {
            antiGCList  = new List <object>();
            IRCCommands = new IRCCommandList();

            BaseIRCLib.Database.SetDatabase(this);
            BaseIRCLib.Server.SetServer(this);

            Steamworks.Load();
            steamClient  = Steamworks.CreateInterface <ISteamClient009>("SteamClient009");
            clientEngine = Steamworks.CreateInterface <IClientEngine>("CLIENTENGINE_INTERFACE_VERSION001");

            pipe = steamClient.CreateSteamPipe();
            user = steamClient.ConnectToGlobalUser(pipe);

            clientFriends = Steamworks.CastInterface <IClientFriends>(clientEngine.GetIClientFriends(user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001"));
            clientUser    = Steamworks.CastInterface <ISteamUser014>(steamClient.GetISteamUser(user, pipe, "SteamUser014"));
            //clientUser = Steamworks.CastInterface<IClientUser>(clientEngine.GetIClientUser(user, pipe, "CLIENTUSER_INTERFACE_VERSION001"));

            Callback <PersonaStateChange_t>    stateChange   = new Callback <PersonaStateChange_t>(StateChange, PersonaStateChange_t.k_iCallback);
            Callback <FriendChatMsg_t>         friendMessage = new Callback <FriendChatMsg_t>(FriendMessage, FriendChatMsg_t.k_iCallback);
            Callback <ChatRoomMsg_t>           chatMessage   = new Callback <ChatRoomMsg_t>(ChatMessage, ChatRoomMsg_t.k_iCallback);
            Callback <ChatMemberStateChange_t> chatResult    = new Callback <ChatMemberStateChange_t>(ChatResult, ChatMemberStateChange_t.k_iCallback);
            Callback <ChatRoomInvite_t>        chatInvite    = new Callback <ChatRoomInvite_t>(ChatInvite, ChatRoomInvite_t.k_iCallback);

            if (File.Exists("clients.list"))
            {
                clientList = ClientList.LoadClients("clients.list");
            }
            else
            {
                clientList = new ClientList();
                clientList.Save("clients.list");
            }

            foreach (string f in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Commands"), "*.dll"))
            {
                Assembly fA = Assembly.LoadFile(f);
                foreach (Type m in fA.GetTypes())
                {
                    object a = fA.CreateInstance(m.FullName);
                    if (a == null)
                    {
                        Console.WriteLine("Skipping implementation of {0}", m.Name);
                        continue;
                    }

                    antiGCList.Add(a);

                    RegisterCommands(a);
                }
            }
        }
Пример #2
0
		/// <summary>
		/// Initializes the <c>SteamManager</c>.
		/// This MUST be called before other Steam operations are executed.
		/// </summary>
		/// <returns><c>true</c> if everything initialized properly, <c>false</c> otherwise.</returns>
		public static bool Init()
		{
			if (Enabled)
			{
				_log.Warn("Tried to call Init method when SteamManager has already been initialized! Aborting...");
				return false;
			}
			_log = LogManager.GetLogger(typeof(SteamManager));
			try
			{
				if (!Steamworks.Load())
				{
					_log.Error("Steamworks failed to load, throwing exception!");
					throw new SteamException("Steamworks failed to load.", SteamExceptionType.SteamworksLoadFail);
				}

				Client = Steamworks.CreateInterface<ISteamClient010>("SteamClient010");
				if (Client == null)
				{
					_log.Error("Steamclient is NULL!! Throwing exception!");
					throw new SteamException("Steamclient failed to load! Is the client running? (Sharpcraft.Steam.SteamManager.Client == null!)",
											 SteamExceptionType.SteamLoadFail);
				}

				Pipe = Client.CreateSteamPipe();
				User = Client.ConnectToGlobalUser(Pipe);

				Friends = Steamworks.CastInterface<ISteamFriends002>(Client.GetISteamFriends(User, Pipe, "SteamFriends002"));

				if (Friends == null)
					return false;

				FriendList = new SteamFriendList();

				_steamWatcher = new Timer(SteamCheck, null, 0, 1000);
			}
			catch (SteamException ex)
			{
				_log.Warn("Warning! SteamManager caught a SteamException exception, returning FALSE. Steam components will NOT LOAD!");
				_log.Warn("The SteamException type was: " + System.Enum.GetName(typeof(SteamExceptionType), ex.Type));
				return false;
			}
			_log.Info("SteamManager has been initialized!");
			SteamLoaded = true;
			Enabled = true;
			return true;
		}
Пример #3
0
        public bool Initialize()
        {
            if (!Steamworks.Load())
            {
                return(false);
            }

            SteamClient = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");
            if (SteamClient == null)
            {
                return(false);
            }


            Pipe = SteamClient.CreateSteamPipe();
            if (Pipe == 0)
            {
                return(false);
            }

            User = SteamClient.ConnectToGlobalUser(Pipe);
            if (User == 0)
            {
                return(false);
            }


            SteamFriends = Steamworks.CastInterface <ISteamFriends002>(SteamClient.GetISteamFriends(User, Pipe, "SteamFriends002"));
            if (SteamFriends == null)
            {
                return(false);
            }


            SteamUser = Steamworks.CastInterface <ISteamUser013>(SteamClient.GetISteamUser(User, Pipe, "SteamUser013"));
            if (SteamUser == null)
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
        static IFace GetInterface <IFace>(GetterFunc func, string errMsg)
            where IFace : INativeWrapper, new()
        {
            IFace iface = default(IFace);

            try
            {
                iface = Steamworks.CastInterface <IFace>(func());
            }
            catch (Exception ex)
            {
                throw new SteamException(errMsg, ex);
            }

            if (iface == null)
            {
                throw new SteamException(errMsg);
            }

            return(iface);
        }
Пример #5
0
        static void Main(string[] args)
        {
            CSteamID qq = 133724098;


            if (!Steamworks.Load())
            {
                return;
            }

            ISteamClient008 steamclient = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");

            Console.WriteLine("client: " + steamclient);

            int pipe = steamclient.CreateSteamPipe();
            int user = steamclient.ConnectToGlobalUser(pipe);

            Console.WriteLine(user);
            Console.WriteLine(pipe);

            ISteamUtils004   utils   = Steamworks.CastInterface <ISteamUtils004>(steamclient.GetISteamUtils(pipe, "SteamUtils004"));
            ISteamFriends005 friends = Steamworks.CastInterface <ISteamFriends005>(steamclient.GetISteamFriends(user, pipe, "SteamFriends005"));

            int num = friends.GetFriendCount(EFriendFlags.k_EFriendFlagAll);

            for (int i = 0; i < num; i++)
            {
                CSteamID id   = friends.GetFriendByIndex(i, (int)EFriendFlags.k_EFriendFlagAll);
                string   name = friends.GetFriendPersonaName(id);

                Debug.WriteLine(name);
            }

            CallbackDispatcher.SpawnDispatchThread(pipe);
            Thread.Sleep(5000);
            CallbackDispatcher.StopDispatchThread(pipe);

            steamclient.ReleaseUser(pipe, user);
            steamclient.ReleaseSteamPipe(pipe);
        }
Пример #6
0
        public bool GetInterface()
        {
            steamFriends = Steamworks.CastInterface<ISteamFriends002>( steamClient.GetISteamFriends( user, pipe, "SteamFriends002" ) );

            if ( steamFriends == null )
                return false;

            clientFriends = Steamworks.CastInterface<IClientFriends>( clientEngine.GetIClientFriends( user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001" ) );

            if ( clientFriends == null )
                return false;

            VTable vTable = new VTable( clientFriends.Interface );

            getChatMsg = vTable.GetFunc<NativeGetChatRoomEntry>( 99 );
            getChatName = vTable.GetFunc<NativeGetChatRoomName>( 117 );

            groupChatEnabled = true;
            groupStatusMsg = "Enabled with vtable offsets. (Dangerous)";

            CallbackDispatcher.SpawnDispatchThread( pipe );

            return true;
        }
Пример #7
0
        public bool GetInterface()
        {
            steamFriends = Steamworks.CastInterface <ISteamFriends002>(steamClient.GetISteamFriends(user, pipe, "SteamFriends002"));

            if (steamFriends == null)
            {
                return(false);
            }

            clientFriends = Steamworks.CastInterface <IClientFriends>(clientEngine.GetIClientFriends(user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001"));

            if (clientFriends == null)
            {
                return(false);
            }

            VTScan vtScan = new VTScan(clientFriends.Interface);

            if (vtScan.Init())
            {
                /*
                 * .text:3809F73D 6A 00                                   push    0
                 * .text:3809F73F 68 62 D4 46 38                          push    offset unk_3846D462
                 * .text:3809F744 68 95 03 00 00                          push    394h
                 * .text:3809F749 68 40 E7 3C 38                          push    offset aEBuild_slav_20 ; "e:\\build_slave\\steam_rel_client_win32\\b"...
                 * .text:3809F74E 6A 00                                   push    0
                 * .text:3809F750 68 90 E7 3C 38                          push    offset asc_383CE790 ; "Assertion Failed: bufRet.GetUint8() == "...
                 * .text:3809F755 FF 15 44 E5 37 38                       call    ds:AssertMsgImplementation
                 */
                var results = vtScan.DoScan <NativeGetChatRoomEntry>(
                    "\x6A\x00\x68\x62\xD4\x46\x38\x68\x83\x03\x00\x00\x68\x40\xE7\x3C\x38\x6A\x00\x68\x90\xE7\x3C\x38\xFF\x15\x44\xE5\x37\x38",
                    "xxx????xxxxxx????xxx????xx????"
                    );

                bool foundFirst = false;

                if (results.Count == 0)
                {
                    groupStatusMsg = "Error: Unable to scan for GetChatRoomEntry";
                }
                else
                {
                    if (results.Count > 1)
                    {
                        groupStatusMsg = "Error: Scan for GetChatRoomEntry gave multiple results!";
                    }
                    else
                    {
                        getChatMsg = results[0].Delegate;
                        foundFirst = true;
                    }
                }

                /*
                 * .text:380A06A4 6A 00                                   push    0
                 * .text:380A06A6 68 69 D4 46 38                          push    offset unk_3846D469
                 * .text:380A06AB 68 AB 03 00 00                          push    3AAh
                 * .text:380A06B0 68 40 E7 3C 38                          push    offset aEBuild_slav_20 ; "e:\\build_slave\\steam_rel_client_win32\\b"...
                 * .text:380A06B5 6A 00                                   push    0
                 * .text:380A06B7 68 90 E7 3C 38                          push    offset asc_383CE790 ; "Assertion Failed: bufRet.GetUint8() == "...
                 * .text:380A06BC FF 15 44 E5 37 38                       call    ds:AssertMsgImplementation
                 */

                var results2 = vtScan.DoScan <NativeGetChatRoomName>(
                    "\x6A\x00\x68\x69\xD4\x46\x38\x68\x99\x03\x00\x00\x68\x40\xE7\x3C\x38\x6A\x00\x68\x90\xE7\x3C\x38\xFF\x15\x44\xE5\x37\x38",
                    "xxx????xxxxxx????xxx????xx????"
                    );

                if (results2.Count == 0)
                {
                    groupStatusMsg = "Error: Unable to scan for GetChatRoomName";
                }
                else
                {
                    if (results2.Count > 1)
                    {
                        groupStatusMsg = "Error: Scan for GetChatRoomName gave multiple results!";
                    }
                    else
                    {
                        getChatName      = results2[0].Delegate;
                        groupChatEnabled = foundFirst && true;
                    }
                }
            }
            else
            {
                groupStatusMsg = "Error: Unable to initialize scan!";
            }

            CallbackDispatcher.SpawnDispatchThread(pipe);

            return(true);
        }