Function at 0x509490
Capabilities:
Delete registry key
Persist via windows service
Set registry value

Disassembly:
sub esp, 0xa38
push ebx
push ebp
push esi
push edi
push str.SeLoadDriverPrivilege
call fcn.005092d0
mov ebx, dword [esp + 0xa50]
add esp, 4
lea eax, [esp + 0x20]
push ebx
push str.SystemCurrentControlSetServices_s
push eax
call fcn.0051cdff
add esp, 0xc
lea ecx, [esp + 0x10]
lea edx, [esp + 0x20]
push ecx
push edx
push reloc.OLEAUT32.dll_SysReAllocString
call dword [sym.imp.ADVAPI32.dll_RegCreateKeyW]
test eax, eax
je 0x5094e7
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0xa38
ret
mov ecx, dword [esp + 0x10]
mov esi, dword [sym.imp.ADVAPI32.dll_RegSetValueExW]
lea eax, [esp + 0x14]
push 4
push eax
push 4
push 0
mov edi, 1
push str.Type
push ecx
mov dword [esp + 0x2c], edi
call esi
mov eax, dword [esp + 0x10]
lea edx, [esp + 0x14]
push 4
push edx
push 4
push 0
push str.ErrorControl
push eax
mov dword [esp + 0x2c], edi
call esi
mov edx, dword [esp + 0x10]
lea ecx, [esp + 0x14]
push 4
push ecx
push 4
push 0
push str.Start
push edx
mov dword [esp + 0x2c], 3
call esi
mov eax, dword [esp + 0xa50]
lea ecx, [esp + 0x638]
push eax
push str.___s
push ecx
call fcn.0051cdff
lea edx, [esp + 0x644]
push edx
call fcn.0051d1ab
add esp, 0x10
mov ecx, dword [esp + 0x10]
shl eax, 1
push eax
lea eax, [esp + 0x63c]
push eax
push edi
push 0
push str.ImagePath
push ecx
call esi
mov edx, dword [esp + 0x10]
push edx
call dword [sym.imp.ADVAPI32.dll_RegCloseKey]
mov esi, dword [sym.imp.KERNEL32.dll_GetModuleHandleW]
push str.RtlNtStatusToDosError
push str.ntdll.dll
call esi
mov edi, dword [sym.imp.KERNEL32.dll_GetProcAddress]
push eax
call edi
push str.RtlAnsiStringToUnicodeString
push str.ntdll.dll
mov ebp, eax
call esi
push eax
call edi
push str.NtLoadDriver
push str.ntdll.dll
call esi
push eax
call edi
mov esi, eax
push ebx
lea eax, [esp + 0x844]
push str.RegistryMachineSystemCurrentControlSetServices_s
push eax
call fcn.0051cdff
lea ecx, [esp + 0x84c]
mov dword [esp + 0x28], ecx
lea edx, [esp + 0x84c]
push edx
call fcn.0051d1ab
shl eax, 1
add esp, 0x10
mov word [esp + 0x18], ax
lea eax, [esp + 0x18]
push eax
call esi
lea ecx, [esp + 0x20]
lea edx, [esp + 0x430]
push ecx
push str._sEnum
push edx
mov edi, eax
call fcn.0051cdff
mov esi, dword [sym.imp.ADVAPI32.dll_RegDeleteKeyW]
add esp, 0xc
lea eax, [esp + 0x430]
push eax
push reloc.OLEAUT32.dll_SysReAllocString
call esi
lea ecx, [esp + 0x20]
lea edx, [esp + 0x430]
push ecx
push str._sSecurity
push edx
call fcn.0051cdff
add esp, 0xc
lea eax, [esp + 0x430]
push eax
push reloc.OLEAUT32.dll_SysReAllocString
call esi
lea ecx, [esp + 0x20]
push ecx
push reloc.OLEAUT32.dll_SysReAllocString
call esi
test edi, edi
je 0x509698
cmp edi, 0xc000010e
je 0x509698
push edi
call ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0xa38
ret
push ebx
lea edx, [esp + 0x22c]
push str.._s
push edx
call fcn.0051cdff
add esp, 0xc
mov edi, dword [sym.imp.KERNEL32.dll_CreateFileW]
lea eax, [esp + 0x228]
push 0
push 0x80
push 3
push 0
push 0
push 0xc0000000
push eax
call edi
mov esi, dword [esp + 0xa54]
cmp eax, 0xffffffff
mov dword [esi], eax
jne 0x509712
push ebx
lea ecx, [esp + 0x22c]
push str..Global_s
push ecx
call fcn.0051cdff
add esp, 0xc
lea edx, [esp + 0x228]
push 0
push 0x80
push 3
push 0
push 0
push 0xc0000000
push edx
call edi
mov dword [esi], eax
mov ecx, dword [esi]
xor eax, eax
pop edi
cmp ecx, 0xffffffff
pop esi
pop ebp
setne al
pop ebx
add esp, 0xa38
ret