コード例 #1
0
ファイル: dris.cs プロジェクト: Zagrous/EdgeEnergy.Dashboard
        // calls the DDProtCheck function in the appropriate DLL
        public static int DdProtCheck(Dris dris, byte[] data)
        {
            int retCode = -1;

            if (IntPtr.Size == 4)
            {
                try
                {
                    retCode = DdProtCheck32.DDProtCheck(dris, data);
                }
                catch (DllNotFoundException)
                {
                    MessageBox.Show("Cannot find dpwin32.dll. This should be in the same folder as DllTest.",
                                    "EdgeEnergy", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            else
            {
                try
                {
                    retCode = DdProtCheck64.DDProtCheck(dris, data);
                }
                catch (DllNotFoundException)
                {
                    MessageBox.Show("Cannot find dpwin64.dll. This should be in the same folder as DllTest.",
                                    "EdgeEnergy", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            return(retCode);
        }
コード例 #2
0
ファイル: dris.cs プロジェクト: Zagrous/EdgeEnergy.Dashboard
        // converts to DRIS structure to a byte array (so we can do encryption)
        public void DrisToByteArray(Dris dris, byte[] data)
        {
            GCHandle myGc = GCHandle.Alloc(data, GCHandleType.Pinned);

            Marshal.StructureToPtr(dris, myGc.AddrOfPinnedObject(), false);
            myGc.Free();
        }
コード例 #3
0
ファイル: dris.cs プロジェクト: Zagrous/EdgeEnergy.Dashboard
        // converts a byte array to the DRIS structure (so we can do encryption)
        public void ByteArrayToDris(byte[] data, Dris dris)
        {
            GCHandle myGc = GCHandle.Alloc(data, GCHandleType.Pinned);

            Marshal.PtrToStructure(myGc.AddrOfPinnedObject(), dris);
            myGc.Free();
        }
コード例 #4
0
ファイル: dris.cs プロジェクト: Zagrous/EdgeEnergy.Dashboard
        public const int ProtectionCheck = 1;           // checks for dongle, check program params...

        public static int ProtCheck()
        {
            var dris = new Dris();                                                      // initialise the DRIS with random values & set the header

            dris.size     = Marshal.SizeOf(dris);
            dris.function = ProtectionCheck;                            // standard protection check, checks for dongle
            dris.flags    = 0;                                          // no extra flags, but you may want to specify some if you want to start a network user or decrement execs,...

            int retCode = DinkeyPro.DdProtCheck(dris, null);

            //if (retCode != 0)
            //{
            //    dris.DisplayError(retCode, dris.ext_err);
            //    return retCode;
            //}

            // later in your code you can check other values in the DRIS...
            if (dris.sdsn != 12227)
            {
                MessageBox.Show(string.Format("Edge Energy Dongle not found ({0},{1}).", retCode, dris.sdsn), "EdgeEnergy", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                return(-1);
            }

            // later on in your program you can check the return code again
            if (dris.ret_code != 0)
            {
                MessageBox.Show(string.Format("Edge Energy Dongle not found ({0}).", retCode), "EdgeEnergy", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return(-1);
            }

            // if you are using a network dongle and you want to list the network users then use this function:
            // DisplayNetUsers(dris);

            return(0);
        }
コード例 #5
0
ファイル: dris.cs プロジェクト: Zagrous/EdgeEnergy.Dashboard
 public static extern int DDProtCheck([In, Out, MarshalAs(UnmanagedType.LPStruct)] Dris dris, byte[] data);