Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > I pee in the op...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 65 Topic 5073 of 5097
Post > Topic >>

I pee in the open

by Evenbit <nbaker2328@[EMAIL PROTECTED] > Jul 9, 2008 at 04:53 PM

Yes, I've discovered the nifty gcc 'popen' function which can be used
from ASM to do stuff like this:

; nasm -f elf -o tellmore.o tellmore.asm
; gcc -o tellmore tellmore.o
section .data
cmd	db	'more', 10, 0
mod	db	'w', 0
fmt	db	'%d', 10, 0

section .bss
cnt	resd 1
fid	resd 1

section .text
	global main
	extern popen
	extern pclose
	extern fprintf

main:
	push mod
	push cmd
	call popen
	add esp, 8
	mov [fid], eax
	mov ecx, 50
	mov [cnt], ecx
loop:
	push DWORD [cnt]
	push fmt
	push DWORD [fid]
	call fprintf
	add esp, 12
	dec DWORD [cnt]
	jnz loop

	mov eax, [fid]
	push eax
	call pclose
	add esp, 4

	xor eax, eax
	ret

Okay, the reason I am playing with this ( I'm sure you were
wondering ) is that I've been investigating the use of zenity (and
other "interactive scripting widgets") from ASM.

zenity is GUI and is default installed in Ubunty.  An example of its
use:

Install surfraw, then run this:
burnt.sh
#!/bin/bash

ELVI=$(zenity \
	--list \
	--title="ELVI" \
	--text "Pick an elvi service:" \
	--radiolist \
	--column "Pick" \
	--column "Elvi" \
	TRUE "sourceforge" \
	FALSE "freshmeat" \
	FALSE "slashdot");

TEXT=$(zenity \
	--entry \
	--title="TERM" \
	--text "Enter the search term?");

echo ""
echo "searching" $ELVI "for" $TEXT

surfraw $ELVI $TEXT

And, no, you don't exactly have to be "burnt" to catch the irony.

Also, long before zenity, there were dialog, Xdialog, etc... and all
Debians have a smaller CUI thingy called whiptail.

This ncurses-based thingy downloaded with a 2008 tag, but my tests
show it isn't even Y2K compliant, amoung other things.
http://invisible-island.net/dialog/

Anyway, I've learned how to get text input from zenity:

; nasm -f elf -o result.o result.asm
; gcc -o result result.o
section .data
cmd	db	'zenity --entry', 10, 0
mod	db	'r', 0

section .bss
fid	resd 1
buf	resb 256

section .text
	global main
	extern popen
	extern pclose
	extern fgets
	extern printf

main:
	push mod
	push cmd
	call popen
	add esp, 8
	mov [fid], eax

	push DWORD [fid]
	push 256
	push buf
	call fgets
	add esp, 12

	push buf
	call printf
	add esp, 4

	mov eax, [fid]
	push eax
	call pclose
	add esp, 4

	xor eax, eax
	ret

But, my question is, how does one go about obtaining a number value
result??

$ zenity --question; echo $?

Gives 0 if I click 'Okay'
Gives 1 if I click 'Cancel'

Nathan.
 




 65 Posts in Topic:
I pee in the open
Evenbit <nbaker2328@[E  2008-07-09 16:53:06 
Re: popen
"Rod Pemberton"  2008-07-09 20:56:51 
Re: popen
Evenbit <nbaker2328@[E  2008-07-09 19:58:21 
Re: popen
"Rod Pemberton"  2008-07-11 02:52:12 
Re: popen
Frank Kotler <fbkotler  2008-07-13 00:30:59 
Re: popen
"Wolfgang Kern"  2008-07-13 12:26:35 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-10 02:28:37 
Re: popen
"Rod Pemberton"  2008-07-10 06:21:23 
Re: I pee in the open
dickey <dickey@[EMAIL   2008-07-10 12:28:50 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-10 22:40:17 
Re: popen
"Rod Pemberton"  2008-07-11 02:51:50 
Re: popen
"Wolfgang Kern"  2008-07-11 10:20:05 
Re: popen
Frank Kotler <fbkotler  2008-07-13 00:02:24 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-12 23:29:49 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-10 22:46:01 
Re: popen
Evenbit <nbaker2328@[E  2008-07-10 23:04:28 
Re: popen
"Rod Pemberton"  2008-07-11 02:52:30 
Re: I pee in the open
dickey <dickey@[EMAIL   2008-07-11 04:29:55 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 10:26:00 
Re: popen
"Rod Pemberton"  2008-07-12 04:30:09 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-11 11:07:14 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 22:50:36 
Re: popen
"Wolfgang Kern"  2008-07-12 10:12:07 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 23:40:34 
Re: popen
"Rod Pemberton"  2008-07-12 04:30:18 
Re: popen
Evenbit <nbaker2328@[E  2008-07-12 06:04:15 
Re: popen
"Rod Pemberton"  2008-07-12 12:17:53 
Re: I pee in the open
Robert Redelmeier <red  2008-07-12 14:38:08 
Re: popen
Evenbit <nbaker2328@[E  2008-07-12 17:23:12 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-12 17:50:34 
Re: I pee in the open
Robert Redelmeier <red  2008-07-13 15:28:01 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-12 23:18:34 
Re: I pee in the open
Robert Redelmeier <red  2008-07-13 15:43:23 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-13 10:55:11 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-13 11:13:18 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-13 23:14:26 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-14 16:58:07 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-15 03:26:44 
Re: I pee in the open
"Wolfgang Kern"  2008-07-15 11:14:58 
Re: I pee in the open
"rio" <a@[EM  2008-07-15 14:01:18 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-25 21:19:28 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-28 21:27:18 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-13 12:21:39 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-13 12:29:56 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-13 15:52:23 
Re: I pee in the open
"Rod Pemberton"  2008-07-14 03:57:23 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-14 13:52:24 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-14 14:18:56 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-15 15:59:33 
Re: I pee in the open
"Rod Pemberton"  2008-07-16 02:25:36 
Re: I pee in the open
Robert Redelmeier <red  2008-07-16 13:08:26 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-15 19:04:35 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-19 13:07:45 
Re: I pee in the open
"Rod Pemberton"  2008-07-19 18:50:56 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-19 20:00:51 
Re: I pee in the open
"Rod Pemberton"  2008-07-20 14:46:04 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-20 19:21:50 
Re: I pee in the open
"Rod Pemberton"  2008-07-21 04:18:17 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-20 21:06:28 
Re: I pee in the open
Robert Redelmeier <red  2008-07-22 23:18:19 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-21 13:19:49 
Re: I pee in the open
"Rod Pemberton"  2008-07-21 19:49:34 
Re: I pee in the open
"Rod Pemberton"  2008-07-22 17:53:28 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-21 20:53:52 
Re: I pee in the open
NathanCBaker@[EMAIL PROTE  2008-08-02 10:41:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 12:59:42 CDT 2008.