Function at 0x4a6fa0
Capabilities:
Allocate thread local storage
Check mutex on windows
Query environment variable
Set environment variable

Disassembly:
push ebp
mov ebp, esp
push 0xffffffffffffffff
push 0x4acd76
mov eax, dword fs:[0]
push eax
mov dword fs:[0], esp
sub esp, 0x8c
push ebx
push esi
mov esi, ecx
push edi
mov dword [ebp - 0x10], esp
mov dword [ebp - 0x14], esi
mov dword [esi], 0
call dword [sym.imp.KERNEL32.dll_GetCurrentProcessId]
push eax
mov dword [ebp - 0x18], eax
push str.QihooThreadLocalStorageMutexByLiZhao
push str._s__u
lea eax, [ebp - 0x98]
push 0x40
push eax
call dword [sym.imp.ntdll.dll__snprintf]
add esp, 0x14
lea ecx, [ebp - 0x98]
xor edi, edi
mov byte [ebp - 0x58], 0
push ecx
push 1
push edi
call dword [sym.imp.KERNEL32.dll_CreateMutexA]
mov ebx, eax
test ebx, ebx
mov dword [ebp - 0x24], ebx
je 0x4a722b
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0xb7
jne 0x4a702e
push 0xffffffffffffffff
push ebx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
lea edx, [ebp - 0x54]
push 0x1f
push edx
push str.________.__________:
mov dword [ebp - 4], 0
call dword [sym.imp.KERNEL32.dll_GetEnvironmentVariableA]
test eax, eax
je 0x4a7082
mov byte [ebp + eax - 0x54], 0
lea eax, [ebp - 0x2c]
lea ecx, [ebp - 0x30]
push eax
push ecx
lea edx, [ebp - 0x54]
push str._x:_x
push edx
call dword [sym.imp.ntdll.dll_sscanf]
add esp, 0x10
cmp eax, 2
jne 0x4a7082
mov eax, dword [ebp - 0x18]
mov ecx, dword [ebp - 0x30]
cmp ecx, eax
jne 0x4a7082
mov ecx, dword [ebp - 0x2c]
mov dword [esi], ecx
jmp 0x4a71fb
push 0x5c0
call sub.MSVCRT.dll_void____cdecl_operator_new_unsigned_int_
mov esi, eax
add esp, 4
mov dword [ebp - 0x34], esi
test esi, esi
je 0x4a70fd
lea edx, [esi + 8]
mov dword [esi], 0
mov dword [esi + 4], 0xffffffff
mov ecx, 0x168
lea edi, [edx + 8]
xor eax, eax
mov dword [edx], 0
rep stosd dword es:[edi], eax
mov dword [edx + 0x5ac], edx
mov dword [edx + 0x5a8], edx
mov dword [edx + 0x5b0], edx
mov byte [ebp - 4], 2
mov dword [esi + 0x5bc], eax
call dword [sym.imp.KERNEL32.dll_TlsAlloc]
cmp eax, 0xffffffff
mov dword [esi + 4], eax
jne 0x4a70f9
lea edx, [ebp - 0x28]
push 0x4b7f58
push edx
mov dword [ebp - 0x28], 2
call sub.MSVCRT.dll__CxxThrowException
mov dword [esi], ebx
jmp 0x4a70ff
xor esi, esi
mov eax, dword [ebp - 0x14]
mov byte [ebp - 4], 0
test esi, esi
mov dword [eax], esi
jne 0x4a7121
lea ecx, [ebp - 0x1c]
push 0x4b7f58
push ecx
mov dword [ebp - 0x1c], 1
call sub.MSVCRT.dll__CxxThrowException
mov edx, dword [ebp - 0x18]
push esi
push edx
lea eax, [ebp - 0x54]
push str._x:_x
push eax
mov edi, 1
call dword [sym.imp.ntdll.dll_sprintf]
add esp, 0x10
lea ecx, [ebp - 0x54]
push ecx
push str.________.__________:
call dword [sym.imp.KERNEL32.dll_SetEnvironmentVariableA]
test eax, eax
jne 0x4a71f8
lea edx, [ebp - 0x20]
push 0x4b7f58
push edx
mov dword [ebp - 0x20], 3
call sub.MSVCRT.dll__CxxThrowException
push 0
push str.________.__________:
call dword [sym.imp.KERNEL32.dll_SetEnvironmentVariableA]
mov esi, dword [ebp - 0x24]
push esi
call dword [sym.imp.KERNEL32.dll_ReleaseMutex]
mov eax, dword [ebp - 0x14]
mov ebx, dword [eax]
test ebx, ebx
je 0x4a71eb
mov eax, dword [ebx + 4]
cmp eax, 0xffffffff
je 0x4a7198
push eax
call dword [sym.imp.KERNEL32.dll_TlsFree]
mov eax, dword [ebx]
test eax, eax
je 0x4a71a5
push eax
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, dword [ebx + 0x5b0]
lea esi, [ebx + 8]
cmp eax, esi
je 0x4a71c7
mov edi, dword [eax + 0x5a8]
push eax
call fcn.004a90a8
add esp, 4
cmp edi, esi
mov eax, edi
jne 0x4a71b2
push ebx
mov dword [esi + 0x5ac], esi
mov dword [esi + 0x5a8], esi
call fcn.004a90a8
mov ecx, dword [ebp - 0x14]
add esp, 4
mov eax, 0x4a7228
mov dword [ecx], 0
ret
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, 0x4a7228
ret
mov esi, dword [ebp - 0x14]
mov eax, dword [esi]
push ebx
inc dword [eax + 0x5bc]
call dword [sym.imp.KERNEL32.dll_ReleaseMutex]
test edi, edi
jne 0x4a722b
push ebx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, esi
mov ecx, dword [ebp - 0xc]
mov dword fs:[0], ecx
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov ecx, dword [ebp - 0xc]
mov eax, esi
pop edi
pop esi
mov dword fs:[0], ecx
pop ebx
mov esp, ebp
pop ebp
ret