+ if (pPP->user.Revision != 1 || pPP->mach.Revision != 1)
+ {
+ SetLastError(ERROR_REVISION_MISMATCH);
+ return FALSE;
+ }
+
+ //Lohnegrim: unneeded
+ //if (pPP->mach.MinSleepAc < PowerSystemWorking)
+ //{
+ // SetLastError(ERROR_GEN_FAILURE);
+ // return FALSE;
+ //}
+ if ((int)pPP->mach.MinSleepAc >= PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ //Lohnegrim: unneeded
+ //if (pPP->mach.MinSleepDc < PowerSystemWorking)
+ //{
+ // SetLastError(ERROR_GEN_FAILURE);
+ // return FALSE;
+ //}
+ if ((int)pPP->mach.MinSleepDc >= PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ if (pPP->mach.ReducedLatencySleepAc == PowerSystemUnspecified)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ if ((int)pPP->mach.ReducedLatencySleepAc >= PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ if (pPP->mach.ReducedLatencySleepDc < PowerSystemWorking)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ if ((int)pPP->mach.ReducedLatencySleepDc >= PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+
+ if (!CheckPowerActionPolicy(&pPP->mach.OverThrottledAc,PowerCaps))
+ {
+ return FALSE;
+ }
+ if (!CheckPowerActionPolicy(&pPP->mach.OverThrottledDc,PowerCaps))
+ {
+ return FALSE;
+ }
+ if (!CheckPowerActionPolicy(&pPP->user.IdleAc,PowerCaps))
+ {
+ return FALSE;
+ }
+ if (!CheckPowerActionPolicy(&pPP->user.IdleDc,PowerCaps))
+ {
+ return FALSE;
+ }
+ if (pPP->user.MaxSleepAc < PowerSystemWorking)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ //Lohnegrim: unneeded
+ /*if ((int)pPP->user.MaxSleepAc > PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }*/
+ if (pPP->user.MaxSleepDc < PowerSystemWorking)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+ //Lohnegrim: unneeded
+ /*if ((int)pPP->user.MaxSleepDc >= PowerSystemShutdown)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }*/
+ if (PowerCaps.SystemS1)
+ {
+ pPP->mach.MinSleepAc=PowerSystemSleeping1;
+ pPP->mach.MinSleepDc=PowerSystemSleeping1;
+ }
+ else if (PowerCaps.SystemS2)
+ {
+ pPP->mach.MinSleepAc=PowerSystemSleeping2;
+ pPP->mach.MinSleepDc=PowerSystemSleeping2;
+ }
+ else if (PowerCaps.SystemS3)
+ {
+ pPP->mach.MinSleepAc=PowerSystemSleeping3;
+ pPP->mach.MinSleepDc=PowerSystemSleeping3;
+ }
+
+ if (PowerCaps.SystemS4)
+ {
+ pPP->user.MaxSleepAc=PowerSystemSleeping3;
+ pPP->user.MaxSleepDc=PowerSystemSleeping3;
+ }
+ else if (PowerCaps.SystemS3)
+ {
+ pPP->user.MaxSleepAc=PowerSystemSleeping2;
+ pPP->user.MaxSleepDc=PowerSystemSleeping2;
+ }
+ else if (PowerCaps.SystemS1)
+ {
+ pPP->user.MaxSleepAc=PowerSystemSleeping1;
+ pPP->user.MaxSleepDc=PowerSystemSleeping1;
+ }
+ //Lohnegrim: I dont know where to get this info from, so i removed it
+ //pPP->user.OptimizeForPowerAc=TRUE;
+ //pPP->user.OptimizeForPowerDc=TRUE;
+
+ FixSystemPowerState(&pPP->mach.ReducedLatencySleepAc,PowerCaps);
+ FixSystemPowerState(&pPP->mach.ReducedLatencySleepDc,PowerCaps);