| 148 | } |
| 149 | |
| 150 | BOOL __cdecl LoadNTDriver(char* lpszDriverName, char* lpszDriverPath) |
| 151 | { |
| 152 | //char szDriverImagePath[256]; |
| 153 | //�õ�����������·�� |
| 154 | //GetFullPathNameA(lpszDriverPath, 256, szDriverImagePath, NULL); |
| 155 | |
| 156 | BOOL bRet = FALSE; |
| 157 | |
| 158 | SC_HANDLE hServiceMgr = NULL;//SCM�������ľ�� |
| 159 | SC_HANDLE hServiceDDK = NULL;//NT������������ |
| 160 | |
| 161 | //������ƹ����� |
| 162 | hServiceMgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 163 | |
| 164 | if (hServiceMgr == NULL) |
| 165 | { |
| 166 | //OpenSCManagerʧ�� |
| 167 | printf("OpenSCManager() Faild %d ! \n", GetLastError()); |
| 168 | bRet = FALSE; |
| 169 | goto BeforeLeave; |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | ////OpenSCManager�ɹ� |
| 174 | printf("OpenSCManager() ok ! \n"); |
| 175 | } |
| 176 | |
| 177 | //������������Ӧ�ķ��� |
| 178 | hServiceDDK = CreateServiceA(hServiceMgr, |
| 179 | lpszDriverName, //�����������ע����е����� |
| 180 | lpszDriverName, // ע������������ DisplayName ֵ |
| 181 | SERVICE_ALL_ACCESS, // ������������ķ���Ȩ�� |
| 182 | SERVICE_KERNEL_DRIVER,// ��ʾ���صķ������������� |
| 183 | SERVICE_DEMAND_START, // ע������������ Start ֵ |
| 184 | SERVICE_ERROR_IGNORE, // ע������������ ErrorControl ֵ |
| 185 | lpszDriverPath, // ע������������ ImagePath ֵ |
| 186 | NULL, |
| 187 | NULL, |
| 188 | NULL, |
| 189 | NULL, |
| 190 | NULL); |
| 191 | |
| 192 | DWORD dwRtn; |
| 193 | //�жϷ����Ƿ�ʧ�� |
| 194 | if (hServiceDDK == NULL) |
| 195 | { |
| 196 | dwRtn = GetLastError(); |
| 197 | if (dwRtn != ERROR_IO_PENDING && dwRtn != ERROR_SERVICE_EXISTS) |
| 198 | { |
| 199 | //��������ԭ������ʧ�� |
| 200 | printf("CrateService() Faild %d ! \n", dwRtn); |
| 201 | bRet = FALSE; |
| 202 | goto BeforeLeave; |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | //����ʧ�ܣ������ڷ����Ѿ������� |
| 207 | printf("CrateService() Faild Service is ERROR_IO_PENDING or ERROR_SERVICE_EXISTS! \n"); |
nothing calls this directly
no outgoing calls
no test coverage detected