sysstatemgmt/systemstatereferenceplugins/custcmd/src/ssmuiproviderdllswitch.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // ssmcustomuidswitch.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @released
       
    22 */
       
    23 #include <emulator.h>
       
    24 
       
    25 extern "C" {
       
    26 
       
    27 #include "ssmuiproviderdllswitch_stubs.h"
       
    28 
       
    29 FARPROC vector[MAX_ORDINAL + 1];
       
    30 
       
    31 void fill_vector(HINSTANCE aDll)
       
    32 	{
       
    33 	int i;
       
    34 	for (i=1; i <= MAX_ORDINAL; i++)
       
    35 		{
       
    36 		vector[i] = GetProcAddress(aDll, (LPCSTR)i);
       
    37 		}
       
    38 	vector[0] = (FARPROC)1;		// initialised
       
    39 	}
       
    40 
       
    41 void init_vector()
       
    42 	{
       
    43 	// prevent deadlock with EKA2 scheduler
       
    44 	__LOCK_HOST;
       
    45 
       
    46 	HINSTANCE instance;
       
    47 
       
    48 	// Try loading dll with customised uid data first
       
    49 	//
       
    50 	instance = LoadLibraryA("ssmuiproviderdllcustomised.dll");
       
    51 	if (instance != NULL)
       
    52 		{
       
    53 		fill_vector(instance);
       
    54 		return;
       
    55 		}
       
    56 
       
    57 	// Try loading dll with default uid data
       
    58 	//
       
    59 	instance = LoadLibraryA("ssmuiproviderdlldefault.dll");
       
    60 	if (instance != NULL)
       
    61 		{
       
    62 		fill_vector(instance);
       
    63 		return;
       
    64 		}
       
    65 
       
    66 	// die
       
    67 	//
       
    68 	OutputDebugStringA("Unable to load ssm custom command uid implementation");
       
    69 	_asm int 3;
       
    70 	}
       
    71 
       
    72 __declspec(naked) void common_dispatch()
       
    73 	{
       
    74 	_asm cmp	dword ptr vector,0		// initialised?
       
    75 	_asm jne  	call_though_vector
       
    76 	_asm push	eax
       
    77 	_asm push	ecx
       
    78 	_asm push	edx
       
    79 	_asm call	init_vector
       
    80 	_asm pop	edx
       
    81 	_asm pop 	ecx
       
    82 	_asm pop 	eax
       
    83 call_though_vector:
       
    84 	_asm jmp	[vector+eax*4]
       
    85 	} //lint !e1065 Suppress Symbol 'common_dispatch(void)' not declared as "C" conflicts
       
    86 }