From 952970cc2a18a603e0bdccdc1f907b73da7eb4f4 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 27 Apr 2017 17:44:54 +0300 Subject: test -> simple --- utils/CMakeLists.txt | 3 +- utils/README.md | 6 ++-- utils/libsimple/CMakeLists.txt | 9 ++++++ utils/libsimple/README.md | 43 +++++++++++++++++++++++++++ utils/libsimple/include/libsimple/all.hpp | 8 +++++ utils/libsimple/include/libsimple/device.hpp | 19 ++++++++++++ utils/libsimple/src/device.cpp | 37 +++++++++++++++++++++++ utils/libsimple/utils/CMakeLists.txt | 2 ++ utils/libsimple/utils/exchange_ints.cpp | 44 ++++++++++++++++++++++++++++ utils/libtest/CMakeLists.txt | 9 ------ utils/libtest/README.md | 43 --------------------------- utils/libtest/include/libtest/all.hpp | 8 ----- utils/libtest/include/libtest/device.hpp | 19 ------------ utils/libtest/src/device.cpp | 37 ----------------------- utils/libtest/utils/CMakeLists.txt | 2 -- utils/libtest/utils/exchange_ints.cpp | 44 ---------------------------- 16 files changed, 167 insertions(+), 166 deletions(-) create mode 100644 utils/libsimple/CMakeLists.txt create mode 100644 utils/libsimple/README.md create mode 100644 utils/libsimple/include/libsimple/all.hpp create mode 100644 utils/libsimple/include/libsimple/device.hpp create mode 100644 utils/libsimple/src/device.cpp create mode 100644 utils/libsimple/utils/CMakeLists.txt create mode 100644 utils/libsimple/utils/exchange_ints.cpp delete mode 100644 utils/libtest/CMakeLists.txt delete mode 100644 utils/libtest/README.md delete mode 100644 utils/libtest/include/libtest/all.hpp delete mode 100644 utils/libtest/include/libtest/device.hpp delete mode 100644 utils/libtest/src/device.cpp delete mode 100644 utils/libtest/utils/CMakeLists.txt delete mode 100644 utils/libtest/utils/exchange_ints.cpp (limited to 'utils') diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 716c661..31c8511 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,5 +1,6 @@ project(windows7_drivers_utils) add_subdirectory(libservice) + add_subdirectory(libnt_path_converter) -add_subdirectory(libtest) +add_subdirectory(libsimple) diff --git a/utils/README.md b/utils/README.md index 5d03428..1579471 100644 --- a/utils/README.md +++ b/utils/README.md @@ -4,12 +4,12 @@ Driver utilities A couple of usage examples are included along with the drivers. * [libservice]: Utilities to load/unload the drivers. -* [libtest]: [test] driver usage examples. +* [libsimple]: [simple] driver usage examples. * [libnt_path_converter]: [nt_path_converter] driver usage examples. [libservice]: libservice/README.md -[libtest]: libtest/README.md -[test]: ../src/test +[libsimple]: libsimple/README.md +[simple]: ../src/simple [libnt_path_converter]: libnt_path_converter/README.md [nt_path_converter]: ../src/nt_path_converter diff --git a/utils/libsimple/CMakeLists.txt b/utils/libsimple/CMakeLists.txt new file mode 100644 index 0000000..ff61bd7 --- /dev/null +++ b/utils/libsimple/CMakeLists.txt @@ -0,0 +1,9 @@ +file(GLOB_RECURSE libsimple_headers "include/*.hpp") +file(GLOB libsimple_sources "src/*.cpp") +add_library(libsimple + ${libsimple_sources} + ${libsimple_headers}) +target_link_libraries(libsimple libservice) +target_include_directories(libsimple PUBLIC include/) + +add_subdirectory(utils) diff --git a/utils/libsimple/README.md b/utils/libsimple/README.md new file mode 100644 index 0000000..1d9896a --- /dev/null +++ b/utils/libsimple/README.md @@ -0,0 +1,43 @@ +simple driver utilities +======================= + +[simple] driver usage examples. + +[simple]: ../../src/simple + +Usage +----- + +### exchange_ints.exe + +``` +Usage: exchange_ints.exe N +``` + +Parses its argument as an `unsigned int` and exchanges it with the one stored +in [simple] driver's memory. +For example: + +``` +> exchange_ints.exe 1 +42 +``` + +``` +> exchange_ints.exe 32 +1 +``` + +``` +> exchange_ints.exe 100500 +32 +``` + +See also +-------- + +* [Building the utilities] +* [License] + +[Building the utilities]: ../README.md#building-the-utilities +[License]: ../../README.md#license diff --git a/utils/libsimple/include/libsimple/all.hpp b/utils/libsimple/include/libsimple/all.hpp new file mode 100644 index 0000000..474b802 --- /dev/null +++ b/utils/libsimple/include/libsimple/all.hpp @@ -0,0 +1,8 @@ +// Copyright (c) 2015 Egor Tensin +// 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 "device.hpp" diff --git a/utils/libsimple/include/libsimple/device.hpp b/utils/libsimple/include/libsimple/device.hpp new file mode 100644 index 0000000..3318818 --- /dev/null +++ b/utils/libsimple/include/libsimple/device.hpp @@ -0,0 +1,19 @@ +// Copyright (c) 2015 Egor Tensin +// 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 "libservice/all.hpp" + +namespace libsimple +{ + class Device : libservice::Device + { + public: + Device(); + + unsigned int exchange_ints(unsigned int) const; + }; +} diff --git a/utils/libsimple/src/device.cpp b/utils/libsimple/src/device.cpp new file mode 100644 index 0000000..57e6963 --- /dev/null +++ b/utils/libsimple/src/device.cpp @@ -0,0 +1,37 @@ +// Copyright (c) 2015 Egor Tensin +// 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. + +#include "libsimple/all.hpp" + +#include "libservice/all.hpp" + +#include + +namespace libsimple +{ + namespace + { + const char* const device_path = "\\\\.\\simple_device1"; + const auto exchange_ints_ctl_code = CTL_CODE(0x8001, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS); + } + + Device::Device() + : libservice::Device(libservice::Device::open(device_path)) + { } + + unsigned int Device::exchange_ints(unsigned int src) const + { + unsigned int dest; + + send_control_code( + exchange_ints_ctl_code, + &src, + sizeof(src), + &dest, + sizeof(dest)); + + return dest; + } +} diff --git a/utils/libsimple/utils/CMakeLists.txt b/utils/libsimple/utils/CMakeLists.txt new file mode 100644 index 0000000..8824e3e --- /dev/null +++ b/utils/libsimple/utils/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(exchange_ints exchange_ints.cpp) +target_link_libraries(exchange_ints libsimple) diff --git a/utils/libsimple/utils/exchange_ints.cpp b/utils/libsimple/utils/exchange_ints.cpp new file mode 100644 index 0000000..2935b2f --- /dev/null +++ b/utils/libsimple/utils/exchange_ints.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2015 Egor Tensin +// 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. + +#include "libsimple/all.hpp" + +#include +#include +#include +#include + +namespace +{ + bool parse_int(unsigned int& dest, const std::string& src) + { + std::istringstream iss(src); + char c; + return iss >> dest && !iss.get(c); + } +} + +int main(int argc, char* argv[]) +{ + try + { + unsigned int src; + + if (argc != 2 || !parse_int(src, argv[1])) + { + std::cout << "Usage: " << argv[0] << " N\n"; + return 1; + } + + std::cout << libsimple::Device().exchange_ints(src) << "\n"; + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + + return 0; +} diff --git a/utils/libtest/CMakeLists.txt b/utils/libtest/CMakeLists.txt deleted file mode 100644 index 8c64ba1..0000000 --- a/utils/libtest/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -file(GLOB_RECURSE libtest_headers "include/*.hpp") -file(GLOB libtest_sources "src/*.cpp") -add_library(libtest - ${libtest_sources} - ${libtest_headers}) -target_link_libraries(libtest libservice) -target_include_directories(libtest PUBLIC include/) - -add_subdirectory(utils) diff --git a/utils/libtest/README.md b/utils/libtest/README.md deleted file mode 100644 index 0257c71..0000000 --- a/utils/libtest/README.md +++ /dev/null @@ -1,43 +0,0 @@ -test driver utilities -===================== - -[test] driver usage examples. - -[test]: ../../src/test - -Usage ------ - -### exchange_ints.exe - -``` -Usage: exchange_ints.exe N -``` - -Parses its argument as an `unsigned int` and exchanges it with the one stored -in [test] driver's memory. -For example: - -``` -> exchange_ints.exe 1 -42 -``` - -``` -> exchange_ints.exe 32 -1 -``` - -``` -> exchange_ints.exe 100500 -32 -``` - -See also --------- - -* [Building the utilities] -* [License] - -[Building the utilities]: ../README.md#building-the-utilities -[License]: ../../README.md#license diff --git a/utils/libtest/include/libtest/all.hpp b/utils/libtest/include/libtest/all.hpp deleted file mode 100644 index 474b802..0000000 --- a/utils/libtest/include/libtest/all.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// 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 "device.hpp" diff --git a/utils/libtest/include/libtest/device.hpp b/utils/libtest/include/libtest/device.hpp deleted file mode 100644 index 591d215..0000000 --- a/utils/libtest/include/libtest/device.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// 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 "libservice/all.hpp" - -namespace libtest -{ - class Device : libservice::Device - { - public: - Device(); - - unsigned int exchange_ints(unsigned int) const; - }; -} diff --git a/utils/libtest/src/device.cpp b/utils/libtest/src/device.cpp deleted file mode 100644 index f06a22a..0000000 --- a/utils/libtest/src/device.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// 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. - -#include "libtest/all.hpp" - -#include "libservice/all.hpp" - -#include - -namespace libtest -{ - namespace - { - const char* const device_path = "\\\\.\\test_device1"; - const auto exchange_ints_ctl_code = CTL_CODE(0x8001, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS); - } - - Device::Device() - : libservice::Device(libservice::Device::open(device_path)) - { } - - unsigned int Device::exchange_ints(unsigned int src) const - { - unsigned int dest; - - send_control_code( - exchange_ints_ctl_code, - &src, - sizeof(src), - &dest, - sizeof(dest)); - - return dest; - } -} diff --git a/utils/libtest/utils/CMakeLists.txt b/utils/libtest/utils/CMakeLists.txt deleted file mode 100644 index 9b22ab2..0000000 --- a/utils/libtest/utils/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(exchange_ints exchange_ints.cpp) -target_link_libraries(exchange_ints libtest) diff --git a/utils/libtest/utils/exchange_ints.cpp b/utils/libtest/utils/exchange_ints.cpp deleted file mode 100644 index f70badf..0000000 --- a/utils/libtest/utils/exchange_ints.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// 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. - -#include "libtest/all.hpp" - -#include -#include -#include -#include - -namespace -{ - bool parse_int(unsigned int& dest, const std::string& src) - { - std::istringstream iss(src); - char c; - return iss >> dest && !iss.get(c); - } -} - -int main(int argc, char* argv[]) -{ - try - { - unsigned int src; - - if (argc != 2 || !parse_int(src, argv[1])) - { - std::cout << "Usage: " << argv[0] << " N\n"; - return 1; - } - - std::cout << libtest::Device().exchange_ints(src) << "\n"; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } - - return 0; -} -- cgit v1.2.3