`; Set hKey with RegOpenKeyExA
Xor Ecx, Ecx
Lea Ebx, [Ebp – 52H]
Push Ebx ; phkResult
Push 2H ; samDesired = KEY_SET_VALUE
Push Ecx ; ulOptions = NULL
Mov Cl, 6EH
Push Ecx
Push 75525C6EH
Push 6F697372H
Push 6556746EH
Push 65727275H
Push 435C7377H
Push 6F646E69H
Push 575C7466H
Push 6F736F72H
Push 63694D5CH
Push 65726177H
Push 74666F53H
Push Esp ; lpSubkey
Push 80000001H ; hKey = HKEY_CURRENT_USER
Mov Eax, [Ebp – 34H]
Call Eax ; Call RegOpenKeyEx
Lea Edi, [Ebp – 52H]
Mov Eax, [Ebp - 3CH]
Lea Edx, [Ebp - 200H] ; Pointer to buffer that stores exe path
Push Edx
Call Eax ; Call lstrlenA
; RegSetValueExA
Xor Ecx, Ecx
Push Eax ; cbData
Lea Eax, [Ebp - 200H]
Push Eax ; lpData = pointer to the path of the exe
Inc Ecx
Push Ecx ; dwType = REG_SZ
Dec Ecx
Push Ecx ; Reserved
Push 74696873H
Push Esp ; lpValueName
Push Edi ; hKey
Mov Eax, [Ebp - 38H]
Call Eax ; Call RegSetValueExA`
So i tried to write an MASM program that creates new registry key for my exe file. But after calling the RegOpenKeyExA it return 0x000003E6 to eax which indicates that it’s error 998 and nothing was returned to phkResult. I think i am missing something very straight forward but i can’t figure out what it is despite that i have debugged this for few hours now. Please help.
Hưng Bạch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.