void __fastcall ssh_interceptor_iodevice_close_device(SshInterceptorIoDevice io_dev) { SSH_DEBUG(SSH_D_HIGHSTART, ("Closing stream device...")); SSH_ASSERT(io_dev != NULL); SSH_ASSERT(ssh_interceptor_iodevice_is_open(io_dev) == FALSE); if (io_dev->handle) DeactivateDevice(io_dev->handle); }
//change by ligq 2014.8.15 //change deinit timing __LIB_RADIO_EXPORT BOOL Radio_Exit() { int ret=FALSE; exit_sms_table_base(); RilInitOK=FALSE; if(g_hEvent)CloseHandle(g_hEvent); ret=RilInstance.DeInitRil(); //DeActive Driver if(g_hRil)DeactivateDevice(g_hRil); //if(g_hVCom)DeactivateDevice(g_hVCom); return ret; }
static int deinstall (void) { int result = 0; HANDLE shd; DEVMGR_DEVICE_INFORMATION dinfo; memset (&dinfo, 0, sizeof dinfo); dinfo.dwSize = sizeof dinfo; shd = FindFirstDevice (DeviceSearchByLegacyName, L"GPG1:", &dinfo); if (shd == INVALID_HANDLE_VALUE) { if (GetLastError () == 18) fprintf (stderr, PGM": device not found\n"); else { fprintf (stderr, PGM": FindFirstDevice failed: rc=%d\n", (int)GetLastError ()); result = 1; } } else { fprintf (stderr, PGM": ActivateDevice handle is %p\n", dinfo.hDevice); if (dinfo.hDevice && dinfo.hDevice != INVALID_HANDLE_VALUE) { if (!DeactivateDevice (dinfo.hDevice)) { fprintf (stderr, PGM": DeactivateDevice failed: rc=%d\n", (int)GetLastError ()); result = 1; } else fprintf (stderr, PGM": DeactivateDevice succeeded\n"); } FindClose (shd); } return result; }
BOOL FindActiveMatchandUnload(PTCHAR pPath, PTCHAR pKeyMatch) { BOOL found = FALSE; LONG status; /* reg api status */ HKEY hOpenKey = NULL; /* opened key handle */ DWORD hndValue; ULONG bufferSize; TCHAR keyMatchBuffer[MAX_REG_KEY_LENGTH]; do { status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, pPath, 0, 0, &hOpenKey); if (status != ERROR_SUCCESS) { break; } bufferSize = sizeof(DWORD); status = RegQueryValueEx(hOpenKey, DEVLOAD_HANDLE_VALNAME, NULL, NULL, (PUCHAR)&hndValue, &bufferSize); if (status != ERROR_SUCCESS) { break; } bufferSize = sizeof(keyMatchBuffer); status = RegQueryValueEx(hOpenKey, DEVLOAD_DEVKEY_VALNAME, NULL, NULL, (PUCHAR)&keyMatchBuffer, &bufferSize); if (status != ERROR_SUCCESS) { break; } if (NULL == pKeyMatch) { /* output verbose if we are not matching */ PRINT_CONSOLE((TEXT(" Found Key:%s, Hnd:0x%X\r\n"),keyMatchBuffer, hndValue)); } if (pKeyMatch != NULL) { if (_tcscmp(keyMatchBuffer,pKeyMatch) == 0) { PRINT_CONSOLE((TEXT("--- Unloading Driver: %s .... \r\n"),keyMatchBuffer)); found = TRUE; DeactivateDevice((HANDLE)hndValue); } } } while (FALSE); if (hOpenKey != NULL) { RegCloseKey(hOpenKey); } return found; }