diff options
Diffstat (limited to 'um/libservice/include')
-rw-r--r-- | um/libservice/include/libservice/all.hpp | 15 | ||||
-rw-r--r-- | um/libservice/include/libservice/common.hpp | 17 | ||||
-rw-r--r-- | um/libservice/include/libservice/device.hpp | 75 | ||||
-rw-r--r-- | um/libservice/include/libservice/handle.hpp | 77 | ||||
-rw-r--r-- | um/libservice/include/libservice/service.hpp | 73 | ||||
-rw-r--r-- | um/libservice/include/libservice/service_handle.hpp | 76 | ||||
-rw-r--r-- | um/libservice/include/libservice/service_manager.hpp | 63 | ||||
-rw-r--r-- | um/libservice/include/libservice/singleton.hpp | 43 | ||||
-rw-r--r-- | um/libservice/include/libservice/windows_error.hpp | 31 |
9 files changed, 0 insertions, 470 deletions
diff --git a/um/libservice/include/libservice/all.hpp b/um/libservice/include/libservice/all.hpp deleted file mode 100644 index a5761e0..0000000 --- a/um/libservice/include/libservice/all.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" -#include "device.hpp" -#include "handle.hpp" -#include "service.hpp" -#include "service_handle.hpp" -#include "service_manager.hpp" -#include "singleton.hpp" -#include "windows_error.hpp" diff --git a/um/libservice/include/libservice/common.hpp b/um/libservice/include/libservice/common.hpp deleted file mode 100644 index a1c46fb..0000000 --- a/um/libservice/include/libservice/common.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#define LIBSERVICE_FILE_PATH __FILE__ -#define LIBSERVICE_LINE_NUMBER __LINE__ -#define LIBSERVICE_FUNCTION_NAME __FUNCTION__ - -#define LIBSERVICE_TO_STRING(s) LIBSERVICE_TO_STRING_(s) -#define LIBSERVICE_TO_STRING_(s) #s - -#define LIBSERVICE_LINE_NUMBER_STRING LIBSERVICE_TO_STRING(LIBSERVICE_LINE_NUMBER) - -#define LIBSERVICE_NOEXCEPT throw() diff --git a/um/libservice/include/libservice/device.hpp b/um/libservice/include/libservice/device.hpp deleted file mode 100644 index ac292c8..0000000 --- a/um/libservice/include/libservice/device.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" -#include "handle.hpp" - -#include <Windows.h> - -#include <cstddef> - -#include <string> -#include <utility> - -namespace libservice -{ - class Device - { - public: - typedef DWORD Code; - - static Device open(const std::string& path); - - Device(Device&& other) LIBSERVICE_NOEXCEPT - { - swap(other); - } - - Device& operator=(Device other) LIBSERVICE_NOEXCEPT - { - swap(other); - return *this; - } - - void swap(Device& other) LIBSERVICE_NOEXCEPT - { - using std::swap; - swap(handle, other.handle); - } - - std::size_t get_required_output_size( - Code code, - const void* in_buf, - std::size_t in_buf_size) const; - - std::size_t send_control_code( - Code code, - const void* in_buf, - std::size_t in_buf_size, - void* out_buf, - std::size_t out_buf_size) const; - - private: - Device(Handle handle) - : handle(std::move(handle)) - { } - - Handle handle; - - Device(const Device&) = delete; - }; - - void swap(Device&, Device&) LIBSERVICE_NOEXCEPT; -} - -namespace std -{ - template <> - void swap<libservice::Device>( - libservice::Device&, - libservice::Device&) LIBSERVICE_NOEXCEPT; -} diff --git a/um/libservice/include/libservice/handle.hpp b/um/libservice/include/libservice/handle.hpp deleted file mode 100644 index 5e351d2..0000000 --- a/um/libservice/include/libservice/handle.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" - -#include <Windows.h> - -#include <memory> -#include <type_traits> -#include <utility> - -namespace libservice -{ - class Handle - { - public: - Handle() = default; - - Handle(HANDLE raw) - : impl(raw) - { } - - Handle(Handle&& other) LIBSERVICE_NOEXCEPT - { - swap(other); - } - - Handle& operator=(Handle other) LIBSERVICE_NOEXCEPT - { - swap(other); - return *this; - } - - operator bool() const - { - return static_cast<bool>(impl); - } - - operator HANDLE() const - { - return impl.get(); - } - - void swap(Handle& other) LIBSERVICE_NOEXCEPT - { - using std::swap; - swap(impl, other.impl); - } - - private: - struct Deleter - { - void operator()(HANDLE raw) - { - CloseHandle(raw); - } - }; - - std::unique_ptr<std::remove_pointer<HANDLE>::type, Deleter> impl; - - Handle(const Handle&) = delete; - }; - - void swap(Handle& a, Handle& b) LIBSERVICE_NOEXCEPT; -} - -namespace std -{ - template <> - void swap<libservice::Handle>( - libservice::Handle& a, - libservice::Handle& b) LIBSERVICE_NOEXCEPT; -} diff --git a/um/libservice/include/libservice/service.hpp b/um/libservice/include/libservice/service.hpp deleted file mode 100644 index 089f790..0000000 --- a/um/libservice/include/libservice/service.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" -#include "service_handle.hpp" -#include "service_manager.hpp" - -#include <string> -#include <utility> - -namespace libservice -{ - class Service - { - public: - static bool exists( - const ServiceManager&, - const std::string& name); - - static Service open( - const ServiceManager&, - const std::string& name); - - static Service install( - const ServiceManager&, - const std::string& name, - const std::string& bin_path); - - void start() const; - void stop() const; - void uninstall() const; - - Service(Service&& other) LIBSERVICE_NOEXCEPT - { - swap(other); - } - - Service& operator=(Service other) LIBSERVICE_NOEXCEPT - { - swap(other); - return *this; - } - - void swap(Service& other) LIBSERVICE_NOEXCEPT - { - using std::swap; - swap(handle, other.handle); - } - - private: - Service(ServiceHandle handle) - : handle(std::move(handle)) - { } - - ServiceHandle handle; - - Service(const Service&) = delete; - }; - - void swap(Service&, Service&) LIBSERVICE_NOEXCEPT; -} - -namespace std -{ - template <> - void swap<libservice::Service>( - libservice::Service&, - libservice::Service&) LIBSERVICE_NOEXCEPT; -} diff --git a/um/libservice/include/libservice/service_handle.hpp b/um/libservice/include/libservice/service_handle.hpp deleted file mode 100644 index 2883ff3..0000000 --- a/um/libservice/include/libservice/service_handle.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" - -#include <Windows.h> - -#include <memory> -#include <utility> - -namespace libservice -{ - class ServiceHandle - { - public: - ServiceHandle() = default; - - ServiceHandle(SC_HANDLE raw) - : impl(raw) - { } - - ServiceHandle(ServiceHandle&& other) LIBSERVICE_NOEXCEPT - { - swap(other); - } - - ServiceHandle& operator=(ServiceHandle other) LIBSERVICE_NOEXCEPT - { - swap(other); - return *this; - } - - operator bool() const - { - return static_cast<bool>(impl); - } - - operator SC_HANDLE() const - { - return impl.get(); - } - - void swap(ServiceHandle& other) LIBSERVICE_NOEXCEPT - { - using std::swap; - swap(impl, other.impl); - } - - private: - struct Deleter - { - void operator()(SC_HANDLE raw) - { - CloseServiceHandle(raw); - } - }; - - std::unique_ptr<SC_HANDLE__, Deleter> impl; - - ServiceHandle(const ServiceHandle&) = delete; - }; - - void swap(ServiceHandle&, ServiceHandle&) LIBSERVICE_NOEXCEPT; -} - -namespace std -{ - template <> - void swap<libservice::ServiceHandle>( - libservice::ServiceHandle&, - libservice::ServiceHandle&) LIBSERVICE_NOEXCEPT; -} diff --git a/um/libservice/include/libservice/service_manager.hpp b/um/libservice/include/libservice/service_manager.hpp deleted file mode 100644 index 80e6f12..0000000 --- a/um/libservice/include/libservice/service_manager.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" -#include "service_handle.hpp" - -#include <Windows.h> - -#include <utility> - -namespace libservice -{ - class ServiceManager - { - public: - static ServiceManager open(); - - ServiceManager(ServiceManager&& other) LIBSERVICE_NOEXCEPT - { - swap(other); - } - - ServiceManager& operator=(ServiceManager other) LIBSERVICE_NOEXCEPT - { - swap(other); - return *this; - } - - void swap(ServiceManager& other) LIBSERVICE_NOEXCEPT - { - using std::swap; - swap(handle, other.handle); - } - - operator SC_HANDLE() const - { - return handle; - } - - private: - ServiceManager(ServiceHandle handle) - : handle(std::move(handle)) - { } - - ServiceHandle handle; - - ServiceManager(const ServiceManager&) = delete; - }; - - void swap(ServiceManager& a, ServiceManager& b) LIBSERVICE_NOEXCEPT; -} - -namespace std -{ - template <> - void swap<libservice::ServiceManager>( - libservice::ServiceManager&, - libservice::ServiceManager&) LIBSERVICE_NOEXCEPT; -} diff --git a/um/libservice/include/libservice/singleton.hpp b/um/libservice/include/libservice/singleton.hpp deleted file mode 100644 index 1c7b1a7..0000000 --- a/um/libservice/include/libservice/singleton.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include <mutex> - -namespace libservice -{ - template <typename DerivedT> - class Singleton - { - public: - static DerivedT& get() - { - std::call_once(initialized, initialize); - return get_unsafe(); - } - - protected: - Singleton() = default; - virtual ~Singleton() = default; - - private: - static void initialize() - { - get_unsafe(); - } - - static DerivedT& get_unsafe() - { - static DerivedT instance; - return instance; - } - - static std::once_flag initialized; - }; - - template <typename DerivedT> - std::once_flag Singleton<DerivedT>::initialized; -} diff --git a/um/libservice/include/libservice/windows_error.hpp b/um/libservice/include/libservice/windows_error.hpp deleted file mode 100644 index f7ac90e..0000000 --- a/um/libservice/include/libservice/windows_error.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "common.hpp" -#include "singleton.hpp" - -#include <string> -#include <system_error> - -namespace libservice -{ - class WindowsErrorCategory - : public std::error_category - , public Singleton<WindowsErrorCategory> - { - public: - const char* name() const LIBSERVICE_NOEXCEPT { return "Windows"; } - - std::string message(int) const; - - private: - friend class Singleton<WindowsErrorCategory>; - }; -} - -#define LIBSERVICE_ERROR_PREFIX \ - "Error in function '" LIBSERVICE_FUNCTION_NAME "' at file '" LIBSERVICE_FILE_PATH "', line " LIBSERVICE_LINE_NUMBER_STRING |