flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Windows > how to read a string from standard input aka keyboard | 
  
| Author | 
  | 
              
| 
                  
                   sinsi 12 Jan 2008, 06:10 
                  ReadConsole/ReadConsoleInput ? 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:19 
                  Thanks sinsi! 
                  Last edited by 0.1 on 12 Jan 2008, 06:45; edited 1 time in total  | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:25 
                  Still not working!
 
                  Code: format PE Console entry start include 'win32ax.inc' section '.code' code readable executable proc start uses ebx local buff[1024]:BYTE local count:DWORD invoke GetStdHandle, STD_INPUT_HANDLE invoke ReadConsole, eax, addr buff, 1024, addr count, 0 ret endp section '.idata' import data readable library kernel32,'kernel32.dll' import kernel32,\ GetStdHandle,'GetStdHandle',\ ReadConsole,'ReadConsole' Last edited by 0.1 on 12 Jan 2008, 06:45; edited 1 time in total  | 
              |||
                  
  | 
              
| 
                  
                   sinsi 12 Jan 2008, 06:28 
                  Try using GetStdHandle with STD_INPUT_HANDLE and passing that to ReadConsole 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:30 
                  Ha! Ha! Ha!  | 
              |||
                  
  | 
              
| 
                  
                   sinsi 12 Jan 2008, 06:36 
                  Code: format PE Console 4.0 entry start include 'win32ax.inc' section '.code' code readable executable proc start uses ebx local buff[1024]:BYTE local count:DWORD invoke GetStdHandle,STD_INPUT_HANDLE mov ebx,eax invoke ReadConsole, ebx, addr buff, 1024, addr count, 0 ret endp section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,ReadConsole,'ReadConsoleA',GetStdHandle,'GetStdHandle' heh heh 0 was 'standard input' in DOS days edit: using eax with invoke can be a problem when also using 'addr' in masm, dunno about fasm Last edited by sinsi on 12 Jan 2008, 06:41; edited 1 time in total  | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:39 
                  strange!  
                  
                Why not pass eax?  | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:44 
                  Sorry for so much trouble!
 
                  
                Fixed now  | 
              |||
                  
  | 
              
| 
                  
                   sinsi 12 Jan 2008, 06:47 
                  I shall discard my reply, since you seem to have a 'thought-interface' to your pc...you seem to reply to mine obscenely quick   
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:52 
                  Code: format PE Console entry start include 'win32ax.inc' ; section '.data' data readable writable section '.code' code readable executable proc start uses ebx local buff[1024]:BYTE local count:DWORD local stdin:DWORD local stdout:DWORD invoke GetStdHandle, STD_INPUT_HANDLE mov [stdin], eax invoke GetStdHandle, STD_OUTPUT_HANDLE mov [stdout], eax invoke ReadConsole, [stdin], addr buff, 1024, addr count, 0 invoke WriteConsole, [stdout], addr buff, [count], addr count, 0 ret endp section '.idata' import data readable library kernel32,'kernel32.dll' import kernel32,\ GetStdHandle,'GetStdHandle',\ ReadConsole,'ReadConsoleA',\ WriteConsole,'WriteConsoleA' One more problem! If I input: a b c I get the output: a Why? You know how to fix? PS: By the way, fasm uses edx for address! Last edited by 0.1 on 12 Jan 2008, 06:56; edited 1 time in total  | 
              |||
                  
  | 
              
| 
                  
                   0.1 12 Jan 2008, 06:56 
                  so stupid of me!
 
                  
                sorry! again! fixed.  | 
              |||
                  
  | 
              
| 
                  
                   vid 12 Jan 2008, 11:58 
                  Do not read STDIN with ReadConsole. It may not be a console (it can be redirected from something else). Use ReadFile.
 
                  
                And after ReadConsole / ReadFile, you should check return value for error.  | 
              |||
                  
  | 
              
| 
                  
                   AlexP 12 Jan 2008, 18:24 
                  lol your code is pretty high-level fasm, when I use readconsole i just make a pointer in memory called hStdIn and hStdOut if I ever use WriteConsole.  IDK about using ReadFile with the console, but I've heard of it working.  I usually just add printf from msvcrt.dll and _getch from the same library when I need to pause the screen. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   semiono 12 Oct 2010, 15:35 
                  Is it'll enaugh ReadConsole() to get input  parametres for use it CreateProcess,'\PATH\Far.exe', ebx... ?
 
                  Or i need strongly GetCommanline api?? _________________ Windows 9, FL Studio 19  | 
              |||
                  
  | 
              
| 
                  
                   baldr 12 Oct 2010, 17:15 
                  semiono,
 
                  
                stdin is not your command line.  | 
              |||
                  
  | 
              
| 
                  
                   semiono 12 Oct 2010, 17:19 
                  Yes! I found my bug! board.flatassembler.net/topic.php?t=12019
 
                  
                Code: invoke GetCommandLine <THIS DO NOT NEED ANY PARSING> invoke CreateProcess,exec,[eax],NULL,NU.... Well!!  | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.