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

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x14
push ebx
mov ebx, ecx
mov dword [ebp - 0x10], edx
push esi
push edi
mov dword [ebp - 8], ebx
push dword [ebx + 0xb8]
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
test eax, eax
je 0x409b0d
mov eax, 0xfffffffa
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
lea eax, [ebx + 0xd8]
push eax
mov dword [ebp - 0xc], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
test byte [ebx + 0xf0], 1
je 0x409c7c
push str.event_sources_modified__reallocating_event_data
push str.handle_events
push 4
push ebx
call fcn.004078c0
mov edx, dword [ebx + 0x104]
lea eax, [ebx + 0x100]
mov esi, dword [edx + 4]
lea edi, [edx - 8]
add esp, 0x10
sub esi, 8
cmp edx, eax
je 0x409b98
mov ebx, eax
nop word [eax + eax]
mov ecx, dword [edx + 4]
mov eax, dword [edx]
push edi
mov dword [ecx], eax
mov ecx, dword [edx]
mov eax, dword [edx + 4]
mov dword [ecx + 4], eax
mov dword [edx], 0
mov dword [edx + 4], 0
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov edi, esi
add esp, 4
mov esi, dword [esi + 0xc]
sub esi, 8
lea edx, [edi + 8]
cmp edx, ebx
jne 0x409b60
mov ebx, dword [ebp - 8]
cmp dword [ebx + 0x108], 0
je 0x409bb2
push str.program_assertion_failed___event_data_already_allocated
push str.usbi_alloc_event_data
push 2
jmp 0x409d4a
mov eax, dword [ebx + 0xfc]
lea esi, [ebx + 0xf8]
mov dword [ebx + 0x10c], 0
lea edx, [eax - 8]
cmp eax, esi
je 0x409d3e
xor ecx, ecx
inc ecx
mov dword [ebx + 0x10c], ecx
mov eax, dword [edx + 0xc]
lea edx, [eax - 8]
cmp eax, esi
jne 0x409bd5
mov eax, ecx
cmp ecx, 1
je 0x409bf6
cmp eax, 2
jne 0x409d3e
push 4
push ecx
call dword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_calloc]
mov edi, eax
add esp, 8
test edi, edi
jne 0x409c1e
lea esi, [eax - 0xb]
mov eax, dword [ebp - 0xc]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov eax, dword [ebx + 0xfc]
lea edx, [eax - 8]
cmp eax, esi
je 0x409c42
mov ecx, edi
nop dword [eax]
mov eax, dword [edx]
lea ecx, [ecx + 4]
mov dword [ecx - 4], eax
mov eax, dword [edx + 0xc]
lea edx, [eax - 8]
cmp eax, esi
jne 0x409c30
and dword [ebx + 0xf0], 0xfffffffe
mov dword [ebx + 0x108], edi
jne 0x409c7c
push dword [ebx + 0xc]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
test eax, eax
jne 0x409c7c
xor ecx, ecx
call fcn.0040a810
push eax
push str.ResetEvent_failed:__s
push str.usbi_clear_event
push 2
push 0
call fcn.004078c0
add esp, 0x14
lea eax, [ebx + 0xd8]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ecx, dword [ebp - 0x10]
mov esi, 0x3e8
push ebx
push dword [ebx + 0xb8]
mov dword [ebp - 4], 0
mov eax, dword [ecx + 4]
cdq
idiv esi
imul ecx, dword [ecx], 0x3e8
add eax, ecx
test edx, edx
lea edi, [eax + 1]
cmove edi, eax
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
mov esi, dword [ebx + 0x10c]
mov eax, dword [ebx + 0x108]
push edi
push esi
push str.WaitForMultipleObjects___for__lu_HANDLEs_with_timeout_in__dms
push str.usbi_wait_for_events
push 4
push ebx
mov dword [ebp - 0x10], eax
call fcn.004078c0
add esp, 0x18
push edi
mov edi, dword [ebp - 0x10]
push 0
push edi
push esi
call dword [sym.imp.KERNEL32.dll_WaitForMultipleObjects]
mov esi, eax
push esi
push str.WaitForMultipleObjects___returned__lu
push str.usbi_wait_for_events
push 4
push ebx
call fcn.004078c0
add esp, 0x14
cmp esi, 0x102
jne 0x409d6b
xor eax, eax
cmp dword [ebx + 0x10], eax
jne 0x409dbe
mov eax, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
lea esi, [ebx + 0x84]
push esi
call eax
mov ecx, ebx
call fcn.00409790
mov eax, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push esi
call eax
xor edi, edi
jmp 0x409dfd
push str.program_assertion_failed___expected_exactly_1_or_2_HANDLEs
push str.usbi_alloc_event_data
push 1
push ebx
call fcn.004078c0
mov eax, dword [ebp - 0xc]
add esp, 0x10
mov esi, 0xffffff9d
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
cmp esi, 0xffffffff
jne 0x409d91
xor ecx, ecx
call fcn.0040a810
push eax
push str.WaitForMultipleObjects___failed:__s
push str.usbi_wait_for_events
push 1
push ebx
call fcn.004078c0
add esp, 0x14
or edi, esi
jmp 0x409dfd
xor eax, eax
test esi, esi
sete al
cmp dword [ebx + 0x10], 0
mov dword [ebp - 4], eax
je 0x409dbe
cmp esi, 1
je 0x409db8
push 0
push dword [edi + 4]
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
test eax, eax
mov eax, dword [ebp - 4]
jne 0x409dbb
or eax, 2
mov dword [ebp - 4], eax
xor edi, edi
test al, 1
je 0x409dd1
mov ecx, ebx
call fcn.00409860
mov edi, eax
test edi, edi
jne 0x409dfd
cmp dword [ebp - 4], 2
jb 0x409dfd
mov eax, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
lea esi, [ebx + 0x84]
push esi
call eax
mov ecx, ebx
call fcn.00409790
mov ecx, ebx
call fcn.00408f10
mov edi, eax
mov eax, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push esi
call eax
push 0
push dword [ebx + 0xb8]
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
mov eax, edi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret