Ejemplo n.º 1
0
VOID
FmDeviceCleanup(
               WDFDEVICE Device
               )
/*++
Routine Description:

    This event is called when the device object is destroyed.
    Cleanup any associated data.

Arguments:

Return Value:

   VOID

--*/
{
    PFM_DEVICE_DATA   fmData;

    PAGED_CODE();

    fmData = FmDeviceDataGet(Device);

    if (fmData->Flags & REG_VALUE_CREATED_FLAG) {
        RtlDeleteRegistryValue(
                              RTL_REGISTRY_DEVICEMAP,
                              L"SERIALCOMM",
                              fmData->PdoName.Buffer
                              );
    }
}
Ejemplo n.º 2
0
BOOLEAN HidePort(IN PC0C_FDOPORT_EXTENSION pDevExt)
{
    BOOLEAN res;
    NTSTATUS status;

    if (!pDevExt->shown)
        return TRUE;

    res = TRUE;

    if ((pDevExt->shown & C0C_SHOW_WMIREG) != 0) {
        status = IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER);
        pDevExt->shown &= ~C0C_SHOW_WMIREG;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden WMIREG");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoWMIRegistrationControl FAIL");
        }
    }

    if (pDevExt->symbolicLinkName.Buffer && (pDevExt->shown & C0C_SHOW_INTERFACE) != 0) {
        status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, FALSE);
        pDevExt->shown &= ~C0C_SHOW_INTERFACE;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden INTERFACE");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoSetDeviceInterfaceState FAIL");
        }
    }

    if (pDevExt->ntDeviceName.Buffer && (pDevExt->shown & C0C_SHOW_DEVICEMAP) != 0) {
        status = RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP,
                                        pDevExt->ntDeviceName.Buffer);
        pDevExt->shown &= ~C0C_SHOW_DEVICEMAP;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden DEVICEMAP");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort RtlDeleteRegistryValue " C0C_SERIAL_DEVICEMAP L" FAIL");
        }
    }

    if (pDevExt->win32DeviceName.Buffer && (pDevExt->shown & C0C_SHOW_SYMLINK) != 0) {
        status = IoDeleteSymbolicLink(&pDevExt->win32DeviceName);
        pDevExt->shown &= ~C0C_SHOW_SYMLINK;

        if (NT_SUCCESS(status)) {
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Hidden SYMLINK");
        } else {
            res = FALSE;
            Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort IoDeleteSymbolicLink FAIL");
        }
    }

    if ((pDevExt->shown & C0C_SHOW_PORTNAME) != 0)
        res = (HidePortName(pDevExt) && res);

    pDevExt->shown &= ~C0C_SHOW_SHOWN;

    Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"HidePort - ", res ? L"OK" : L"FAIL");

    return res;
}