Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (isPause)
        {
            return;
        }

        CheckDel();
        int len = ForceHandleList.Count;

        if (len > 0)
        {
            for (int i = 0; i < len; i++)
            {
                ForceHandleList[i]();
            }
        }

        len = HandleList.Count;
        if (len > 0)
        {
            for (int i = 0; i < len; i++)
            {
                HandleList[i]();
            }
        }
    }
Esempio n. 2
0
        private static AuthHandle EstablishOIAP(TPMWrapper tpm)
        {
            ILog log = LogManager.GetLogger("EstablishOIAP");

            for (int i = 0; i < 2; i++)
            {
                TPMCommandRequest  request  = new TPMCommandRequest(TPMCommandNames.TPM_CMD_OIAP, new Parameters());
                TPMCommandResponse response = tpm.Process(request);

                AuthHandle myAuthHandle = response.Parameters.GetValueOf <AuthHandle> ("auth_handle");

//				Parameters parameters = new Parameters ();
                //				parameters.AddValue ("handle", myAuthHandle);
                //				TPMCommandRequest requestFlush = new TPMCommandRequest (TPMCommandNames.TPM_CMD_FLUSH_SPECIFIC, parameters);
                //				tpm.Process (requestFlush);

                //return myAuthHandle;
            }

            Parameters listHandlesParameters = new Parameters();

            listHandlesParameters.AddPrimitiveType("capArea", CapabilityData.TPMCapabilityArea.TPM_CAP_HANDLE);
            listHandlesParameters.AddPrimitiveType("handle_type", TPMResourceType.TPM_RT_AUTH);

            TPMCommandRequest  listHandlesRequest  = new TPMCommandRequest(TPMCommandNames.TPM_CMD_GetCapability, listHandlesParameters);
            TPMCommandResponse listHandlesResponse = tpm.Process(listHandlesRequest);

            HandleList loadedKeyHandles = listHandlesResponse.Parameters.GetValueOf <HandleList> ("handles");



            return(null);
        }
Esempio n. 3
0
    /// <summary>
    /// 添加处理
    /// </summary>
    /// <param name="handle"></param>
    private int AddHandle2List(UpdateHandle handle)
    {
        int id = GetHandleId();

        HandleList.Add(handle);
        IndexDict.Add(id, handle);
        return(id);
    }
Esempio n. 4
0
    private void RestoreList()
    {
        int len = useList.Count;

        HandleList.RemoveRange(0, len);
        for (int i = 0; i < useList.Count; i++)
        {
            HandleList.Add(useList[i]);
        }
    }
Esempio n. 5
0
        private void listHandles_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                if (listHandles.SelectedIndices.Count == 0)
                {
                    return;
                }

                if (HandleList.ConfirmHandleClose())
                {
                    closeMenuItem_Click(sender, null);
                }
            }
        }
Esempio n. 6
0
    /// <summary>
    /// 删除处理
    /// </summary>
    /// <param name="handle"></param>
    private void RemoveHandleFormList(UpdateHandle handle)
    {
        int ind = HandleList.IndexOf(handle);

        if (ind >= 0)
        {
            HandleList.RemoveAt(ind);
        }
        else
        {
            ind = ForceHandleList.IndexOf(handle);
            if (ind >= 0)
            {
                ForceHandleList.RemoveAt(ind);
            }
        }
        ind = FixedUpdateHandle.IndexOf(handle);
        if (ind > 0)
        {
            ForceHandleList.RemoveAt(ind);
        }
        //else
        //{
        //    GameLogger.LogError("找不到已经注册的handle删除");
        //}
        if (IndexDict.ContainsValue(handle))
        {
            int id = -1;
            foreach (KeyValuePair <int, UpdateHandle> item in IndexDict)
            {
                if (item.Value == handle)
                {
                    id = item.Key;
                    break;
                }
            }
            if (id >= 0)
            {
                IndexDict.Remove(id);
            }
        }
    }
Esempio n. 7
0
        private void propertiesMenuItem_Click(object sender, EventArgs e)
        {
            string type = listHandles.SelectedItems[0].SubItems[1].Text;

            if (type == "DLL" || type == "Mapped File")
            {
                FileUtils.ShowProperties(listHandles.SelectedItems[0].SubItems[2].Text);
                return;
            }

            try
            {
                HandleList.ShowHandleProperties(
                    (SystemHandleEntry)listHandles.SelectedItems[0].Tag
                    );
            }
            catch (Exception ex)
            {
                PhUtils.ShowException("Unable to show handle properties", ex);
            }
        }
 private void grow()
 {
     int newCapacity = (entries.Length << 1) + 1;
     byte[] newStatus = new byte[newCapacity];
     Object[] newEntries = new Object[newCapacity];
     HandleList[] newDeps = new HandleList[newCapacity];
     System.Array.Copy(status, 0, newStatus, 0, _size);
     System.Array.Copy(entries, 0, newEntries, 0, _size);
     System.Array.Copy(deps, 0, newDeps, 0, _size);
     status = newStatus;
     entries = newEntries;
     deps = newDeps;
 }
 internal void markDependency(int dependent, int target)
 {
     if (dependent == NULL_HANDLE || target == NULL_HANDLE) {
     return;
     }
     switch (status[dependent]) {
     case STATUS_UNKNOWN:
         switch (status[target]) {
             case STATUS_OK:
                 // ignore dependencies on objs with no exception
                 break;
             case STATUS_EXCEPTION:
                 // eagerly propagate exception
                 markException(dependent,
                     (Exception) entries[target]);
                 break;
             case STATUS_UNKNOWN:
                 // add to dependency list of target
                 if (deps[target] == null) {
                     deps[target] = new HandleList();
                 }
                 deps[target].add(dependent);
                 // remember lowest unresolved target seen
                 if (lowDep < 0 || lowDep > target) {
                     lowDep = target;
                 }
                 break;
             default:
                 throw new Exception();
         }
         break;
     case STATUS_EXCEPTION:
         break;
     default:
         throw new Exception();
     }
 }
Esempio n. 10
0
        void CreateProcessWithExplicitHandles(string lpApplicationName, string lpCommandLine, string lpCurrentDirectory)
        {
            IntPtr lpAttributeList = IntPtr.Zero;

            IntPtr size = IntPtr.Zero;

            InitializeProcThreadAttributeList(lpAttributeList, 1, 0, ref size);
            lpAttributeList = Marshal.AllocHGlobal(size.ToInt32());
            if (!InitializeProcThreadAttributeList(lpAttributeList, 1, 0, ref size))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "InitializeProcThreadAttributeList failed");
            }
            try
            {
                STARTUPINFOEX info = new STARTUPINFOEX();
                info.StartupInfo.cb      = Marshal.SizeOf(info);
                info.lpAttributeList     = lpAttributeList;
                info.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
                IntPtr readPipe;
                IntPtr writePipe;
                SECURITY_ATTRIBUTES security_attributes = new SECURITY_ATTRIBUTES();
                security_attributes.nLength = Marshal.SizeOf(security_attributes);
                security_attributes.lpSecurityDescriptor = IntPtr.Zero;
                security_attributes.bInheritHandle       = 1;

                if (!CreatePipe(out readPipe, out writePipe, ref security_attributes, 0))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "CreatePipe failed");
                }

                IntPtr readPipe2, writePipe2;
                if (!CreatePipe(out readPipe2, out writePipe2, ref security_attributes, 0))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "CreatePipe failed");
                }
                info.StartupInfo.hStdError  = writePipe;
                info.StartupInfo.hStdOutput = writePipe;
                info.StartupInfo.hStdInput  = INVALID_HANDLE_VALUE;

                HandleList handles = new HandleList()
                {
                    handle0 = writePipe
                };
                if (!UpdateProcThreadAttribute(lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
                                               ref handles, (IntPtr)(1 * Marshal.SizeOf(typeof(IntPtr))), IntPtr.Zero, IntPtr.Zero))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "UpdateProcThreadAttribute failed");
                }

                PROCESS_INFORMATION lpProcessInformation;
                if (!CreateProcess(lpApplicationName,
                                   lpCommandLine,
                                   IntPtr.Zero,
                                   IntPtr.Zero,
                                   true,
                                   /* CREATE_UNICODE_ENVIRONMENT | */ EXTENDED_STARTUPINFO_PRESENT,
                                   IntPtr.Zero,
                                   lpCurrentDirectory,
                                   ref info,
                                   out lpProcessInformation))
                {
                    CloseHandle(readPipe);
                    CloseHandle(writePipe);
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "CreateProcess " + lpApplicationName + " failed");
                }
                CloseHandle(writePipe);
                CloseHandle(lpProcessInformation.hThread);
                CloseHandle(lpProcessInformation.hProcess);

                StringBuilder output = new StringBuilder();
                using (var stream = new FileStream(readPipe, FileAccess.Read))
                {
                    byte[] buffer = new byte[4096];
                    while (true)
                    {
                        int n = stream.Read(buffer, 0, buffer.Length);
                        if (n == 0)
                        {
                            break;
                        }
                        output.Append(Encoding.Default.GetString(buffer, 0, n));

                        if (buffer.Where(c => c == '\n').Count() > 0) // matches Console.Out.WriteLine("JobManager has started"); in JobManager
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                DeleteProcThreadAttributeList(lpAttributeList);
                Marshal.FreeHGlobal(lpAttributeList);
            }
        }
Esempio n. 11
0
 private static extern bool UpdateProcThreadAttribute(IntPtr lpAttributeList, uint dwFlags, IntPtr Attribute, [In] ref HandleList handles, IntPtr cbSize, IntPtr lpPreviousValue, IntPtr lpReturnSize);
Esempio n. 12
0
 internal static extern TelephonyError TelephonyDeinit(ref HandleList list);
Esempio n. 13
0
 internal static extern TelephonyError TelephonyInit(out HandleList list);