fix arm and x86 building
This commit is contained in:
@@ -454,6 +454,12 @@ func (mm *MemoryModule) setupTLS(reason uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tebAddr := teb.CurrentTEB()
|
tebAddr := teb.CurrentTEB()
|
||||||
|
if tebAddr == 0 {
|
||||||
|
if tlsData != 0 {
|
||||||
|
_ = windows.VirtualFree(tlsData, 0, windows.MEM_RELEASE)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
tlsArrayField := (*uintptr)(unsafe.Pointer(tebAddr + 0x58)) // ThreadLocalStoragePointer
|
tlsArrayField := (*uintptr)(unsafe.Pointer(tebAddr + 0x58)) // ThreadLocalStoragePointer
|
||||||
oldArray := *tlsArrayField
|
oldArray := *tlsArrayField
|
||||||
|
|
||||||
@@ -538,6 +544,10 @@ func (mm *MemoryModule) SetupThreadTLS() func() {
|
|||||||
|
|
||||||
ptrSize := unsafe.Sizeof(uintptr(0))
|
ptrSize := unsafe.Sizeof(uintptr(0))
|
||||||
tebAddr := teb.CurrentTEB()
|
tebAddr := teb.CurrentTEB()
|
||||||
|
if tebAddr == 0 {
|
||||||
|
_ = windows.VirtualFree(tlsData, 0, windows.MEM_RELEASE)
|
||||||
|
return func() {}
|
||||||
|
}
|
||||||
tlsArrayField := (*uintptr)(unsafe.Pointer(tebAddr + 0x58))
|
tlsArrayField := (*uintptr)(unsafe.Pointer(tebAddr + 0x58))
|
||||||
oldArray := *tlsArrayField
|
oldArray := *tlsArrayField
|
||||||
|
|
||||||
@@ -572,9 +582,11 @@ func (mm *MemoryModule) SetupThreadTLS() func() {
|
|||||||
_ = windows.VirtualFree(newArray, 0, windows.MEM_RELEASE)
|
_ = windows.VirtualFree(newArray, 0, windows.MEM_RELEASE)
|
||||||
}
|
}
|
||||||
tebNow := teb.CurrentTEB()
|
tebNow := teb.CurrentTEB()
|
||||||
|
if tebNow != 0 {
|
||||||
field := (*uintptr)(unsafe.Pointer(tebNow + 0x58))
|
field := (*uintptr)(unsafe.Pointer(tebNow + 0x58))
|
||||||
*field = oldArray
|
*field = oldArray
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func peString(addr uintptr) string {
|
func peString(addr uintptr) string {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build windows && 386
|
||||||
|
|
||||||
|
package teb
|
||||||
|
|
||||||
|
func CurrentTEB() uintptr {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build windows && arm64
|
||||||
|
|
||||||
|
package teb
|
||||||
|
|
||||||
|
func CurrentTEB() uintptr {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user