flat assembler
Message board for the users of flat assembler.
Index
> Windows > WIN32 Console Tutorial |
Author |
|
gumletis 22 Feb 2005, 18:57
i also wanna do that, but don't even know how to get input, or output, i know how to make the console, do like this
1. Open your included folder, and copy "win32ax.inc" to "win32console.inc" 2.. Edit the first thing "format PE 4.0" to "format PE console" in the file "win32console.inc" 3. your ready! example on how to do it with the console include '%fasminc%\win32console.inc' .data hello db 'hello world',0 .code start: invoke MessageBox,0,hello,hello,MB_OK invoke ExitProcess,0 .end start |
|||
22 Feb 2005, 18:57 |
|
Nikolay Petrov 22 Feb 2005, 20:20
if you want to work with console - use crtdll.dll or msvcrt.dll(C runtime libraries). You will find many help about it in the net and not only
look at this is example as begining. Code: ;fasmw 1.57 console program format PE CONSOLE entry start include '%fasminc%\win32a.inc' ;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« section "ComSpec" code readable executable start: invoke SetConsoleTitle,AppTitle cinvoke __GetMainArgs,argc,argv,env_arr,0 ;show num arguments cinvoke printf,szArgc,[argc] ;show arguments xor ecx,ecx mov eax,[argv] @@: cmp dword[eax+4*ecx],0 je @f push eax ecx lea edx,dword[ecx+1] cinvoke printf,szArgv,edx,dword[eax+4*ecx] pop ecx eax inc ecx jmp @r @@: ;show array environment variables cinvoke printf,EnvText xor ecx,ecx mov eax,[env_arr] @@: cmp dword[eax+4*ecx],0 je @f push eax ecx lea edx,dword[ecx+1] cinvoke printf,szEnv,edx,dword[eax+4*ecx] pop ecx eax inc ecx jmp @r @@: cinvoke printf,entexit cinvoke getchar cinvoke exit,0 ;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« section ".data" data readable writeable ;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« n equ 13,10 ;enter t equ 9 ;tab AppTitle db " Command Line Demo",0 entexit db n,n,"Press Enter to exit...",0 szArgc db "Command Line Argumets = %d",n,n,0 szArgv db "Argument %d - %s",n,0 szEnv db "%d - %s",n,0 EnvText db n,n,"Environment Variables:",n,n,0 argv dd ? ;arguments argc dd ? ;num arguments env_arr dd ? ;array environment variables ;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« section ".idata" import data readable library kernel32, "kernel32.dll",\ crtdll, "crtdll.dll" import kernel32,SetConsoleTitle,'SetConsoleTitleA' import crtdll,\ __GetMainArgs, '__GetMainArgs',\ getchar, 'getchar',\ exit, 'exit',\ printf, 'printf' ;««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« ;.rdata ; --> if you want to add version or icon |
|||
22 Feb 2005, 20:20 |
|
iklin 23 Feb 2005, 17:47
This is my little template code for console proggies.
Code: format PE console entry start Include '%fasminc%\win32a.inc' Include '%fasminc%\fresh\globals.inc' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; macro section struc dc [data] { common .data db data,0 .size = $-.data-1 } macro write str { invoke WriteFile, [hout], str, str#.size, temp, 0 ; invoke WriteConsole, [hout], str, str#.size, temp, 0 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; initialized data iglobal _hello dc 13,10,'Hello, world!',13,10 endg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; uninitialized data uglobal hinstance dd ? ; hheap dd ? hout dd ? temp dd ? endg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; code section ;section '.code' code readable executable start: invoke GetModuleHandle, 0 mov [hinstance], eax ; invoke GetProcessHeap ; mov [hheap], eax invoke GetStdHandle, STD_OUTPUT_HANDLE mov [hout], eax write _hello finish: invoke ExitProcess, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; import section ;section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,\ ExitProcess,'ExitProcess',\ GetModuleHandle,'GetModuleHandleA',\ GetProcessHeap,'GetProcessHeap',\ GetStdHandle,'GetStdHandle',\ WriteFile,'WriteFile' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; data section ;section '.data' data readable writeable IncludeAllGlobals |
|||
23 Feb 2005, 17:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.