Hello all!

Here I'm going to tell how to use russian resourses in fasm when using fasm's macroses to create resources. Ok, I don't know the *right* way to do it, but what I suggest works very well.

So, let's begin. When I first tried to use russian resources I thought, that it would be enough to assign strings unicode values. So I created unicode strings for all my strings that I was going to use in menus & dialogs. It worked in menus, however dialogs didn't want to appear at all or appeared dialog didn't look like it should. After examining dialogitem macro from resource.inc I discovered that it uses construction <if +title eq title> to determine if parameter is string or number. That was the source of problem, because what I was passing was no more string, it was sequence of numbers. There were no way to tell fasm how to determine if argument should be treated as string or as number, so I used other method to solve this problem.

I changed unicode strings generation in fasm itself. Ok, this is very easy to do once you know what you have to change. Several lines should be changed in assemble.inc under copy_word_string label like this:

copy_word_string:
xor ah,ah
lods byte
cmp al, 0c0h
jb not_rus
sub al, 0b0h
mov ah, 4
not_rus:
stos word
loop copy_word_string

instead of:

copy_word_string:
lods byte
stos word
loop copy_word_string

and that's all that is needed to use russian menus & dialogs! From now on you can write russian strings in resources.
Of course, the above solution is a bit tricky (I think that changes I made influence not only du, but also dw directive), but it works.

P.S. As one can easily see all this can be applied not only to russian language.

To Tomasz Grisztar: I think the best solution would be to have switch which sets language for unicode strings generation. That would be enough to solve the problem. Additionally win32 part of fasm can detect the language used by system and use it when processing du directive if no language was set.
Posted on 2002-10-06 13:54:39 by wanderer
You don't have to modify the fasm, you can obtain the same result by using the macroinstruction. Here's an example macroinstruction that does the same conversion with an unmodified fasm version:


macro du [str]
{
local ..count,..wchar
virtual at 0
du str
..count = $ shr 1
end virtual
repeat ..count
virtual at 0
du str
load ..wchar word from (%-1)*2
end virtual
; -> begin conversion part
if ..wchar<00C0h | ..wchar>00FFh
dw ..wchar
else
db ..wchar-00B0h,4
end if
; -> end conversion part
end repeat
}

struc du [str] {du str}

So it's possible to make include files with macroinstructions for Unicode conversion for different languages.
Posted on 2002-10-06 15:10:58 by Tomasz Grysztar
Thanks again, Privalov!

By the way, I never guessed, that instructions inside virtual directive generate code somewhere in memory and this code can be reached. I thought it's used for offsets' generation only. That's always the way - if something doesn't work - rtfm.

I have a suggestion: you can put info that's new comparing to old docs to a separate section of help, so that familiar with fasm could read only new, not everything. It would let not to read already known info.
Posted on 2002-10-06 16:29:10 by wanderer