Esempio n. 1
0
        private ProgramInfo GetProgramInfoForInitialProcess()
        {
            if (_programInfoForInitialProcess == null)
            {
                lock (_programInfoForInitialProcessGuard)
                {
                    _programInfoForInitialProcess ??= ProgramInfo.CreateProgramInfoForInitialProcess(FsServer);
                }
            }

            return(_programInfoForInitialProcess);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the <see cref="ProgramInfo"/> associated with the specified program ID.
        /// </summary>
        /// <param name="programInfo">If the method returns successfully, contains the <see cref="ProgramInfo"/>
        /// associated with the specified program ID.</param>
        /// <param name="programId">The program ID of the <see cref="ProgramInfo"/> to get.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.TargetProgramNotFound"/>: The <see cref="ProgramInfo"/> was not found.</returns>
        public Result GetProgramInfoByProgramId(out ProgramInfo programInfo, ulong programId)
        {
            lock (ProgramInfoList)
            {
                foreach (ProgramInfo info in ProgramInfoList)
                {
                    if (info.ProgramId.Value == programId)
                    {
                        programInfo = info;
                        return(Result.Success);
                    }
                }

                programInfo = default;
                return(ResultFs.TargetProgramNotFound.Log());
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the <see cref="ProgramInfo"/> associated with the specified program ID.
        /// </summary>
        /// <param name="programInfo">If the method returns successfully, contains the <see cref="ProgramInfo"/>
        /// associated with the specified program ID.</param>
        /// <param name="programId">The program ID of the <see cref="ProgramInfo"/> to get.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.TargetProgramNotFound"/>: The <see cref="ProgramInfo"/> was not found.</returns>
        public Result GetProgramInfoByProgramId(out ProgramInfo programInfo, ulong programId)
        {
            lock (ProgramInfoList)
            {
                foreach (ProgramInfo info in ProgramInfoList)
                {
                    if (info.ProgramId.Value == programId)
                    {
                        programInfo = info;
                        return(Result.Success);
                    }
                }

                UnsafeHelpers.SkipParamInit(out programInfo);
                return(ResultFs.TargetProgramNotFound.Log());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Registers a program with information about that program in the program registry.
        /// </summary>
        /// <param name="processId">The process ID of the program.</param>
        /// <param name="programId">The <see cref="ProgramId"/> of the program.</param>
        /// <param name="storageId">The <see cref="StorageId"/> where the program is located.</param>
        /// <param name="accessControlData">The FS access control data header located in the program's ACI.</param>
        /// <param name="accessControlDescriptor">The FS access control descriptor located in the program's ACID.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.InvalidArgument"/>: The process ID is already registered.</returns>
        public Result RegisterProgram(ulong processId, ProgramId programId, StorageId storageId,
                                      ReadOnlySpan <byte> accessControlData, ReadOnlySpan <byte> accessControlDescriptor)
        {
            var programInfo = new ProgramInfo(FsServer, processId, programId, storageId, accessControlData,
                                              accessControlDescriptor);

            lock (ProgramInfoList)
            {
                foreach (ProgramInfo info in ProgramInfoList)
                {
                    if (info.Contains(processId))
                    {
                        return(ResultFs.InvalidArgument.Log());
                    }
                }

                ProgramInfoList.AddLast(programInfo);
                return(Result.Success);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the <see cref="ProgramInfo"/> associated with the specified process ID.
        /// </summary>
        /// <param name="programInfo">If the method returns successfully, contains the <see cref="ProgramInfo"/>
        /// associated with the specified process ID.</param>
        /// <param name="processId">The process ID of the <see cref="ProgramInfo"/> to get.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.TargetProgramNotFound"/>: The <see cref="ProgramInfo"/> was not found.</returns>
        public Result GetProgramInfo(out ProgramInfo programInfo, ulong processId)
        {
            lock (ProgramInfoList)
            {
                if (ProgramInfo.IsInitialProgram(processId))
                {
                    programInfo = GetProgramInfoForInitialProcess();
                    return(Result.Success);
                }

                foreach (ProgramInfo info in ProgramInfoList)
                {
                    if (info.Contains(processId))
                    {
                        programInfo = info;
                        return(Result.Success);
                    }
                }

                programInfo = default;
                return(ResultFs.TargetProgramNotFound.Log());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the <see cref="ProgramInfo"/> associated with the specified process ID.
        /// </summary>
        /// <param name="programInfo">If the method returns successfully, contains the <see cref="ProgramInfo"/>
        /// associated with the specified process ID.</param>
        /// <param name="processId">The process ID of the <see cref="ProgramInfo"/> to get.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.ProgramInfoNotFound"/>: The <see cref="ProgramInfo"/> was not found.</returns>
        public Result GetProgramInfo(out ProgramInfo programInfo, ulong processId)
        {
            lock (ProgramInfoList)
            {
                if (ProgramInfo.IsInitialProgram(processId))
                {
                    programInfo = GetProgramInfoForInitialProcess();
                    return(Result.Success);
                }

                foreach (ProgramInfo info in ProgramInfoList)
                {
                    if (info.Contains(processId))
                    {
                        programInfo = info;
                        return(Result.Success);
                    }
                }

                UnsafeHelpers.SkipParamInit(out programInfo);
                return(ResultFs.ProgramInfoNotFound.Log());
            }
        }