[BROWSER] Add the browser service

This commit is contained in:
Eric Kohl 2020-05-21 22:49:33 +02:00
parent 80b139d726
commit 1b90e54242
8 changed files with 468 additions and 0 deletions

View File

@ -1,5 +1,6 @@
add_subdirectory(audiosrv) add_subdirectory(audiosrv)
add_subdirectory(browser)
add_subdirectory(dcomlaunch) add_subdirectory(dcomlaunch)
add_subdirectory(dhcpcsvc) add_subdirectory(dhcpcsvc)
add_subdirectory(dnsrslvr) add_subdirectory(dnsrslvr)

View File

@ -0,0 +1,22 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl)
add_rpc_files(server ${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/browser.idl)
spec2def(browser.dll browser.spec ADD_IMPORTLIB)
list(APPEND SOURCE
browser.c
rpcserver.c
precomp.h)
add_library(browser MODULE
${SOURCE}
browser.rc
${CMAKE_CURRENT_BINARY_DIR}/browser_s.c
${CMAKE_CURRENT_BINARY_DIR}/browser_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/browser.def)
set_module_type(browser win32dll UNICODE)
target_link_libraries(browser wine ${PSEH_LIB})
add_importlibs(browser advapi32 rpcrt4 msvcrt kernel32 ntdll)
add_pch(browser precomp.h SOURCE)
add_cd_file(TARGET browser DESTINATION reactos/system32 FOR all)

View File

@ -0,0 +1,184 @@
/*
* PROJECT: ReactOS Browser Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Browser service RPC server
* COPYRIGHT: Eric Kohl 2020 <eric.kohl@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
WINE_DEFAULT_DEBUG_CHANNEL(browser);
/* GLOBALS ******************************************************************/
HINSTANCE hDllInstance;
static WCHAR ServiceName[] = L"browser";
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
static SERVICE_STATUS ServiceStatus;
/* FUNCTIONS *****************************************************************/
static
VOID
UpdateServiceStatus(
DWORD dwState)
{
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
ServiceStatus.dwCurrentState = dwState;
ServiceStatus.dwControlsAccepted = 0;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
if (dwState == SERVICE_START_PENDING ||
dwState == SERVICE_STOP_PENDING ||
dwState == SERVICE_PAUSE_PENDING ||
dwState == SERVICE_CONTINUE_PENDING)
ServiceStatus.dwWaitHint = 10000;
else
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
}
static
DWORD
WINAPI
ServiceControlHandler(
DWORD dwControl,
DWORD dwEventType,
LPVOID lpEventData,
LPVOID lpContext)
{
TRACE("ServiceControlHandler()\n");
switch (dwControl)
{
case SERVICE_CONTROL_STOP:
TRACE(" SERVICE_CONTROL_STOP received\n");
/* Stop listening to incoming RPC messages */
RpcMgmtStopServerListening(NULL);
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
case SERVICE_CONTROL_PAUSE:
TRACE(" SERVICE_CONTROL_PAUSE received\n");
UpdateServiceStatus(SERVICE_PAUSED);
return ERROR_SUCCESS;
case SERVICE_CONTROL_CONTINUE:
TRACE(" SERVICE_CONTROL_CONTINUE received\n");
UpdateServiceStatus(SERVICE_RUNNING);
return ERROR_SUCCESS;
case SERVICE_CONTROL_INTERROGATE:
TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
return ERROR_SUCCESS;
case SERVICE_CONTROL_SHUTDOWN:
TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
default :
TRACE(" Control %lu received\n", dwControl);
return ERROR_CALL_NOT_IMPLEMENTED;
}
}
static
DWORD
ServiceInit(VOID)
{
HANDLE hThread;
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)RpcThreadRoutine,
NULL,
0,
NULL);
if (!hThread)
{
ERR("Can't create PortThread\n");
return GetLastError();
}
else
CloseHandle(hThread);
return ERROR_SUCCESS;
}
VOID
WINAPI
ServiceMain(
_In_ INT ArgCount,
_In_ PWSTR *ArgVector)
{
DWORD dwError;
UNREFERENCED_PARAMETER(ArgCount);
UNREFERENCED_PARAMETER(ArgVector);
FIXME("ServiceMain(%d %p)\n", ArgCount, ArgVector);
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandler,
NULL);
if (!ServiceStatusHandle)
{
ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
return;
}
UpdateServiceStatus(SERVICE_START_PENDING);
dwError = ServiceInit();
if (dwError != ERROR_SUCCESS)
{
ERR("Service stopped (dwError: %lu\n", dwError);
UpdateServiceStatus(SERVICE_STOPPED);
return;
}
UpdateServiceStatus(SERVICE_RUNNING);
}
BOOL
WINAPI
DllMain(
_In_ HINSTANCE hinstDLL,
_In_ DWORD fdwReason,
_In_ PVOID pvReserved)
{
UNREFERENCED_PARAMETER(pvReserved);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
hDllInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/* EOF */

View File

@ -0,0 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "Browser Service Dll"
#define REACTOS_STR_INTERNAL_NAME "browser"
#define REACTOS_STR_ORIGINAL_FILENAME "browser.dll"
#include <reactos/version.rc>

View File

@ -0,0 +1,3 @@
@ stub I_BrowserServerEnumForXactsrv
@ stdcall ServiceMain(long ptr)
@ stub SvchostPushServiceGlobals

View File

@ -0,0 +1,33 @@
/*
* PROJECT: ReactOS Browser Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Browser service RPC server
* COPYRIGHT: Eric Kohl 2020 <eric.kohl@reactos.org>
*/
#ifndef _BROWSER_PCH_
#define _BROWSER_PCH_
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#include <browser_s.h>
#include <wine/debug.h>
extern HINSTANCE hDllInstance;
DWORD
WINAPI
RpcThreadRoutine(
LPVOID lpParameter);
#endif /* _BROWSER_PCH_ */

View File

@ -0,0 +1,208 @@
/*
* PROJECT: ReactOS Browser Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Browser service RPC server
* COPYRIGHT: Eric Kohl 2020 <eric.kohl@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
//#include "lmerr.h"
WINE_DEFAULT_DEBUG_CHANNEL(browser);
/* FUNCTIONS *****************************************************************/
DWORD
WINAPI
RpcThreadRoutine(
LPVOID lpParameter)
{
RPC_STATUS Status;
Status = RpcServerUseProtseqEpW(L"ncacn_np", 20, L"\\pipe\\browser", NULL);
if (Status != RPC_S_OK)
{
ERR("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerRegisterIf(browser_v0_0_s_ifspec, NULL, NULL);
if (Status != RPC_S_OK)
{
ERR("RpcServerRegisterIf() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE);
if (Status != RPC_S_OK)
{
ERR("RpcServerListen() failed (Status %lx)\n", Status);
}
return 0;
}
void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
/* Function 0 */
NET_API_STATUS
__stdcall
I_BrowserrServerEnum(
BROWSER_IDENTIFY_HANDLE ServerName,
LPWSTR Transport,
LPWSTR ClientName,
LPSERVER_ENUM_STRUCT EnumStruct,
DWORD PreferedMaximumLength,
LPDWORD TotalEntries,
DWORD ServerType,
LPWSTR Domain,
LPDWORD ResumeHandle)
{
UNIMPLEMENTED;
return 0;
}
/* Function 1 (BrowserrDebugCall) */
NET_API_STATUS
__stdcall
BrowserOpnum1NotUsedOnWire(VOID)
{
UNIMPLEMENTED;
return 0;
}
/* Function 2 */
NET_API_STATUS
__stdcall
I_BrowserrQueryOtherDomains(
BROWSER_IDENTIFY_HANDLE ServerName,
LPSERVER_ENUM_STRUCT EnumStruct,
LPDWORD TotalEntries)
{
UNIMPLEMENTED;
return 0;
}
/* Function 3 */
NET_API_STATUS
__stdcall
I_BrowserrResetNetlogonState(
BROWSER_IDENTIFY_HANDLE ServerName)
{
UNIMPLEMENTED;
return 0;
}
/* Function 4 */
NET_API_STATUS
__stdcall
I_BrowserrDebugTrace(
BROWSER_IDENTIFY_HANDLE ServerName,
LPSTR String)
{
UNIMPLEMENTED;
return 0;
}
/* Function 5 */
NET_API_STATUS
__stdcall
I_BrowserrQueryStatistics(
BROWSER_IDENTIFY_HANDLE ServerName,
LPBROWSER_STATISTICS *Statistics)
{
UNIMPLEMENTED;
return 0;
}
/* Function 6 */
NET_API_STATUS
__stdcall
I_BrowserrResetStatistics(
BROWSER_IDENTIFY_HANDLE ServerName)
{
UNIMPLEMENTED;
return 0;
}
/* Function 7 - Not used on wire */
NET_API_STATUS
__stdcall
NetrBrowserStatisticsClear(
BROWSER_IDENTIFY_HANDLE ServerName)
{
UNIMPLEMENTED;
return 0;
}
/* Function 8 */
NET_API_STATUS
__stdcall
NetrBrowserStatisticsGet(
BROWSER_IDENTIFY_HANDLE ServerName,
DWORD Level,
LPBROWSER_STATISTICS_STRUCT StatisticsStruct)
{
UNIMPLEMENTED;
return 0;
}
/* Function 9 */
NET_API_STATUS
__stdcall
I_BrowserrSetNetlogonState(
BROWSER_IDENTIFY_HANDLE ServerName,
LPWSTR DomainName,
LPWSTR EmulatedComputerName,
DWORD Role)
{
UNIMPLEMENTED;
return 0;
}
/* Function 10 */
NET_API_STATUS
__stdcall
I_BrowserrQueryEmulatedDomains(
BROWSER_IDENTIFY_HANDLE ServerName,
PBROWSER_EMULATED_DOMAIN_CONTAINER EmulatedDomains)
{
UNIMPLEMENTED;
return 0;
}
/* Function 11 (BrowserrServerEnumEx) */
NET_API_STATUS
__stdcall
BrowserOpnum11NotUsedOnWire(void)
{
UNIMPLEMENTED;
return 0;
}
/* EOF */

View File

@ -1556,6 +1556,18 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Blue","ImagePath",0x00020000,"system32\d
HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Start",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Start",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Type",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Blue","Type",0x00010001,0x00000001
; Browser service
HKLM,"SYSTEM\CurrentControlSet\Services\Browser",,0x00000010
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","DisplayName",0x00000000,%BROWSER_SERVICE%
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","Description",0x00000000,%BROWSER_SERVICE_DESCRIPTION%
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","DependOnService",0x00010000,"LanmanWorkstation","LanmanServer"
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","ErrorControl",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","ObjectName",0x00000000,"LocalSystem"
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","Start",0x00010001,0x00000002
HKLM,"SYSTEM\CurrentControlSet\Services\Browser","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\Browser\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\browser.dll"
; EMS Serial Administration Console Driver ; EMS Serial Administration Console Driver
HKLM,"SYSTEM\CurrentControlSet\Services\sacdrv","ErrorControl",0x00010001,0x00000000 HKLM,"SYSTEM\CurrentControlSet\Services\sacdrv","ErrorControl",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Services\sacdrv","Group",0x00000000,"EMS" HKLM,"SYSTEM\CurrentControlSet\Services\sacdrv","Group",0x00000000,"EMS"