static internal Interop.TEEC_Operation64 Create_TEEC_Operation64() { Interop.TEEC_Operation64 op = new Interop.TEEC_Operation64(); op.started = 0; op.paramTypes = 0; op.paramlist = new Interop.TEEC_Parameter64[4]; return(op); }
/// <summary> /// This function invokes a command within the specified session. /// The parameter commandID is an identifier that is used to indicate which of the exposed trusted /// application functions should be invoked. The supported command identifier values are defined by the /// trusted application's protocol. /// There can be up to four parameter objects given in the <paramref name="paramlist"/> array. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="commandID">The command.</param> /// <param name="paramlist">The array of parameters.</param> /// <privilege>http://tizen.org/privilege/tee.client</privilege> /// <privlevel>partner</privlevel> /// <feature>http://tizen.org/feature/security.tee</feature> /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception> /// <exception cref="NotSupportedException">The required feature is not supported.</exception> /// <exception cref="InvalidOperationException">The operation is invalid.</exception> /// <exception cref="ArgumentException">The argument <paramref name="paramlist"/> is wrong.</exception> public void InvokeCommand(uint commandID, Parameter[] paramlist) { int ret; uint ro; if (paramlist != null) { if (IntPtr.Size == 4) { Interop.TEEC_Operation32 op = Create_TEEC_Operation32(); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { op.paramTypes |= InitParam(ref op.paramlist, i, paramlist[i]) << (8 * i); } Marshal.StructureToPtr(op, opptr, false); ret = Interop.Libteec.InvokeCommand(session_imp, commandID, opptr, out ro); op = Marshal.PtrToStructure <Interop.TEEC_Operation32>(opptr); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { UpdateParam(op.paramlist[i], ref paramlist, i); } } else { Interop.TEEC_Operation64 op = Create_TEEC_Operation64(); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { op.paramTypes |= InitParam(ref op.paramlist, i, paramlist[i]) << (8 * i); } Marshal.StructureToPtr(op, opptr, false); ret = Interop.Libteec.InvokeCommand(session_imp, commandID, opptr, out ro); op = Marshal.PtrToStructure <Interop.TEEC_Operation64>(opptr); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { UpdateParam(op.paramlist[i], ref paramlist, i); } } } else { ret = Interop.Libteec.InvokeCommand(session_imp, commandID, IntPtr.Zero, out ro); } for (int i = 0; i < 4; ++i) { if (shm[i] != null) { context.ReleaseSharedMemory(shm[i]); shm[i] = null; } } //MAYBE map origin of return code to specific Exception Interop.CheckNThrowException(ret, string.Format("InvokeCommand({0})", commandID)); }
internal void Open64(Guid destination, uint loginMethod, byte[] connectionData, Parameter[] paramlist) { Interop.TEEC_UUID uuid = Interop.TEEC_UUID.ToTeecUuid(destination); int ret; uint ro; if (paramlist != null) { Interop.TEEC_Operation64 op = Create_TEEC_Operation64(); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { op.paramTypes |= InitParam(ref op.paramlist, i, paramlist[i]) << (8 * i); } Marshal.StructureToPtr(op, opptr, false); ret = Interop.Libteec.OpenSession(context.context_imp, session_imp, ref uuid, loginMethod, connectionData, opptr, out ro); op = Marshal.PtrToStructure <Interop.TEEC_Operation64>(opptr); for (int i = 0; i < 4 && i < paramlist.Length; ++i) { UpdateParam(op.paramlist[i], ref paramlist, i); } } else { ret = Interop.Libteec.OpenSession(context.context_imp, session_imp, ref uuid, loginMethod, connectionData, IntPtr.Zero, out ro); } for (int i = 0; i < 4; ++i) { if (shm[i] != null) { shm[i].Dispose(); shm[i] = null; } } //MAYBE map origin of return code to specyfic Exception Interop.CheckNThrowException(ret, string.Format("OpenSession('{0}')", destination)); opened = true; }