Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Sunday, March 24 2019 @ 09:37 AM CET

A Simple Window in Console Mode


CodingLevel : newbie

OS : linux
Language : asm

in the last article Creating MessageBox in console mode it was a static in the
sense we couldnt move it around and it didnt have an interactiveness

lets see how we can create a small window and move it around the screen

you would need libnewt installed to assemble and link this code

.intel_syntax noprefix
.include "macro.mac"

title:		 .asciz "Sample Window"
roottext:	 .asciz "Hit UP,DOWN,LEFT,RIGHT keys to move the window HIT DEL key to close and quit"

.lcomm keypressed,4
.lcomm upkey,4
.lcomm leftkey,4

.global start

	invoke newtInit
	invoke newtCls 
	mov dword ptr ds:[leftkey],11
	mov dword ptr ds:[upkey],11
	invoke newtOpenWindow,leftkey,upkey,50,10,"offset title"
	invoke newtDrawRootText,0,0,"offset roottext"
	invoke newtRefresh
	invoke newtGetKey
	mov keypressed,eax

	cmp dword ptr ds:[keypressed], 0x8001
	jne keydown
	dec dword ptr ds:[upkey]
	invoke move_window
	jmp loop_start
	cmp dword ptr ds:[keypressed], 0x8002
	jne keyleft
	inc dword ptr ds:[upkey]
	invoke move_window
	jmp loop_start
        cmp dword ptr ds:[keypressed],0x8004
	jne keyright
	dec dword ptr ds:[leftkey]
	invoke move_window
	jmp loop_start
        cmp dword ptr ds:[keypressed],0x8005
	jne close_wind
	inc dword ptr ds:[leftkey]
	invoke move_window
	jmp loop_start
	cmp dword ptr ds:[keypressed],0x8007
	jne loop_start
	invoke newtFinished
	invoke exit ,1
	invoke newtPopWindow
        invoke newtOpenWindow,leftkey,upkey,50,10,"offset title"
        invoke newtRefresh

assemble and link with

as -o simpwind.o simpwind.s 
ld -o simpwind simpwind.o -s -defsym _start=start 
--dynamic-linker=/lib/ /usr/lib/ /usr/lib/
source and precompiled binary attached
simpwind.tar.gz thanks to all of you

What's Related

Story Options

A Simple Window in Console Mode | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
 Copyright © 2019 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.06 seconds