Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Wednesday, August 23 2017 @ 01:56 PM CEST

Creating a Console Mode Messagebox with Newt and Gas In assembly


CodingLevel : newbie

OS : linux
Language : asm

i was wanting to test my invoke macro a little further
for those who arent aware take a look at my earlier articles
about using gas with intel sysntax and also using masm like
invoke style

so what better way than to program a simple message box in assembly
exactly like iczelions starter tutorial :)

so to do console user interfaces some libraries are available
like ncurses ,newt,cdk, etc

i experimented with ncurses and found it to be too longwinded
it has subroutines where we have to assemble every part and make a 1000 line
code to make a simple message box

rant against ncurses skip the paragraph to get to the point directly
to expand what i said above
first you need to know what is the size of the terminal
viz how many lines how many cols
then you have to know what is the size of string you have
then you have to decide what would be the size of your message box
then depending upon your size of message box you have to calculate
where you have to move your cursor for dispalying the message box
once you have done that then you have to code to place the
title,text ,button etc within the above message box
then you have to code a callback routine that waits for button press
and then clear the window and reset the terminal
well that kinda sucks for a newbie tutorial
especially who habitually gone through
invoke MessageBoxA,NULL,offset Title,Offset Text,NULL
invoke ExitProcess masm code
to create a simple Message box()

some rant about cdk (curses development kit)

i also tried mike glovers cdk (curses development kit ) but since it basically sits
above ncurses i found it to be too drab and colour less
he himself hasnt coded a single window sample with background color
in his example codes which is what i was really aiming to see
rant end here

i chose newt because it lives upto its name nifty erik's windowing tool

so now its enough introduction lets get to the code

copy paste the code below as messagebox.s

.intel_syntax noprefix   
.include "macro.mac"  
title: .asciz "Sample Window\n"
buttontext: .asciz "OK\n"
instext:  .asciz  "linux asm is great\n"


.global start
        invoke newtInit
        invoke newtWinMessage,"offset title","offset buttontext","offset instext"
        invoke newtFinished
        invoke exit ,1

assemble and link with the commandline below

as -o messagebox.o messagebox.s
ld -o messagebox messagebox.o -s -defsym _start=start 
--dynamic-linker=/lib/ /usr/lib/ /usr/lib/

well thats all lets run it and see the out put : oops we need visual isnt it :)
below is a screen shot

the source is attached here

thanks to Detten for taking time to install newt and newt devel that wasnt
installed by default on his server
thanks to you all for reading through to here


What's Related

Story Options

Creating a Console Mode Messagebox with Newt and Gas In assembly | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
 Copyright © 2017 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.05 seconds