Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Registry access after driver load??

Reply
Thread Tools Display Modes

Registry access after driver load??

 
 
Steeve
Guest
Posts: n/a

 
      12-08-2009
Hi guys,
Please bear with me, very premitive question.

I have installed my file system filter driver in WindowsXP, i have the
field(REG_SZ) in the
registry as password. If this password is empty; driver doesn't load there
is an check added to avoid loading of driver without valid password.

I have the user application to write the new password into registry. But
am not able to see the changed password after

RegSetValueEx function.

Am unable to figure out the cause. Is it the registry access by the user
program is invalid, or writing unicode string (i tried this no success)

Any suggestion is appreciated. Thanks in advance

The part of the registry access & change code is copied below.

char szNewPassword[]="abcde";

Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\Mydriver ",
0,KEY_QUERY_VALUE,&hKey);

if( nResult == ERROR_SUCCESS )
{
int nMaxLen = 16;

RegQueryValueEx(hKey,
L"Password",
NULL,(LPDWORD)&lpType,(LPBYTE)szPassword,
(LPDWORD)&nMaxLen);

printf("Old password %S",szPassword);

nMaxLen=6;

RegSetValueEx(hKey,
L"NewPassword",
NULL,REG_SZ,(BYTE *)szNewPassword,
nMaxLen);

RegQueryValueEx(hKey,
L"Password",
NULL,(LPDWORD)&lpType,(LPBYTE)szChanged,
(LPDWORD)&nMaxLen);

printf(" %S",szChanged);
}

--
Steeve
Singapore
 
Reply With Quote
 
 
 
 
Pavel A.
Guest
Posts: n/a

 
      12-08-2009
Yes this likely is because of unicode conversions.
Since you use wide strings as key names, your program
probably is compiled with UNICODE. But your password string is ascii.
Get a debugger, debug.

Good luck with filesystem drivers.
--pa


"Steeve" <> wrote in message
news:139079B1-2B7D-4BA5-98D4-...
> Hi guys,
> Please bear with me, very premitive question.
>
> I have installed my file system filter driver in WindowsXP, i have the
> field(REG_SZ) in the
> registry as password. If this password is empty; driver doesn't load there
> is an check added to avoid loading of driver without valid password.
>
> I have the user application to write the new password into registry. But
> am not able to see the changed password after
>
> RegSetValueEx function.
>
> Am unable to figure out the cause. Is it the registry access by the user
> program is invalid, or writing unicode string (i tried this no success)
>
> Any suggestion is appreciated. Thanks in advance
>
> The part of the registry access & change code is copied below.
>
> char szNewPassword[]="abcde";
>
> Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> L"SYSTEM\\CurrentControlSet\\Services\\Mydriver ",
> 0,KEY_QUERY_VALUE,&hKey);
>
> if( nResult == ERROR_SUCCESS )
> {
> int nMaxLen = 16;
>
> RegQueryValueEx(hKey,
> L"Password",
> NULL,(LPDWORD)&lpType,(LPBYTE)szPassword,
> (LPDWORD)&nMaxLen);
>
> printf("Old password %S",szPassword);
>
> nMaxLen=6;
>
> RegSetValueEx(hKey,
> L"NewPassword",
> NULL,REG_SZ,(BYTE *)szNewPassword,
> nMaxLen);
>
> RegQueryValueEx(hKey,
> L"Password",
> NULL,(LPDWORD)&lpType,(LPBYTE)szChanged,
> (LPDWORD)&nMaxLen);
>
> printf(" %S",szChanged);
> }
>
> --
> Steeve
> Singapore


 
Reply With Quote
 
Tim Roberts
Guest
Posts: n/a

 
      12-08-2009
Steeve <> wrote:
>
>Please bear with me, very premitive question.


Yes, your snippet is a textbook example of the reason why you should check
the error return codes from APIs.

>Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> L"SYSTEM\\CurrentControlSet\\Services\\Mydriver ",
> 0,KEY_QUERY_VALUE,&hKey);


Here, you are asking for permission to query values from the registry.
That's all you asked for, so that's all you get.

>if( nResult == ERROR_SUCCESS )
>{
> int nMaxLen = 16;
>
> RegQueryValueEx(hKey,
> L"Password",
> NULL,(LPDWORD)&lpType,(LPBYTE)szPassword,
> (LPDWORD)&nMaxLen);
>
> printf("Old password %S",szPassword);
>
> nMaxLen=6;
>
> RegSetValueEx(hKey,
> L"NewPassword",
> NULL,REG_SZ,(BYTE *)szNewPassword,
> nMaxLen);


Here you are trying to change the value. You didn't ask for permission to
change the value. This API fails, but since you don't check the error
codes, you don't realize it.

If you want to write the value, ask for KEY_READ|KEY_WRITE.
--
Tim Roberts,
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dear Microsoft - UAC (.png & wmp) issues should be addressed. JSandPC Windows Vista Administration 120 12-02-2008 04:42 PM
My PnP Monitor is seen as Non PnP??? Colin Windows Vista Hardware 1 11-29-2007 05:01 PM
BUGCODE_USB_DRIVER with external USB HDD PHILIPS Deathwing00 Windows Vista Hardware 11 06-15-2007 07:02 PM
Missing VGA driver rh0000 Windows Vista Hardware 14 06-13-2007 10:21 AM
americas army stuttering under vista premium ernie Windows Vista Games 0 02-27-2007 10:20 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59