flat assembler
Message board for the users of flat assembler.

Index > Windows > Undefinded Symbol "mov [f.cb],sizeof.STARTUPINFO"

Author
Thread Post new topic Reply to topic
Havok



Joined: 29 Oct 2011
Posts: 7
Havok 05 Nov 2011, 22:28
Hello all,

Sorry for another noob question,but this is starting to drive me nutty. I took revolution's advice and declared all the structures but ran into a problem with FASM telling me "mov [f.cb],sizeof.STARTUPINFO" is undefined.
Code:
format pe gui

struc sockaddr_in
{
.sin_family dw ?
.sin_port   dw ?
.sin_addr   dd ?
.sin_zero   db 8 dup (?)
}
struc STARTUPINFO
{
.cb              dd ?
.lpReserved     dd ?
.lpDesktop      dd ?
.lpTitle        dd ?
.dwX            dd ?
.dwY            dd ?
.dwXSize        dd ?
.dwYSize        dd ?
.dwXCountChars  dd ?
.dwYCountChars  dd ?
.dwFillAttribute dd ?
.dwFlags       dd ?
.wShowWindow    dw ?
.cbReserved2    dw ?
.lpReserved2    dd ?
.hStdInput      dd ?
.hStdOutput     dd ?
.hStdError      dd ?
.size      = $-.cb
}

push a 
push 0202h
call [WSAStartup]
push 0
push 0
push 0
push 6
push 1
push 2
call [WSASocket]
mov [b],eax
mov [c.sin_family],2
push d
call [htons]
mov [c.sin_port],ax
push 0
call [htonl]
mov [c.sin_addr],eax
push e
push c
call [accept]
mov [f.cb],sizeof.STARTUPINFO

a db WSADATA
b dd 0
c sockaddr_in
d db '80',0
e db sizeof.sockaddr_in
f STARTUPINFO
    


Thanks for any help you can provide.
Post 05 Nov 2011, 22:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19869
Location: In your JS exploiting you and your system
revolution 05 Nov 2011, 22:42
Use STARTUPINFO.size

You never defined sizeof.STARTUPINFO anywhere.

Same with sizeof.sockaddr_in. It will be undefined also.
Post 05 Nov 2011, 22:42
View user's profile Send private message Visit poster's website Reply with quote
Havok



Joined: 29 Oct 2011
Posts: 7
Havok 05 Nov 2011, 22:49
It says I haven't defined "STARTUPINFO.size" either when I use it. I obviously have to learn how to define these things correctly.
Post 05 Nov 2011, 22:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8263
Location: Kraków, Poland
Tomasz Grysztar 05 Nov 2011, 22:55
You should have used it this way:
Code:
mov [f.cb],f.size    


STRUC directive is just a kind of macro, that's why it doesn't define any constants by itself, only when you actually use it. Note that sometimes the structure may not have fixed size and then you'd have "f.size" be different from "g.size" even when "f" and "g" were defined using the same "struc" macro.
Post 05 Nov 2011, 22:55
View user's profile Send private message Visit poster's website Reply with quote
Havok



Joined: 29 Oct 2011
Posts: 7
Havok 05 Nov 2011, 23:07
Ah now i'm starting to understand it. Thanks to the both of you. Tomasz you've made a wonderful assembler, thank you. Taking a bit to get used to, but I can't wait to get more involved in it.
Post 05 Nov 2011, 23:07
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1561
Location: Toronto, Canada
AsmGuru62 05 Nov 2011, 23:13
You get sizeof 'thingy' when using struct/ends macros, like MASM declares it.
Post 05 Nov 2011, 23:13
View user's profile Send private message Send e-mail Reply with quote
Havok



Joined: 29 Oct 2011
Posts: 7
Havok 05 Nov 2011, 23:30
thanks for that AsmGuru62. I haven't look at any MASM examples. I need to do more homework it seems Smile.
Post 05 Nov 2011, 23:30
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.