Exemplo n.º 1
0
        /// <summary>
        /// Gets the TLS address of the specified thread and slot index.
        /// </summary>
        /// <param name="threadHandle"></param>
        /// <param name="slotIndex"></param>
        /// <returns></returns>
        public uint GetTlsAddress(IntPtr threadHandle, int slotIndex = 0)
        {
            Kernel32.SuspendThread(threadHandle);
            ThreadContext context = Kernel32.GetThreadContext(threadHandle);

            Kernel32.ResumeThread(threadHandle);
            LdtEntry ldt = Kernel32.GetThreadSelectorEntry(threadHandle, context.SegFs);

            uint tlsArrayPtr     = ldt.BaseAddress + 0x2C;
            uint tlsArrayAddress = Memory.ReadUInt32(tlsArrayPtr);

            return(Memory.ReadUInt32(tlsArrayAddress + slotIndex * sizeof(uint)));
        }
Exemplo n.º 2
0
 public static extern bool GetThreadSelectorEntry(SafeMemoryHandle hThread, uint dwSelector,
     out LdtEntry lpSelectorEntry);
Exemplo n.º 3
0
 public static extern bool GetThreadSelectorEntry(SafeMemoryHandle hThread, int dwSelector,
                                                  out LdtEntry lpSelectorEntry);
Exemplo n.º 4
0
 private static extern bool UnmanagedGetThreadSelectorEntry(
     IntPtr hThread,
     uint dwSelector,
     out LdtEntry lpSelectorEntry
     );