flat assembler
Message board for the users of flat assembler.

Index > Windows > String resources...

Author
Thread Post new topic Reply to topic
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Hello everybody.
Im just wondering how i can add an STRING TABLE on the resources in the resource section of my fasm code? Confused

Thanks! Smile

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 03 Oct 2004, 00:37
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov
Code:
; String Table Demo

format PE GUI 4.0

NEXT_STRING      = 1
END_STRING_TABLE = 0

macro stringtable label
 { 
   local data,size
   label dd RVA data,size,0,0
   data dw ?
   string_size equ size = $ - data
 }

macro stritem string,action
 {
   local size
   virtual at 0
      db string
      size=$
   end virtual
   dw size
   du string
   if action  = END_STRING_TABLE
      string_size
   end if   
 }

ID_STRINGTABLE = 1
IDS_HELLO      = ID_STRINGTABLE+(ID_STRINGTABLE-1)*15
IDS_GOODBYE    = ID_STRINGTABLE+(ID_STRINGTABLE-1)*15+1
; next IDS_... will be +2

include '%fasminc%\win32a.inc'

section '.code' code readable executable

entry start
;--------------- Follow Code -----------------
  start:
      invoke GetModuleHandle,0
      mov [hInstance],eax

      invoke LoadString,[hInstance],IDS_HELLO,buffer,64
      invoke MessageBox,0,buffer,AppName,0

      invoke LoadString,[hInstance],IDS_GOODBYE,buffer,64
      invoke MessageBox,0,buffer,AppName,0

      invoke ExitProcess,0
;--------------- Follow Data -----------------
section '.data' data readable writeable


AppName db 'Resource String Table Demo',0
hInstance dd ?
buffer rb 64

;------------- Follow Import section --------------
section '.idata' import data readable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         MessageBox,'MessageBoxA',\
         LoadString,'LoadStringA'

;------------ Follow Resource section -------------
section '.rsrc' resource data readable
;or section '.rsrc' resource from 'main.bin' data readable

   directory RT_STRING,str1


   resource str1,ID_STRINGTABLE,LANG_NEUTRAL,str_table


   stringtable str_table
        stritem "Hello my friend...",NEXT_STRING ;IDS_HELLO
        stritem "Goodbye .)",END_STRING_TABLE    ;IDS_GOODBYE    


Code:
; compile the file with fasmw
; C:\fasmw\ResEd\main.bin - 152 bytes

    db 0,0,0,0,32,0,0,0,255,255,0,0,255,255,0,0,\
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
       88,0,0,0,32,0,0,0,255,255,6,0,255,255,1,0,\
       0,0,0,0,0,16,2,4,0,0,0,0,0,0,0,0,\
       0,0,18,0,72,0,101,0,108,0,108,0,111,0,32,0,\
       109,0,121,0,32,0,102,0,114,0,105,0,101,0,110,0,\
       100,0,46,0,46,0,46,0,10,0,71,0,111,0,111,0,\
       100,0,98,0,121,0,101,0,32,0,46,0,41,0,0,0,\
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
       0,0,0,0,0,0,0,0    


Last edited by Nikolay Petrov on 04 Oct 2004, 05:33; edited 1 time in total
Post 03 Oct 2004, 21:31
View user's profile Send private message Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Oh Thanks! this works perfect!

Thanks for the help!


Cheers!

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 04 Oct 2004, 00:44
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Hi!

Could someone post an example without using macros, so that I can understand the StringTable and have a little more control over the ID's

Code:
directory RT_STRING, strings

resource strings, \
1, LANG_NEUTRAL, str_table

stringtable        str_table, \    


This is where I get lost, where to define the strings and the associated ID's. I will be needing 5 separate strings with ID's that match others in my program. The main use for these strings is for ToolTip hints in my Windows program. Or maybe there is another way to declare these strings for ToolTips. I've just done it this way in MASM32. I could not find an example on the board.

Thanks for any help.

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 24 Jan 2005, 12:10
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Hi!

Another alternative which would work for me, and help me to learn the effect of macros is:

View the output of the fasm directly after processing macros, but before translating the code from fasm code to machine code.

Is that possible?

Thanks!

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 24 Jan 2005, 13:54
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov
i hope that it's help you. Realy i use string tables very rarely.


Description:
Download
Filename: strtbl.rar
Filesize: 947 Bytes
Downloaded: 195 Time(s)

Post 24 Jan 2005, 19:02
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Nickolay,

Thank You Exclamation

Time again for me to study. I'm having fun with FASM.

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 24 Jan 2005, 19:28
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Nickolay,

Thanks for the code! However, the generation of the resource code is still wrapped in the mystery of the macro Shocked It's a mystery to me anyway. I've been trying to decypher the macros and notice it generates UNICODE string for the ANSI string provided and generates the size of the UNICODE string. My question is: is there some plain declaration definition for the RT_STRING string line?

I got your macros to work, but I don't understand what is happening. Question

Also, is there a way to see the code that FASM's macros generate? Something like the output of all the preprocessors, just before assembling.

Thanks again,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 25 Jan 2005, 12:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.