Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/modules/HelloWorld/HelloWorld.cpp

Source at commit 655 created 13 years 4 months ago.
By meklort, Modules update. removed hardcoding for dyld_stub_bunder in modules.c Added a subset of klibc for a more complete c library implimentation. Added a subset of uclibc++ for an initial c++ implimentation. Note: cout / cin / file io has been disabled. Also note that exceptions and rtti is disabled. Modified the helow world code foa small c++ test.
1/*
2 * Copyright (c) 2009 Evan Lojewski. All rights reserved.
3 *
4 */
5extern "C"
6{
7#include "libsaio.h"
8#include "modules.h"
9}
10
11class HW {
12private:
13int id;
14public:
15virtual void setId( int id );
16virtual void printHello( void );
17};
18
19void helloWorld(void* binary, void* arg2, void* arg3, void* arg4)
20{
21HW* obj = new HW;
22HW* obj2 = new HW;
23obj->setId(1);
24obj->printHello();
25delete obj;
26
27obj2->setId(2);
28obj2->printHello();
29delete obj2;
30
31printf("Hello world from ExecKernel hook. Binary located at 0x%X\n", binary);
32getc();
33
34}
35
36void HelloWorld_start()
37{
38//printf("Hooking 'ExecKernel'\n");
39register_hook_callback("ExecKernel", &helloWorld);
40register_hook_callback("Kernel Start", &helloWorld);
41
42}
43
44void HW::printHello()
45{
46printf("[%d] HelloWorld from a c++ function\n", id);
47}
48
49void HW::setId(int id)
50{
51this->id = id;
52}
53

Archive Download this file

Revision: 655