Sponsored Content
Full Discussion: Execute code in kernel mode.
Top Forums Programming Execute code in kernel mode. Post 302504491 by Corona688 on Monday 14th of March 2011 06:09:18 PM
Old 03-14-2011
You're not writing this in C++, are you? Your gettimeofday function will be named some crazy operator-overloaded C++ hashed name.

[edit] Add this exact code to libkeepalive.c:

Code:
// below #include <netinet/tcp.h>
#include <sys/time.h>

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
        write(2, "LOOOL", 5);
        return(-1);
}

Then run make in the appropriate directory:
Code:
$ ls
AUTHORS    FEEDBACK  Makefile  VERSION  test
ChangeLog  LICENSE   README    src      wtf.cpp
$ make
 make
make -C src/
make[1]: Entering directory `/home/tyler/code/c/1shot/speedhack/libkeepalive-0.2/src'
gcc -fPIC   -c -o libkeepalive.o libkeepalive.c
gcc -shared -Wl,-soname,libkeepalive.so -o libkeepalive.so libkeepalive.o -ldl
rm libkeepalive.o
make[1]: Leaving directory `/home/tyler/code/c/1shot/speedhack/libkeepalive-0.2/src'
make -C test/
make[1]: Entering directory `/home/tyler/code/c/1shot/speedhack/libkeepalive-0.2/test'
gcc     test.c   -o test
make[1]: Leaving directory `/home/tyler/code/c/1shot/speedhack/libkeepalive-0.2/test'
cp src/libkeepalive.so libkeepalive.so
strip -s libkeepalive.so
$ g++ -o wtf wtf.cpp
$

...then use it like so:
Code:
$ export LD_PRELOAD="./libkeepalive.so"
$ ./wtf
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
LOOOLS: -1216950284 MS: -1076618008
....

And be sure to export LD_PRELOAD="" before doing anything else because you will continue to see LOOOL's popping up in bizzare places Smilie

I suspect the difference is in the makefile. Some rather bizzare options are required to prevent gcc from complaining about your symbols conflicting with libc's when you build stuff like this.

Last edited by Corona688; 03-14-2011 at 07:15 PM..
This User Gave Thanks to Corona688 For This Post:
 

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

k_trap - kernel mode trap type 0x0000000E

HELP is urgently required, I run on SCO Unix 3 and this is the panic message that I get every time that I reboot 10U k_trap - kernel mode trap type 0x0000000E I have checked the swap already having the following results: #swap -l path dev swaplo blocks free... (3 Replies)
Discussion started by: alex_slb
3 Replies

2. SCO

unexpected trap in kernel mode

hi, I am trying to install sco openserver 5.0.4 on an old system. However, l was not able to proceed after putting the bootstr l have this panic message of PANIC: K_trap - kernel mode trap tupe 0x00000006 will someone kindly help to decode this error kayode (1 Reply)
Discussion started by: kayode
1 Replies

3. Linux

Kernel panic - not syncing: cannot execute a PAE-enabled kernel on PAE-less CPU

ok so I just installed fedora core 6 on my dell inspiron 700m and I go to boot into linux and I get this error. Has anyone seen this before? I also had XP Pro and Vista installed on this pc prior to putting fedora core 6 on the machine. I'm trying to setup a triple boot system. Please Help... (2 Replies)
Discussion started by: dave043
2 Replies

4. Programming

Aplication user and kernel mode (data access)

Hi all, I am trying to setup a program to use a device driver and am confusing buffer access between User and Kernel mode. I think all applications running in User space have to communicate with the device drivers using io control calls and then have some functions called back from the driver... (1 Reply)
Discussion started by: Brendan Kennedy
1 Replies

5. UNIX for Dummies Questions & Answers

Kernel Mode

Hi all i have queastion. Can anybody pease help me what is user mode and kernel mode and the term "De-mountable volumes" means? Thanks Palash (2 Replies)
Discussion started by: palash2k
2 Replies

6. SCO

PANIC: k_trap - Kernel mode trap type 0x0000000E

Hi, i'm another question: I'm a directory /usr/data on my server sco unix 5.0.5: # du /usr/data 4386948 /usr/data I'm tried to connect to ftp directory /usr/data to this server and: PANIC: k_trap - Kernel mode trap type 0x0000000E Cannot dump 262040 pages to dumpdev hd(1/41):space... (3 Replies)
Discussion started by: sebpes
3 Replies

7. Programming

which function copies data from user to kernel mode

when transitionaning from user to kernel mode which function copies data from user mode buffer to kernel mode? (5 Replies)
Discussion started by: rupeshkp728
5 Replies

8. Programming

HELP!!: CPU resource allocation between kernel modules and user mode process

Hi,all: I run my program which consists of one kernel module and one user mode process on a dual core server. The problem here is the kernel module consumes 100% of one core while the user mode process only consumes 10% of the other core, is there any solution that I can assign some computing... (1 Reply)
Discussion started by: neyshule
1 Replies

9. UNIX for Advanced & Expert Users

Precaution to access user mode buffers from kernel

When accessing a user mode buffers from kernel space drivers what precautions must we take and how those precautions need to be implemented? (0 Replies)
Discussion started by: rupeshkp728
0 Replies
GO-PATH(7)						 Miscellaneous Information Manual						GO-PATH(7)

NAME
go - tool for managing Go source code DESCRIPTION
The Go path is used to resolve import statements. It is implemented by and documented in the go/build package. The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list. GOPATH must be set to build and install packages outside the standard Go tree. Each directory listed in GOPATH must have a prescribed structure: The src/ directory holds source code. The path below 'src' determines the import path or executable name. The pkg/ directory holds installed package objects. As in the Go tree, each target operating system and architecture pair has its own sub- directory of pkg (pkg/GOOS_GOARCH). If DIR is a directory listed in the GOPATH, a package with source in DIR/src/foo/bar can be imported as "foo/bar" and has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". The bin/ directory holds compiled commands. Each command is named for its source directory, but only the final element, not the entire path. That is, the command with source in DIR/src/foo/quux is installed into DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped so that you can add DIR/bin to your PATH to get at the installed commands. If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin. Here's an example directory layout: GOPATH=/home/user/gocode /home/user/gocode/ src/ foo/ bar/ (go code in package bar) x.go quux/ (go code in package main) y.go bin/ quux (installed command) pkg/ linux_amd64/ foo/ bar.a (installed package object) Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list. AUTHOR
This manual page was written by Michael Stapelberg <stapelberg@debian.org>, for the Debian project (and may be used by others). 2012-05-13 GO-PATH(7)
All times are GMT -4. The time now is 10:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy