Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

How to recycling system resources when user application crashes

coder_lizzoecoder_lizzoe Member - All Emails Posts: 20

Hi, all
My need is to apply and release some system resources through user application control, such as DMA Transaction and MmProbeAndLockPages.
Once I had accquired these system resource, I need them to be hold until I released by IOCTL cmd manually. Under normal circumstances, everything works fine, but once the application crashed(bug or any other reason) before release them, the OS will be hang out while sytem rebooting unless press the computer's Reset button. Whitout rebooting, if re-run the application directly, this may leads OS to blue screen.
Is there a safe and effective way to proactively recycle or shut down these resources when the application crashed?
Thanks.

Comments

  • Pavel_APavel_A Member Posts: 2,659

    until I released by IOCTL cmd manually

    Instead of IOCTL command to release, make the IOCTL pending (waiting in a KMDF queue). To release, cancel the ioctl.
    If the app exits or crashes, the IOCTL will be canceled automatically for you. Bingo.

    -- pa

  • anton_bassovanton_bassov Member Posts: 4,928

    Is there a safe and effective way to proactively recycle or shut down these resources when the application crashed?

    Well, even if the client app crashes before sending an IOCTL, your driver is still going to receive IRP_MJ_CLOSE anyway , right. Therefore, as long as your driver is properly written, you still have a chance to make a proper cleanup even if the client app does not exit gracefully....

    Anton Bassov

  • coder_lizzoecoder_lizzoe Member - All Emails Posts: 20

    Well, even if the client app crashes before sending an IOCTL, your driver is still going to receive IRP_MJ_CLOSE anyway , right. Therefore, as long as your driver is properly written, you still have a chance to make a proper cleanup even if the client app does not exit gracefully....

    This is another question for me :(
    In the routine EVT_WDF_DRIVER_DEVICE_ADD, I'd registered the EVT_WDF_FILE_CLEANUP and EVT_WDF_FILE_CLOSE

    EVT_WDF_DEVICE_FILE_CREATE  DeviceFileCreate;
    EVT_WDF_FILE_CLEANUP              FileCleanup;
    EVT_WDF_FILE_CLOSE                   FileClose;
    WDF_FILEOBJECT_CONFIG_INIT(&fileConfig, 
        DeviceFileCreate, 
        FileCleanup, 
        FileClose);
    VOID FileCleanup(IN WDFFILEOBJECT  FileObject)
    {
        UNREFERENCED_PARAMETER(FileObject);
        KdPrint(("Enther File Cleanup"));
    }
    
    VOID FileClose(IN WDFFILEOBJECT  FileObject)
    {
        UNREFERENCED_PARAMETER(FileObject);
        KdPrint(("Enther File Close"));
    }
    

    The DebugView is always opened during program execution, but the log doesn't give any output when the program crashes.
    Occasionally, I found that after about six minutes, the log was output. I'm so confused...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space