Shtreeba icon indicating copy to clipboard operation
Shtreeba copied to clipboard

TLS无法正确处理

Open pig4210 opened this issue 3 years ago • 2 comments

VS2015 及以上版本编译的 DLL ,使用你的工具注入,可能会发生崩溃。 虽然你处理了 TLS ,但仍然是无用的。 经调试发现,正常 LoadLibrary 注入的 DLL ,TlsIndex 值不为 0 。 而工具注入的 TlsIndex 值为 0 ,这其实是错误的。这导致所有的 static 变量无法被初始化。 注意: TlsIndex 只有在主模块中才可以为 0 ,其他所有 DLL 有各自不同的,非零值的 TlsIndex 。 这个问题目前看来,只能在 DLL 编译时,加入 /Zc:threadSafeInit- 解决。但这样,static 变量将非线程安全。

pig4210 avatar Jun 22 '21 09:06 pig4210

Maybe english? P.S Translated.

@mdilai "The DLL compiled by VS2015 and above may crash if injected with your tool. Although you have dealt with TLS, it is still useless. After debugging, it is found that the TlsIndex value of the DLL injected by the normal LoadLibrary is not 0. The TlsIndex value injected by the tool is 0, which is actually wrong. This causes all static variables to fail to be initialized. Note: TlsIndex can be 0 only in the main module. All other DLLs have their own different, non-zero TlsIndex. At present, this problem can only be solved by adding /Zc:threadSafeInit- when compiling the DLL. But in this way, static variables will not be thread-safe."

AlexanderQueen avatar Jun 22 '21 14:06 AlexanderQueen

@pig4210 Хаха ну ти і повеселив мене, братан. Готуєтесь що скоро весь світ буде балакати вашими закарлюками лол? :rofl:

Okay, i heard a lot of complaining about TLS issues from some random people but never catch this by myself. Probably i did a bare minimum TLS handling to get my reference DLL to work but it not complete and insufficient for your one. To be able to try fix this, you need to provide me a some example DLL that crash using Shtreeba, so i can test it.

mdilai avatar Jul 07 '21 15:07 mdilai