Author Topic: Registry and chinese  (Read 126 times)

Amadeus

  • Regular Member
  • *
  • Posts: 2
Registry and chinese
« 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.

Code: [Select]
.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

Code: [Select]
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
Code: [Select]
invoke MessageBoxW,0,chr$("TEST"),chr$("test"),40hit shows me the chinese characters

thanks
Amadeus 

aw27

  • Member
  • ****
  • Posts: 697
Re: Registry and chinese
« Reply #1 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.

HSE

  • Member
  • ****
  • Posts: 532
  • <AMD>< 7-32>
Re: Registry and chinese
« Reply #2 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

Amadeus

  • Regular Member
  • *
  • Posts: 2
Re: Registry and chinese
« Reply #3 on: August 01, 2017, 10:32:09 PM »
thank you guys

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