2012-10-08 2 views
0

커널 드라이버 (.sys)가 있는데이 드라이버를 설치하고 제어하는 ​​데 사용할 수있는 좋은 소스가 있습니까?좋은 C++ 드라이버 설치 및 제어 코드

+0

어떤 시스템을 말하고 있습니까? 어쨌든이 사이트는 실제로 소스 코드를 작성하고 기존 코드를 찾는 것이 아닙니다. –

+0

@JerryCoffin Windows, XP, Vista, 7, 8 용 드라이버 – Roman

답변

1

을 제어하는 ​​"SC 정지"를 "시작 SC"와 몇 년 전 NDIS 드라이버를 설치하기 위해 작성한 코드가 있습니다. 그것은 XP에서 테스트되고 사용되었지만, 그보다 더 새로운 것은 확실하지 않습니다. 다른 유형의 드라이버를 설치하려면 대부분 그룹 및 종속성을 변경해야합니다.

#define Win32_LEAN_AND_MEAN 
#include <windows.h> 

void install_NDIS_driver(char const *path, char const *name) { 
// This uses the name as both the driver name and the display name. 

    SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE); 
    SC_HANDLE service = CreateService(manager, 
     name,      // driver name 
     name,      // driver display name 
     GENERIC_EXECUTE,   // allow ourselves to start the service. 
     SERVICE_KERNEL_DRIVER,  // type of driver. 
     SERVICE_SYSTEM_START,  // starts after boot drivers. 
     SERVICE_ERROR_NORMAL,  // log any problems, but don't crash if it can't be loaded. 
     path,      // path to binary file. 
     "NDIS",      // group to which this driver belongs. 
     NULL,      
     "NDIS\0",     // driver we depend upon. 
     NULL,      // run from the default LocalSystem account. 
     NULL);      // don't need a password for LocalSystem . 
    // The driver is now installed in the machine. We'll try to start it dynamically. 

    StartService(service, 0, NULL); // no arguments - drivers get their "stuff" from the registry. 

    CloseServiceHandle(service); // We're done with the service handle 
    CloseServiceHandle(manager); // and with the service manager. 
} 
+0

일부 코드가 변경되었습니다. 감사합니다. – Roman

0

Windows Service Controller을 사용하여 커널 모드 드라이버를 등록하고 제어 할 수 있습니다.

  1. 를 사용하여 서비스를 만들려면 .SYS 파일을 가리키는 유형 = 커널과 binPath에 "SC 작성"
  2. 를 사용하여 드라이버