flat assembler
Message board for the users of flat assembler.

Index > Windows > Reading Struct from Resoureces

Author
Thread Post new topic Reply to topic
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless
i have a record in resources that has 2 variables, when i try to read it it only displays the first item and not the second. any idea whats the problem?

Code:

struct USERINFORMATION_STRUCT
  szUsername              dw MAX_PATH dup (?)
 szPassword              dw MAX_PATH dup (?)
ends


invoke           GetModuleHandle,0
           mov                     [handle], eax
               invoke          FindResource, NULL, RC_STR0, RT_RCDATA
              mov                     [hRes], eax
         invoke          LoadResource, NULL, [hRes]
          mov                     [hReturn], eax
              invoke          SizeofResource, NULL, [hRes]
                mov                     [sRes], eax
         invoke          LockResource, [hReturn]
             mov                     [pRes], eax
         invoke          RtlMoveMemory, Settings, [pRes], [sRes]
             invoke          FreeResource, [hReturn]

         invoke  MessageBox, 0, addr Settings.szUsername, "szUsername", MB_OK
              invoke  MessageBox, 0, addr Settings.szPassword, "szPassword", MB_OK
    


i also tried this
Code:
              push    esi
         mov             esi, Settings
               invoke  MessageBox, 0, addr esi+USERINFORMATION_STRUCT.szUsername, "szUsername", MB_OK
            invoke  MessageBox, 0, addr esi+USERINFORMATION_STRUCT.szPassword, "szPassword", MB_OK
    
Post 22 Aug 2010, 09:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
How are you storing that structure in the resource section? If you start showing the password first the problem also happens? (Just checking the program is not crashing for some reason when accessing the username)
Post 22 Aug 2010, 13:36
View user's profile Send private message Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless
i store them from a delphi application, and no, no matter what i did, only username shows, if i tried to display password then username, password is empty and username shows.

im porting the code from my delphi code, and in delphi it works fine, i guess its something in dealing with the struct in fasm
Post 22 Aug 2010, 17:40
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
But are Delphi strings UNICODE? Are you using win32a*.inc or win32w*.inc?

For a quick test change dw to db, recompile and run.
Post 22 Aug 2010, 17:56
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 03:55; edited 1 time in total
Post 22 Aug 2010, 17:59
View user's profile Send private message Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless
yea, username was always "john" and password was "123456"
Post 22 Aug 2010, 20:56
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Nameless,

Yardman has a point: did you ensure that szUsername and szPassword members in that resource are exactly MAX_PATH words in size? It seems that you didn't define that resource as USERINFORMATION_STRUCT <"john", 0>, <"123456", 0> — that won't compile unless you change dw to du.
Post 25 Aug 2010, 19:04
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.