1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/symc/uc_exe.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,144 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32\euser\epoc\win32\uc_exe.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32std_private.h>
1.23 +#include <e32wins.h>
1.24 +#include <u32exec.h>
1.25 +#include <e32svr.h>
1.26 +
1.27 +#ifdef __VC32__
1.28 +#define __FLTUSED
1.29 +#endif //__VC32__
1.30 +
1.31 +// include the static data definitions
1.32 +#include "win32crt.h"
1.33 +
1.34 +// include compiler helpers
1.35 +#include "x86hlp.inl"
1.36 +
1.37 +/**
1.38 +We use this class to execute code before and after "main".
1.39 +*/
1.40 +class TExeInit
1.41 + {
1.42 +public:
1.43 + TExeInit();
1.44 + ~TExeInit();
1.45 + };
1.46 +
1.47 +
1.48 +GLREF_C TInt E32Main();
1.49 +
1.50 +/*
1.51 +void globalDestructorFunc()
1.52 + {
1.53 + destroyStatics(); // this is a macro
1.54 + }
1.55 +*/
1.56 +
1.57 +extern "C"
1.58 +EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo)
1.59 +//
1.60 +// Ordinal 1 - the EPOC executable entrypoint
1.61 +//
1.62 + {
1.63 + if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit))
1.64 + {
1.65 + SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo;
1.66 +
1.67 +#ifdef USE_INSTRUMENTED_HEAP
1.68 + cinfo.iFlags |= ETraceHeapAllocs;
1.69 +#elif defined(ENABLE_HEAP_MONITORING)
1.70 + cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
1.71 +#endif
1.72 + TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo);
1.73 +
1.74 + //if (r==KErrNone)
1.75 + // r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
1.76 +
1.77 + if (r==KErrNone)
1.78 + {
1.79 + if (aReason==KModuleEntryReasonProcessInit)
1.80 + {
1.81 + // Init statics for implicitly linked DLLs
1.82 + User::InitProcess();
1.83 +
1.84 + if (r==KErrNone)
1.85 + {
1.86 + // Init statics for EXE
1.87 + //constructStatics();
1.88 +
1.89 + r = E32Main();
1.90 + }
1.91 + }
1.92 + else
1.93 + r = (*cinfo.iFunction)(cinfo.iPtr);
1.94 + }
1.95 + User::Exit(r);
1.96 + }
1.97 + if (aReason==KModuleEntryReasonException)
1.98 + {
1.99 + User::HandleException(aInfo);
1.100 + return 0;
1.101 + }
1.102 + User::Invariant();
1.103 + return 0;
1.104 + }
1.105 +
1.106 +
1.107 +#ifdef WIN32
1.108 +
1.109 +
1.110 +#define WIN32_LEAN_AND_MEAN
1.111 +#include <windows.h>
1.112 +
1.113 +
1.114 +////Prevent early static init on win32
1.115 +/**
1.116 +Our Symbian OS EXEs are in fact Windows DLLs.
1.117 +*/
1.118 +extern "C"
1.119 +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1.120 + {
1.121 + return 1;
1.122 + }
1.123 +
1.124 +/*
1.125 +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
1.126 + {
1.127 + //Should never be run
1.128 + return 0;
1.129 + };
1.130 +*/
1.131 +
1.132 +
1.133 +
1.134 +
1.135 +TExeInit::TExeInit()
1.136 + {
1.137 +
1.138 + }
1.139 +
1.140 +TExeInit::~TExeInit()
1.141 + {
1.142 +
1.143 + }
1.144 +
1.145 +
1.146 +
1.147 +#endif