From ee9c7dc0b647a9528c36749325f90c53e67b1ed0 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 25 Feb 2014 08:45:37 +0400 Subject: [PATCH] fntcache: Added stub Font Cache service. --- configure | 2 + configure.ac | 1 + dlls/fntcache/Makefile.in | 5 ++ dlls/fntcache/fntcache.spec | 3 + dlls/fntcache/main.c | 112 ++++++++++++++++++++++++++++++++++++ loader/wine.inf.in | 24 ++++++-- 6 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 dlls/fntcache/Makefile.in create mode 100644 dlls/fntcache/fntcache.spec create mode 100644 dlls/fntcache/main.c diff --git a/configure b/configure index 833356115ae..a38957f0e5c 100755 --- a/configure +++ b/configure @@ -1028,6 +1028,7 @@ enable_explorerframe enable_ext_ms_win_gdi_devcaps_l1_1_0 enable_faultrep enable_fltlib +enable_fntcache enable_fusion enable_fwpuclnt enable_gameux @@ -16849,6 +16850,7 @@ wine_fn_config_dll ext-ms-win-gdi-devcaps-l1-1-0 enable_ext_ms_win_gdi_devcaps_l wine_fn_config_dll faultrep enable_faultrep implib wine_fn_config_test dlls/faultrep/tests faultrep_test wine_fn_config_dll fltlib enable_fltlib +wine_fn_config_dll fntcache enable_fntcache wine_fn_config_dll fusion enable_fusion wine_fn_config_test dlls/fusion/tests fusion_test wine_fn_config_dll fwpuclnt enable_fwpuclnt diff --git a/configure.ac b/configure.ac index 224b8c5d2f9..357434368aa 100644 --- a/configure.ac +++ b/configure.ac @@ -2857,6 +2857,7 @@ WINE_CONFIG_DLL(ext-ms-win-gdi-devcaps-l1-1-0) WINE_CONFIG_DLL(faultrep,,[implib]) WINE_CONFIG_TEST(dlls/faultrep/tests) WINE_CONFIG_DLL(fltlib) +WINE_CONFIG_DLL(fntcache) WINE_CONFIG_DLL(fusion) WINE_CONFIG_TEST(dlls/fusion/tests) WINE_CONFIG_DLL(fwpuclnt) diff --git a/dlls/fntcache/Makefile.in b/dlls/fntcache/Makefile.in new file mode 100644 index 00000000000..4d5342cfbe2 --- /dev/null +++ b/dlls/fntcache/Makefile.in @@ -0,0 +1,5 @@ +MODULE = fntcache.dll +IMPORTS = advapi32 + +C_SRCS = \ + main.c diff --git a/dlls/fntcache/fntcache.spec b/dlls/fntcache/fntcache.spec new file mode 100644 index 00000000000..cd309949287 --- /dev/null +++ b/dlls/fntcache/fntcache.spec @@ -0,0 +1,3 @@ +@ stub DllRegisterServer +@ stub DllUnregisterServer +@ stdcall -private ServiceMain(long ptr) diff --git a/dlls/fntcache/main.c b/dlls/fntcache/main.c new file mode 100644 index 00000000000..91c20e0779b --- /dev/null +++ b/dlls/fntcache/main.c @@ -0,0 +1,112 @@ +/* + * Font Cache service + * + * Copyright 2014 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define WIN32_LEAN_AND_MEAN +#include +#include "winsvc.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(fontcache); + +static HINSTANCE hInst; +static SERVICE_STATUS_HANDLE service_handle; +static HANDLE stop_event; + +/*********************************************************************** + * DllMain (fntcache.@) + */ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + + switch (fdwReason) + { + case DLL_WINE_PREATTACH: + return FALSE; /* prefer native version */ + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + hInst = hinstDLL; + break; + } + + return TRUE; +} + +static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, void *event_data, void *context ) +{ + SERVICE_STATUS status; + + status.dwServiceType = SERVICE_WIN32; + status.dwControlsAccepted = SERVICE_ACCEPT_STOP; + status.dwWin32ExitCode = 0; + status.dwServiceSpecificExitCode = 0; + status.dwCheckPoint = 0; + status.dwWaitHint = 0; + + switch(ctrl) + { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + WINE_TRACE( "shutting down\n" ); + status.dwCurrentState = SERVICE_STOP_PENDING; + status.dwControlsAccepted = 0; + SetServiceStatus( service_handle, &status ); + SetEvent( stop_event ); + return NO_ERROR; + default: + WINE_FIXME( "got service ctrl %x\n", ctrl ); + status.dwCurrentState = SERVICE_RUNNING; + SetServiceStatus( service_handle, &status ); + return NO_ERROR; + } +} + +/*********************************************************************** + * ServiceMain (fntcache.@) + */ +VOID WINAPI ServiceMain(DWORD argc, LPWSTR *argv) +{ + static const WCHAR fontcacheW[] = {'F','o','n','t','C','a','c','h','e',0}; + SERVICE_STATUS status; + + WINE_TRACE( "starting service\n" ); + + stop_event = CreateEventW( NULL, TRUE, FALSE, NULL ); + + service_handle = RegisterServiceCtrlHandlerExW( fontcacheW, service_handler, NULL ); + if (!service_handle) + return; + + status.dwServiceType = SERVICE_WIN32; + status.dwCurrentState = SERVICE_RUNNING; + status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + status.dwWin32ExitCode = 0; + status.dwServiceSpecificExitCode = 0; + status.dwCheckPoint = 0; + status.dwWaitHint = 10000; + SetServiceStatus( service_handle, &status ); + + WaitForSingleObject( stop_event, INFINITE ); + + status.dwCurrentState = SERVICE_STOPPED; + status.dwControlsAccepted = 0; + SetServiceStatus( service_handle, &status ); + WINE_TRACE( "service stopped\n" ); +} diff --git a/loader/wine.inf.in b/loader/wine.inf.in index ac6c697970d..595d4b9069a 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -121,8 +121,9 @@ AddService=Spooler,0,SpoolerService AddService=StiSvc,0,StiService AddService=TermService,0,TerminalServices AddService=PlugPlay,0,PlugPlayService -AddService=FontCache3.0.0.0,0,FontCacheService +AddService=FontCache3.0.0.0,0,WPFFontCacheService AddService=LanmanServer,0,LanmanServerService +AddService=FontCache,0,FontCacheService [DefaultInstall.NT.Services] AddService=BITS,0,BITSService @@ -132,8 +133,9 @@ AddService=Spooler,0,SpoolerService AddService=StiSvc,0,StiService AddService=TermService,0,TerminalServices AddService=PlugPlay,0,PlugPlayService -AddService=FontCache3.0.0.0,0,FontCacheService +AddService=FontCache3.0.0.0,0,WPFFontCacheService AddService=LanmanServer,0,LanmanServerService +AddService=FontCache,0,FontCacheService [DefaultInstall.ntamd64.Services] AddService=BITS,0,BITSService @@ -143,8 +145,9 @@ AddService=Spooler,0,SpoolerService AddService=StiSvc,0,StiService AddService=TermService,0,TerminalServices AddService=PlugPlay,0,PlugPlayService -AddService=FontCache3.0.0.0,0,FontCacheService +AddService=FontCache3.0.0.0,0,WPFFontCacheService AddService=LanmanServer,0,LanmanServerService +AddService=FontCache,0,FontCacheService [Strings] MciExtStr="Software\Microsoft\Windows NT\CurrentVersion\MCI Extensions" @@ -2989,7 +2992,7 @@ ServiceType=32 StartType=2 ErrorControl=1 -[FontCacheService] +[WPFFontCacheService] Description="Windows Presentation Foundation font cache service" DisplayName="Windows Presentation Foundation Font Cache 3.0.0.0" ServiceBinary="%10%\Microsoft.Net\Framework\v3.0\wpf\presentationfontcache.exe" @@ -3010,6 +3013,19 @@ ErrorControl=1 HKR,Parameters,"ServiceDll",,"%11%\srvsvc.dll" ;; HKLM,%CurrentVersionNT%\SvcHost,"netsvcs",0x00010008,"lanmanserver" +[FontCacheService] +AddReg=FontCacheServiceKeys +Description="Windows Font Cache Service" +DisplayName="Windows Font Cache Service" +ServiceBinary="%11%\svchost.exe -k netsvcs" +ServiceType=32 +StartType=3 +ErrorControl=1 + +[FontCacheServiceKeys] +HKR,Parameters,"ServiceDll",,"%11%\fntcache.dll" +;; HKLM,%CurrentVersionNT%\SvcHost,"netsvcs",0x00010008,"fontcache" + [Services] HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -a -r" HKLM,"System\CurrentControlSet\Services\Eventlog\Application",,16