惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
IT之家
IT之家
Cyberwarzone
Cyberwarzone
T
Troy Hunt's Blog
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 叶小钗
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
The Hacker News
The Hacker News
Jina AI
Jina AI
T
Tor Project blog
V
Vulnerabilities – Threatpost
酷 壳 – CoolShell
酷 壳 – CoolShell
Spread Privacy
Spread Privacy
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Simon Willison's Weblog
Simon Willison's Weblog
Security Latest
Security Latest
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
I
Intezer
The Cloudflare Blog
Cisco Talos Blog
Cisco Talos Blog
SecWiki News
SecWiki News
博客园 - 【当耐特】
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
Lohrmann on Cybersecurity
Scott Helme
Scott Helme
Google Online Security Blog
Google Online Security Blog
量子位
The Last Watchdog
The Last Watchdog
AI
AI
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security Affairs
P
Palo Alto Networks Blog
S
Secure Thoughts
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Attack and Defense Labs
Attack and Defense Labs

博客园 - catlog

曲终人不散 在Windows2000/XP的安全模式下,替换Gina 如何再Win2000/XP下,加入自己的认证? 是走的时候了 VC++ FAQ--VC和MFC的未来,还有Whidbey 明华的EKey 头晕,出个题目考考你 - catlog - 博客园 基于pkcs11的MS CSP的OpenSource实现 生活就是混下去。 用 WB Editor 连接 博客园 的全攻略 取得当前用户的权限(privileges) 一首词 如何用IPHelp取得网卡的详细信息 令人吃惊的完成端口Copy速度! 如何订阅OSR的新闻组? 1:0中国胜科威特 win98下如何控制登陆? 故土难离 Windows 2000的引导过程
如何在Win2000/xp下禁止某些硬件?比如说网卡,CD-ROM..
catlog · 2004-03-12 · via 博客园 - catlog

在NT的基础上,MS在NT4.0后的操作系统里都提供了很多以SetupDiXXXXX开头的函数,

就是大家经常所说的 SetupAPI.现在举一些简单的例子来说明这些情况:

1,首先我们要访问系统的硬件库,用API SetupDiGetClassDevs,在DDK的文档中,函数的原型如下:

HDEVINFO SetupDiGetClassDevs( IN LPGUID ClassGuid,OPTIONAL IN PCTSTR Enumerator,OPTIONAL IN HWND hwndParent,OPTIONAL IN DWORD Flags );

成功后我们可以得到一个HANDLE,指向DECINFO。Enumerator我们可以指定特定的设备类型,如“USB”,"PCI"等

2,然后利用HDEVINFO hDev 遍历所有的硬件,API原型如下:

WINSETUPAPI BOOL WINAPI SetupDiEnumDeviceInfo( INHDEVINFO DeviceInfoSet,IN DWORD MemberIndex, OUTPSP_DEVINFO_DATA DeviceInfoData );

在遍历过程中,我们可以用SetupDiGetDeviceRegistryProperty 得到硬件的属性值,如名称,GUID等,可以参考

/ Device registry property codes
// (Codes marked as read-only (R) may only be used for
// SetupDiGetDeviceRegistryProperty)
//
// These values should cover the same set of registry properties
// as defined by the CM_DRP codes in cfgmgr32.h.
//
#define SPDRP_DEVICEDESC (0x00000000) // DeviceDesc (R/W)
#define SPDRP_HARDWAREID (0x00000001) // HardwareID (R/W)
#define SPDRP_COMPATIBLEIDS (0x00000002) // CompatibleIDs (R/W)
#define SPDRP_NTDEVICEPATHS (0x00000003) // Unsupported, DO NOT USE
#define SPDRP_SERVICE (0x00000004) // Service (R/W)
#define SPDRP_CONFIGURATION (0x00000005) // Configuration (R)
#define SPDRP_CONFIGURATIONVECTOR (0x00000006) // ConfigurationVector (R)
#define SPDRP_CLASS (0x00000007) // Class (R--tied to ClassGUID)
#define SPDRP_CLASSGUID (0x00000008) // ClassGUID (R/W)
#define SPDRP_DRIVER (0x00000009) // Driver (R/W)
#define SPDRP_CONFIGFLAGS (0x0000000A) // ConfigFlags (R/W)
#define SPDRP_MFG (0x0000000B) // Mfg (R/W)
#define SPDRP_FRIENDLYNAME (0x0000000C) // FriendlyName (R/W)
#define SPDRP_LOCATION_INFORMATION (0x0000000D) // LocationInformation (R/W)
#define SPDRP_PHYSICAL_DEVICE_OBJECT_NAME (0x0000000E) // PhysicalDeviceObjectName (R)
#define SPDRP_CAPABILITIES (0x0000000F) // Capabilities (R)
#define SPDRP_UI_NUMBER (0x00000010) // UiNumber (R)
#define SPDRP_UPPERFILTERS (0x00000011) // UpperFilters (R/W)
#define SPDRP_LOWERFILTERS (0x00000012) // LowerFilters (R/W)
#define SPDRP_MAXIMUM_PROPERTY (0x00000013) // Upper bound on ordinals
也可以在过虑特定的设备如 SPDRP_DEVTYPE = NET。CDROM等。

3。现在我们可以禁止或启用特定的设备了。相关API

SetupDiSetClassInstallParams

SetupDiCallClassInstaller

至此,我们已经做到我们想要的,

程序在VC6,SP5,WinDDK2462 ,Win2000下调试通过。