windows-virtual-devices 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 49c2e50115117734e671b3ffbcc4e6cea74d686ae8bef707d08b123647f58b94
4
+ data.tar.gz: bf1c6b5b02008bd3d9c44c9a433184b3f30d1c7d38d3be04b6c3b60149d5b6c6
5
+ SHA512:
6
+ metadata.gz: 70bf89b8a89f41cee28bece09dc33e775efe014c1e9ee2322943057832d280e6ac77ce0353511c7dfc7090544657f9db0b1f80a44dfa4c60a69fa855efacf79c
7
+ data.tar.gz: c09275cc63dbbe8c3cd3a0c65f20b31c80c46f160889415f17e12e8287b1146b4fe01d560ccdde6c6ed5c4a2c0f71f3bb4799beb69e2745f7a8e7cab886ea014
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TitanCSA
4
+
5
+ This license applies to the user-mode source code, examples, build scripts,
6
+ and documentation in this repository.
7
+ It does not apply to the prebuilt kernel
8
+ driver, driver catalogs, or INF files under Installer/UI/Package; those files are
9
+ covered by licenses/BINARY-LICENSE.txt. Third-party names and projects retain their own
10
+ licenses and trademarks.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Windows-Virtual-Devices Ruby SDK
2
+
3
+ `gem install windows-virtual-devices`
4
+
5
+ Windows x64 Ruby3.1+.
6
+
7
+ ```ruby
8
+ require "windows_virtual_devices"
9
+ WindowsVirtualDevicesSDK::Client.open { |client| p client.call("status") }
10
+ ```
11
+
12
+ [API and operation schema](docs/API.md). Matching driver installed separately.
data/docs/API.md ADDED
@@ -0,0 +1,16 @@
1
+ # Device operations
2
+
3
+ All operations take an argument object; absent arguments mean `{}`.
4
+
5
+ - `check` and `connect`: `{speed:2,input_depth:32,delegate_controls:false,descriptors:[{kind:1,index:0,language:0,interface_number:0,data:[...]}],rules:[{setup:[8 bytes],mask:[8 bytes],action:1,data:[]}]}`. Exact descriptors define USB identity; check validates offline. Connect returns opaque decimal `handle`, actual decimal `device_id`, and token.
6
+ - `status`: returns capabilities, licensing and devices/counters. All uint64 values use decimal strings.
7
+ - `send`: `{handle,endpoint:129,data:[0,1,255]}` uses the explicit native endpoint overload.
8
+ - `disconnect`: `{handle}`. Close also disconnects owned devices.
9
+ - `receive`: `{timeout:0}`; bounded 0..100 ms per call so close cannot wait indefinitely. Poll from a worker if necessary. Returns kind, endpoint, setup, data, IDs and timed_out. Control outputs include opaque reply_handle.
10
+ - `reply`: `{reply_handle,data:[],stall:false}`. Failed replies may be retried; successful handles become stale. Maximum 4096 outstanding control requests.
11
+
12
+ JSON requests are bounded to 1 MiB, byte arrays to4096, descriptors64, rules32, devices16. Original SDK applies additional semantic validation. Unknown/stale/foreign handles fail. Operations are serialized; concurrent operations return busy. Input capture/driver operations are performed only on explicit calls. Production tests only open/close and reject an invalid config offline. Synthetic tests cover the rest without real devices.
13
+
14
+ ## Language client
15
+
16
+ The client calls the native SDK directly. Use the call method with an operation name and argument object. Receive is synchronous and bounded to100ms; use an application worker for responsive UI/event loops. Explicitly close the client after use. 64-bit identifiers and counters are decimal strings. Native errors expose their Windows code. Matching driver and licensing are separate requirements.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2025 Niels Lohmann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ require 'json'
2
+ require 'fiddle'
3
+ require 'thread'
4
+ module WindowsVirtualDevicesSDK
5
+ class NativeError < StandardError
6
+ attr_reader :code
7
+ def initialize(code,message);@code=code;super(message);end
8
+ end
9
+ class Client
10
+ def self.open(library_path: nil)
11
+ client=new(library_path: library_path)
12
+ return client unless block_given?
13
+ begin;yield client;ensure;client.close;end
14
+ end
15
+ def initialize(library_path: nil)
16
+ raise 'Windows x64 required' unless Fiddle::SIZEOF_VOIDP==8 && RUBY_PLATFORM.match?(/mingw|mswin/)
17
+ @library=Fiddle::Handle.new(library_path || ENV['WINDOWS_VIRTUAL_DEVICES_SDK_NATIVE_PATH'] || File.expand_path('../native/WindowsVirtualDevicesJsonSDK.dll',__dir__))
18
+ @mutex=Mutex.new
19
+ @open=Fiddle::Function.new(@library['windows_virtual_devices_json_open'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_INT)
20
+ @close=Fiddle::Function.new(@library['windows_virtual_devices_json_close'],[Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_INT)
21
+ @call=Fiddle::Function.new(@library['windows_virtual_devices_json_call'],[Fiddle::TYPE_LONG_LONG,Fiddle::TYPE_VOIDP,Fiddle::TYPE_INT],Fiddle::TYPE_VOIDP)
22
+ @free=Fiddle::Function.new(@library['windows_virtual_devices_json_free'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_VOID)
23
+ out=Fiddle::Pointer.malloc(8,Fiddle::RUBY_FREE);out[0,8]=[0].pack('Q<');code=@open.call(out);raise NativeError.new(code,'Cannot open SDK') if code!=0
24
+ @session=out[0,8].unpack1('Q<')
25
+ end
26
+ def call(operation,arguments={})
27
+ payload=JSON.generate({operation:operation,arguments:arguments}).encode('UTF-8')
28
+ raise ArgumentError,'Request exceeds 1 MiB' if payload.bytesize>1024*1024
29
+ @mutex.synchronize do
30
+ raise 'SDK is closed' if @session==0
31
+ pointer=@call.call(@session,payload,payload.bytesize);raise NoMemoryError,'Native response allocation failed' if pointer.null?
32
+ begin;response=JSON.parse(pointer.to_s);ensure;@free.call(pointer);end
33
+ raise NativeError.new(response['code'],response['message']) unless response['ok']
34
+ response['result']
35
+ end
36
+ end
37
+ def close
38
+ @mutex.synchronize do
39
+ if @session!=0
40
+ code=@close.call(@session);raise NativeError.new(code,'Native close failed') if code!=0
41
+ @session=0
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: windows-virtual-devices
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - TitanCSA
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: fiddle
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.1'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '1.1'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '2'
32
+ description: Product native SDK operations through a UTF-8 JSON C ABI; driver installed
33
+ separately.
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - LICENSE
39
+ - README.md
40
+ - docs/API.md
41
+ - docs/LICENSE.nlohmann-json
42
+ - lib/windows_virtual_devices.rb
43
+ - native/WindowsVirtualDevicesJsonSDK.dll
44
+ homepage: https://github.com/titanfyre/Windows-Virtual-Devices
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ source_code_uri: https://github.com/titanfyre/Windows-Virtual-Devices
49
+ documentation_uri: https://github.com/titanfyre/Windows-Virtual-Devices/tree/main/Windows-Virtual-Devices-Ruby-rubygems/docs
50
+ allowed_push_host: https://rubygems.org
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '3.1'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 4.0.20
66
+ specification_version: 4
67
+ summary: Windows x64 Windows-Virtual-Devices direct SDK
68
+ test_files: []