Windows-driver-samples | repo contains driver samples
kandi X-RAY | Windows-driver-samples Summary
kandi X-RAY | Windows-driver-samples Summary
These are the official Microsoft Windows Driver Kit (WDK) driver code samples for Windows 10. They provide a foundation for Universal Windows driver support of all hardware form factors, from phones to desktop PCs. Use these samples with Visual Studio 2019 and Windows Driver Kit (WDK) 10.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Windows-driver-samples
Windows-driver-samples Key Features
Windows-driver-samples Examples and Code Snippets
Community Discussions
Trending Discussions on Windows-driver-samples
QUESTION
Im trying to create trace log messages for this Idd Sample Driver. I am following this document.
I add WPP_INIT_TRACING(pDriverObject, pRegistryPath)
to the DriverEntry, and WPP_CLEANUP(pDriverObject)
to the EvtCleanupCallback.
ANSWER
Answered 2022-Feb-02 at 20:59Solved my problem. I wasnt actually installing my driver, since it was still installed from the first time I installed it, so it was always using that driver instead of my new one with WPP enabled. I was installing and uninstalling the driver with pnputil.
I was doing pnputil -d oem20.inf -f
for example to uninstall the driver. This is BAD. I have learned now that force deleting a driver does nothing. The reason I was force deleting was because it wouldnt delete when i still had a device, even though i would exit the sample app.
So what you have to do in order to properly delete the driver is enumerate the devices with pnputil, remove the ones that use your driver, then delete the driver. This allows a proper fresh driver installation.
QUESTION
I am trying to send a Raw Ethernet frame over layer 2, using the prottest.c example code for the NDIS driver, in C. The example works without problem, but when I modify the Ether Type (0x88A4 EtherCat) and adapt the frame with the necessary structure and information, the Writefile function always returns Error 87 (Incorrect parameters).
Is it not possible to write with this function on Layer 2, in Raw, without the TCP/IP stack, what could be wrong?
Thanks for your help. Best regards.
...ANSWER
Answered 2021-Jun-01 at 23:15For security, the driver refuses to send these types of packets by default.
Of course, since you have the source code to the driver, you are free to modify this restriction however you like — it's your driver. You can add a line to specifically allow the 0x88A4 EtherType, or delete the entire if-statement to allow all EtherTypes. You can require the usermode process to be running as Administrator if it wants to send "suspicious" network frames.
A bit more detail on the security angle. If you allow untrusted users/programs to place arbitrary data onto the network, that may compromise or weaken network security. This is why the sample driver (and Windows in general) does not allow arbitrary programs to put arbitrary data on the network.
For example, a malicious program that has unrestricted access to the Ethernet layer can advertise a malicious DHCP server that points clients to a malicious DNS server, conduct ARP poisoning attacks on your switch, DoS a switch (with, for example, 802.3x PAUSE frames, or with LLDPDUs that undermine the QoS policy), or circumvent any firewall policies you might have.
These potential attacks aren't necessarily a deal-breaker: consider that this is roughly the equivalent of allowing someone to plug an arbitrary unmanaged device into an Ethernet jack on your network. If your network already has measures in place to defend against hostile Ethernet endpoints, then removing restrictions from the sample driver not making things much worse. Alternatively, if you have some level of trust for all the users & code on the PCs that will run your driver, then modifying the driver won't matter. Or if your threat model already assumes the network is hostile and unreliable, then removing these restrictions will only help fulfill your threat model's expectations. ;)
QUESTION
I am writing a network driver for Windows. I want to do something like the pseudocode below:
...ANSWER
Answered 2020-Oct-08 at 13:45Found inspiration from a proprietary network driver code. This function turns interface on/off:
QUESTION
I am trying to open a device driver in order to send it an ioctl. There are many examples on SO and elsewhere but virtually all address opening "\\.\PhysicalDrive0" or the like. But I am trying to open a non-disk driver, compiled from Microsoft sample code at GitHub "Windows-driver-samples", namely "simgpio". It appears to have installed correctly but I don't know what "\\.\name" to use. I tried "\\.\simgpio" with no joy. Suggestions?
For reference, I've included the driver's .INF file below.
...ANSWER
Answered 2020-Jul-18 at 20:06Thanks to comment by @Eryk, I was able to open a driver. I include a sample program below. All error checking was omitted for clarity. I used the CDROM driver class in this example. The real challenge is finding the elusive GUID to use - you must do some deep digging in the SDK, DDK, include files or your driver.
QUESTION
I am currently experimenting with the NDIS driver samples. I am trying to print the packets contents (including the MAC-addresses, EtherType and the data).
My first guess was to implement this in the function FilterReceiveNetBufferLists
. Unfortunately I am not sure how to extract the packets contents out of the NetBufferLists
.
ANSWER
Answered 2020-Jul-23 at 04:03That's the right place to start. Consider this code:
QUESTION
I need to get file size in Windows kernel. I read the file into a buffer in kernel, while the code is as below. And I dig out a lot.
...ANSWER
Answered 2020-Jul-14 at 15:01GetFileSize is not a WDK function. Use ZwQueryInformationFile instead of GetFileSize.
Use the codes below
QUESTION
I'm trying to capture some syscalls using Etw in my driver, to be more precise I need capture NtWriteVirtualMemory and NtReadVirtualMemory usermode calls, i tried using the provider: Microsoft Windows Threat Intelligence, I used PerfView to dump the Threat Inteligence xml for Windows 10 1909 and used message compiler to compile the manifest(exactly what microsoft said to do) and checked Microsoft Etw sample code, but for some reason my callback is called only once(when EtwRegister is called in my DriverEntry), to register my callback i just called EtwRegister, what i should do for my callback be called? I'm using Microsoft sample code with a header file that was generated by mc.exe(message compiler)
...ANSWER
Answered 2020-Mar-12 at 17:35The sample you looked at is for an ETW Provider, not a consumer. I'm not sure there is a documented way to consume ETW events from kernel. You can check samples for consuming events from user mode: https://github.com/microsoft/Windows-driver-samples/tree/master/general/tracing/SystemTraceControl
Also note that Microsoft Windows Threat Intelligence ETW provider can only be consumed in Anti-Malware PPL type process. It requires having an Early Launch AntiMalware driver with a matching AntiMalware service. More info can be found at: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/early-launch-antimalware https://docs.microsoft.com/en-us/windows/win32/services/protecting-anti-malware-services-
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Windows-driver-samples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page