The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: DC on August 12, 2011, 03:39:13 AM

Title: regCreateKeyEx Q
Post by: DC on August 12, 2011, 03:39:13 AM
pretty rusty at this...
this code isn't putting a key in the reg...
iDisp is saying  REG_OPENED_EXISTING_KEY...
but when I look with regeditthe key isn't there...

    m2m     sSA.nLength, sizeof SECURITY_ATTRIBUTES
    m2m     sSA.lpSecurityDescriptor,NULL
    m2m     sSA.bInheritHandle,TRUE
    invoke  RegCreateKeyEx, HKEY_LOCAL_MACHINE,addr szFakePath,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,addr sSA,addr hOpenKey,addr iDisp

8|
Title: Re: regCreateKeyEx Q
Post by: dedndave on August 12, 2011, 03:50:50 AM
it should not be necessary to use a SECURITY_ATTRIBUTES structure

to use these functions, you must also...
        INCLUDE    \masm32\include\advapi32.inc
        INCLUDELIB \masm32\lib\advapi32.lib

        .DATA

szSubKey db 'SOFTWARE\TempKey',0

        .DATA?

dwSize   dd ?

        .CODE

        INVOKE  RegCreateKeyEx,HKEY_CURRENT_USER,offset szSubKey,NULL,NULL,
                NULL,KEY_CREATE_SUB_KEY or KEY_SET_VALUE,NULL,offset dwSize,NULL
Title: Re: regCreateKeyEx Q
Post by: DC on August 12, 2011, 04:15:14 AM
thanx... that's working....
I was also looking in CURRENT_USER instead of LOCAL_MACHINE so I don't know if my other code was working or not...
the offset/addr  thing has always been confusing to me... i'll experiment and see...
thanx again dedndave
Title: Re: regCreateKeyEx Q
Post by: DC on August 12, 2011, 04:35:40 AM
p.s. it's also good to know I don't have to mess with those security structures.... reading about those almost made me throw away my computer...
Title: Re: regCreateKeyEx Q
Post by: dedndave on August 12, 2011, 04:51:22 AM
well - that's why i stay in HKEY_CURRENT_USER   :lol

under vista and/or win7, you may have to mess with security issues if using other keys
the simple solution is to have the user run the program as an administrator
but, that's not always desirable
Title: Re: regCreateKeyEx Q
Post by: DC on August 12, 2011, 05:22:21 AM
hhhhmmmmmmmmm...
this is part of my registration for some PhotoShop filters...
is it possible that folks without admin privileges wouldn't be able to register via LOCAL_MACHINE but could via CURRENT_USER?
Title: Re: regCreateKeyEx Q
Post by: dedndave on August 12, 2011, 05:33:13 AM
no - if your stuff has to go in HKLM, then it has to go in HKLM   :P
i don't recall the different access levels for different keys
you can probably google it or search the forum
Title: Re: regCreateKeyEx Q
Post by: DC on August 12, 2011, 06:07:56 AM
I apreciate your help...
have many good ones...
Title: Re: regCreateKeyEx Q
Post by: Astro on August 12, 2011, 11:04:01 PM
Quote from: DC on August 12, 2011, 04:35:40 AM
p.s. it's also good to know I don't have to mess with those security structures.... reading about those almost made me throw away my computer...
They're not that bad. I have a working example somewhere - I'll dig it out and post it.