Example #1
0
 public static void setMyProcessID(int uid, string serverid, int isLocal)
 {
     lock (AppInterProcess._thisSharedLock)
     {
         int    id  = Process.GetCurrentProcess().Id;
         int    num = 3208;
         byte[] array;
         if (serverid == null || serverid == "")
         {
             array = new byte[8];
             System.Array.Clear(array, 0, array.Length);
         }
         else
         {
             array = System.Text.Encoding.ASCII.GetBytes(serverid);
         }
         long num2 = System.BitConverter.ToInt64(array, 0);
         if (AppInterProcess._semaphoreEcoInstance != null)
         {
             AppInterProcess._semaphoreEcoInstance.WaitOne();
             byte[] array2 = AppInterProcess.ReadShareArray(0L, (long)num);
             long   num3   = AppInterProcess.getValue64(array2, 0);
             bool   flag2  = false;
             int    num4   = 0;
             while ((long)num4 < System.Math.Min(num3, 100L))
             {
                 int  num5  = num4 * 32 + 8;
                 long value = AppInterProcess.getValue64(array2, num5);
                 num5 += 8;
                 long value2 = AppInterProcess.getValue64(array2, num5);
                 num5 += 8;
                 long value3 = AppInterProcess.getValue64(array2, num5);
                 num5 += 8;
                 AppInterProcess.getValue64(array2, num5);
                 if (value == (long)uid && value2 == num2 && value3 == (long)isLocal)
                 {
                     AppInterProcess.setValue64(array2, num5, (long)id);
                     flag2 = true;
                     break;
                 }
                 num4++;
             }
             if (!flag2 && num3 < 99L)
             {
                 int num6 = (int)num3 * 32 + 8;
                 AppInterProcess.setValue64(array2, num6, (long)uid);
                 num6 += 8;
                 AppInterProcess.setValue64(array2, num6, num2);
                 num6 += 8;
                 AppInterProcess.setValue64(array2, num6, (long)isLocal);
                 num6 += 8;
                 AppInterProcess.setValue64(array2, num6, (long)id);
                 num3 += 1L;
                 AppInterProcess.setValue64(array2, 0, num3);
             }
             AppInterProcess.WriteShareArray(0L, array2);
             AppInterProcess._semaphoreEcoInstance.Release();
         }
     }
 }
Example #2
0
        public static bool OpenInterProcessShared()
        {
            Semaphore semaphore = AppInterProcess.OpenGlobalSemaphore("Global\\ecoAppMapSemaphore", 1, 1);

            if (semaphore == null)
            {
                return(false);
            }
            AppInterProcess._semaphoreEcoInstance = semaphore;
            int num = 3208;

            AppInterProcess._semaphoreEcoInstance.WaitOne();
            int num2 = AppInterProcess.SetupShareMemoryWithSercurity(num);

            if (num2 <= 0)
            {
                byte[] array = new byte[num];
                System.Array.Clear(array, 0, array.Length);
                AppInterProcess.WriteShareArray(0L, array);
            }
            AppInterProcess._semaphoreEcoInstance.Release();
            return(true);
        }