News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with unicode

Started by Farabi, December 30, 2008, 12:10:18 PM

Previous topic - Next topic

Farabi

Im using invoke SendMessageW,hEdit,EM_GETLINE,0,addr buff to get the text from the RichEdit text box. The real value I should get is 0x0628 but I only get 0x0028. What is wrong with my code?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

First try it with SendMessage and see if it gives the same result.

Is the text in the rich-edit wrapped? If so, you'll only get the top line, none of the wrapped parts.
No snowflake in an avalanche feels responsible.

donkey

Have you tried using IsWindowUnicode to determine if the RE is actually Unicode and not MBCS ? In the case of ANSI MBCS the result would be what you have posted. Aslo, which version of the RichEdit are you using ? Version 1 supports MBCS but not Unicode, you should be using Version 2.0 or greater for Unicode.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

Quote from: Tedd on December 30, 2008, 01:23:37 PM
First try it with SendMessage and see if it gives the same result.

Is the text in the rich-edit wrapped? If so, you'll only get the top line, none of the wrapped parts.

I used SendMessage and the result is for example if the value are 28 06 28 06 (0x628 twice) it become 28 28 00 00.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote from: donkey on December 30, 2008, 05:10:33 PM
Have you tried using IsWindowUnicode to determine if the RE is actually Unicode and not MBCS ? In the case of ANSI MBCS the result would be what you have posted. Aslo, which version of the RichEdit are you using ? Version 1 supports MBCS but not Unicode, you should be using Version 2.0 or greater for Unicode.

I think I used version 2.0
Here is the code
Quote
      invoke LoadLibrary,CADD("RICHED32.DLL")
      .if eax!=0
         mov dllhnd,eax
      .else
         invoke PERR
      .endif
invoke CreateWindowEx,WS_EX_CLIENTEDGE,CADD("RichEdit20A"),NULL,edx,0,0,400,200,hWnd,799,hInstance,NULL
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

I tried the IsWindowUnicode and it seems the richedit is not Unicode version. Which version should I use?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

MichaelW

RICHED32.DLL is version 1. RICHED20.DLL can be version 2 or 3 depending on your version of Windows. UNICODE support was added starting in version 2.

eschew obfuscation

Farabi

Quote from: MichaelW on January 01, 2009, 05:54:03 AM
RICHED32.DLL is version 1. RICHED20.DLL can be version 2 or 3 depending on your version of Windows. UNICODE support was added starting in version 2.



Im using XP. Is it sufficient?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Quote from: Farabi on January 01, 2009, 04:04:44 PM
Im using XP. Is it sufficient?

RICHED32 is only for 1.x, you will have to use RichEd20.dll in order to use unicode. RICHED32 is available on all Windows versions for backward compatibility reasons, though I think it was only ever shipped as the primary rich edit control with Windows 95.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

MichaelW

For Windows XP RICHED20.DLL is Rich Edit 3.0. Starting with SP1 there is also Rich Edit 4.1 (Msftedit.dll), but using it would break compatibility with Window 2000. For Windows 2000 and XP the available Rich Edit 1.0 is actually an emulator.
eschew obfuscation

Farabi

I used the riched20 but it doesnot seems to support unicode. I upload the source.

[attachment deleted by admin]
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Hi Farabi,

Tried to look at it but I don't have any of the macros or code libraries that you use with MASM, I will try to find them (like CADD or memfill) but I am sure they are in MASM32 which means that I will have to install it just to assemble the code, currently I have only a very minimal version of MASM32 on my system since I don't generally ever use it and certainly don't use any of the macros or code libraries that come with it (not that I have anything against them I just prefer my own). Perhaps later today I can take a look.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

MichaelW

The first problem I see is that:

invoke CreateWindowEx,WS_EX_CLIENTEDGE,CADD("RichEdit20A"),...

Should be:

CreateWindowEx,WS_EX_CLIENTEDGE,CADD("RichEdit20W"),...

Or at least this will cause IsWindowUnicode to return true.

But something else is triggering an access violation exception, here:

        00401464 51           push ecx
        00401465 52           push edx
        00401466 8db500f4ffff lea esi,[ebp+0xfffff400] ss:0012f168=00000000
        0040146c 33c9         xor ecx,ecx
        0040146e 03b5ecf3ffff add esi,[ebp+0xfffff3ec] ss:0012f154=0000ee98
FAULT ->00401474 8a0e         mov cl,[esi]

eschew obfuscation

Farabi

Quote from: MichaelW on January 02, 2009, 05:43:54 PM
The first problem I see is that:

invoke CreateWindowEx,WS_EX_CLIENTEDGE,CADD("RichEdit20A"),...

Should be:

CreateWindowEx,WS_EX_CLIENTEDGE,CADD("RichEdit20W"),...

Or at least this will cause IsWindowUnicode to return true.

But something else is triggering an access violation exception, here:

        00401464 51           push ecx
        00401465 52           push edx
        00401466 8db500f4ffff lea esi,[ebp+0xfffff400] ss:0012f168=00000000
        0040146c 33c9         xor ecx,ecx
        0040146e 03b5ecf3ffff add esi,[ebp+0xfffff3ec] ss:0012f154=0000ee98
FAULT ->00401474 8a0e         mov cl,[esi]



Thanks for the analysis. I think I know what causing the access violation exception.
Hm, thats weird, if I put all the buffer value to 0, I cant get any text, but if I fill the buffer with 0x20 it is working fine. Is it normal?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote from: donkey on January 02, 2009, 02:23:10 PM
Hi Farabi,

Tried to look at it but I don't have any of the macros or code libraries that you use with MASM, I will try to find them (like CADD or memfill) but I am sure they are in MASM32 which means that I will have to install it just to assemble the code, currently I have only a very minimal version of MASM32 on my system since I don't generally ever use it and certainly don't use any of the macros or code libraries that come with it (not that I have anything against them I just prefer my own). Perhaps later today I can take a look.

CADD is placed above the include section. And memfill is on MASM32 library.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"