Function at 0x10040510
Capabilities:
Write file on windows

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
push 0xffffffffffffffff
push 0x101a0c80
mov eax, dword fs:[0]
push eax
sub esp, 0x48
push ebx
push esi
push edi
mov eax, dword [0x10279264]
xor eax, esp
push eax
lea eax, [esp + 0x58]
mov dword fs:[0], eax
xor edi, edi
test byte [0x103c3958], 1
mov dword [esp + 0x10], edi
jne 0x10040573
or dword [0x103c3958], 1
push 1
mov edx, str.com_util.writecomm.retry_max
mov dword [esp + 0x64], edi
call fcn.10073220
add esp, 4
or esi, 0xffffffff
mov dword [0x103c3954], eax
mov dword [esp + 0x60], esi
jmp 0x10040576
or esi, 0xffffffff
mov ebx, 2
test byte [0x103c3958], bl
jne 0x100405a9
or dword [0x103c3958], ebx
push 1
mov edx, str.com_util.writecomm.reset_max
mov dword [esp + 0x64], 1
call fcn.10073220
add esp, 4
mov dword [0x103c3950], eax
mov dword [esp + 0x60], esi
test byte [0x103c3958], 4
jne 0x100405d4
or dword [0x103c3958], 4
push edi
mov edx, str.com_util.writecomm.dumpbuf
mov dword [esp + 0x64], ebx
call fcn.10073350
add esp, 4
mov byte [0x103c394d], al
mov dword [esp + 0x60], esi
test byte [0x103c3958], 8
jne 0x10040603
or dword [0x103c3958], 8
push edi
mov edx, str.com_util.writecomm.debug
mov dword [esp + 0x64], 3
call fcn.10073350
add esp, 4
mov byte [0x103c394c], al
mov dword [esp + 0x60], esi
xor ebx, ebx
mov dword [esp + 0x14], edi
cmp byte [0x103c394c], bl
je 0x1004066b
push str.FlashToolLib_host_windows_com_util.cpp
mov edx, 0x10201619
xor cl, cl
mov eax, 0x167
lea esi, [esp + 0x1c]
call fcn.10111280
mov esi, dword [ebp + 0x10]
mov edx, dword [ebp + 0xc]
lea ecx, [esp + 0x10]
push ecx
mov ecx, dword [ebp + 8]
push esi
push edx
push ecx
mov dword [esp + 0x70], 4
mov edx, dword [0x103b321c]
push str.____com_util::WriteComm__p_:___p___5d___p_.
push edx
push eax
call fcn.10111350
mov dword [esp + 0x7c], 0xffffffff
add esp, 0x1c
mov dword [esp + 0x18], vtable.MetaTrace.0
jmp 0x1004066e
mov esi, dword [ebp + 0x10]
cmp dword [ebp + 8], 0xffffffff
jne 0x10040685
jmp 0x100408ec
mov esi, dword [ebp + 0x10]
xor edi, edi
mov eax, dword [0x103b3220]
cmp eax, edi
jne 0x100406e1
push 0x4c
call fcn.1016d7a5
add esp, 4
cmp eax, edi
je 0x100406da
mov dword [eax], vtable.CFlashTool_Com.0
mov dword [eax + 0x48], edi
mov dword [eax + 4], edi
mov dword [eax + 8], edi
mov dword [eax + 0xc], edi
mov dword [eax + 0x10], edi
mov dword [eax + 0x14], edi
mov dword [eax + 0x18], edi
mov dword [eax + 0x1c], edi
mov dword [eax + 0x20], edi
mov dword [eax + 0x24], edi
mov dword [eax + 0x28], edi
mov dword [eax + 0x2c], edi
mov dword [eax + 0x30], edi
mov dword [eax + 0x34], edi
mov dword [eax + 0x38], edi
mov dword [eax + 0x3c], edi
mov dword [eax + 0x40], edi
mov dword [eax + 0x44], edi
jmp 0x100406dc
xor eax, eax
mov dword [0x103b3220], eax
cmp dword [eax + 0x48], edi
je 0x1004070d
mov eax, dword [eax + 0x10]
cmp eax, edi
je 0x1004081d
mov edx, dword [ebp + 0xc]
push 0x16c
push str.FlashToolLib_host_windows_com_util.cpp
lea ecx, [esp + 0x18]
push ecx
mov ecx, dword [ebp + 8]
push esi
push edx
push ecx
call eax
jmp 0x10040722
mov eax, dword [ebp + 0xc]
mov ecx, dword [ebp + 8]
push edi
lea edx, [esp + 0x14]
push edx
push esi
push eax
push ecx
call dword [sym.imp.KERNEL32.dll_WriteFile]
cmp eax, edi
jne 0x1004081d
mov eax, dword [0x103b3220]
cmp eax, edi
jne 0x1004074f
push 0x4c
call fcn.1016d7a5
add esp, 4
cmp eax, edi
je 0x10040748
call fcn.10036030
jmp 0x1004074a
xor eax, eax
mov dword [0x103b3220], eax
cmp dword [eax + 0x48], edi
je 0x10040769
mov eax, dword [eax + 0x18]
cmp eax, edi
je 0x10040771
push 0x16d
push str.FlashToolLib_host_windows_com_util.cpp
call eax
jmp 0x1004076f
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov edi, eax
push str.FlashToolLib_host_windows_com_util.cpp
mov edx, str._ERROR:
or cl, 0xff
mov eax, 0x16e
lea esi, [esp + 0x30]
call fcn.10111280
mov edx, dword [esp + 0x14]
mov ecx, dword [ebp + 8]
push edi
push edx
push ebx
push ecx
mov dword [esp + 0x70], 5
mov edx, dword [0x103b321c]
push str.____com_util::WriteComm__p_:_retry__d___reset__d___Err__u_.
push edx
push eax
call fcn.10111350
mov eax, ebx
mov dword [esp + 0x7c], 0xffffffff
add esp, 0x1c
inc ebx
cmp eax, dword [0x103c3954]
mov dword [esp + 0x2c], vtable.MetaTrace.0
jl 0x10040680
mov eax, dword [esp + 0x14]
mov ecx, eax
inc eax
cmp ecx, dword [0x103c3950]
mov dword [esp + 0x14], eax
jge 0x100407f5
mov edi, dword [ebp + 8]
call fcn.1003ffb0
xor ebx, ebx
jmp 0x10040680
mov eax, dword [ebp + 0x18]
test eax, eax
je 0x100407fe
mov dword [eax], edi
mov esi, dword [ebp + 8]
call fcn.1003fb70
xor eax, eax
mov ecx, dword [esp + 0x58]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
mov eax, dword [ebp + 0x14]
cmp eax, edi
je 0x1004082a
mov edx, dword [esp + 0x10]
mov dword [eax], edx
cmp byte [0x103c394d], 0
je 0x100408ec
mov ebx, esi
cmp esi, 8
jb 0x10040843
mov ebx, 8
push 0x102209a8
push 0x100
push 0x103b3620
call fcn.1016da60
add esp, 0xc
mov esi, eax
test ebx, ebx
jle 0x1004088b
mov eax, dword [ebp + 0xc]
movzx ecx, byte [edi + eax]
push ecx
mov edx, 0x100
push 0x102209ac
sub edx, esi
push edx
lea eax, [esi + 0x103b3620]
push eax
call fcn.1016da60
inc edi
add esp, 0x10
add esi, eax
cmp edi, ebx
jl 0x10040860
mov ecx, 0x100
push 0x102209b4
sub ecx, esi
push ecx
lea edx, [esi + 0x103b3620]
push edx
call fcn.1016da60
add esp, 0xc
push str.FlashToolLib_host_windows_com_util.cpp
mov edx, 0x10201619
xor cl, cl
mov eax, 0x189
lea esi, [esp + 0x44]
call fcn.10111280
mov edx, dword [ebp + 8]
push 0x103b3620
mov dword [esp + 0x64], 6
mov ecx, dword [esp + 0x14]
push ecx
mov ecx, dword [0x103b321c]
push edx
push str.____com_util::WriteComm__p_:_len__5d____s
push ecx
push eax
call fcn.10111350
add esp, 0x18
mov eax, 1
mov ecx, dword [esp + 0x58]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14