Created
March 13, 2020 05:29
-
-
Save KunYi/bbcde28639393fbe23426a78f58921b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <cfgmgr32.h> | |
int main() | |
{ | |
DEVINST devParentInst = 0; | |
DEVINST devInst = 0; | |
CONFIGRET status = 0; | |
const DEVINSTID_W PhantomDevNode = (DEVINSTID_W)L"ROOT\\TOASTER\\0000"; | |
const DEVINSTID_W ToasterBasicID = (DEVINSTID_W)L"TOASTER\\BASIC_TOASTER"; | |
const DEVINSTID_W ToasterSuperID = (DEVINSTID_W)L"TOASTER\\SUPER_TOASTER"; | |
// to get root node | |
status = CM_Locate_DevNode(&devParentInst, NULL, CM_LOCATE_DEVNODE_NORMAL); | |
if (status != CR_SUCCESS) | |
return -1; | |
// Create new Device node | |
status = CM_Create_DevNodeW(&devInst, PhantomDevNode, devParentInst, | |
CM_CREATE_DEVNODE_PHANTOM); | |
if (!(status == CR_SUCCESS || status == CR_ALREADY_SUCH_DEVNODE)) | |
return -2; | |
status = CM_Create_DevNodeW(&devInst, PhantomDevNode, devParentInst, | |
CM_CREATE_DEVNODE_NORMAL); | |
if (!(status == CR_SUCCESS || status == CR_ALREADY_SUCH_DEVNODE)) | |
return -3; | |
// append Hardware ID | |
CM_Add_IDW(devInst, (DEVINSTID_W)ToasterBasicID, CM_ADD_ID_HARDWARE); | |
CM_Add_IDW(devInst, (DEVINSTID_W)ToasterSuperID, CM_ADD_ID_HARDWARE); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment