STROEBEL NJ | 2 Aug 18:38 2005
Picon

Executing memory mapped files


Is it possible to load an executable binary (8k) into memory using mmap()
function ant then executing the binary program in memory.

I tried something like this in C and it only seemed to load the binary into
memory. I then tried the  exec family  to execute the binary but nothing
happened.Maybe in assmebler there is a better method ?

here is the source:

#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <malloc.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <signal.h>
#include </usr/include/sys/types.h>
#include </usr/include/sys/stat.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>

// gcc -o example1 example1.c

(Continue reading)

HIToC | 2 Aug 19:12 2005
Picon

Re: read key from keyboard

On Tuesday 21 December 2004 08:29, Richard Cooper wrote:
> I just found this in the archive.  No one else answered it, so I guess I
> will.  It's quite the pain to figure out really.  I remember spending
> hours if not days trying to learn enough C that I could figure it out from
> the kernel source.  I really hate C.
>
> > How can I read a key from the keyboard when the key is available?
>
> You have to call TCSETSW, which sadly is like the most undocumented IOCTL
> ever...
>
> This code is copy & pasted out of my program Softer.  The assembly syntax
> is different, but I'm sure you can figure it out.  It also makes the I/O
> completely raw, meaning you'll receive 127 instead of 8 for backspace, and
> you'll receive 13 instead of 10 for enter.  This is more than you want if
> you're just looking to read the characters as they are typed, but I don't
> remember how I ever figured out the correct values to get it to do what I
> wanted.  However, if you also want scancodes, then this is exactly what
> you want.
>
> First you need to save the current settings which are creating the line
> buffering and other nonsense so that you can put them back when your
> program is done.
>
> sys sys_ioctl, 0, TCGETS, old_termios
>
> This requires a little structure to save into...
>
>    old_termios
>      .c_iflag resd 1
(Continue reading)

TheReader06 | 2 Aug 20:02 2005
Picon
Picon

Re: read key from keyboard

http://www.unet.univie.ac.at/aix/files/aixfiles/termios.h.htm  explains many of the ioctl
constants..  I just figured most of them out last week when I wrote the below program to turn off terminal
echo in asm, in case anyone needs an example..  Yes, I over-comment assembly, otherwise I spend forever
trying to figure out what I did later ;p   And on a related keyboard note, the A20 gate sucks..

test6.asm:
; for vim syntax highlighting, asmsyntax=nasm
BITS 32

%define TCGETA  0x5405                  ; <asm/ioctls.h>
%define TCSETA  0x5406

%define ICANON  0000002q                ; <bits/termios.h>
%define ECHO    0000010q
%define ECHOE   0000020q
%define ECHOK   0000040q
%define ECHONL  0000100q

%define STDIN_FILENO    0               ; <unistd.h>

%define BUFSIZE 1024

section .bss
buf     resb    BUFSIZE
old     resb    2                       ; save the old flags
tty     resb    17                      ; struct termio tty

section .text
        global _start

(Continue reading)

TheReader06 | 2 Aug 20:11 2005
Picon
Picon

Re: Executing memory mapped files

Here's a piece of a program I wrote to do that..  (So if it doesn't compile, that's why ;)

Also note that it's a flat binary it runs, not an ELF or aout format executable..

test5.c:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
        int inf, infLen;
        void *code;
        void (*func)();

        if (argc != 2)
        {
                printf("Usage: %s <input file>\n", argv[0]);
                exit(-1);
        }

        if ( (inf = open(argv[1], O_RDONLY)) == -1)
        {
                printf("Failed to open '%s'..\n", argv[1]);
                exit(-1);
(Continue reading)

a c | 3 Aug 01:31 2005
Picon

im news, heres why

i wanted to know about this, hopefully someone on here
can look at this and decode it, its a packet,
unfortunately i forgot to -s 0 on tcpdump before i saw
it
but ive seen it a few times before and this is as long
as it gets

04:04:39.6808717 00:XX:aa:XX:aa:XX 0000592
 0x0000 4500 0240 7678 0000 4011 fd35 0000 0000
 0x0010 ffff ffff 0044 0043 022c f66a 0101 0600
 0x0020 7aa4 e836 000a 0000 0000 0000 0000 0000
 0x0030 0000 0000 0000 0000 0000 d0a4 0214 0000
 0x0040 0000 0000 0000 0000 0000 0000 0000 0000
the corrosponding ascii translation, i dont trust
the line wrap.
E.. <at> {x.. <at> ..5....
.....D.C.,.j....
z..6............
................
................

okay so i have no idea what this is, and that bothers
me a little bit, since it -seems- to accompany other
symptoms of funny networking, eg lag, telnet clearing
the screen, sometimes the telnet process forgets how
to
clean up after a backspace so to "a" becomes "_a" 
the _ is the cursor.. thats probably a whole different
issue for a whole different group, i just hope some
hex
(Continue reading)

Claudio Fontana | 3 Aug 02:35 2005
Picon

Re: im news, heres why

This is not very much assembly related, however here
are my 2c:

--- a c <notawwal <at> yahoo.com> wrote:

> i wanted to know about this, hopefully someone on
> here
> can look at this and decode it, its a packet,
> unfortunately i forgot to -s 0 on tcpdump before i
> saw
> it
> but ive seen it a few times before and this is as
> long
> as it gets
> 
> 04:04:39.6808717 00:XX:aa:XX:aa:XX 0000592
>  0x0000 4500 0240 7678 0000 4011 fd35 0000 0000
>  0x0010 ffff ffff 0044 0043 022c f66a 

IP HEADER
=========

IP version=4
IP header length=5*(32 bit words)=20 bytes
Type of service=0 (unused)
datagram size(header+data)= 0x0240 (576 bytes)
ID=0x7678
Flags=none
13 bit fragment offset=0
Time to live=0x40 hops
(Continue reading)

Claudio Fontana | 3 Aug 02:40 2005
Picon

Re: im news, heres why

sorry, just noticed I did crappy calculations.
Port 0x43 is of course not 69, it is 67 which is most
probably a dhcp service.

Claudio

		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

HIToC | 3 Aug 10:31 2005
Picon

Standard output

Hello list!
Normally, when I call the function sys_write on standard output, I
write one ore more character on the screen in the position next
to the last character printed.
I am writing a program that wishes to clean the screen, to print a character
in a fixed position no the screen (x, y) and to modify the characters and
background colors.
What funcionts I have to call in order to have a better controll of the
standard output?

Thanks a lot for every suggestion.
--

-- 
With regards,

					HIToC
					hitoc_mail <at> yahoo.it
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Mohammad Badr | 3 Aug 14:39 2005
Picon

I have a qustion about linux kernel assembly

Hi

I had added an assembly program to the networking
section of kernel linux 2.2.16 without any problem.
But when I add it to kerenel 2.4.1 I could build that
kernel, but I faced with problem when I boot system
with new builded image. I use the following Make file
to build It in the 2.4.1 kernel. 

/*--------------------------------*/
L_TARGET := libtest.a

obj-$(CONFIG_TEST)		+= test.o

override CFLAGS += -Wpointer-arith
override CFLAGS += -Wbad-function-cast
override CFLAGS += -DTERMIO

#-----------------------------------------------------------------------------
# Section 3 - Conversion routines from new style to
old style for Rules.make

#-----------------------------------------------------------------------------
# Section 4 - Rules.make section
include $(TOPDIR)/Rules.make
#-----------------------------------------------------------------------------
# Section 5

$(obj-y):  $(TOPDIR)/include/linux/config.h\

(Continue reading)

TheReader06 | 3 Aug 14:53 2005
Picon
Picon

Re: Standard output

http://www.termsys.demon.co.uk/vtansi.htm

Hope it helps,

Joshua

> Hello list!
> Normally, when I call the function sys_write on standard output, I
> write one ore more character on the screen in the position next
> to the last character printed.
> I am writing a program that wishes to clean the screen, to print a character
> in a fixed position no the screen (x, y) and to modify the characters and
> background colors.
> What funcionts I have to call in order to have a better controll of the
> standard output?
> 
> Thanks a lot for every suggestion.
> -- 
> With regards,
> 
> 
> 					HIToC
> 					hitoc_mail <at> yahoo.it
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)


Gmane