MikoĊaj Zalewski wrote:
@@ -231,6 +247,101 @@ static inline LPWSTR SERV_dupmulti(LPCSTR str) }
/******************************************************************************
- RPC connection with servies.exe
- */
+static BOOL check_services_exe() +{
Put "void" in the brackets here and in many other places.
+static SvcCtlRpcHandle connect_to_server(LPCWSTR server) +{
- WCHAR transport[] = SVCCTL_TRANSPORT;
- WCHAR endpoint[] = SVCCTL_ENDPOINT;
- LPWSTR server_copy = NULL;
- RPC_WSTR binding_str;
- RPC_STATUS status;
- SvcCtlRpcHandle rpc_handle;
- /* unlike Windows we start services.exe on demand. We start it always as
* checking if this is our address can be tricky */
- if (!check_services_exe())
return NULL;
- if (server) /* parameters of RpcStringBindingComposeW are not const */
- {
server_copy = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(server) + 1));
strcpyW(server_copy, server);
- }
RpcStringBindingComposeW doesn't change server if you pass it in, so there is no need to make a copy.
- status = RpcStringBindingComposeW(NULL, transport, server_copy, endpoint, NULL, &binding_str);
- HeapFree(GetProcessHeap(), 0, server_copy);
- if (status != RPC_S_OK)
- {
ERR("RpcStringBindingComposeW failed (%d)\n", (DWORD)status);
return NULL;
- }
diff --git a/include/wine/svcctl.idl b/include/wine/svcctl.idl new file mode 100644 index 0000000..fefd12f --- /dev/null +++ b/include/wine/svcctl.idl @@ -0,0 +1,68 @@ +/*
- svcctl interface definitions - exported by services.exe to access the
- services database
- Copyright 2007 Google (Mikolaj Zalewski)
- 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
- */
+import "wtypes.idl";
+/*
- some defined for the C code
- */
+cpp_quote("#define SVCCTL_TRANSPORT {'n','c','a','c','n','_','n','p',0}"); +cpp_quote("#define SVCCTL_ENDPOINT {'\\','p','i','p','e','\\','s','v','c','c','t','l',0}");
+/* Not the Windows event name - if needed the true one can be found in Inside Windows */ +cpp_quote("#define SVCCTL_STARTED_EVENT (const WCHAR[]){'_','_','w','i','n','e','_','S','v','c','c','t','l','S','t','a','r','t','e','d',0}");
+/* Based on the Samba IDL. Some functions are compatible with Windows but some
- aren't and many are missing (thus function numbers are different) so we
- don't use the Windows uuid which is 367abb81-9844-35f1-ad32-98f038001003 .
- */
+[ uuid(78e2d9e8-d2a8-40d8-9bbe-7328cc5a9c32),
- version(2.0),
- pointer_default(unique),
- endpoint("ncacn_np:[\pipe\svcctl]"),
- helpstring("Service Control")
+] interface svcctl +{
- typedef handle_t SvcCtlRpcHandle;
- typedef struct _POLICY_HANDLE
- {
DWORD dwHandleType;
- GUID uuid;
- } POLICY_HANDLE;
There's no need to use Samba's concept of "POLICY_HANDLE". We fully support the DCE/RPC context_handle type which is what this actually is.
You can find out more about how to use context handles here: http://msdn2.microsoft.com/en-us/library/aa373605(VS.85).aspx
- /* Compatible with Windows function 0x00 */
- DWORD svcctl_CloseServiceHandle(
[in] SvcCtlRpcHandle rpc_handle,
[in,out] POLICY_HANDLE *handle
- );
There's no need for the rpc_handle here once you make the second parameter into a context handle.
- /* Compatible with Windows function 0x0f */
- DWORD svcctl_OpenSCManagerW(
SvcCtlRpcHandle rpc_handle,
[in,unique] LPCWSTR MachineName,
[in,unique] LPCWSTR DatabaseName,
[in] DWORD dwAccessMask,
[out] POLICY_HANDLE *handle
- );
+}