Function at 0x412fe0
Capabilities:
Get thread local storage value
Set thread local storage value

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
sub esp, 0x2c
push ebx
push esi
push edi
mov edi, dword [0x1739e34]
mov dword [esp + 0xc], edx
test edi, edi
je 0x413022
call dword [sym.imp.KERNEL32.dll_GetLastError]
push dword [edi]
mov esi, eax
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
push esi
mov ebx, eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov edx, dword [esp + 0xc]
test ebx, ebx
je 0x413022
mov ebx, dword [ebx + 0xc]
xor esi, esi
jmp 0x41303c
test edx, edx
jne 0x413030
lea eax, [edx + 2]
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov ebx, dword [edx]
xor esi, esi
test edi, edi
je 0x413217
test ebx, ebx
je 0x413201
cmp dword [edi + 4], 0
je 0x413201
test edx, edx
je 0x413201
lea eax, [edi + 8]
mov dword [esp + 0x34], 0
mov dword [esp + 0x28], eax
lea edx, [esp + 0x28]
mov dword [esp + 0x30], 0
mov dword [esp + 0x2c], 0
xchg dword [eax], edx
mov dword [esp + 0x10], edx
test edx, edx
je 0x4130f6
lea ecx, [esp + 0x28]
lea eax, [edx + 4]
xchg dword [eax], ecx
mov ecx, dword [esp + 0x10]
or edx, 0xffffffff
add ecx, 0xc
xor eax, eax
lock cmpxchg dword [ecx], edx
test eax, eax
je 0x4130ac
cmp eax, 0xffffffff
je 0x4130ac
push eax
call dword [sym.imp.KERNEL32.dll_SetEvent]
xor eax, eax
lea ecx, [esp + 0x30]
lock xadd dword [ecx], eax
test eax, eax
jne 0x4130f6
push eax
push eax
push eax
push eax
call dword [sym.imp.KERNEL32.dll_CreateEventW]
mov edx, eax
mov dword [esp + 0x10], edx
test edx, edx
je 0x4130f6
mov ecx, edx
xor eax, eax
lea edx, [esp + 0x30]
lock cmpxchg dword [edx], ecx
mov edx, dword [esp + 0x10]
test eax, eax
jne 0x4130ef
push 0xffffffffffffffff
push edx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
mov edx, dword [esp + 0x10]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
lea eax, [ebx + 0x1c]
mov dword [esp + 0x24], 0
mov dword [esp + 0x18], eax
lea edx, [esp + 0x18]
mov dword [esp + 0x20], 0
mov dword [esp + 0x1c], 0
xchg dword [eax], edx
test edx, edx
je 0x41318e
lea ecx, [esp + 0x18]
lea eax, [edx + 4]
xchg dword [eax], ecx
lea ecx, [edx + 0xc]
xor eax, eax
or edx, 0xffffffff
lock cmpxchg dword [ecx], edx
test eax, eax
je 0x413144
cmp eax, 0xffffffff
je 0x413144
push eax
call dword [sym.imp.KERNEL32.dll_SetEvent]
xor eax, eax
lea ecx, [esp + 0x20]
lock xadd dword [ecx], eax
test eax, eax
jne 0x41318e
push eax
push eax
push eax
push eax
call dword [sym.imp.KERNEL32.dll_CreateEventW]
mov edx, eax
mov dword [esp + 0x10], edx
test edx, edx
je 0x41318e
mov ecx, edx
xor eax, eax
lea edx, [esp + 0x20]
lock cmpxchg dword [edx], ecx
mov edx, dword [esp + 0x10]
test eax, eax
jne 0x413187
push 0xffffffffffffffff
push edx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
mov edx, dword [esp + 0x10]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, dword [ebx + 0x30]
test eax, eax
je 0x4131a1
cmp dword [eax + 4], edi
je 0x4131eb
mov eax, dword [eax + 8]
test eax, eax
jne 0x413195
push 0x18
push 1
call fcn.00419913
add esp, 8
test eax, eax
jne 0x4131b6
lea esi, [eax + 0xc]
jmp 0x4131eb
mov ecx, dword [edi + 0xc]
mov dword [eax], ebx
mov dword [eax + 4], edi
mov dword [eax + 0x14], 0
mov dword [eax + 0xc], ecx
test ecx, ecx
je 0x4131cf
mov dword [ecx + 0x14], eax
mov dword [edi + 0xc], eax
mov ecx, dword [ebx + 0x30]
mov dword [eax + 0x10], 0
mov dword [eax + 8], ecx
test ecx, ecx
je 0x4131e6
mov dword [ecx + 0x10], eax
mov dword [ebx + 0x30], eax
xor esi, esi
lea ecx, [esp + 0x18]
call fcn.00412540
lea ecx, [esp + 0x28]
call fcn.00412540
test esi, esi
jne 0x413217
push dword [esp + 0xc]
push dword [edi]
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
test eax, eax
mov ecx, 0xb
cmove esi, ecx
pop edi
mov eax, esi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret