GetThreadSelectorEntry() public static method

Retrieves a descriptor table entry for the specified selector and thread.
public static GetThreadSelectorEntry ( SafeMemoryHandle threadHandle, uint selector ) : LdtEntry
threadHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the thread containing the specified selector.
selector uint The global or local selector value to look up in the thread's descriptor tables.
return Binarysharp.MemoryManagement.Native.LdtEntry
コード例 #1
0
ファイル: RemoteThread.cs プロジェクト: uta-org/SharpNeedle
        /// <summary>
        ///     Gets the linear address of a specified segment.
        /// </summary>
        /// <param name="segment">The segment to get.</param>
        /// <returns>A <see cref="IntPtr" /> pointer corresponding to the linear address of the segment.</returns>
        public IntPtr GetRealSegmentAddress(SegmentRegisters segment)
        {
            // Get a selector entry for the segment
            LdtEntry entry;

            switch (segment)
            {
            case SegmentRegisters.Cs:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegCs);
                break;

            case SegmentRegisters.Ds:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegDs);
                break;

            case SegmentRegisters.Es:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegEs);
                break;

            case SegmentRegisters.Fs:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegFs);
                break;

            case SegmentRegisters.Gs:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegGs);
                break;

            case SegmentRegisters.Ss:
                entry = ThreadCore.GetThreadSelectorEntry(Handle, Context.SegSs);
                break;

            default:
                throw new InvalidEnumArgumentException("segment");
            }

            // Compute the linear address
            return(new IntPtr(entry.BaseLow | (entry.BaseMid << 16) | (entry.BaseHi << 24)));
        }