Rev 576 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 576 | Rev 1843 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "crt.h" |
1 | #include "crt.h" |
Line 2... | Line 2... | ||
2 | 2 | ||
Line -... | Line 3... | ||
- | 3 | #define atexitBufferSize 32 |
|
- | 4 | ||
- | 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() |
|
3 | #define atexitBufferSize 32 |
32 | #endif |
Line 4... | Line 33... | ||
4 | 33 | ||
5 | char pureCallMessage[] = "PURE function call!"; |
34 | char pureCallMessage[] = "PURE function call!"; |
Line 6... | Line 35... | ||
6 | 35 | ||
7 | char *__argv[2]; |
36 | //char *__argv[2]; |
8 | int __argc; |
37 | //int __argc; |
Line 9... | Line 38... | ||
9 | 38 | ||
10 | void (__cdecl *atExitList[atexitBufferSize])(); |
39 | void (__cdecl *atExitList[atexitBufferSize])(); |
Line 11... | Line 40... | ||
11 | int atExitFnNum = 0; |
40 | int atExitFnNum = 0; |
12 | int main(int argc, char *argv[]); |
41 | int main(int argc, char *argv[]); |
Line 13... | Line 42... | ||
13 | 42 | ||
14 | void exit() |
43 | void exit() |
15 | { int i; |
44 | { /*int i; |
16 | 45 | ||
17 | for ( i = atExitFnNum - 1; i >= 0; i-- ) |
46 | for ( i = atExitFnNum - 1; i >= 0; i-- ) |
18 | atExitList[i](); |
47 | atExitList[i]();*/ |
Line 19... | Line 48... | ||
19 | 48 | ||
20 | __asm |
49 | __asm |
21 | { |
50 | { |
22 | mov eax, -1 |
51 | mov eax, -1 |
23 | int 0x40 |
52 | int 0x40 |
24 | }; |
53 | }; |
Line 35... | Line 64... | ||
35 | } |
64 | } |
36 | else |
65 | else |
37 | { |
66 | { |
38 | return 1; |
67 | return 1; |
39 | } |
68 | } |
40 | } |
69 | }*/ |
Line 41... | Line 70... | ||
41 | 70 | ||
42 | int __cdecl _purecall() |
71 | int __cdecl _purecall() |
43 | { |
72 | { |
44 | exit(); |
73 | exit(); |
45 | return 0; |
74 | return 0; |
Line 46... | Line 75... | ||
46 | } |
75 | } |
47 | 76 | ||
48 | #pragma section(".CRT$XCA",long,read,write) |
77 | #pragma section(".CRT$XCA",long,read,write) |
49 | #pragma section(".CRT$XCZ",long,read,write) |
78 | #pragma section(".CRT$XCZ",long,read,write) |
50 | typedef void (__cdecl *_PVFV)(void); |
79 | typedef void (__cdecl *_PVFV)(void); |
51 | __declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 }; |
80 | //__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 }; |
52 | __declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 }; |
81 | //__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 }; |
53 | // |
82 | // |
54 | #pragma comment(linker, "/merge:.CRT=.rdata") |
83 | #pragma comment(linker, "/merge:.CRT=.rdata") |
55 | // |
84 | // |
- | 85 | void crtStartUp() |
|
- | 86 | {_PVFV *pbegin; |
|
- | 87 | char* __argv[2]; |
|
- | 88 | ||
- | 89 | #ifdef AUTOBUILD |
|
Line 56... | Line 90... | ||
56 | void crtStartUp() |
90 | __MENUET_APP_header.header; |
Line 57... | Line 91... | ||
57 | {_PVFV *pbegin; |
91 | #endif |
58 | 92 | ||
59 | _asm {fninit}; |
93 | _asm {fninit}; |
60 | 94 | ||
61 | for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
95 | /*for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
62 | { |
96 | { |
63 | // |
97 | // |
- | 98 | if ( *pbegin != 0 ) |
|
- | 99 | (**pbegin)(); |
|
- | 100 | } |
|
- | 101 | __argc = 2;*/ |
|
64 | if ( *pbegin != 0 ) |
102 | #ifdef AUTOBUILD |
65 | (**pbegin)(); |
103 | __argv[0] = kosExePath; |
- | 104 | __argv[1] = params; |
|
66 | } |
105 | #else |
67 | __argc = 2; |
106 | __argv[0] = *((char **)0x20); |
68 | __argv[0] = *((char **)0x20); |
107 | __argv[1] = *((char **)0x1C); |