| 170 | } |
| 171 | |
| 172 | bool CheckInstall(PCWSTR cmdLine) { |
| 173 | bool parse = false, success = false; |
| 174 | |
| 175 | auto hRes = ::FindResource(nullptr, MAKEINTRESOURCE(IDR_DRIVER), L"BIN"); |
| 176 | |
| 177 | if (!hRes) |
| 178 | return false; |
| 179 | |
| 180 | auto hGlobal = ::LoadResource(nullptr, hRes); |
| 181 | if (!hGlobal) |
| 182 | return false; |
| 183 | |
| 184 | auto size = ::SizeofResource(nullptr, hRes); |
| 185 | void* pBuffer = ::LockResource(hGlobal); |
| 186 | |
| 187 | if (::wcsstr(cmdLine, L"install")) { |
| 188 | parse = true; |
| 189 | success = DriverHelper::LoadDriver(); |
| 190 | if (!success) |
| 191 | if (DriverHelper::InstallDriver(false,pBuffer,size)) |
| 192 | success = DriverHelper::LoadDriver(); |
| 193 | if (!success) |
| 194 | AtlMessageBox(nullptr, L"Failed to install/load kernel driver", IDS_TITLE, MB_ICONERROR); |
| 195 | } |
| 196 | else if (::wcsstr(cmdLine, L"update")) { |
| 197 | parse = true; |
| 198 | success = DriverHelper::UpdateDriver(pBuffer,size); |
| 199 | if (!success) { |
| 200 | AtlMessageBox(nullptr, L"Failed to update kernel driver", IDS_TITLE, MB_ICONERROR); |
| 201 | } |
| 202 | } |
| 203 | return parse; |
| 204 | } |
| 205 | |
| 206 | LONG WINAPI SelfUnhandledExceptionFilter(EXCEPTION_POINTERS* ExceptionInfo) |
| 207 | { |