Function at 0x401040
Capabilities:
Check if file exists
Create service
Delete service
Persist via windows service
Query service status
Start service
Stop service

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x1e0
mov eax, dword [0x40d004]
xor eax, ebp
mov dword [ebp - 4], eax
push esi
push edi
cmp dword [ebp + 8], 2
jge 0x401072
push str.Usage:_to_installdelete_a_service_nRegisterAutoupdService.exe__i_d__service_program_path__n
call fcn.004016dd
add esp, 4
mov eax, 1
jmp 0x40166a
mov dword [ebp - 0x170], 0x40b3fc
mov eax, dword [ebp + 0xc]
mov ecx, dword [eax + 4]
mov dword [ebp - 0x174], ecx
mov edx, dword [ebp - 0x174]
mov al, byte [edx]
mov byte [ebp - 0x175], al
mov ecx, dword [ebp - 0x170]
cmp al, byte [ecx]
jne 0x4010e6
cmp byte [ebp - 0x175], 0
je 0x4010da
mov edx, dword [ebp - 0x174]
mov al, byte [edx + 1]
mov byte [ebp - 0x176], al
mov ecx, dword [ebp - 0x170]
cmp al, byte [ecx + 1]
jne 0x4010e6
add dword [ebp - 0x174], 2
add dword [ebp - 0x170], 2
cmp byte [ebp - 0x176], 0
jne 0x401088
mov dword [ebp - 0x17c], 0
jmp 0x4010f1
sbb edx, edx
sbb edx, 0xffffffff
mov dword [ebp - 0x17c], edx
mov eax, dword [ebp - 0x17c]
mov dword [ebp - 0x180], eax
cmp dword [ebp - 0x180], 0
jne 0x401438
cmp dword [ebp + 8], 3
jne 0x401121
mov ecx, dword [ebp + 0xc]
mov edx, dword [ecx + 8]
push edx
call dword [sym.imp.SHLWAPI.dll_PathFileExistsA]
test eax, eax
jne 0x401138
push str.Need_service_binary_file__n
call fcn.004016dd
add esp, 4
mov eax, 1
jmp 0x40166a
mov eax, dword [ebp + 0xc]
mov ecx, dword [eax + 8]
mov dword [ebp - 0x184], ecx
mov edx, dword [ebp - 0x184]
add edx, 1
mov dword [ebp - 0x188], edx
mov eax, dword [ebp - 0x184]
mov cl, byte [eax]
mov byte [ebp - 0x189], cl
add dword [ebp - 0x184], 1
cmp byte [ebp - 0x189], 0
jne 0x401153
mov edx, dword [ebp - 0x184]
sub edx, dword [ebp - 0x188]
mov dword [ebp - 0x190], edx
push 0x40b41c
mov eax, dword [ebp + 0xc]
mov ecx, dword [eax + 8]
push ecx
call fcn.004017b0
add esp, 8
cmp eax, dword [ebp - 0x190]
jne 0x4012ad
call fcn.00401000
mov dword [ebp - 0x194], eax
lea edx, [ebp - 0x110]
mov dword [ebp - 0x198], edx
mov eax, dword [ebp - 0x198]
mov dword [ebp - 0x19c], eax
mov ecx, dword [ebp - 0x194]
mov dl, byte [ecx]
mov byte [ebp - 0x19d], dl
mov eax, dword [ebp - 0x198]
mov cl, byte [ebp - 0x19d]
mov byte [eax], cl
mov edx, dword [ebp - 0x194]
add edx, 1
mov dword [ebp - 0x194], edx
mov eax, dword [ebp - 0x198]
add eax, 1
mov dword [ebp - 0x198], eax
cmp byte [ebp - 0x19d], 0
jne 0x4011c6
mov ecx, dword [ebp + 0xc]
mov edx, dword [ecx + 8]
mov dword [ebp - 0x1a4], edx
mov eax, dword [ebp - 0x1a4]
mov dword [ebp - 0x1a8], eax
mov ecx, dword [ebp - 0x1a4]
mov dl, byte [ecx]
mov byte [ebp - 0x1a9], dl
add dword [ebp - 0x1a4], 1
cmp byte [ebp - 0x1a9], 0
jne 0x401221
mov eax, dword [ebp - 0x1a4]
sub eax, dword [ebp - 0x1a8]
mov ecx, dword [ebp - 0x1a8]
mov dword [ebp - 0x1b0], ecx
mov dword [ebp - 0x1b4], eax
lea edx, [ebp - 0x110]
add edx, 0xffffffff
mov dword [ebp - 0x1b8], edx
mov eax, dword [ebp - 0x1b8]
mov cl, byte [eax + 1]
mov byte [ebp - 0x1b9], cl
add dword [ebp - 0x1b8], 1
cmp byte [ebp - 0x1b9], 0
jne 0x40126c
mov edi, dword [ebp - 0x1b8]
mov esi, dword [ebp - 0x1b0]
mov edx, dword [ebp - 0x1b4]
mov ecx, edx
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
jmp 0x401314
mov eax, dword [ebp + 0xc]
mov ecx, dword [eax + 8]
mov dword [ebp - 0x1c0], ecx
lea edx, [ebp - 0x110]
mov dword [ebp - 0x1c4], edx
mov eax, dword [ebp - 0x1c4]
mov dword [ebp - 0x1c8], eax
mov ecx, dword [ebp - 0x1c0]
mov dl, byte [ecx]
mov byte [ebp - 0x1c9], dl
mov eax, dword [ebp - 0x1c4]
mov cl, byte [ebp - 0x1c9]
mov byte [eax], cl
mov edx, dword [ebp - 0x1c0]
add edx, 1
mov dword [ebp - 0x1c0], edx
mov eax, dword [ebp - 0x1c4]
add eax, 1
mov dword [ebp - 0x1c4], eax
cmp byte [ebp - 0x1c9], 0
jne 0x4012d1
push 2
push 0
push 0
call dword [sym.imp.ADVAPI32.dll_OpenSCManagerA]
mov dword [ebp - 0x118], eax
cmp dword [ebp - 0x118], 0
jne 0x401346
push 0x40b420
call fcn.004016dd
add esp, 4
mov eax, 1
jmp 0x40166a
push 0xf01ff
mov ecx, dword [str.abcEBService]
push ecx
mov edx, dword [ebp - 0x118]
push edx
call dword [sym.imp.ADVAPI32.dll_OpenServiceA]
mov dword [ebp - 0x11c], eax
cmp dword [ebp - 0x11c], 0
je 0x40139c
push str.Service_registered__n
call fcn.004016dd
add esp, 4
mov eax, dword [ebp - 0x118]
push eax
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov ecx, dword [ebp - 0x11c]
push ecx
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
xor eax, eax
jmp 0x40166a
push 0
push 0
push 0
push 0
push 0
lea edx, [ebp - 0x110]
push edx
push 1
push 2
push 0x110
push 0xf01ff
mov eax, dword [str.abcEBService]
push eax
mov ecx, dword [str.abcEBService]
push ecx
mov edx, dword [ebp - 0x118]
push edx
call dword [sym.imp.ADVAPI32.dll_CreateServiceA]
mov dword [ebp - 0x114], eax
cmp dword [ebp - 0x114], 0
jne 0x401408
push str.CreateService_failed__n
call fcn.004016dd
add esp, 4
mov eax, dword [ebp - 0x118]
push eax
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov eax, 1
jmp 0x40166a
push 0
push 0
mov ecx, dword [ebp - 0x114]
push ecx
call dword [sym.imp.ADVAPI32.dll_StartServiceA]
mov edx, dword [ebp - 0x118]
push edx
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov eax, dword [ebp - 0x114]
push eax
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
jmp 0x401668
mov dword [ebp - 0x1d0], 0x40b468
mov ecx, dword [ebp + 0xc]
mov edx, dword [ecx + 4]
mov dword [ebp - 0x1d4], edx
mov eax, dword [ebp - 0x1d4]
mov cl, byte [eax]
mov byte [ebp - 0x1d5], cl
mov edx, dword [ebp - 0x1d0]
cmp cl, byte [edx]
jne 0x4014ac
cmp byte [ebp - 0x1d5], 0
je 0x4014a0
mov eax, dword [ebp - 0x1d4]
mov cl, byte [eax + 1]
mov byte [ebp - 0x1d6], cl
mov edx, dword [ebp - 0x1d0]
cmp cl, byte [edx + 1]
jne 0x4014ac
add dword [ebp - 0x1d4], 2
add dword [ebp - 0x1d0], 2
cmp byte [ebp - 0x1d6], 0
jne 0x40144e
mov dword [ebp - 0x1dc], 0
jmp 0x4014b7
sbb eax, eax
sbb eax, 0xffffffff
mov dword [ebp - 0x1dc], eax
mov ecx, dword [ebp - 0x1dc]
mov dword [ebp - 0x1e0], ecx
cmp dword [ebp - 0x1e0], 0
jne 0x401654
push 2
push 0
push 0
call dword [sym.imp.ADVAPI32.dll_OpenSCManagerA]
mov dword [ebp - 0x120], eax
cmp dword [ebp - 0x120], 0
jne 0x401502
push str.openSCManager_failed__n
call fcn.004016dd
add esp, 4
mov eax, 1
jmp 0x40166a
push 0xf01ff
mov edx, dword [str.abcEBService]
push edx
mov eax, dword [ebp - 0x120]
push eax
call dword [sym.imp.ADVAPI32.dll_OpenServiceA]
mov dword [ebp - 0x14c], eax
cmp dword [ebp - 0x14c], 0
jne 0x40154e
push str.Open_services_failed__n
call fcn.004016dd
add esp, 4
mov ecx, dword [ebp - 0x120]
push ecx
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov eax, 1
jmp 0x40166a
lea edx, [ebp - 0x124]
push edx
push 0x24
lea eax, [ebp - 0x148]
push eax
push 0
mov ecx, dword [ebp - 0x14c]
push ecx
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatusEx]
test eax, eax
je 0x4015cd
mov dword [ebp - 0x168], 4
mov dword [ebp - 0x150], 0xa
cmp dword [ebp - 0x168], 4
jne 0x4015cb
mov edx, dword [ebp - 0x150]
sub edx, 1
mov dword [ebp - 0x150], edx
js 0x4015cb
lea eax, [ebp - 0x16c]
push eax
push 1
mov ecx, dword [ebp - 0x14c]
push ecx
call dword [sym.imp.ADVAPI32.dll_ControlService]
cmp dword [ebp - 0x168], 4
jne 0x4015c9
push 0x1f4
call dword [sym.imp.KERNEL32.dll_Sleep]
jmp 0x401585
jmp 0x4015e6
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [ebp - 0x124], eax
push str.Qurey_service_status_failed
call fcn.004016dd
add esp, 4
mov edx, dword [ebp - 0x14c]
push edx
call dword [sym.imp.ADVAPI32.dll_DeleteService]
test eax, eax
je 0x401624
push str.Delete_service_succeed_
call fcn.004016dd
add esp, 4
mov eax, dword [ebp - 0x120]
push eax
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov ecx, dword [ebp - 0x14c]
push ecx
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
xor eax, eax
jmp 0x40166a
push str.Delete_service_failed_
call fcn.004016dd
add esp, 4
mov edx, dword [ebp - 0x120]
push edx
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov eax, dword [ebp - 0x14c]
push eax
call dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
mov eax, 1
jmp 0x40166a
push str.Unknown_command_argument
call fcn.004016dd
add esp, 4
mov eax, 1
jmp 0x40166a
xor eax, eax
pop edi
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401695
mov esp, ebp
pop ebp
ret