First public contribution.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // For the Winscw Emulator only, selects between GCE and non-GCE version of Screen Driver.
15 // The default is the non-GCE based version.
16 // To select the GCE version do one of:
17 // 1. Add a line to the epoc.ini file in \epoc32\data like this:
18 // symbian_graphics_use_gce ON
20 // 2. Start epoc.exe with these parameters, (the "--" IS necessary):
21 // -Dsymbian_graphics_use_gce=ON --
23 // 3. epoc.exe can be told to switch to a different initialisation file than epoc.ini, with the -M parameter.
24 // Progress chaining to the real Scdv is logged in epocwind.out.
38 #include "scdv_stubs.h"
40 FARPROC vector[MAX_ORDINAL+1];
43 void Stop(char* aErrorMessage)
45 void Stop(char* /*aErrorMessage*/)
48 int err = GetLastError();
50 RDebug::Printf("%S, (last error = %i)", aErrorMessage, err);
55 void fill_vector(HINSTANCE aDll)
58 FARPROC address = NULL;
59 for (i=1;i<=MAX_ORDINAL;i++)
61 address = GetProcAddress(aDll, (LPCSTR)i);
64 Stop("... has too few exported functions");
69 address = GetProcAddress(aDll, (LPCSTR)i);
72 Stop("... has too many exported functions");
74 vector[0] = (FARPROC)1; // initialised
77 // redirects DLL calls to GCE or non-GCE implementation
80 // ask HAL which configuration to use
82 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &gce);
83 const char* library = gce ? "_generic_scdv.dll" : "_wins_scdv.dll";
86 RDebug::Printf("Redirecting scdv.dll to \"%s\" ...\n", library);
89 Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel
90 // try to load selected DLL
91 HINSTANCE instance = LoadLibraryA(library);
96 Stop("... unable to load");
100 fill_vector(instance);
102 RDebug::Printf("... DLL loaded successfully");
107 __declspec(naked) void common_dispatch()
109 _asm cmp dword ptr vector,0 // initialised?
110 _asm je do_init_vector
112 _asm jmp [vector+eax*4]
118 _asm call init_vector
122 _asm jmp call_though_vector