我已经为本地内核调试设置了我的系统,因为我只打算编写一个具有两个函数的简单驱动程序。我刚刚构建了一个简单的“hello world”类型的驱动程序,看看我是否能让我的驱动程序运行,目前我已经禁用了驱动程序签名验证并启用了内核 Debug模式,使用:
bcdedit /debug on
我还使用 Windows 测试商店的证书对我的驱动程序进行了测试签名?或者在 VS2015 中叫什么 :)
现在,我的问题是我在构建后通过右键单击 .inf 文件来安装我的驱动程序,但是我在我的驱动程序(下面的代码)中没有看到任何调试打印的输出,所以这让我相信我的驱动程序根本没有运行?或者是什么 ?
我在安装驱动程序的机器上更改了Component Filter Mask的值以进行调试。
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter = 0xFFFFFFFF
所以,我不知道是什么导致我的驱动程序不运行/不输出任何东西。
驱动代码:
#include <ntddk.h>
#include <wdf.h>
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfHelloWorldEvtDeviceAdd;
void WinPrint(const char *message) {
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, message));
}
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
WDF_DRIVER_CONFIG config;
WinPrint("KmdfHelloWorld: DriverEntry\n");
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "DriverEntry called!"));
KdPrintEx((DPFLTR_IHVDRIVER_ID, 0xFFFFFFFF, "DriverEntry called!"));
WinPrint("DriverEntry called!");
WDF_DRIVER_CONFIG_INIT(&config, KmdfHelloWorldEvtDeviceAdd);
status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
return status;
}
NTSTATUS KmdfHelloWorldEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
{
NTSTATUS status;
WDFDEVICE hDevice;
UNREFERENCED_PARAMETER(Driver);
WinPrint("KmdfHelloWorld: KmdfHelloWorldEvtDeviceAdd\n");
WinPrint("Unloading driver!");
status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);
return status;
}
我尝试从驱动程序创建和运行服务,我在提升的命令提示符下使用了以下命令,但我遇到了一些问题,我认为这不是运行内核驱动程序的正确方法(我不知道如何运行一个 :S)。
sc create poschamonitorv2 binPath="C:\x64\debug\poschamonitorv2.sys" DisplayName= "Poscha Monitor"
sc start poschamonitorv2
但这只会导致以下错误
ERROR_CHILD_NOT_COMPLETE
129 (0x81)
The %1 application cannot be run in Win32 mode.
所以我还是没弄明白:/哦,下面是 .INF 文件,它只是从 VS 自动生成的,我做了一些小改动。
;
; PoschaMonitorV2.inf
;
[Version]
Signature="$WINDOWS NT$"
Class=Sample ; TODO: edit Class
ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171} ; TODO: edit ClassGuid
Provider=%ManufacturerName%
CatalogFile=PoschaMonitorV2.cat
DriverVer= ; TODO: set DriverVer in stampinf property pages
[DestinationDirs]
DefaultDestDir = 12
; ================= Class section =====================
[ClassInstall32]
Addreg=SampleClassReg
[SampleClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-5
[SourceDisksNames]
1 = %DiskName%,,,""
[SourceDisksFiles]
PoschaMonitorV2.sys = 1,,
;*****************************************
; Install Section
;*****************************************
[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$
[Standard.NT$ARCH$]
%PoschaMonitorV2.DeviceDesc%=PoschaMonitorV2_Device, Root\PoschaMonitorV2 ; TODO: edit hw-id
[PoschaMonitorV2_Device.NT]
CopyFiles=Drivers_Dir
[Drivers_Dir]
PoschaMonitorV2.sys
;-------------- Service installation
[PoschaMonitorV2_Device.NT.Services]
AddService = PoschaMonitorV2,%SPSVCINST_ASSOCSERVICE%, PoschaMonitorV2_Service_Inst
; -------------- PoschaMonitorV2 driver install sections
[PoschaMonitorV2_Service_Inst]
DisplayName = %PoschaMonitorV2.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_AUTO_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\PoschaMonitorV2.sys
;
;--- PoschaMonitorV2_Device Coinstaller installation ------
;
[DestinationDirs]
PoschaMonitorV2_Device_CoInstaller_CopyFiles = 11
[PoschaMonitorV2_Device.NT.CoInstallers]
AddReg=PoschaMonitorV2_Device_CoInstaller_AddReg
CopyFiles=PoschaMonitorV2_Device_CoInstaller_CopyFiles
[PoschaMonitorV2_Device_CoInstaller_AddReg]
HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"
[PoschaMonitorV2_Device_CoInstaller_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll
[SourceDisksFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames
[PoschaMonitorV2_Device.NT.Wdf]
KmdfService = PoschaMonitorV2, PoschaMonitorV2_wdfsect
[PoschaMonitorV2_wdfsect]
KmdfLibraryVersion = $KMDFVERSION$
[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName="<Your manufacturer name>" ;TODO: Replace with your manufacturer name
ClassName="Samples" ; TODO: edit ClassName
DiskName = "PoschaMonitorV2 Installation Disk"
PoschaMonitorV2.DeviceDesc = "PoschaMonitorV2 Device"
PoschaMonitorV2.SVCDESC = "PoschaMonitorV2 Service"
最佳答案
经过几个小时的纠缠,我终于解决了这个问题,问题是我没有在我的项目设置中为“KMDF Version Minor”和“KMDF Version Major”设置值。你可以在这里阅读更多相关信息:
https://msdn.microsoft.com/en-us/library/windows/hardware/hh825931(v=vs.85).aspx
希望有一天其他人会发现这个有用:)
关于c - 如何运行 KMDF 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32670819/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/