flat assembler
Message board for the users of flat assembler.

Index > Windows > importing stdin

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 03 Jun 2007, 18:06
That and you need cinvoke... It's not a problem as long as it's documented, but if it isn't you get problems, which is why we need more examples of things in fasm. I've noticed there are alot of functions out there that aren't documented, but are used in examples throughout the web. We have them on our computer, but no-one knows anything about them. Compared to MASM, fasm is pretty darn low level, problem is just about everything in ASM is for MASM. Everything in MASM is a big mystery, which is what i like about FASM. Nothing's hidden.
Post 03 Jun 2007, 18:06
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 Jun 2007, 19:13
Quote:
I've noticed there are alot of functions out there that aren't documented, but are used in examples throughout the web

like what? you mean MASM32 "library" functions?
Post 03 Jun 2007, 19:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 03 Jun 2007, 19:29
auxDIBImageLoad() is one of the functions that's not documented anywhere. MSDN has nothing on it. Where's it located? Luckily, that one has enough examples to find out what the input and return is, but while looking it up i noticed that there's a joke going around that the aux functions could be calling mars for all we know. After noticing this, i realized that there are probably more functions in windows that really aren't documented well. And then there's always the problem of a lack of warning. Some functions don't work without another one being called first or one being called after it, and documentation dosn't warn you about it. Which is why i like assembly, you don't just take code and say "welp, it works, so i'll put it into a library then some idiot can use it even if he dosn't know what's going on." I feel for resons like this, examples in fasm not only just help fasm programmers, but programmers for all assemblers and programming languages, so they have a better understanding of what's needed, and what was placed there because it worked in some one's example. That's what i loath about HLLs, but this is off topic and for another discussion...
Post 03 Jun 2007, 19:29
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Jun 2007, 19:54
Maybe because it is not an API at all? By dissasembling a NeHe tutorial you will figure out that that function is linked statically.
Post 03 Jun 2007, 19:54
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 03 Jun 2007, 21:07
I've never looked around though compiled exes much, but i have a theory that just about everything is linked statically when it goes through a compiler.
Post 03 Jun 2007, 21:07
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 Jun 2007, 21:28
yes, it's a openGL function, no reason be on MSDN.

Quote:
I've never looked around though compiled exes much, but i have a theory that just about everything is linked statically when it goes through a compiler.

depends on how you define "going through compiler" Very Happy
Post 03 Jun 2007, 21:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 03 Jun 2007, 21:34
MSDN, for some odd resons, lists other opengl functions. Don't know why it'd be excluded.

As for how i define compiler, i mean being thrown through something like visual studio's massive collection of programs that do alot of things that are a major mystery to us.
Post 03 Jun 2007, 21:34
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Jun 2007, 22:17
But the documented OGL functions comes with Windows while the glaux auxDIBImageLoad function don't, you need to get the .lib file and link to it. Here you have some info about glaux http://members.cox.net/scottheiman/opengl.htm
Post 03 Jun 2007, 22:17
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 Jun 2007, 22:33
Quote:
As for how i define compiler, i mean being thrown through something like visual studio's massive collection of programs that do alot of things that are a major mystery to us.

not to me Wink

you are not right then. for example all DLL stuff is linked dynamically.
Post 03 Jun 2007, 22:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 03 Jun 2007, 22:42
Then what *IS* all that junk being thrown into a program using cout << that compiles to 256kb? XD
Post 03 Jun 2007, 22:42
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
moveax41h



Joined: 18 Feb 2018
Posts: 59
moveax41h 23 Jul 2018, 16:20
How do you do this on Linux?
Post 23 Jul 2018, 16:20
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 23 Jul 2018, 20:36
It's pretty straightforward if you are familiar around the use of file descriptor

1. Just get a file descriptor ("theFile.txt","r") from an opened file.
2. Feed RAX (the return value, FD) into FILE *stream argument

The rest is quite straightforward I think (buffer, size). You can use printf to print the content the returned buffer. Don't forget to close the FD using fclose(fd).

Here's something similar on Win64, different calling convention of course
Code:
; gcc -m64 this.obj -o this.exe
        format MS64 COFF
        public main
        
        extrn fgets
        extrn fopen
        extrn fclose
        extrn printf

        section '.data' writeable
stream  db 'theFile.txt',0   ;put some text in here
mode    db 'r',0
strs    rb 1000             ;save buffer 1000 bytes

        section '.text' executable
main:
        sub     rsp,40

        mov     rdx,mode
        mov     rcx,stream
        call    fopen
        mov     r15,rax     ;save file handle
                        
        mov     r8,rax       ;FILE stream
        mov     rdx,500     ;int n. read first 500 characters
        mov     rcx,strs     ;char *str
        call    fgets   
                
        mov     rcx,r15     ;close file handle
        call    fclose
        
        mov     rcx,strs
        call    printf
                
        add     rsp,40
        ret    
Post 23 Jul 2018, 20:36
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 23 Jul 2018, 20:58
I wasn't aware that this is an 11 year old thread.

Never mind, at least it finally wakes up to a 64-bit code!

How time flies...
Post 23 Jul 2018, 20:58
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19275
Location: In your JS exploiting you and your system
revolution 23 Jul 2018, 21:16
fasmnewbie wrote:
I wasn't aware that this is an 11 year old thread.
Old threads still contain useful information. So no problem, it can be updated as needed.
Post 23 Jul 2018, 21:16
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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, Twitter.

Website powered by rwasa.