Example #1
0
        private static string findSessionKey(Process p)
        {
            string key = null;

            MemorySearcher ms = new MemorySearcher(p);

            try
            {
                ms.BuildCache();
                string url = ms.FindString(m_SEARCH_STRING, m_SEARCH_WILDCARDS);
                while (url == null)
                {
                    Thread.Sleep(1000);
                    ms.BuildCache();
                    url = ms.FindString(m_SEARCH_STRING, m_SEARCH_WILDCARDS);
                }

                Match m = m_SESSION_KEY_REGEX.Match(url);
                if (m.Success)
                {
                    key = m.Groups[1].Value;
                }
            }
            finally
            {
                ms.ClearCache();
            }

            return key;
        }
Example #2
0
        private void WaitForUrlThread(object s)
        {
            Process p = WaitForProcess();

            MemorySearcher ms = new MemorySearcher(p);
            try
            {
                Debug.WriteLine("Caching Gw2 memory regions...");
                ms.BuildCache();
                Debug.WriteLine("Searching for url...");
                string url = ms.FindString(searchString, searchWildcards);
                while (url == null)
                {
                    Debug.WriteLine("Url not found, waiting 1 second and trying again.");
                    Thread.Sleep(1000);
                    Debug.WriteLine("Caching new Gw2 memory regions...");
                    ms.BuildCache();
                    Debug.WriteLine("Searching for url...");
                    url = ms.FindString(searchString, searchWildcards);
                }
                Debug.WriteLine(String.Format("Url found {0}", url));
                this.Uri = url;
                Key = ParseSessionKey(url);
                //event fired
            }
            finally
            {
                ms.ClearCache();
                running = false;

                if (UriFound != null)
                {
                    UriFound(this, new UriFoundEventArgs(Uri, Key));
                }
            }
        }