aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/um/wrappers
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-15 14:05:29 +0200
committerEgor Tensin <egor@tensin.name>2026-06-15 14:12:29 +0200
commitb3eef140da853414776c8e03a70629a613a25ed0 (patch)
treedcdb314d2fdd92f501c09f3ae5681a731cb00dee /um/wrappers
parentwdk10: disable the packaging target (diff)
downloadwindows7-drivers-b3eef140da853414776c8e03a70629a613a25ed0.tar.gz
windows7-drivers-b3eef140da853414776c8e03a70629a613a25ed0.zip
workflows/ci: add clang-format job
Diffstat (limited to 'um/wrappers')
-rw-r--r--um/wrappers/nt_namespace/include/nt_namespace/device.hpp18
-rw-r--r--um/wrappers/nt_namespace/src/device.cpp52
-rw-r--r--um/wrappers/nt_namespace/utils/convert_nt_path.cpp10
-rw-r--r--um/wrappers/simple/include/simple/device.hpp18
-rw-r--r--um/wrappers/simple/src/device.cpp49
-rw-r--r--um/wrappers/simple/utils/exchange_ints.cpp29
6 files changed, 82 insertions, 94 deletions
diff --git a/um/wrappers/nt_namespace/include/nt_namespace/device.hpp b/um/wrappers/nt_namespace/include/nt_namespace/device.hpp
index a3d725c..3856f2e 100644
--- a/um/wrappers/nt_namespace/include/nt_namespace/device.hpp
+++ b/um/wrappers/nt_namespace/include/nt_namespace/device.hpp
@@ -9,13 +9,13 @@
#include <string>
-namespace nt_namespace
-{
- class Device : service::Device
- {
- public:
- Device();
+namespace nt_namespace {
- std::wstring convert_nt_path(const std::wstring&);
- };
-}
+class Device : service::Device {
+public:
+ Device();
+
+ std::wstring convert_nt_path(const std::wstring&);
+};
+
+} // namespace nt_namespace
diff --git a/um/wrappers/nt_namespace/src/device.cpp b/um/wrappers/nt_namespace/src/device.cpp
index 4f9021b..4e1d7b0 100644
--- a/um/wrappers/nt_namespace/src/device.cpp
+++ b/um/wrappers/nt_namespace/src/device.cpp
@@ -12,39 +12,35 @@
#include <string>
#include <vector>
-namespace nt_namespace
-{
- namespace
- {
- const auto device_path = "\\\\.\\nt_namespace";
- const auto control_code = CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS);
- }
+namespace nt_namespace {
+namespace {
- Device::Device()
- : service::Device(service::Device::open(device_path))
- { }
+const auto device_path = "\\\\.\\nt_namespace";
+const auto control_code = CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS);
- std::wstring Device::convert_nt_path(const std::wstring& src)
- {
- const auto in_buf = src.c_str();
- const auto in_buf_size = (src.size() + 1) * sizeof(wchar_t);
+} // namespace
- static_assert(sizeof(control_code) == sizeof(service::Device::Code), "CTL_CODE() must return DWORDs");
+Device::Device() : service::Device(service::Device::open(device_path)) {}
- const auto nbreq = get_required_output_size(
- static_cast<service::Device::Code>(control_code),
- in_buf,
- in_buf_size);
+std::wstring Device::convert_nt_path(const std::wstring& src) {
+ const auto in_buf = src.c_str();
+ const auto in_buf_size = (src.size() + 1) * sizeof(wchar_t);
- std::vector<unsigned char> output(nbreq);
+ static_assert(
+ sizeof(control_code) == sizeof(service::Device::Code), "CTL_CODE() must return DWORDs"
+ );
- send_control_code(
- static_cast<service::Device::Code>(control_code),
- in_buf,
- in_buf_size,
- output.data(),
- nbreq);
+ const auto nbreq = get_required_output_size(
+ static_cast<service::Device::Code>(control_code), in_buf, in_buf_size
+ );
- return reinterpret_cast<wchar_t*>(output.data());
- }
+ std::vector<unsigned char> output(nbreq);
+
+ send_control_code(
+ static_cast<service::Device::Code>(control_code), in_buf, in_buf_size, output.data(), nbreq
+ );
+
+ return reinterpret_cast<wchar_t*>(output.data());
}
+
+} // namespace nt_namespace
diff --git a/um/wrappers/nt_namespace/utils/convert_nt_path.cpp b/um/wrappers/nt_namespace/utils/convert_nt_path.cpp
index ec215dc..b4500ee 100644
--- a/um/wrappers/nt_namespace/utils/convert_nt_path.cpp
+++ b/um/wrappers/nt_namespace/utils/convert_nt_path.cpp
@@ -8,16 +8,12 @@
#include <exception>
#include <iostream>
-int wmain(int argc, wchar_t* argv[])
-{
- try
- {
+int wmain(int argc, wchar_t* argv[]) {
+ try {
nt_namespace::Device dev;
for (int i = 1; i < argc; ++i)
std::wcout << dev.convert_nt_path(argv[i]) << L"\n";
- }
- catch (const std::exception& e)
- {
+ } catch (const std::exception& e) {
std::cerr << e.what() << "\n";
return 1;
}
diff --git a/um/wrappers/simple/include/simple/device.hpp b/um/wrappers/simple/include/simple/device.hpp
index acbda76..5d18516 100644
--- a/um/wrappers/simple/include/simple/device.hpp
+++ b/um/wrappers/simple/include/simple/device.hpp
@@ -7,13 +7,13 @@
#include "service/all.hpp"
-namespace simple
-{
- class Device : service::Device
- {
- public:
- Device();
+namespace simple {
- unsigned int exchange_ints(unsigned int) const;
- };
-}
+class Device : service::Device {
+public:
+ Device();
+
+ unsigned int exchange_ints(unsigned int) const;
+};
+
+} // namespace simple
diff --git a/um/wrappers/simple/src/device.cpp b/um/wrappers/simple/src/device.cpp
index d1a0d42..1388c55 100644
--- a/um/wrappers/simple/src/device.cpp
+++ b/um/wrappers/simple/src/device.cpp
@@ -3,37 +3,38 @@
// For details, see https://github.com/egor-tensin/windows7-drivers.
// Distributed under the MIT License.
-#include "simple/all.hpp"
-
#include "service/all.hpp"
+#include "simple/all.hpp"
#include <Windows.h>
-namespace simple
-{
- namespace
- {
- const auto device_path = "\\\\.\\simple_device1";
- const auto exchange_ints_ctl_code = CTL_CODE(0x8001, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS);
- }
+namespace simple {
+namespace {
- Device::Device()
- : service::Device(service::Device::open(device_path))
- { }
+const auto device_path = "\\\\.\\simple_device1";
+const auto exchange_ints_ctl_code = CTL_CODE(0x8001, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS);
- unsigned int Device::exchange_ints(unsigned int src) const
- {
- static_assert(sizeof(exchange_ints_ctl_code) == sizeof(service::Device::Code), "CTL_CODE() must produce DWORDs");
+} // namespace
- unsigned int dest;
+Device::Device() : service::Device(service::Device::open(device_path)) {}
- send_control_code(
- static_cast<service::Device::Code>(exchange_ints_ctl_code),
- &src,
- sizeof(src),
- &dest,
- sizeof(dest));
+unsigned int Device::exchange_ints(unsigned int src) const {
+ static_assert(
+ sizeof(exchange_ints_ctl_code) == sizeof(service::Device::Code),
+ "CTL_CODE() must produce DWORDs"
+ );
- return dest;
- }
+ unsigned int dest;
+
+ send_control_code(
+ static_cast<service::Device::Code>(exchange_ints_ctl_code),
+ &src,
+ sizeof(src),
+ &dest,
+ sizeof(dest)
+ );
+
+ return dest;
}
+
+} // namespace simple
diff --git a/um/wrappers/simple/utils/exchange_ints.cpp b/um/wrappers/simple/utils/exchange_ints.cpp
index cf8d70c..59f8dab 100644
--- a/um/wrappers/simple/utils/exchange_ints.cpp
+++ b/um/wrappers/simple/utils/exchange_ints.cpp
@@ -10,32 +10,27 @@
#include <sstream>
#include <string>
-namespace
-{
- bool parse_int(unsigned int& dest, const std::string& src)
- {
- std::istringstream iss(src);
- char c;
- return iss >> dest && !iss.get(c);
- }
+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
- {
+} // namespace
+
+int main(int argc, char* argv[]) {
+ try {
unsigned int src = 0;
- if (argc != 2 || !parse_int(src, argv[1]))
- {
+ if (argc != 2 || !parse_int(src, argv[1])) {
std::cout << "Usage: " << argv[0] << " N\n";
return 1;
}
std::cout << simple::Device().exchange_ints(src) << "\n";
- }
- catch (const std::exception& e)
- {
+ } catch (const std::exception& e) {
std::cerr << e.what() << "\n";
return 1;
}