| 1 | /* $Id: tstExeMainStub.c 2878 2006-11-12 12:41:15Z bird $ */ | 
|---|
| 2 | /** @file | 
|---|
| 3 | * | 
|---|
| 4 | * kLdr testcase - DLL Stub. | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> | 
|---|
| 7 | * | 
|---|
| 8 | * | 
|---|
| 9 | * This file is part of kLdr. | 
|---|
| 10 | * | 
|---|
| 11 | * kLdr is free software; you can redistribute it and/or modify | 
|---|
| 12 | * it under the terms of the GNU General Public License as published by | 
|---|
| 13 | * the Free Software Foundation; either version 2 of the License, or | 
|---|
| 14 | * (at your option) any later version. | 
|---|
| 15 | * | 
|---|
| 16 | * kLdr is distributed in the hope that it will be useful, | 
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 19 | * GNU General Public License for more details. | 
|---|
| 20 | * | 
|---|
| 21 | * You should have received a copy of the GNU General Public License | 
|---|
| 22 | * along with kLdr; if not, write to the Free Software | 
|---|
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 24 | * | 
|---|
| 25 | */ | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | /******************************************************************************* | 
|---|
| 29 | *   Header Files                                                               * | 
|---|
| 30 | *******************************************************************************/ | 
|---|
| 31 | #include "tst.h" | 
|---|
| 32 |  | 
|---|
| 33 | #ifdef __OS2__ | 
|---|
| 34 | # define INCL_BASE | 
|---|
| 35 | # include <os2.h> | 
|---|
| 36 |  | 
|---|
| 37 | #elif defined(__WIN__) | 
|---|
| 38 | /* nothing */ | 
|---|
| 39 |  | 
|---|
| 40 | #elif defined(__NT__) | 
|---|
| 41 | # include <ddk/ntapi.h> /** @todo fix the nt port. */ | 
|---|
| 42 |  | 
|---|
| 43 | #else | 
|---|
| 44 | # error "port me" | 
|---|
| 45 | #endif | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | extern int main(); | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | #ifdef __OS2__ | 
|---|
| 52 | /** | 
|---|
| 53 | * OS/2 'main'. | 
|---|
| 54 | */ | 
|---|
| 55 | ULONG _System OS2Main(HMODULE hmod, ULONG fFlag, ULONG ulReserved, PSZ pszzEnv, PSZ pszzCmdLine) | 
|---|
| 56 | { | 
|---|
| 57 | int rc; | 
|---|
| 58 | rc = main(); | 
|---|
| 59 | return rc; | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | #elif defined(__WIN__) | 
|---|
| 63 | /** | 
|---|
| 64 | * Windows'main' | 
|---|
| 65 | */ | 
|---|
| 66 | int WindowsMain(void) | 
|---|
| 67 | { | 
|---|
| 68 | int rc; | 
|---|
| 69 | rc = main(); | 
|---|
| 70 | return rc; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | #elif defined(__NT__) | 
|---|
| 74 | /** | 
|---|
| 75 | * Windows NT 'main' | 
|---|
| 76 | */ | 
|---|
| 77 | VOID NtProcess(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved) | 
|---|
| 78 | { | 
|---|
| 79 | int rc; | 
|---|
| 80 | rc = main(); | 
|---|
| 81 | /* (no way around this) */ | 
|---|
| 82 | for (;;) | 
|---|
| 83 | ZwTerminateProcess(NtCurrentProcess(), rc); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | #else | 
|---|
| 87 | # error "port me" | 
|---|
| 88 | #endif | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|