The MASM Forum

General => The Campus => Topic started by: Amadeus on August 01, 2017, 08:10:25 PM

Title: Registry and chinese
Post by: Amadeus on August 01, 2017, 08:10:25 PM
Hello all and good morning,
my name is Amadeus, i am from italy so english is not my native language, so please
apologize for the errors.

I'm pretty new to masm til now everything i become to run (naturelly with lot of reseach and try 'n error)  ::)

But now i come to a point and cant find any solution,what i am tryin
is to write to registry so that value is in chinese characters
e.g.


.data
SubKey db "Software\Test\Prova",0

.code
        invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr SubKey,NULL,NULL,NULL, KEY_ALL_ACCESS,NULL,addr hKey,NULL
.if eax == ERROR_SUCCESS
invoke RegSetValueExW,hKey,chr$("TEST1"),NULL,REG_SZ,chr$("test"),4
.else
invoke MessageBox,hWin,addr Err,0,0
.endif
invoke RegCloseKey,hKey


it should create something like this

TEST1     REG_SZ    瑥獴

but it does not!!

i dont know why, i mean the rappresentation of "test" is 0x7465, 0x7374

any help is appreciate

p.s: if i use this
invoke MessageBoxW,0,chr$("TEST"),chr$("test"),40h
it shows me the chinese characters

thanks
Amadeus 
Title: Re: Registry and chinese
Post by: aw27 on August 01, 2017, 08:29:59 PM
Hello Amadeus,
I have not tested, but it appears that you are not counting with the NULL terminator of the REG_SZ on the number of bytes.

I would also recommend that you present a complete sample in order to avoid guesswork.
Title: Re: Registry and chinese
Post by: HSE on August 01, 2017, 08:54:25 PM
Welcome Amadeus.

You have an ANSI string, but you are calling a UNICODE function to write it. Try RegSetValueExA.

Regards. HSE
Title: Re: Registry and chinese
Post by: Amadeus on August 01, 2017, 10:32:09 PM
thank you guys

that was exactly what was wrong now
everythings is working :)