flat assembler
Message board for the users of flat assembler.
Index
> Windows > text resources |
Author |
|
madmatt 26 May 2006, 18:48
How would you declare a text resource in the resource section?
|
|||
26 May 2006, 18:48 |
|
Quantum 27 May 2006, 00:35
A string table?
|
|||
27 May 2006, 00:35 |
|
Vasilev Vjacheslav 27 May 2006, 08:17
Code: STRINGTABLE LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL { 102, "testtt" } LoadString(hInstance,102,szBuffer,20); |
|||
27 May 2006, 08:17 |
|
madmatt 27 May 2006, 10:47
Vasilev: I mean using fasm macros
|
|||
27 May 2006, 10:47 |
|
madmatt 29 May 2006, 23:19
Hey Thomasz! can you help me out with this one? You know your macros better than anyone, especially me.
|
|||
29 May 2006, 23:19 |
|
madmatt 31 May 2006, 10:55
Thanks Reverend,
But I couldn't get it to work properly, so I just decided to use the visual C++ compiler to compile the resource. And now it works. I tried to find the data format using google but all information I found uses the HLL resource macros. Does anyone know where to find the raw resource data formats? |
|||
31 May 2006, 10:55 |
|
Reverend 31 May 2006, 19:05
Now I know 100% right (last time I didn't check it, just sent message ). Here is the working example:
Code: include '%fasminc%\encoding\win1250.inc' ; choose encoding directory RT_STRING, dir_strings resource dir_strings,\ 1, LANG_ENGLISH+SUBLANG_DEFAULT, res_strings ; STRINGTABLE with id = 1 can have STRINGS with ids between 0-15 resdata res_strings du 0 ; id = 0 du 0 ; id = 1 du 5, 'aaaaa' ; id = 2 du 4, 'test' ; id = 3 endres |
|||
31 May 2006, 19:05 |
|
madmatt 02 Jun 2006, 08:57
Hate to say it Reverend, but still crashing on me. did everything you showed me in your code post. I'll have to see if I can find the raw data format somehow. I haven't any luck googling so far. If anyone else has had success with this please let me know.
MadMatt |
|||
02 Jun 2006, 08:57 |
|
Reverend 04 Jun 2006, 19:32
Here is the whole working code. At least it works correct for me. Let me know what doesn't work for you if it stills occurs.
Code: format PE GUI 4.0 include '%fasminc%\win32a.inc' include '%fasminc%\encoding\win1250.inc' section '.text' code readable writeable executable invoke LoadString, 0, 2, buffer, buffer.size invoke MessageBox, 0, buffer, buffer, MB_OK invoke LoadString, 0, 3, buffer, buffer.size invoke MessageBox, 0, buffer, buffer, MB_OK ret section '.data' data readable writeable buffer rb 256 buffer.size = 256 section '.idata' readable writeable data import library user32,'USER32.DLL' import user32,\ LoadString,'LoadStringA',\ MessageBox,'MessageBoxA' end data section '.rsrc' data readable writeable resource directory RT_STRING, dir_strings resource dir_strings,\ 1, LANG_ENGLISH+SUBLANG_DEFAULT, res_strings resdata res_strings du 0 ; id = 0 du 0 ; id = 1 du 5, 'aaaaa' ; id = 2 du 4, 'test' ; id = 3 endres |
|||
04 Jun 2006, 19:32 |
|
LocoDelAssembly 04 Jun 2006, 21:53
Anyone knows how to do string resources multi-language?
Code: section '.rsrc' data readable writeable resource directory RT_STRING, dir_strings, RT_STRING, dir_strings_sp resource dir_strings,\ 1, LANG_ENGLISH+SUBLANG_DEFAULT, res_strings resdata res_strings du 0 ; id = 0 du 0 ; id = 1 du 5, 'aaaaa' ; id = 2 du 4, 'test' ; id = 3 endres resource dir_strings_sp,\ 1, LANG_SPANISH, res_strings_sp resdata res_strings_sp du 0 ; id = 0 du 0 ; id = 1 du 5, 'aaaaa' ; id = 2 du 4, 'prueba' ; id = 3 endres The resource section above compiles but in my spanish instalation of Windows XP always shows 'test' instead of 'prueba'. Reverend, note that if you change 'test' with 'test1234' your program displays 'test' anyway. |
|||
04 Jun 2006, 21:53 |
|
UCM 04 Jun 2006, 22:19
The prefixing byte is the length. (I had this error too.)
So, you would change 4,'test' to 8,'test1234' and not 4,'test1234' |
|||
04 Jun 2006, 22:19 |
|
LocoDelAssembly 04 Jun 2006, 22:43
ahahaha, I thought that the prefixing byte was the ID (yes, I know that the coments doesn't say the same)
Thanks!! |
|||
04 Jun 2006, 22:43 |
|
madmatt 05 Jun 2006, 08:17
Hey reverend, thanks for your help! Finally got my program working! I realize what I was doing wrong , and thanks to locodelassembly's question and UCM's revelation (that's not the ID its the LENGTH!), I was able to find the error and correct it (along with a few other bugs).
|
|||
05 Jun 2006, 08:17 |
|
Reverend 05 Jun 2006, 17:56
Huh, I forgot to mention it's not the ID preceding the text but it's the string's length
locodelassembly: I have just written a simple wrapeer for your needs. Here it is: Code: proc LoadStringEx hInstance, uID, lpBuffer, nBufferMax, wLang:WORD mov eax, [uID] shr eax, 4 inc eax movzx edx, [wLang] invoke FindResourceEx, [hInstance], RT_STRING, eax, edx invoke LoadResource, [hInstance], eax mov ecx, [uID] and ecx, 0FFFFFFF0h sub ecx, [uID] neg ecx @@: movzx edx, word [eax] lea eax, [eax+edx*2+2] loop @B movzx ecx, word [eax] lea edx, [eax+2] invoke WideCharToMultiByte, 0, 0, edx, ecx, [lpBuffer], [nBufferMax], 0, 0 ret endp And here is the whole code using it (NOTE that both stringtables have the same id but different language): Code: format PE GUI 4.0 include '%fasminc%\win32a.inc' include '%fasminc%\encoding\win1250.inc' section '.text' code readable writeable executable stdcall LoadStringEx, 0, 2, buffer, buffer.size, LANG_ENGLISH+SUBLANG_DEFAULT invoke MessageBox, 0, buffer, buffer, MB_OK stdcall LoadStringEx, 0, 2, buffer, buffer.size, LANG_POLISH+SUBLANG_DEFAULT invoke MessageBox, 0, buffer, buffer, MB_OK ret proc LoadStringEx hInstance, uID, lpBuffer, nBufferMax, wLang:WORD mov eax, [uID] shr eax, 4 inc eax movzx edx, [wLang] invoke FindResourceEx, [hInstance], RT_STRING, eax, edx invoke LoadResource, [hInstance], eax mov ecx, [uID] and ecx, 0FFFFFFF0h sub ecx, [uID] neg ecx @@: movzx edx, word [eax] lea eax, [eax+edx*2+2] loop @B movzx ecx, word [eax] lea edx, [eax+2] invoke WideCharToMultiByte, 0, 0, edx, ecx, [lpBuffer], [nBufferMax], 0, 0 ret endp section '.data' data readable writeable buffer rb 256 buffer.size = 256 section '.idata' readable writeable data import library user32,'USER32.DLL',\ kernel32,'KERNEL32.DLL' import user32,\ LoadString,'LoadStringA',\ MessageBox,'MessageBoxA' import kernel32,\ FindResourceEx,'FindResourceExA',\ LoadResource,'LoadResource',\ WideCharToMultiByte,'WideCharToMultiByte' end data section '.rsrc' data readable writeable resource directory RT_STRING, dir_strings resource dir_strings,\ 1, LANG_ENGLISH+SUBLANG_DEFAULT, res_strings_eng,\ 1, LANG_POLISH+SUBLANG_DEFAULT, res_strings_pl resdata res_strings_eng du 0 ; id = 0 du 0 ; id = 1 du 6, 'length' ; id = 2 endres resdata res_strings_pl du 0 ; id = 0 du 0 ; id = 1 du 7, 'dlugosc'; id = 2 endres EDIT: It works for these two examples for sure. I didn't test it further, it's possible that the proc may need some changes to be more universal |
|||
05 Jun 2006, 17:56 |
|
LocoDelAssembly 05 Jun 2006, 19:00
Hey thanks Reverend!!
I found an easiest way making a little change to your resource section Code: section '.rsrc' data readable writeable resource directory RT_STRING, dir_strings resource dir_strings,\ 1, LANG_ENGLISH+SUBLANG_DEFAULT, res_strings_eng,\ 1, LANG_SPANISH, res_strings_sp resdata res_strings_eng du 0 ; id = 0 du 0 ; id = 1 du 6, 'length' ; id = 2 du 8, 'a string' endres resdata res_strings_sp du 0 ; id = 0 du 0 ; id = 1 du 6, 'tamaño'; id = 2 du 10, 'una cadena' endres Using that resource section (and changing encoding to WIN1252) with your first working program displays "tamaño"(this one required the new encoding for the "ñ" character) and "una cadena" on my system. If I replace LANG_SPANISH with LANG_POLISH then "length" and "a string" are displayed. Thanks again!! |
|||
05 Jun 2006, 19:00 |
|
Reverend 05 Jun 2006, 21:03
I think it depends on what language is set in your operating system. I guess you have Spanish set. And so somewhere deep in kernel32.dll code (exactly somewhere in innards of FindResource) it searches first for Spanish resource. But my proc is supposed to work on every language. And so you can have English, Polish, Spanish, Chinese or every other encoding and just pass it to my proc.
|
|||
05 Jun 2006, 21:03 |
|
LocoDelAssembly 05 Jun 2006, 22:48
That's true but what I was finding is a way in which the applicacion shows the apropiate strings based on the language of the installed OS. In your case I can select the language and in my case Windows selects it for me (and if the native language is not present then the SUBLANG_DEFAULT is used).
|
|||
05 Jun 2006, 22:48 |
|
zhak 06 May 2014, 22:49
I'm a necromancer! )) Ressurecting an old topic.
Tried to figure out how to compile string resorces, and I'm afraid there's something wrong with resources.inc I'm using [url='http://melander.dk/reseditor/']Resource Editor[/url] to check compiled resources At first I tried to add string resources mannually using the macros: Code: section '.rsrc' data readable resource include 'include/macros/resource.inc' include 'include/macros/utf-8.inc' directory 6, res_strings resource res_strings,\ 1, 0, res_strings_eng resdata res_strings_eng du 7, '!?@02:0' du 7,'*9DJE'*' endres It compiles OK, but when I open the binary in the resource editor, I get an error: String table (#1): Premature end of data And String Table is shown as on screenshots below: But then I tried to include precompiled .res file, created with RC.EXE ver 6.2 Code: section '.rsrc' data readable resource from 'sz.res' and sz.rc: Code: STRINGTABLE BEGIN 0 L"\x0421\x043f\x0440\x0430\x0432\x043a\x0430" 1 L"\x062a\x0639\x0644\x064a\x0645\x0627\x062a" END Resource editor didn't show any errors and resources were good: Is there a bug in a macro which causes incorrect resources? However, .exe files produced with resources from macros work and display information OK, as you all know. It's veeery strange |
|||
06 May 2014, 22:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.