Beispiel #1
0
        /*private static void findItemsClass(IntPtr handle, RemoteMemoryStream rms, uint start, uint size)
        {
            rms.InitCache(start, start + size);
            Application.DoEvents();
            try
            {
                uint i = 0;
                uint v;
                uint w;
                BinaryReader binr = new BinaryReader(rms);
                for (i = 0; i < size - 0x5C; i += 4)
                {
                    rms.Seek(start + i, SeekOrigin.Begin);
                    //v = mem[(i) / 4];
                    v = binr.ReadUInt32();
                    if (v != SwfClassToken)
                        continue;

                    rms.Seek(start + i, SeekOrigin.Begin);
                    fClass economic = new fClass(rms, "mResources_vector");

                    fClass items = economic.gC("mResources_vector");
                    itemEntries = new List<CItemEntry>();
                    CItemEntry.reset();
                    foreach (fClass it in items.getClassList("dResourceDefaultDefinition"))
                    {
                        string n = it.gSTR("resourceName_string");
                        Debug.Print("{0} {1}", it.gINT("amount"), n);
                        if ((n != "Population") && (n != "HardCurrency"))
                            itemEntries.Add(new CItemEntry(it));
                    }
                }
            }
            catch (EndOfStreamException e)
            {
                return;
            }
        }*/
        private static void findMainClass(IntPtr handle, RemoteMemoryStream rms, Int64 start, Int64 size)
        {
            rms.InitCache(start, start + size);
            Application.DoEvents();
            try
            {
                uint i = 0;
                uint v;
                uint w;
                uint swftoken;
                BinaryReader binr = new BinaryReader(rms);
                for (i = 0; i < size - 0x5C; i += 4)
                {
                    rms.Seek(start + i, SeekOrigin.Begin);
                    //v = mem[(i) / 4];
                    v = binr.ReadUInt32();
                    if ((v < (uint)npswf.BaseAddress) || (v > (uint)((uint)npswf.BaseAddress + npswf.ModuleMemorySize)))
                        continue;
                    swftoken = v;

                    rms.Seek(start+i, SeekOrigin.Begin);
                    fClass player = new fClass(rms, "cPlayerData");

                    /*if (start + i > 0xBEF0000)
                    {
                        v = binr.ReadUInt32();
                        v = binr.ReadUInt32();
                        if ((v & 0xFFFF) == 4)
                        {
                            string s = player.getClassName();
                            if (s != "")
                                Debug.Print("{0:x} Classname {1}",start+i, s);
                        }
                    }*/

                    if (player.gUINT("mGeologistsAmount") > 25) continue;
                    if (player.gUINT("mExplorersAmount") > 25) continue;
                    if (player.gUINT("mPlayerId") == 0) continue;
                    if (player.gUINT("mPlayerLevel") > 50) continue;
                    if (player.gUINT("mPlayerLevel") == 0) continue;
                    //Debug.Print("P level {0}", player.gUINT("mPlayerLevel"));
                    if (player.gUINT("mGeneralsAmount") > 25) continue;
                    v = player.gUINT("mCurrentBuildingsCountAll");
                    w = player.gUINT("mCurrentMaximumBuildingsCountAll");
                    if (w < v) continue;
                    if (v == 0) continue;
                    if (v > 1000) continue;
                    if (w > 1000) continue;
                    if (w == 0) continue;
                    Debug.Print("Main class at?: {0:x}", start + i);
                    Debug.Print("Buildings {0}/{1}", w, v);

                    //if (w == 135) Debugger.Break();
                    fClass resources = player.gO("mGeneralInterface.mCurrentPlayerZone.map_PlayerID_Resources", player.gUINT("mPlayerId"), "cResources");
                    if (resources == null) continue;
                    fClass items = resources.gC("mResources_vector");
                    Debug.Print("mResources_vector: {0:x}", resources.gUINT("mResources_vector"));
                    itemEntries = new List<CItemEntry>();
                    CItemEntry.reset();
                    foreach (fClass it in items.getClassList("dResource"))
                    {
                        string n=it.gSTR("name_string");
                        Debug.Print("{0} {1}", it.gINT("amount"), n);
                        if((n!="Population")&&(n!="HardCurrency"))
                            itemEntries.Add(new CItemEntry(it));
                    }

                    MainClass = start + i;

                    fClass fdeposits = player.gC("mGeneralInterface.mCurrentPlayerZone.mStreetDataMap.mDeposits_vector");
                    Debug.Print("Deposits at?: {0:x}", fdeposits.getOffset());

                    foreach (fClass r in fdeposits.getClassList("cDeposit"))
                    {
                        CResourceEntry RE = new CResourceEntry(r);
                        Debug.Print("{0}", RE.Name);
                        if (!(((RE.Name == "Wood") || (RE.Name == "RealWood")) && !Params.trees))
                            resourceEntries.Add(RE);
                    }

                    DbConnection3.Open();
                    fClass fbuildings = player.gC("mGeneralInterface.mCurrentPlayerZone.mStreetDataMap.mBuildings_vector");
                    Buildings = new Dictionary<String, uint>();
                    buildingEntries = new List<CBuildingEntry>();
                    Debug.Print("Buildings at?: {0:x}", fbuildings.getOffset());
                    foreach (fClass b in fbuildings.getClassList("cBuilding"))
                    {
                        CBuildingEntry BE = new CBuildingEntry(b);
                        Debug.Print("{0} {1} {2}", BE.Name, BE.X, BE.Y);
                        Debug.Print("{0}", BE.wayTime1);
                        Debug.Print("{0}", BE.wayTime2);
                        if (!Buildings.ContainsKey(BE.Name))
                            Buildings.Add(BE.Name, 1);
                        else
                            Buildings[BE.Name]++;
                        buildingEntries.Add(BE);
                    }
                    DbConnection3.Close();

                    MainClass = start + i;
                    SwfClassToken = swftoken;
                    Debug.Print("Main class at: {0:x}", start + i);

                    Debug.Print("{0:x}", player.gC("mGeneralInterface.mCurrentPlayerZone").getOffset());
                    rms.RemoveCache();
                }
            }
            catch (EndOfStreamException e)
            {
                return;
            }
            return;
        }
Beispiel #2
0
        public static bool connect()
        {
            uint MaxAddress = 0x7fffffff;
            Int64 address = 0;
            bool result;

            itemEntries = new List<CItemEntry>();
            resourceEntries = new List<CResourceEntry>();
            string[] processes;
            if (!isLinux)
                processes = new string[] { "plugin-container", "iexplore", "chrome" }; //plugin-container für Chrome und Firefox ... IE macht wieder sein eigenes Ding
            else
                processes = new string[] { "plugin-containe", "plugin-container" };
            foreach (string pname in processes)
            {
                List<MyProcess> pList = new List<MyProcess>();

                if (!isLinux)
                    foreach (Process p in Process.GetProcessesByName(pname))
                        pList.Add(new MyProcess(p));
                else
                    foreach (LinuxProcess p in Linux.GetProcessesByName(pname))
                        pList.Add(new MyProcess(p));

                foreach (MyProcess p in pList)
                {
                    Main = p;
                    npswf = null;
                    Debug.Print("Process: {0}", pname);

                    if (!isLinux)
                    {
                        foreach (MyProcessModule mo in GetProcessModules(p.Process))
                        {
                            Debug.Print(mo.ModuleName.ToUpper());
                            if (mo.ModuleName.ToUpper() == "NPSWF32.DLL") //wird von Firefox geladen
                            {
                                npswf = mo;
                                break;
                            }
                            if (mo.ModuleName.ToUpper() == "GCSWF32.DLL") //wird von Chrome geladen
                            {
                                npswf = mo;
                                break;
                            }
                            if ((mo.ModuleName.ToUpper().Substring(0, 5) == "FLASH") && (mo.ModuleName.ToUpper().Substring(mo.ModuleName.Length - 4, 4) == ".OCX")) //Flash*.ocx ... Internet Explorer ...
                            {
                                npswf = mo;
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (MyProcessModule mo in Linux.GetProcessModules(p.LinuxProcess))
                        {
                            Debug.Print("Module ...");
                            Debug.Print(mo.ModuleName.ToUpper());
                            if (mo.ModuleName.ToUpper() == "LIBFLASHPLAYER.SO")
                            {
                                npswf = mo;
                                int i = 0;
                                foreach (MyProcessModule mo2 in Linux.GetProcessModules(p.LinuxProcess))
                                    if (mo2.ModuleName.ToUpper() == "LIBFLASHPLAYER.SO")
                                        if (i++ >= 1)
                                            npswf.ModuleMemorySize += mo2.ModuleMemorySize;
                                break;
                            }
                        }
                    }

                    Debug.Print("End module list loop");

                    if (npswf == null) continue; //nix gefunden ... versuche es mit nächstem Prozess

                    Debug.Print("npswf found ...");

                    RemoteMemoryStream rms = new RemoteMemoryStream(p.Handle);
                    Int64 size;
                    uint br = 0;
                    address = 0;
                    MEMORY_BASIC_INFORMATION m = new MEMORY_BASIC_INFORMATION();
                    do
                    {
                        result = VirtualQueryEx(p.Handle, (IntPtr)address, out m, (uint)Marshal.SizeOf(m));
                        if (!result) break; //am ende angekommen ... wir können aufhören

                        Debug.Print("Searching in:{0:x} - {1:x} Size: {2:x}", (long)m.BaseAddress, (long)m.BaseAddress + (long)m.RegionSize, m.RegionSize);
                        size = m.RegionSize.ToInt64();
                        if (size > Params.maxmemsize)
                        {
                            address = m.BaseAddress.ToInt64() + m.RegionSize.ToInt64();
                            continue;
                        }
                        if (size == 0)
                        {
                            address = m.BaseAddress.ToInt64() + m.RegionSize.ToInt64();
                            continue;
                        }
                        rms.Seek(m.BaseAddress, SeekOrigin.Begin);

                        findMainClass(p.Handle, rms, m.BaseAddress.ToInt64(), m.RegionSize.ToInt64());
                        if (buildingEntries!=null)
                        {
                            break;
                        }

                        //if ((fClass.Count != 0) && (Main != null) && ((itemEntries.Count > 0) && (!Params.buildingsonly))) break;

                        address = m.BaseAddress.ToInt64() + m.RegionSize.ToInt64();

                    } while (address <= MaxAddress);

                    if ((Main != null) && (itemEntries.Count > 0 && (!Params.buildingsonly))) break;
                }
                if ((Main != null) && ((itemEntries.Count > 0) && (!Params.buildingsonly))) break;
            }

            if ((Main == null) || ((itemEntries.Count == 0) && (!Params.buildingsonly)))
            {
                string errorcode = "";
                if (Main == null)
                    errorcode += "1";
                else
                    errorcode += "0";

                if (itemEntries.Count == 0)
                    errorcode += "1";
                else
                    errorcode += "0";

                if (resourceEntries.Count == 0) //kein KO-Kriterium, aber dennoch hilfreich bei der Fehlersuche
                    errorcode += "1";
                else
                    errorcode += "0";

                if (npswf == null)
                    errorcode += "1";
                else
                    errorcode += "0";

                MessageBox.Show("Fehlercode: " + errorcode + "\nDaten konnten nicht abgefangen werden.\nEntweder ist das Spiel noch nicht gestartet, oder die Version dieses Programms ist veraltet!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return true;
        }