Ticket #2558: powerreq.patch

File powerreq.patch, 747 bytes (added by Alex, 7 years ago)

Patch for enabling ES_SYSTEM_REQUIRED while service is running.

  • Service.cpp

     
    483483    if (!nServiceRunning)
    484484        PostQuitMessage(0);
    485485
     486    // force system working power state (S0) while service is running.
     487    EXECUTION_STATE prevState = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
     488    if (!prevState)
     489        PostQuitMessage(0);
     490   
    486491    MSG msg;
    487492    while (GetMessage(&msg, 0, 0, 0)) {
    488493        TranslateMessage(&msg);
     
    492497    delete pServer;
    493498    WSACleanup();
    494499
     500    // Revert power state.
     501    SetThreadExecutionState(prevState);
     502
    495503    SetEvent(killServiceEvent);
    496504    return 0;
    497505}
     
    607615    }
    608616
    609617    return 1;
    610 }
    611  No newline at end of file
     618}