コード例 #1
0
ファイル: BaseSession.cs プロジェクト: suifengsigan/TEST_1
        public static void InitLicense()
        {
            bool flag = false;

            try
            {
                flag = verifyAssemblyData(false);
            }
            catch (NeedSNAPAuthorLicenseException exception)
            {
                if (JAM_presence_check_snap_author_license() != 0)
                {
                    throw exception;
                }
                Trace.WriteLine(exception);
                Trace.WriteLine("Validation failed but author license exists - loading library");
                AddDLLAuthorization(JAM.ToStringFromLocale(JAM_get_filename(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName)), ResourceUtilities.SignatureType.SNAP_TYPE);
            }
            catch (NeedDOTNETAuthorLicenseException exception2)
            {
                if (JAM_presence_check_dotnet_author_license() != 0)
                {
                    throw exception2;
                }
                Trace.WriteLine(exception2);
                Trace.WriteLine("Validation failed but author license exists - loading library");
                AddDLLAuthorization(JAM.ToStringFromLocale(JAM_get_filename(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName)), ResourceUtilities.SignatureType.NORMAL_TYPE);
            }
            catch (Exception exception3)
            {
                throw exception3;
            }
            if (!flag)
            {
                int status = JAM_check_session_license(AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName);
                if (status != 0)
                {
                    Trace.WriteLine("Could not obtain runtime license");
                    throw NXException.Create(status);
                }
            }
        }
コード例 #2
0
ファイル: BaseSession.cs プロジェクト: suifengsigan/TEST_1
        public static bool RefreshSessionTable()
        {
            bool flag = false;

            try
            {
                verifyAssemblyData(true);
                flag = true;
            }
            catch (NeedSNAPAuthorLicenseException exception)
            {
                if (JAM_presence_check_snap_author_license() != 0)
                {
                    throw exception;
                }
                Trace.WriteLine(exception);
                Trace.WriteLine("Validation failed but author license exists - loading library");
                AddDLLAuthorization(JAM.ToStringFromLocale(JAM_get_filename(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName)), ResourceUtilities.SignatureType.SNAP_TYPE);
                return(true);
            }
            catch (NeedDOTNETAuthorLicenseException exception2)
            {
                if (JAM_presence_check_dotnet_author_license() != 0)
                {
                    throw exception2;
                }
                Trace.WriteLine(exception2);
                Trace.WriteLine("Validation failed but author license exists - loading library");
                AddDLLAuthorization(JAM.ToStringFromLocale(JAM_get_filename(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName)), ResourceUtilities.SignatureType.NORMAL_TYPE);
                return(true);
            }
            catch (Exception exception3)
            {
                throw exception3;
            }
            return(flag);
        }
コード例 #3
0
ファイル: BaseSession.cs プロジェクト: suifengsigan/TEST_1
        public static bool needToEvaluate()
        {
            ResourceUtilities.SignatureType sigType = ResourceUtilities.SignatureType.NORMAL_TYPE;
            string key = JAM.ToStringFromLocale(evalualuteCallStack(ref sigType));

            if ((key == null) || (sigType == ResourceUtilities.SignatureType.MINI_SNAP))
            {
                return(false);
            }
            bool flag = true;

            if ((sessionList == null) || !sessionList.Contains(key))
            {
                return(flag);
            }
            int num = sessionList.IndexOfKey(key);

            ResourceUtilities.SignatureType type2 = (ResourceUtilities.SignatureType)sessionList.GetValueList()[num];
            if ((type2 == ResourceUtilities.SignatureType.BOTH_TYPE) || (type2 == sigType))
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
        public static TaggedObject Get(Tag objectTag, string name)
        {
            ObjectMapEntry entry;
            string         str;
            string         str2;
            Type           type;

            RegisterTagEventHandler();
            if (objectTag == Tag.Null)
            {
                return(null);
            }
            objectMap.TryGetValue(objectTag, out entry);
            classNameMap.TryGetValue(objectTag, out str);
            if (name != null)
            {
                str2 = name;
            }
            else
            {
                int    error = 0;
                IntPtr s     = JAM_ask_object_class_name_managed(objectTag, ref error);
                if (error != 0)
                {
                    throw new Exception(string.Concat(new object[] { "Could not get class name for tag: ", objectTag, ", error: ", error }));
                }
                str2 = JAM.ToStringFromLocale(s);
            }
            if ((entry != null) && (str2 != str))
            {
                Delete(objectTag);
                entry = null;
            }
            if (entry != null)
            {
                return(entry.Obj);
            }
            classMap.TryGetValue(str2, out type);
            if (type == null)
            {
                type = FindTypeForClass(str2, typeof(TaggedObject));
            }
            if (type == null)
            {
                throw new Exception(string.Concat(new object[] { "No automation class for tag: ", objectTag, ", class: ", str2 }));
            }
            ConstructorInfo info = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);

            if (info == null)
            {
                throw new Exception("No constructor found for: " + type);
            }
            TaggedObject obj2  = (TaggedObject)info.Invoke(null);
            MethodInfo   info2 = type.GetMethod("initialize", BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);

            if (info2 != null)
            {
                info2.Invoke(obj2, null);
            }
            ObjectMapEntry entry2 = new ObjectMapEntry(obj2, str2);

            objectMap[objectTag]    = entry2;
            classNameMap[objectTag] = str2;
            obj2.SetTag(objectTag);
            return(obj2);
        }
コード例 #5
0
ファイル: BaseSession.cs プロジェクト: suifengsigan/TEST_1
        public static bool verifyAssemblyData(bool callEvaluateStack)
        {
            return(true);

            bool   flag  = false;
            bool   flag2 = false;
            IntPtr p     = JAM_get_filename(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName);

            ResourceUtilities.SignatureType sigType = ResourceUtilities.SignatureType.NORMAL_TYPE;
            if (((p == IntPtr.Zero) && (JAM_dotnet_verification_override() == 0)) || callEvaluateStack)
            {
                p = evalualuteCallStack(ref sigType);
            }
            else
            {
                sigType = determineSignatureNeeded();
            }
            if (sigType != ResourceUtilities.SignatureType.MINI_SNAP)
            {
                if (CheckDLLAuthorization(AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName, sigType))
                {
                    JAM.SMFree(p);
                }
                else
                {
                    string filename = JAM.ToStringFromLocale(p);
                    flag2 = verifyAssembly(filename, ref flag, sigType);
                    if (flag2)
                    {
                        AddDLLAuthorization(AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName, sigType);
                    }
                    else
                    {
                        StackTrace trace = new StackTrace();
                        SortedList list  = GenerateInitialDllList();
                        string     key   = Path.GetFileNameWithoutExtension(filename) + ".dll";
                        list.Add(key, "notsigned");
                        if (trace.FrameCount > 0)
                        {
                            for (int i = 0; (i < trace.FrameCount) && !flag2; i++)
                            {
                                string location = trace.GetFrame(i).GetMethod().Module.Assembly.Location;
                                string str5     = Path.GetFileNameWithoutExtension(JAM.ToStringFromLocale(JAM_get_filename("", location))) + ".dll";
                                if (list.Contains(str5))
                                {
                                    string strA = (string)list.GetValueList()[0];
                                    if (((string.Compare(strA, "skip", false) == 0) || (string.Compare(strA, "notsigned", false) == 0)) || (string.Compare(strA, "signed", false) == 0))
                                    {
                                        continue;
                                    }
                                }
                                flag2 = verifyAssembly(JAM.ToStringFromLocale(JAM_get_filename("", location)), ref flag, sigType);
                                if (flag2)
                                {
                                    list.Add(str5, "signed");
                                    AddDLLAuthorization(location, sigType);
                                }
                                else
                                {
                                    list.Add(str5, "notsigned");
                                }
                            }
                        }
                        if (!flag2)
                        {
                            if (sigType == ResourceUtilities.SignatureType.SNAP_TYPE)
                            {
                                throw new NeedSNAPAuthorLicenseException("Invalid NX signature found");
                            }
                            throw new NeedDOTNETAuthorLicenseException("Invalid NX signature found");
                        }
                    }
                }
                if (flag)
                {
                    JAM_declare_alliance_context(AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName);
                }
            }
            return(flag);
        }
コード例 #6
0
ファイル: BaseSession.cs プロジェクト: suifengsigan/TEST_1
        public static IntPtr evalualuteCallStack(ref ResourceUtilities.SignatureType sigType)
        {
            StackTrace trace = new StackTrace();

            sigType = ResourceUtilities.SignatureType.NORMAL_TYPE;
            bool       flag  = false;
            bool       flag2 = false;
            SortedList list  = GenerateInitialDllList();
            ArrayList  c     = new ArrayList();

            if (trace.FrameCount > 0)
            {
                for (int i = 0; i < trace.FrameCount; i++)
                {
                    string location = trace.GetFrame(i).GetMethod().Module.Assembly.Location;
                    string path     = JAM.ToStringFromLocale(JAM_get_filename("", location));
                    string key      = Path.GetFileNameWithoutExtension(path) + ".dll";
                    if (!list.Contains(key) && !c.Contains(path))
                    {
                        c.Add(path);
                    }
                    //if (!flag && (string.Compare(key, "Snap.dll", true) == 0))
                    //{
                    //    flag = true;
                    //    sigType = ResourceUtilities.SignatureType.SNAP_TYPE;
                    //}
                    //if (!flag2 && (string.Compare(key, "MiniSnap.dll", true) == 0))
                    //{
                    //    flag2 = true;
                    //    sigType = ResourceUtilities.SignatureType.MINI_SNAP;
                    //}
                }
                int    num2  = 0;
                string str4  = null;
                bool   flag3 = false;
                for (int j = 0; j < c.Count; j++)
                {
                    string fileName = Path.GetFileName((string)c[j]);
                    if (string.Compare("journal.dll", fileName, true) == 0)
                    {
                        num2++;
                        if (!flag3)
                        {
                            flag3 = true;
                            str4  = (string)c[j];
                        }
                    }
                }
                if (num2 > 0)
                {
                    if (num2 == 1)
                    {
                        ArrayList list3 = new ArrayList(c);
                        list3.Remove(str4);
                        if (list3.Count == 0)
                        {
                            return(IntPtr.Zero);
                        }
                        JAM_lprintf("Detected call to non-NX dll while replaying journal.\n");
                        JAM_lprintf("Validating DLL - " + list3[0] + "\n");
                        return(JAM.ToLocaleString((string)list3[0]));
                    }
                    JAM_lprintf("Detected call to non-NX dll while replaying journal.\n");
                    JAM_lprintf("Validating DLL - " + str4 + "\n");
                    return(JAM.ToLocaleString(str4));
                }
                if (c.Count > 0)
                {
                    return(JAM.ToLocaleString((string)c[0]));
                }
                JAM_lprintf("No journal.dll detected in call stack while replaying journal.\n");
            }
            return(IntPtr.Zero);
        }