Function at 0x10004fe0
Capabilities:
Get thread local storage value

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
sub esp, 0x14
push ebx
push esi
push edi
mov edi, dword [ebp + 8]
test edi, edi
je 0x10005352
mov esi, dword [edi + 0x24]
push 0x1005e1ac
push str.libusb_close
push 4
mov esi, dword [esi + 4]
push esi
call fcn.10006070
add esp, 0x10
push dword [esi + 0xb8]
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
mov ebx, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov dword [esp + 0x1c], eax
test eax, eax
jne 0x100050a8
lea eax, [esi + 0xd8]
push eax
call ebx
mov ecx, dword [esi + 0xf4]
mov edx, dword [esi + 0xf0]
lea eax, [ecx + 1]
mov dword [esi + 0xf4], eax
test ecx, ecx
jne 0x10005059
mov eax, edx
or eax, 0x20
mov dword [esi + 0xf0], eax
test edx, edx
jne 0x10005088
push dword [esi + 0xc]
call dword [sym.imp.KERNEL32.dll_SetEvent]
test eax, eax
jne 0x10005088
xor ecx, ecx
call fcn.10006320
push eax
push str.SetEvent_failed:__s
push str.usbi_signal_event
push 2
push 0
call fcn.10006070
add esp, 0x14
lea eax, [esi + 0xd8]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
lea eax, [esi + 0x9c]
push eax
call ebx
mov dword [esi + 0xb4], 1
lea eax, [esi + 0x84]
push eax
call ebx
mov ebx, dword [esi + 0x80]
lea edx, [esi + 0x7c]
mov ecx, dword [ebx + 4]
lea eax, [ebx - 4]
sub ecx, 4
mov dword [esp + 0x10], eax
mov dword [esp + 0x14], ecx
cmp ebx, edx
je 0x100051a6
lea edx, [eax + 0x58]
mov dword [esp + 0x18], edx
cmp dword [edx], edi
jne 0x10005188
lea edi, [eax + 0x3c]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [esp + 0x10]
push edi
mov eax, dword [eax + 0x30]
mov dword [esp + 0x14], eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
test byte [esp + 0x10], 4
jne 0x10005144
push str.Device_handle_closed_while_transfer_was_still_being_processed__but_the_device_is_still_connected_as_far_as_we_know
push str.do_close
push 1
push esi
call fcn.10006070
add esp, 0x10
test byte [esp + 0x10], 2
je 0x1000512f
push str.A_cancellation_for_an_in_flight_transfer_hasnt_completed_but_closing_the_device_handle
push str.do_close
push 2
jmp 0x1000513b
push str.A_cancellation_hasnt_even_been_scheduled_on_the_transfer_for_which_the_device_is_closing
push str.do_close
push 1
push esi
call fcn.10006070
add esp, 0x10
mov ecx, dword [ebx + 4]
mov eax, dword [ebx]
mov edi, dword [ebp + 8]
push edi
mov dword [ecx], eax
mov ecx, dword [ebx]
mov eax, dword [ebx + 4]
mov dword [ecx + 4], eax
mov eax, dword [esp + 0x1c]
push eax
push str.Removed_transfer__p_from_the_in_flight_list_because_device_handle__p_closed
push str.do_close
push 4
mov dword [ebx], 0
mov dword [ebx + 4], 0
push esi
mov dword [eax], 0
call fcn.10006070
mov ecx, dword [esp + 0x2c]
add esp, 0x18
mov eax, ecx
mov dword [esp + 0x10], ecx
mov ecx, dword [ecx + 8]
lea edx, [esi + 0x7c]
sub ecx, 4
mov dword [esp + 0x14], ecx
lea ebx, [eax + 4]
cmp ebx, edx
jne 0x100050d3
lea eax, [esi + 0x84]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
lea edi, [esi + 0x3c]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov ebx, dword [ebp + 8]
push edi
mov edi, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ecx, dword [ebx + 0x20]
mov eax, dword [ebx + 0x1c]
mov dword [ecx], eax
mov ecx, dword [ebx + 0x1c]
mov eax, dword [ebx + 0x20]
mov dword [ecx + 4], eax
mov dword [ebx + 0x1c], 0
mov dword [ebx + 0x20], 0
call edi
push ebx
call fcn.100071a0
mov ecx, dword [ebx + 0x24]
add esp, 4
mov dword [esp + 0x10], ecx
test ecx, ecx
je 0x100052ab
or eax, 0xffffffff
lock xadd dword [ecx], eax
dec eax
jne 0x100052ab
mov edi, ecx
movzx eax, byte [edi + 0xe]
push eax
movzx eax, byte [edi + 0xc]
push eax
push str.destroy_device__d._d
push str.libusb_unref_device
push 4
push dword [edi + 4]
call fcn.10006070
mov ecx, dword [edi + 8]
add esp, 0x18
call fcn.10004e30
mov eax, dword [edi + 4]
push edi
mov eax, dword [eax + 0x128]
mov eax, dword [eax + 0x3c]
call eax
mov ebx, dword [edi + 4]
add esp, 4
mov dword [edi + 0x34], 0
lea edi, [ebx + 0x1c]
push edi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [esp + 0x10]
push edi
mov edi, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ecx, dword [eax + 0x18]
mov eax, dword [eax + 0x14]
mov dword [ecx], eax
mov ecx, dword [esp + 0x14]
mov edx, dword [ecx + 0x14]
mov eax, dword [ecx + 0x18]
mov dword [edx + 4], eax
mov dword [ecx + 0x14], 0
mov dword [ecx + 0x18], 0
call edi
mov edx, dword [esp + 0x10]
mov ecx, ebx
push 2
call fcn.10007750
push dword [esp + 0x14]
call fcn.10031bb6
mov ebx, dword [ebp + 8]
add esp, 8
push ebx
call dword [sym.imp.KERNEL32.dll_DeleteCriticalSection]
push ebx
call fcn.10031bb6
add esp, 4
cmp dword [esp + 0x1c], 0
jne 0x10005352
mov ebx, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
lea eax, [esi + 0xd8]
push eax
call ebx
add dword [esi + 0xf4], 0xffffffff
jne 0x100052e5
and dword [esi + 0xf0], 0xffffffdf
cmp dword [esi + 0xf0], 0
jne 0x10005319
push dword [esi + 0xc]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
test eax, eax
jne 0x10005319
xor ecx, ecx
call fcn.10006320
push eax
push str.ResetEvent_failed:__s
push str.usbi_clear_event
push 2
push 0
call fcn.10006070
add esp, 0x14
lea eax, [esi + 0xd8]
push eax
call edi
lea eax, [esi + 0x9c]
mov dword [esi + 0xb4], 0
push eax
call edi
lea edi, [esi + 0xbc]
push edi
call ebx
add esi, 0xd4
push esi
call dword [sym.imp.KERNEL32.dll_WakeAllConditionVariable]
push edi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 4