Sponsored Content
Full Discussion: Execute code in kernel mode.
Top Forums Programming Execute code in kernel mode. Post 302504483 by lilezek on Monday 14th of March 2011 05:55:36 PM
Old 03-14-2011
Sorry, it is not LOOOOOL, it is LOOOLAZO at the start of the gettimeofday from speed hack. A no sense mistake, sorry.

---------- Post updated at 04:55 PM ---------- Previous update was at 04:49 PM ----------

New code:

Code:
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <dlfcn.h>

static timeval * timezero = 0;

typedef int (*go)(struct timeval *tv,struct timezone *tz);

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
    write(2, "LOOOL", 5);
    go gettimeofday_orig;
    int val;
    gettimeofday_orig=(go)dlsym(RTLD_NEXT,"gettimeofday");
    if (!timezero)
    {
        timezero = new timeval;
        struct timezone tmp;
        val = gettimeofday_orig(timezero,&tmp);
        (*tv) = (*timezero);
        (*tz) = tmp;
        return val;
    }
    // Doblar la velocidad:
    struct timezone tmpz;
    struct timeval tmpv;
    val = gettimeofday_orig(&tmpv,&tmpz);
    tmpv.tv_sec = 2*tmpv.tv_sec - timezero->tv_sec;
    tmpv.tv_usec = 2*tmpv.tv_usec - timezero->tv_usec;
    while(tmpv.tv_usec >= 1000000)
    {
        tmpv.tv_usec -= 1000000;
        tmpv.tv_sec += 1;
    }
    return val;
}

I don't know why when I add <iostream> I'm forced to write c code instead c++. I needed to write struct at each declaration of structure... Any idea?

PD: It seems not to get executed. Just that.

Last edited by pludi; 03-14-2011 at 08:10 PM.. Reason: Language
 

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
TIMERADD(3)						   BSD Library Functions Manual 					       TIMERADD(3)

NAME
timeradd, timersub, timerclear, timerisset, timercmp -- operations on timevals SYNOPSIS
#include <sys/time.h> void timeradd(struct timeval *a, struct timeval *b, struct timeval *res); void timersub(struct timeval *a, struct timeval *b, struct timeval *res); void timerclear(struct timeval *tvp); int timerisset(struct timeval *tvp); int timercmp(struct timeval *a, struct timeval *b, CMP); DESCRIPTION
These macros are provided for manipulating timeval structures for use with the gettimeofday(2) and settimeofday(2) calls. The structure is defined in <sys/time.h> as: struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; timeradd() adds the time information stored in a to b and stores the resulting timeval in res. The results are simplified such that the value of res->tv_usec is always less than 1,000,000 (1 second). timersub() subtracts the time information stored in b from a and stores the resulting timeval in res. timerclear() initializes tvp to midnight (0 hour) January 1st, 1970 (the Epoch). timerisset() returns true if tvp is set to any time value other than the Epoch. timercmp() compares a to b using the comparison operator given in CMP, and returns the result of that comparison. SEE ALSO
gettimeofday(2) HISTORY
The timeradd() family of macros were imported from NetBSD 1.1, and appeared in FreeBSD 2.2.6. BSD
August 11, 1999 BSD
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy