Rev 576 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
576 | serge | 1 | #include "crt.h" |
2 | |||
3 | #define atexitBufferSize 32 |
||
4 | |||
1843 | clevermous | 5 | #ifdef AUTOBUILD |
6 | char kosExePath[1024]; |
||
7 | char exeStack[16384]; |
||
8 | char params[1024]; |
||
9 | // must be alphabetically first in the image |
||
10 | #pragma data_seg(".1seg") |
||
11 | struct |
||
12 | { |
||
13 | char header[8]; |
||
14 | int headerver; |
||
15 | void* entry; |
||
16 | void* i_end; |
||
17 | void* memsize; |
||
18 | void* stack; |
||
19 | void* params; |
||
20 | void* icon; |
||
21 | } __MENUET_APP_header = { |
||
22 | {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'}, |
||
23 | 1, |
||
24 | &crtStartUp, |
||
25 | 0, // filled by doexe2.asm |
||
26 | 0, // filled by doexe2.asm |
||
27 | exeStack + sizeof(exeStack), |
||
28 | params, |
||
29 | kosExePath |
||
30 | }; |
||
31 | #pragma data_seg() |
||
32 | #endif |
||
33 | |||
576 | serge | 34 | char pureCallMessage[] = "PURE function call!"; |
35 | |||
1843 | clevermous | 36 | //char *__argv[2]; |
37 | //int __argc; |
||
576 | serge | 38 | |
39 | void (__cdecl *atExitList[atexitBufferSize])(); |
||
40 | int atExitFnNum = 0; |
||
41 | int main(int argc, char *argv[]); |
||
42 | |||
43 | void exit() |
||
1843 | clevermous | 44 | { /*int i; |
576 | serge | 45 | |
46 | for ( i = atExitFnNum - 1; i >= 0; i-- ) |
||
1843 | clevermous | 47 | atExitList[i]();*/ |
576 | serge | 48 | |
49 | __asm |
||
50 | { |
||
51 | mov eax, -1 |
||
52 | int 0x40 |
||
53 | }; |
||
54 | }; |
||
55 | |||
1843 | clevermous | 56 | /*int __cdecl atexit( void (__cdecl *func )( void )) |
576 | serge | 57 | { |
58 | // |
||
59 | if ( atExitFnNum < atexitBufferSize ) |
||
60 | { |
||
61 | // |
||
62 | atExitList[atExitFnNum++] = func; |
||
63 | return 0; |
||
64 | } |
||
65 | else |
||
66 | { |
||
67 | return 1; |
||
68 | } |
||
1843 | clevermous | 69 | }*/ |
576 | serge | 70 | |
71 | int __cdecl _purecall() |
||
72 | { |
||
73 | exit(); |
||
74 | return 0; |
||
75 | } |
||
76 | |||
77 | #pragma section(".CRT$XCA",long,read,write) |
||
78 | #pragma section(".CRT$XCZ",long,read,write) |
||
79 | typedef void (__cdecl *_PVFV)(void); |
||
1843 | clevermous | 80 | //__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 }; |
81 | //__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 }; |
||
576 | serge | 82 | // |
83 | #pragma comment(linker, "/merge:.CRT=.rdata") |
||
84 | // |
||
85 | void crtStartUp() |
||
86 | {_PVFV *pbegin; |
||
1843 | clevermous | 87 | char* __argv[2]; |
576 | serge | 88 | |
1843 | clevermous | 89 | #ifdef AUTOBUILD |
90 | __MENUET_APP_header.header; |
||
91 | #endif |
||
92 | |||
576 | serge | 93 | _asm {fninit}; |
94 | |||
1843 | clevermous | 95 | /*for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
576 | serge | 96 | { |
97 | // |
||
98 | if ( *pbegin != 0 ) |
||
99 | (**pbegin)(); |
||
100 | } |
||
1843 | clevermous | 101 | __argc = 2;*/ |
102 | #ifdef AUTOBUILD |
||
103 | __argv[0] = kosExePath; |
||
104 | __argv[1] = params; |
||
105 | #else |
||
576 | serge | 106 | __argv[0] = *((char **)0x20); |
107 | __argv[1] = *((char **)0x1C); |
||
1843 | clevermous | 108 | #endif |
109 | main(/*__argc*/2, __argv); |
||
576 | serge | 110 | exit(); |
111 | }>> |
||
112 |