Function at 0x409e10
Capabilities:
Get thread local storage value
Resolve function by parsing pe exports

Disassembly:
push ebp
mov ebp, esp
sub esp, 0xc
push ebx
mov ebx, dword [ebp + 8]
test ebx, ebx
je 0x40a0b6
push esi
push edi
push 0x436653
push str.libusb_close
push 4
push 0
call fcn.0040b040
mov eax, dword [ebx + 0x24]
add esp, 0x10
mov edi, dword [eax + 0x1c]
push dword [edi + 0xc0]
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
mov ebx, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
xor ecx, ecx
test eax, eax
setne cl
mov dword [ebp - 0xc], ecx
test eax, eax
jne 0x409ee9
lea esi, [edi + 0xec]
push esi
call ebx
cmp dword [edi + 0x104], 0
jne 0x409ed6
cmp dword [edi + 0x108], 0
jne 0x409ed6
lea eax, [edi + 0x124]
cmp dword [edi + 0x128], eax
jne 0x409ed6
lea eax, [edi + 0x12c]
cmp dword [edi + 0x130], eax
jne 0x409ed6
push 1
lea eax, [ebp - 1]
mov dword [edi + 0x108], 1
push eax
push dword [edi + 0x10]
mov byte [ebp - 1], 1
call fcn.0040e5a0
add esp, 0xc
cmp eax, 1
je 0x409edc
push str.internal_signalling_write_failed
push str.usbi_signal_event
push 2
push edi
call fcn.0040b040
add esp, 0x10
jmp 0x409edc
inc dword [edi + 0x108]
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push edi
call fcn.0040d130
lea eax, [edi + 0x80]
push eax
call ebx
mov eax, dword [edi + 0x7c]
lea ecx, [edi + 0x78]
mov ebx, dword [eax + 4]
lea esi, [eax - 4]
sub ebx, 4
mov dword [ebp - 8], eax
cmp eax, ecx
je 0x409fd1
mov ecx, dword [ebp + 8]
lea edx, [edi + 0x78]
cmp dword [esi + 0x40], ecx
jne 0x409fbb
lea eax, [esi + 0x28]
push eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
test byte [esi + 0x24], 4
jne 0x409f69
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 edi
call fcn.0040b040
add esp, 0x10
test byte [esi + 0x24], 2
je 0x409f54
push str.A_cancellation_for_an_in_flight_transfer_hasnt_completed_but_closing_the_device_handle
push str.do_close
push 2
jmp 0x409f60
push str.A_cancellation_hasnt_even_been_scheduled_on_the_transfer_for_which_the_device_is_closing
push str.do_close
push 1
push edi
call fcn.0040b040
add esp, 0x10
lea eax, [esi + 0x28]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov edx, dword [ebp - 8]
push dword [ebp + 8]
mov ecx, dword [edx + 4]
mov eax, dword [edx]
mov dword [ecx], eax
mov ecx, dword [edx]
mov eax, dword [edx + 4]
mov dword [ecx + 4], eax
lea eax, [esi + 0x40]
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 [edx], 0
mov dword [edx + 4], 0
push 0
mov dword [eax], 0
call fcn.0040b040
mov ecx, dword [ebp + 8]
lea edx, [edi + 0x78]
add esp, 0x18
mov esi, ebx
mov ebx, dword [ebx + 8]
sub ebx, 4
lea eax, [esi + 4]
mov dword [ebp - 8], eax
cmp eax, edx
jne 0x409f12
lea eax, [edi + 0x80]
push eax
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
lea esi, [edi + 0x3c]
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov ebx, dword [ebp + 8]
push esi
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 dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push ebx
call dword [0x438cac]
add esp, 4
push dword [ebx + 0x24]
call fcn.0040ad10
push ebx
call dword [sym.imp.KERNEL32.dll_DeleteCriticalSection]
push ebx
call fcn.004211d6
add esp, 4
cmp dword [ebp - 0xc], 0
jne 0x40a0b4
lea esi, [edi + 0xec]
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [edi + 0x108]
dec eax
cmp dword [edi + 0x104], 0
mov dword [edi + 0x108], eax
jne 0x40a0a7
test eax, eax
jne 0x40a0a7
lea eax, [edi + 0x124]
cmp dword [edi + 0x128], eax
jne 0x40a0a7
lea eax, [edi + 0x12c]
cmp dword [edi + 0x130], eax
jne 0x40a0a7
push 1
lea eax, [ebp + 0xb]
push eax
push dword [edi + 0xc]
call fcn.0040e4f0
add esp, 0xc
cmp eax, 1
je 0x40a0a7
push str.internal_signalling_read_failed
push str.usbi_clear_event
push 2
push edi
call fcn.0040b040
add esp, 0x10
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push edi
call fcn.0040d250
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 4