Function at 0x421ce0
Capabilities:
Check for time delay via gettickcount
Get thread local storage value

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x10
push ebx
push esi
push edi
mov edi, ecx
push dword [edi + 0x38]
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
mov ecx, dword [edi + 0xf0]
mov esi, eax
or ecx, dword [edi + 0xf4]
mov eax, dword [sym.imp.KERNEL32.dll_SetEvent]
mov dword [ebp - 8], esi
mov dword [ebp - 4], eax
je 0x421dd7
cmp dword [ebp + 8], 2
je 0x421dd7
cmp byte [edi + 0x13c], 0
lea esi, [edi + 0x124]
je 0x421d33
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [edi + 0xd8]
mov ecx, dword [ebp - 8]
inc dword [eax + 0x1c]
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0x44], ecx
jne 0x421dc7
cmp byte [ecx + 0xb6], 0
je 0x421dc7
mov dword [eax + 0x44], 0
mov byte [ecx + 0xb6], 0
mov eax, dword [edi + 0x100]
or eax, dword [edi + 0x104]
je 0x421dbe
push 0
call fcn.00461bfb
sub eax, dword [edi + 0x100]
add esp, 4
mov ecx, dword [edi + 0xf8]
cdq
mov ebx, eax
mov eax, dword [edi + 0xfc]
cmp eax, edx
jg 0x421dae
jl 0x421d98
cmp ecx, ebx
jae 0x421dae
mov dword [edi + 0xf8], 0
mov dword [edi + 0xfc], 0
jmp 0x421dbe
sub ecx, ebx
mov dword [edi + 0xf8], ecx
sbb eax, edx
mov dword [edi + 0xfc], eax
push dword [edi + 0x144]
call dword [ebp - 4]
cmp byte [esi + 0x18], 0
je 0x421dd4
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov esi, dword [ebp - 8]
mov ebx, dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
or ecx, 0xffffffff
cmp dword [edi + 8], 3
mov eax, dword [ebp + 8]
lea edx, [ecx + 2]
jne 0x421e1d
cmp eax, 2
je 0x421e1d
cmp dword [esi + 0x14], 0
jne 0x4220b1
mov eax, dword [edi + 0xc0]
lock xadd dword [eax], ecx
je 0x421e11
push 0xffffffffffffffff
push dword [edi + 0xbc]
call ebx
mov dword [esi + 0x14], 1
jmp 0x4220b1
test eax, eax
je 0x4220c0
cmp dword [esi + 0xc], 0
jne 0x422094
mov eax, dword [edi + 0xb8]
lea esi, [edi + 0xb4]
lock xadd dword [eax], ecx
je 0x421e4c
push 0xffffffffffffffff
push dword [esi]
call ebx
mov edx, 1
mov eax, dword [ebp - 8]
cmp dword [eax + 8], 0
je 0x421f87
push str.Attempt_to_upgrade_lock_from_shared_to_exclusive_can_cause_deadlock_n
call fcn.0041a150
mov eax, dword [edi + 0xd8]
add esp, 4
cmp dword [eax + 8], 1
je 0x421f6e
cmp dword [eax + 0x18], 0
je 0x421e8e
mov eax, dword [edi]
mov ecx, edi
push 0
push 0
push 7
call dword [eax]
mov eax, dword [edi + 0xd8]
mov dword [eax + 0x18], 1
mov ecx, esi
mov eax, dword [edi + 0xd8]
inc dword [eax + 0x14]
call fcn.004282e0
mov eax, dword [edi + 0xf0]
or eax, dword [edi + 0xf4]
je 0x421ec0
push dword [edi + 0x144]
call dword [ebp - 4]
nop dword [eax]
push dword [edi + 0x8c]
push dword [edi + 0xd0]
call ebx
test eax, eax
jne 0x421ee8
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 1
jne 0x421ee8
cmp dword [eax + 8], 0
je 0x422079
mov eax, dword [esi + 4]
or ecx, 0xffffffff
lock xadd dword [eax], ecx
je 0x421efa
push 0xffffffffffffffff
push dword [esi]
call ebx
call sub.KERNEL32.dll_GetTickCount
mov edx, dword [edi + 0xd8]
mov ecx, eax
sub ecx, dword [edx + 0x34]
cmp ecx, dword [edi + 0x8c]
jb 0x421f24
mov dword [edx + 0x34], eax
mov eax, dword [edi + 0xd8]
dec dword [eax + 8]
cmp dword [eax + 8], 1
je 0x421f39
mov eax, dword [esi + 4]
mov ecx, 1
lock xadd dword [eax], ecx
inc ecx
test ecx, ecx
jg 0x421ec0
push dword [esi]
jmp 0x421eb9
mov eax, dword [edi + 0xd8]
mov dword [eax + 0xc], 1
mov eax, dword [edi + 0xd8]
mov dword [eax + 8], 0
mov eax, dword [edi + 0xd8]
dec dword [eax + 0x14]
mov eax, dword [edi + 0xd8]
mov dword [eax + 0x18], 0
jmp 0x422072
mov dword [eax + 0xc], 1
mov eax, dword [edi + 0xd8]
mov dword [eax + 8], 0
jmp 0x422072
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 0
jne 0x421fa5
cmp dword [eax + 8], 0
jne 0x421fa5
mov dword [eax + 0xc], 1
jmp 0x422072
inc dword [eax + 0x14]
mov ecx, edx
mov eax, dword [esi + 4]
lock xadd dword [eax], ecx
inc ecx
test ecx, ecx
jg 0x421fbb
push dword [esi]
call dword [ebp - 4]
mov eax, dword [edi + 0xf0]
or eax, dword [edi + 0xf4]
je 0x421fd2
push dword [edi + 0x144]
call dword [ebp - 4]
push dword [edi + 0x8c]
push dword [edi + 0xc8]
call ebx
test eax, eax
jne 0x421ffa
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 1
jne 0x421ffa
cmp dword [eax + 8], 0
je 0x422079
mov eax, dword [esi + 4]
or ecx, 0xffffffff
lock xadd dword [eax], ecx
je 0x42200c
push 0xffffffffffffffff
push dword [esi]
call ebx
call sub.KERNEL32.dll_GetTickCount
mov edx, dword [edi + 0xd8]
mov ecx, eax
sub ecx, dword [edx + 0x34]
cmp ecx, dword [edi + 0x8c]
jb 0x422039
mov dword [edx + 0x34], eax
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 0
jne 0x42204e
add dword [eax + 8], 0xffffffff
je 0x42205c
mov eax, dword [esi + 4]
mov ecx, 1
lock xadd dword [eax], ecx
inc ecx
test ecx, ecx
jg 0x421fd2
push dword [esi]
jmp 0x421fcf
mov ecx, edi
call fcn.004222e0
mov ecx, edi
call fcn.00429600
mov eax, dword [edi + 0xd8]
mov dword [eax + 0xc], 1
mov eax, dword [edi + 0xd8]
dec dword [eax + 0x14]
mov ecx, esi
call fcn.004282e0
mov edx, dword [ebp - 8]
mov ecx, dword [edi + 0xd8]
mov eax, dword [edx + 0xb0]
mov dword [ecx + 0x40], eax
mov dword [edx + 0xc], 1
jmp 0x4220b1
mov eax, dword [edi + 0xd8]
mov eax, dword [eax + 0x40]
cmp eax, dword [esi + 0xb0]
je 0x4220b1
mov eax, dword [edi]
mov ecx, edi
push 0
push 0
push 9
call dword [eax]
cmp dword [ebp + 8], 2
je 0x4222d1
jmp 0x4221de
cmp dword [esi + 8], 0
jne 0x4221de
cmp dword [esi + 0xc], 0
jne 0x4221de
mov eax, dword [edi + 0xb8]
lea esi, [edi + 0xb4]
lock xadd dword [eax], ecx
je 0x4220ec
push 0xffffffffffffffff
push dword [esi]
call ebx
mov ecx, dword [edi + 0xd8]
mov eax, dword [ecx + 0x14]
add eax, dword [ecx + 0xc]
je 0x4221ca
inc dword [ecx + 0x10]
mov ecx, esi
call fcn.004282e0
mov eax, dword [edi + 0xf0]
or eax, dword [edi + 0xf4]
je 0x422120
push dword [edi + 0x144]
call dword [ebp - 4]
nop
push dword [edi + 0x8c]
push dword [edi + 0xcc]
call ebx
test eax, eax
jne 0x422148
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 0
jne 0x422148
cmp dword [eax + 8], 0
jg 0x4221d4
mov eax, dword [esi + 4]
or ecx, 0xffffffff
lock xadd dword [eax], ecx
je 0x42215a
push 0xffffffffffffffff
push dword [esi]
call ebx
call sub.KERNEL32.dll_GetTickCount
mov edx, dword [edi + 0xd8]
mov ecx, eax
sub ecx, dword [edx + 0x34]
cmp ecx, dword [edi + 0x8c]
jae 0x422187
mov eax, dword [esi + 4]
mov ecx, 1
lock xadd dword [eax], ecx
inc ecx
test ecx, ecx
jg 0x422120
push dword [esi]
jmp 0x42211c
mov dword [edx + 0x34], eax
mov eax, dword [edi + 0xd8]
cmp dword [eax + 0xc], 0
je 0x4221b3
mov ecx, edi
call fcn.004222e0
mov ecx, edi
call fcn.00429600
mov eax, dword [edi + 0xd8]
mov dword [eax + 0xc], 0
jmp 0x4221b6
dec dword [eax + 0x14]
mov eax, dword [edi + 0xd8]
inc dword [eax + 8]
mov eax, dword [edi + 0xd8]
dec dword [eax + 0x10]
jmp 0x4221cd
inc dword [ecx + 8]
mov ecx, esi
call fcn.004282e0
mov eax, dword [ebp - 8]
mov dword [eax + 8], 1
mov eax, dword [edi + 0xf0]
or eax, dword [edi + 0xf4]
je 0x422218
cmp byte [edi + 0x13c], 0
lea esi, [edi + 0x124]
je 0x422202
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [edi + 0xd8]
dec dword [eax + 0x1c]
cmp byte [esi + 0x18], 0
je 0x422218
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ecx, edi
call fcn.004222e0
test al, al
jne 0x42222c
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 4
mov eax, dword [edi + 0xb8]
or ecx, 0xffffffff
lock xadd dword [eax], ecx
dec ecx
je 0x422246
push 0xffffffffffffffff
push dword [edi + 0xb4]
call ebx
mov eax, dword [edi + 0x40]
mov eax, dword [eax + 0x14]
add eax, dword [edi + 0x3c]
mov dword [edi + 0x48], eax
mov eax, dword [edi + 0x40]
mov eax, dword [eax + 0x2c]
add eax, dword [edi + 0x3c]
mov dword [edi + 0x4c], eax
mov eax, dword [edi + 0xd8]
mov ecx, dword [eax + 0x28]
lea edx, [ecx + ecx*2]
shl edx, 3
cmp dword [edi + 8], 2
je 0x422296
mov eax, 0x13
sub eax, ecx
mov ecx, dword [edi + 0x40]
mov eax, dword [edi + eax*4]
mov dword [edi + 0x44], eax
mov eax, ecx
sub eax, edx
mov eax, dword [eax + 0x3c]
mov dword [edi + 0x84], eax
mov eax, dword [edx + ecx + 0x24]
jmp 0x4222ae
mov eax, dword [edi + ecx*4 + 0x48]
mov ecx, dword [edi + 0x40]
mov dword [edi + 0x44], eax
mov eax, dword [ecx + edx + 0x24]
mov dword [edi + 0x84], eax
mov eax, dword [ecx + edx + 0x24]
mov dword [edi + 0x80], eax
mov ecx, 1
mov eax, dword [edi + 0xb8]
lock xadd dword [eax], ecx
inc ecx
test ecx, ecx
jg 0x4222d1
push dword [edi + 0xb4]
call dword [ebp - 4]
pop edi
pop esi
mov al, 1
pop ebx
mov esp, ebp
pop ebp
ret 4