Giter Club home page Giter Club logo

windows-rust-driver-samples's Issues

Installing the sample driver causes an error - invalid parameter for service or function

The error on the device:

Windows cannot initialize the device driver for this hardware. (Code 37)

An invalid parameter was passed to a service or function.

There is this event:

Device ROOT\SAMPLE\0000 had a problem starting.

Driver Name: oem24.inf
Class Guid: {78a1c341-4539-11d3-b88d-00c04fad5171}
Service: ECHO_2
Lower Filters: 
Upper Filters: 
Problem: 0x25
Problem Status: 0xC000000D

System:
-Windows 10 VM
-DriverCertificate has been installed on the machine
-Did all the steps - including driver signing.

Port OSR KMDF USB-FX2 sample.

The OSR USB-FX2 board is a standard learning device for driver developers getting their feet wet with KMDF and USB development. See more details on MSDN here: https://learn.microsoft.com/en-us/samples/microsoft/windows-driver-samples/sample-kmdf-function-driver-for-osr-usb-fx2/

The C source code can be viewed here: https://github.com/microsoft/Windows-driver-samples/tree/main/usb/kmdf_fx2

I will be porting this sample (within current capabilities) to Rust to explore the limitations and capabilities of our current infrastructure.

error: linking with `link.exe` failed: exit code: 1120

D:\code\rust\code\windows\Windows-rust-driver-samples\general\echo\kmdf\driver\DriverSync>cargo +nightly make
[cargo-make] INFO - cargo make 0.37.1
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: echo-2
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "cargo" "fmt"
[cargo-make] INFO - Skipping Task: format-toml-conditioned-flow
[cargo-make] INFO - Execute Command: "cargo" "build" "--all-features"
   Compiling proc-macro2 v1.0.67
   Compiling unicode-ident v1.0.12
   Compiling windows_x86_64_msvc v0.48.5
   Compiling winapi v0.3.9
   Compiling once_cell v1.18.0
   Compiling glob v0.3.1
   Compiling rustversion v1.0.14
   Compiling lazy_static v1.4.0
   Compiling libc v0.2.148
   Compiling rustix v0.38.13
   Compiling prettyplease v0.2.15
   Compiling clang-sys v1.6.1
   Compiling bitflags v2.4.0
   Compiling regex-syntax v0.7.5
   Compiling log v0.4.20
   Compiling windows-targets v0.48.5
   Compiling windows-sys v0.48.0
   Compiling memchr v2.6.3
   Compiling minimal-lexical v0.2.1
   Compiling serde v1.0.188
   Compiling quote v1.0.33
   Compiling syn v2.0.33
   Compiling nom v7.1.3
   Compiling thiserror v1.0.48
   Compiling bindgen v0.68.1
   Compiling libloading v0.7.4
   Compiling either v1.9.0
   Compiling serde_json v1.0.107
   Compiling wdk-build v0.1.0
   Compiling windows-core v0.51.1
   Compiling itoa v1.0.9
   Compiling regex-automata v0.3.8
   Compiling rustc-hash v1.1.0
   Compiling shlex v1.2.0
   Compiling errno v0.3.3
   Compiling home v0.5.5
   Compiling cexpr v0.6.0
   Compiling which v4.4.2
   Compiling lazycell v1.3.0
   Compiling ryu v1.0.15
   Compiling peeking_take_while v0.1.2
   Compiling windows v0.51.1
   Compiling cfg-if v1.0.0
   Compiling tracing-core v0.1.31
   Compiling overload v0.1.1
   Compiling thread_local v1.1.7
   Compiling regex v1.9.5
   Compiling tracing-log v0.1.3
   Compiling nu-ansi-term v0.46.0
   Compiling sharded-slab v0.1.4
   Compiling smallvec v1.11.0
   Compiling spin v0.5.2
   Compiling paste v1.0.14
   Compiling tracing-subscriber v0.3.17
   Compiling wdk-panic v0.1.0
   Compiling serde_derive v1.0.188
   Compiling thiserror-impl v1.0.48
   Compiling wdk-macros v0.1.0
   Compiling wdk-sys v0.1.0
   Compiling wdk v0.1.0
   Compiling echo-2 v0.1.0 (D:\code\rust\code\windows\Windows-rust-driver-samples\general\echo\kmdf\driver\DriverSync)
   Compiling wdk-alloc v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 3m 05s
[cargo-make] INFO - Execute Command: "cargo" "test" "--all-features"
   Compiling spin v0.5.2
   Compiling wdk-panic v0.1.0
   Compiling lazy_static v1.4.0
   Compiling wdk-sys v0.1.0
   Compiling wdk-alloc v0.1.0
   Compiling wdk v0.1.0
   Compiling echo-2 v0.1.0 (D:\code\rust\code\windows\Windows-rust-driver-samples\general\echo\kmdf\driver\DriverSync)
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustcmf3ZsW\\symbols.o" "D:\\code\\rust\\code\\windows\\Windows-rust-driver-samples\\target\\debug\\deps\\echo_2-dfe775342f36be9b.test-4e25e9a00f55b6b4.test.23704e6cc03fe591-cgu.0.rcgu.o.rcgu.o" "/LIBPATH:D:\\code\\rust\\code\\windows\\Windows-rust-driver-samples\\target\\debug\\deps" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22621.0\\km\\x64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\wdf\\kmdf\\x64\\1.33" "/LIBPATH:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-6856e76ba99f7e60.rlib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "BufferOverflowFastFailK.lib" "ntoskrnl.lib" "hal.lib" "wmilib.lib" "WdfLdr.lib" "WdfDriverEntry.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\code\\rust\\code\\windows\\Windows-rust-driver-samples\\target\\debug\\deps\\echo_2-dfe775342f36be9b.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Administrator\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/NXCOMPAT" "/DYNAMICBASE" "/MAP" "/MAPINFO:EXPORTS" "/OPT:REF,ICF" "/INTEGRITYCHECK" "/MANIFEST:NO" "/DRIVER" "/NODEFAULTLIB" "/SUBSYSTEM:NATIVE" "/KERNEL" "/ENTRY:FxDriverEntry"
  = note: msvcrt.lib(tlssup.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(std_type_info_static.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(delete_scalar_size.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(delete_scalar.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(gs_support.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(guard_support.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(gs_cookie.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          msvcrt.lib(loadcfg.obj) : warning LNK4257: 未对内核模式编译对象文件;映像可能不会运行
          echo_2-dfe775342f36be9b.test-4e25e9a00f55b6b4.test.23704e6cc03fe591-cgu.0.rcgu.o.rcgu.o : error LNK2019: 无法解析的外部符号 floor,函数 _ZN52_$LT$$u5b$f64$u5d$$u20$as$u20$test..stats..Stats$GT$9quartiles17h70ec751af0614305E 中引用了该符号
          echo_2-dfe775342f36be9b.test-4e25e9a00f55b6b4.test.23704e6cc03fe591-cgu.0.rcgu.o.rcgu.o : error LNK2019: 无法解析的外部符号 _CxxThrowException,函数 __rust_start_panic 中引用了该符号
          msvcrt.lib(delete_scalar.obj) : error LNK2019: 无法解析的外部符号 free,函数 "void __cdecl operator delete(void *)" (??3@YAXPEAX@Z) 中引用了该符号
          D:\code\rust\code\windows\Windows-rust-driver-samples\target\debug\deps\echo_2-dfe775342f36be9b.exe : fatal error LNK1120: 3 个无法解析的外部命令


error: could not compile `echo-2` (lib test) due to previous error
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

D:\code\rust\code\windows\Windows-rust-driver-samples\general\echo\kmdf\driver\DriverSync>

Issue with fresh "cargo make"

Hi!

I've tried to compile the example code on Windows 11 ARM, but it fails with the following error message:

As user:

**********************************************************************
** Enterprise Windows Driver Kit (WDK) build environment
** Version ni_release_svc_prod1.22621.2428
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.1.5
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
C:\Users\x\repos\Windows-rust-driver-samples>cargo make
[cargo-make] INFO - cargo make 0.37.10
[cargo-make] INFO - Execute Command: "rust-script" "target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: workspace
C:\Users\x\repos\Windows-rust-driver-samples
[cargo-make][1] INFO - Execute Command: "rust-script" "C:\\Users\\x\\repos\\Windows-rust-driver-samples\\target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make][1] INFO - Calling cargo metadata to extract project info
[cargo-make][1] INFO - Cargo metadata done
[cargo-make][1] INFO - Project: echoapp
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: default
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration
[cargo-make][1] INFO - Running Task: build
[cargo-make][1] INFO - Execute Command: "cargo" "build"
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
echoapp does not contain a package.metadata.wdk section in its manifest. Skipping package-driver task.
[cargo-make][1] INFO - Skipping Task: package-driver-flow
[cargo-make][1] INFO - Running Task: default
[cargo-make][1] INFO - Build Done in 1.14 seconds.
[cargo-make][1] INFO - Execute Command: "rust-script" "C:\\Users\\x\\repos\\Windows-rust-driver-samples\\target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make][1] INFO - Calling cargo metadata to extract project info
[cargo-make][1] INFO - Cargo metadata done
[cargo-make][1] INFO - Project: echo-2
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: default
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration
[cargo-make][1] INFO - Running Task: build
[cargo-make][1] INFO - Execute Command: "cargo" "build"
   Compiling wdk-sys v0.2.0
memory allocation of 26306674688 bytes failed132: wdk-sys(build)
[cargo-make][1] ERROR - Error while executing command, exit code: -1073740791
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 8 - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.

I guessed that A required privilege is not held by the client. may mean that administrator rights are needed, to I re-ran it in an admin prompt.

As admin user:

**********************************************************************
** Enterprise Windows Driver Kit (WDK) build environment
** Version ni_release_svc_prod1.22621.2428
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.1.5
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************

C:\Users\x\repos\Windows-rust-driver-samples>cargo make
[cargo-make] INFO - cargo make 0.37.10
[cargo-make] INFO - Execute Command: "rust-script" "target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: workspace
C:\Users\x\repos\Windows-rust-driver-samples
[cargo-make][1] INFO - Execute Command: "rust-script" "C:\\Users\\x\\repos\\Windows-rust-driver-samples\\target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make][1] INFO - Calling cargo metadata to extract project info
[cargo-make][1] INFO - Cargo metadata done
[cargo-make][1] INFO - Project: echoapp
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: default
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration
[cargo-make][1] INFO - Running Task: build
[cargo-make][1] INFO - Execute Command: "cargo" "build"
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling windows_aarch64_msvc v0.52.0
   Compiling once_cell v1.19.0
   Compiling windows-targets v0.52.0
   Compiling windows-sys v0.52.0
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling uuid-macro-internal v1.7.0
   Compiling uuid v1.7.0
   Compiling echoapp v0.1.0 (C:\Users\x\repos\Windows-rust-driver-samples\general\echo\kmdf\exe)
    Finished dev [unoptimized + debuginfo] target(s) in 5.53s
echoapp does not contain a package.metadata.wdk section in its manifest. Skipping package-driver task.
[cargo-make][1] INFO - Skipping Task: package-driver-flow
[cargo-make][1] INFO - Running Task: default
[cargo-make][1] INFO - Build Done in 6.56 seconds.
[cargo-make][1] INFO - Execute Command: "rust-script" "C:\\Users\\x\\repos\\Windows-rust-driver-samples\\target\\_cargo_make_temp\\persisted_scripts\\D4060E7434B3779E78A683E8BA00D06A5D08BE8C95BC432359E22F06CB30EF1C.rs"
[cargo-make][1] INFO - Calling cargo metadata to extract project info
[cargo-make][1] INFO - Cargo metadata done
[cargo-make][1] INFO - Project: echo-2
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: default
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration
[cargo-make][1] INFO - Running Task: build
[cargo-make][1] INFO - Execute Command: "cargo" "build"
   Compiling proc-macro2 v1.0.78
   Compiling windows_aarch64_msvc v0.48.5
   Compiling windows_aarch64_msvc v0.52.0
   Compiling once_cell v1.19.0
   Compiling windows-targets v0.52.0
   Compiling windows-sys v0.52.0
   Compiling serde v1.0.196
   Compiling anstyle v1.0.6
...
   Compiling wdk-panic v0.2.0
   Compiling wdk v0.2.0
   Compiling echo-2 v0.1.0 (C:\Users\x\repos\Windows-rust-driver-samples\general\echo\kmdf\driver\DriverSync)
   Compiling wdk-sys v0.2.0
memory allocation of 26306674688 bytes failed132: wdk-sys(build)
[cargo-make][1] ERROR - Error while executing command, exit code: -1073740791
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 8 - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.

Any ideas what went wrong?

error

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.7.4
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files\Microsoft Visual Studio\2022\Enterprise>cd /d D:\code\rust\code\windows\Windows-rust-driver-samples

D:\code\rust\code\windows\Windows-rust-driver-samples>cargo build
   Compiling wdk-sys v0.1.0
error: failed to run custom build command for `wdk-sys v0.1.0`

Caused by:
  process didn't exit successfully: `D:\code\rust\code\windows\Windows-rust-driver-samples\target\debug\build\wdk-sys-109708047c4dbb69\build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'WDKContentRoot should be able to be detected. Ensure that the WDK is installed, or that the environment setup scripts in the eWDK have been run.', C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wdk-build-0.1.0\src\lib.rs:111:64
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

D:\code\rust\code\windows\Windows-rust-driver-samples>

Digital Signature Problem

Hello

Everything seems to compile up just fine on my Windows 10 (x64) system but seem to run into a problem in Step 8 for "Install the Driver from the Admin Prompt"

D:\Win-rust-driver-samples\test\target\debug>pnputil.exe /add-driver echo_2.inf /install

Microsoft PnP Utility

Adding driver package:  echo_2.inf
Failed to add driver package: The third-party INF does not contain digital signature information.

Total driver packages:  1
Added driver packages:  0

It fails to add the driver with the as the INF does not contain digital signature information.

How to correct this?

Thanks as I think that everything is very close to working, now.

driver not loaded

Running a recent VM Ware Windows 11 VM to test the driver. Also using up-to-date SDKs.
I can build the driver and the sample application. I repeated all the steps mentioned in the repo. Yet, the driver doesn't seem to get loaded after installing it (which also installs it without any errors). What am I missing here? Since I am new to driver development, what else can I do to debug what's going on? Besides output from the installation and device creation stuff.

pnputil

PS C:\Users\guy\Desktop\New folder> pnputil.exe /add-driver .\echo_2.inf /install
Microsoft PnP Utility

Adding driver package:  echo_2.inf
Driver package added successfully.
Published Name:         oem8.inf
Driver package installed on device: SWD\DEVGEN\{5a3f9cb9-29c5-4349-badd-48ba5a0c1477}

Total driver packages:  1
Added driver packages:  1

devgen

PS C:\Users\guy\Desktop> .\devgen.exe /add /hardwareid "root\ECHO_2"
Microsoft Device Generator

Device successfully created. Device Instance ID: SWD\DEVGEN\{5a3f9cb9-29c5-4349-badd-48ba5a0c1477}

The test app only returns:

Error: "Error: No active device interfaces found.  Is the sample driver loaded?"

And yes i tried turning my pc off and on again multiple times :D

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.