Function at 0x405270
Capabilities:
Check for time delay via gettickcount
Query service status
Start service
Stop service

Disassembly:
sub esp, 0x3c
push ebx
push ebp
push esi
push edi
push 1
push 0
push 0
call dword [sym.imp.ADVAPI32.dll_OpenSCManagerA]
mov edi, eax
test edi, edi
mov dword [esp + 0x10], edi
jne 0x4052aa
push str.chg::OpenSCManager_Failed
push 0x413ed4
call dword [sym.imp.USER32.dll_wsprintfA]
add esp, 8
xor eax, eax
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x3c
ret
mov eax, dword [esp + 0x54]
push 0xb4
push eax
push edi
call dword [sym.imp.ADVAPI32.dll_OpenServiceA]
mov esi, eax
test esi, esi
jne 0x4052ea
push str.chg::OpenService_Failed
push 0x413ed4
call dword [sym.imp.USER32.dll_wsprintfA]
add esp, 8
push esi
mov esi, dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
call esi
push edi
call esi
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x3c
ret
lea ecx, [esp + 0x30]
push ecx
push esi
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatus]
mov ebx, eax
test ebx, ebx
jne 0x405325
push str.chg::QueryServiceStatus_Failed
push 0x413ed4
call dword [sym.imp.USER32.dll_wsprintfA]
add esp, 8
push esi
mov esi, dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
call esi
push edi
call esi
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x3c
ret
mov ebp, dword [esp + 0x50]
mov eax, dword [esp + 0x34]
cmp eax, ebp
je 0x405478
cmp ebp, 0xffff
jne 0x4053d2
push 0
push 0
push esi
call dword [sym.imp.ADVAPI32.dll_StartServiceA]
mov edi, dword [sym.imp.KERNEL32.dll_GetTickCount]
mov dword [esp + 0x54], eax
call edi
lea edx, [esp + 0x14]
mov ebx, eax
push edx
push esi
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatus]
test eax, eax
je 0x405399
mov ebp, dword [sym.imp.KERNEL32.dll_Sleep]
cmp dword [esp + 0x18], 4
je 0x405399
push 0x1f4
call ebp
call edi
sub eax, ebx
cmp eax, 0x2710
jae 0x405399
lea eax, [esp + 0x14]
push eax
push esi
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatus]
test eax, eax
jne 0x405370
mov eax, dword [esp + 0x54]
test eax, eax
jne 0x405470
push str.chg::StartService_Failed
push 0x413ed4
call dword [sym.imp.USER32.dll_wsprintfA]
add esp, 8
push esi
mov esi, dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
call esi
mov ecx, dword [esp + 0x10]
push ecx
call esi
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x3c
ret
lea edx, [esp + 0x30]
push edx
push ebp
push esi
call dword [sym.imp.ADVAPI32.dll_ControlService]
cmp ebp, 1
mov dword [esp + 0x54], eax
je 0x4053ed
cmp ebp, 5
jne 0x40543e
mov edi, dword [sym.imp.KERNEL32.dll_GetTickCount]
call edi
mov ebx, eax
lea eax, [esp + 0x14]
push eax
push esi
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatus]
test eax, eax
je 0x40543a
mov ebp, dword [sym.imp.KERNEL32.dll_Sleep]
cmp dword [esp + 0x18], 1
je 0x405436
push 0x1f4
call ebp
call edi
sub eax, ebx
cmp eax, 0x2710
jae 0x405436
lea ecx, [esp + 0x14]
push ecx
push esi
call dword [sym.imp.ADVAPI32.dll_QueryServiceStatus]
test eax, eax
jne 0x40540d
mov ebp, dword [esp + 0x50]
mov edi, dword [esp + 0x10]
mov eax, dword [esp + 0x54]
test eax, eax
jne 0x405474
push ebp
push str.chg::ControlService__WaitServiceStatus___d__Failed
push 0x413ed4
call dword [sym.imp.USER32.dll_wsprintfA]
add esp, 0xc
push esi
mov esi, dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
call esi
push edi
call esi
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x3c
ret
mov edi, dword [esp + 0x10]
mov ebx, dword [esp + 0x54]
push esi
mov esi, dword [sym.imp.ADVAPI32.dll_CloseServiceHandle]
call esi
push edi
call esi
pop edi
pop esi
mov eax, ebx
pop ebp
pop ebx
add esp, 0x3c
ret