简体   繁体   中英

How i convert IEnumerable<long> to long

I make a version checker for a game. We can't see game version from anywhere. We just found version string with Cheat engine. And this is the version string address = 56 32 2E ?? ?? ?? 00 00 56 32 2E ?? ?? ?? 00 00

I'm using Memory.DLL for ArrayOfBytes scan then I want to change it to string.

I tried many methods but I can't fix this.

ERROR AT HERE:

using Memory;

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
        while (true)
        {
            int pID = m.getProcIDFromName("Growtopia");

            bool openProc = false;

            if (pID > 0) openProc = m.OpenProcess(pID);
            long myAobScan = m.AoBScan(0x700000000000, 0x7FFFFFFFFFFF, "56 32 2E ?? ?? ?? 00 00").Result; //ERROR AT HERE... // VERSION ADDRESS
            vers.Text = myAobScan.ToString();

            if (openProc)
            {
                m.writeMemory("0x7FF6F22818C7", "bytes", "0x90 0x90"); // BAN BYPASS
            }
        }
}

IEnumerable Params:

public async Task<IEnumerable<long>> AoBScan(long start, long end, string search, bool writable = false, bool executable = true, string file = "")

IEnumerable can contain between 0 and several hundred thousand longs. So your problem is, it needs to know WHICH long you want to use.

Without knowing how AoBScan behaves (just knowing the parameters isn't super helpful to understanding what the method does) it's hard to tell if you are expecting just one long from it or if there are many to choose from.

That being said, to convert an IEnumerable to a single instance, you have to select one of the items. There's a few ways to do it...

You could use the below to pull out the first

long myAobScan = m.AoBScan(0x700000000000, 0x7FFFFFFFFFFF, "56 32 2E ?? ?? ?? 00 00").Result.First();

Or the below to pull out the last

long myAobScan = m.AoBScan(0x700000000000, 0x7FFFFFFFFFFF, "56 32 2E ?? ?? ?? 00 00").Result.Last();

Or write a Where predicate to pull out the one that matches criteria you expect

long myAobScan = m.AoBScan(0x700000000000, 0x7FFFFFFFFFFF, "56 32 2E ?? ?? ?? 00 00").Result.Where(lng => lng > 10);

All of these will pull ONE long out of the IEnumerable. If you need to pull ALL of them out and convert them to a string, that's a different question altogether.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM