TL;DR
目前遊走在Windows上開發程式,要能夠與Storage Device溝通,除了DeviceIoControl之外,應該就屬於SetupDiXXX classes functions。透過API能夠取得Device interface and device informations,如:Location information、Device Path等等諸如從電腦管理內針對裝置的property內容。
這一系列Functions前期因為接手前人程式碼,加上期初找尋相關資訊大部分都散亂且有看沒有懂,只知道怎麼用而已,重點應該是當時沒有足夠精確的關鍵字可以查找。偶然間這幾天因同事其他需求,便利用這個機會好好深入了解一番,瞬間打通DISK、USB、PCI等裝置的Informations retrieved。
我會放上所找到相關的資源,多半為MSDN文檔,不得不說新版本的內容滿淺顯易懂,且主題分類比較明確,針對微軟的轉型,但又得包容過去的API,實在是花了一番功夫,才得以消化幾成內容。具體內容可能無法解釋的很精確,附上連結還請有需要的人可以參考,我針對我所使用到的進行一些個人筆記的介紹。
此文原始程式碼已上傳到GitHub上,算是配合一起使用。
底層會有Kernel driver去偵測裝置,初始化後會向User mode進行註冊,並查找適合的Driver package進行安裝及初始化,到這邊都沒問題,PnP management就會接手後續動作,此時就可以順利啟用裝置。
詳細過程請參考此網址:How Windows Installs Devices
你可能會有興趣的關鍵字:PnP、INF
可以RUN後,就可以進入我們的主題,初探Device information set。分別是:
這篇講述整個Device information set的整體架構,並提及Create及Enum的方式貫穿這部分的應用。
In user mode, devices that belong to either device setup classes or device interface classes are managed by using device information elements and device information sets. A device information set consists of device information elements for all the devices that belong to some device setup class or device interface class.