interesting but this is not the case i personaly need (want) to do
as i said it partially works - now i can
load .o as plugins but cannot call functions from it
i began to read coff documentation in hoping to resolve this (
http://wiki.osdev.org/COFF)
let me state my present problem
i compile such plugin
int tab[1000];
int rand1();
int rand2();
int rand3();
void mangen(int* data, int frame_size_x, int frame_size_y)
{
for(int j=0; j<frame_size_y; j++)
for(int i=0; i<frame_size_x; i++)
{
if(i<100 && j<100)
if((i+j)%2==0)
data[j*frame_size_x+i] = rand1() + rand2() + rand3() ;
}
}
i got such binary from this
00000000 4C 01 04 00 00 00 00 00-6E 01 00 00 10 00 00 00 L.......n.......
00000010 00 00 04 01 2E 74 65 78-74 00 00 00 00 00 00 00 .....text.......
00000020 00 00 00 00 88 00 00 00-B4 00 00 00 50 01 00 00 ............P...
00000030 00 00 00 00 03 00 00 00-20 00 30 60 2E 64 61 74 ........ .0`.dat
00000040 61 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 a...............
00000050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000060 40 00 30 C0 2E 62 73 73-00 00 00 00 00 00 00 00 @.0..bss........
00000070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000080 00 00 00 00 00 00 00 00-80 00 30 C0 2E 64 72 65 ..........0..dre
00000090 63 74 76 65 00 00 00 00-00 00 00 00 14 00 00 00 ctve............
000000A0 3C 01 00 00 00 00 00 00-00 00 00 00 00 00 00 00 <...............
000000B0 40 00 30 C0 55 89 E5 56-53 83 EC 10 C7 45 F4 00 @.0.U..VS....E..
000000C0 00 00 00 EB 66 C7 45 F0-00 00 00 00 EB 51 83 7D ....f.E......Q.}
000000D0 F0 63 7F 47 83 7D F4 63-7F 41 8B 45 F4 8B 55 F0 .c.G.}.c.A.E..U.
000000E0 01 D0 83 E0 01 85 C0 75-32 8B 45 F4 89 C2 0F AF .......u2.E.....
000000F0 55 0C 8B 45 F0 01 D0 8D-14 85 00 00 00 00 8B 45 U..E...........E
00000100 08 8D 34 02 E8 00 00 00-00 89 C3 E8 00 00 00 00 ..4.............
00000110 01 C3 E8 00 00 00 00 01-D8 89 06 83 45 F0 01 8B ............E...
00000120 45 F0 3B 45 0C 7C A7 83-45 F4 01 8B 45 F4 3B 45 E.;E.|..E...E.;E
00000130 10 7C 92 83 C4 10 5B 5E-5D C3 90 90 20 2D 61 6C .|....[^]... -al
00000140 69 67 6E 63 6F 6D 6D 3A-22 5F 74 61 62 22 2C 35 igncomm:"_tab",5
00000150 51 00 00 00 0D 00 00 00-14 00 58 00 00 00 0E 00 Q.........X.....
00000160 00 00 14 00 5F 00 00 00-0F 00 00 00 14 00 2E 66 ...._..........f
00000170 69 6C 65 00 00 00 00 00-00 00 FE FF 00 00 67 01 ile...........g.
00000180 73 6B 72 79 70 74 2E 63-00 00 00 00 00 00 00 00 skrypt.c........
00000190 00 00 5F 6D 61 6E 67 65-6E 00 00 00 00 00 01 00 .._mangen.......
000001A0 20 00 02 01 00 00 00 00-00 00 00 00 00 00 00 00 ...............
000001B0 00 00 00 00 00 00 2E 74-65 78 74 00 00 00 00 00 .......text.....
000001C0 00 00 01 00 00 00 03 01-86 00 00 00 03 00 00 00 ................
000001D0 00 00 00 00 00 00 00 00-00 00 2E 64 61 74 61 00 ...........data.
000001E0 00 00 00 00 00 00 02 00-00 00 03 01 00 00 00 00 ................
000001F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 2E 62 ...............b
00000200 73 73 00 00 00 00 00 00-00 00 03 00 00 00 03 01 ss..............
00000210 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000220 00 00 2E 64 72 65 63 74-76 65 00 00 00 00 04 00 ...drectve......
00000230 00 00 03 01 14 00 00 00-00 00 00 00 00 00 00 00 ................
00000240 00 00 00 00 00 00 5F 74-61 62 00 00 00 00 A0 0F ......_tab......
00000250 00 00 00 00 00 00 02 00-5F 72 61 6E 64 31 00 00 ........_rand1..
00000260 00 00 00 00 00 00 20 00-02 00 5F 72 61 6E 64 32 ...... ..._rand2
00000270 00 00 00 00 00 00 00 00-20 00 02 00 5F 72 61 6E ........ ..._ran
00000280 64 33 00 00 00 00 00 00-00 00 20 00 02 00 04 00 d3........ .....
00000290 00 00 - ..
the procedure assembly dump is
skrypt.o: file format pe-i386
architecture: i386, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x00000000
Disassembly of section .text:
00000000 <_mangen>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 56 push %esi
4: 53 push %ebx
5: 83 ec 10 sub $0x10,%esp
8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
f: eb 66 jmp 77 <_mangen+0x77>
11: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
18: eb 51 jmp 6b <_mangen+0x6b>
1a: 83 7d f0 63 cmpl $0x63,-0x10(%ebp)
1e: 7f 47 jg 67 <_mangen+0x67>
20: 83 7d f4 63 cmpl $0x63,-0xc(%ebp)
24: 7f 41 jg 67 <_mangen+0x67>
26: 8b 45 f4 mov -0xc(%ebp),%eax
29: 8b 55 f0 mov -0x10(%ebp),%edx
2c: 01 d0 add %edx,%eax
2e: 83 e0 01 and $0x1,%eax
31: 85 c0 test %eax,%eax
33: 75 32 jne 67 <_mangen+0x67>
35: 8b 45 f4 mov -0xc(%ebp),%eax
38: 89 c2 mov %eax,%edx
3a: 0f af 55 0c imul 0xc(%ebp),%edx
3e: 8b 45 f0 mov -0x10(%ebp),%eax
41: 01 d0 add %edx,%eax
43: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
4a: 8b 45 08 mov 0x8(%ebp),%eax
4d: 8d 34 02 lea (%edx,%eax,1),%esi
50: e8 00 00 00 00 call 55 <_mangen+0x55>
55: 89 c3 mov %eax,%ebx
57: e8 00 00 00 00 call 5c <_mangen+0x5c>
5c: 01 c3 add %eax,%ebx
5e: e8 00 00 00 00 call 63 <_mangen+0x63>
63: 01 d8 add %ebx,%eax
65: 89 06 mov %eax,(%esi)
67: 83 45 f0 01 addl $0x1,-0x10(%ebp)
6b: 8b 45 f0 mov -0x10(%ebp),%eax
6e: 3b 45 0c cmp 0xc(%ebp),%eax
71: 7c a7 jl 1a <_mangen+0x1a>
73: 83 45 f4 01 addl $0x1,-0xc(%ebp)
77: 8b 45 f4 mov -0xc(%ebp),%eax
7a: 3b 45 10 cmp 0x10(%ebp),%eax
7d: 7c 92 jl 11 <_mangen+0x11>
7f: 83 c4 10 add $0x10,%esp
82: 5b pop %ebx
83: 5e pop %esi
84: 5d pop %ebp
85: c3 ret
86: 90 nop
87: 90 nop
I need now some simple routine that would
give mi information which function pointer i need to poke in which offset before running the routine