sambul35 wrote:Is this corruption of stack permanent on disk or only in RAM, and restored to normal stack upon reboot?
First to say that the stack is located somewhre in the IA32 memory address space:
It may be located on any disk (pagefile), or in RAM.
But it is more probable that the call stack of a program running on an average system is located in RAM.
You could build as many call stacks you want:
Typically the system (OS), every process and every task has their own call stack.
What happens with the call stack depends on what you call "reboot".
The corruption "survives" the ACPI modes G0, G1, S0-S4, and C0-C7 (containing S3=Sleep=Suspend to RAM and S4=Hibernate=Suspend to disk).
Returning from these states doesn't "restore" the stack (it's stays corrupted).
Only if the system (re)boots from ACPI modes S5 (=soft off), S6 (=PSU disconnected from MB) and G3 (=mechanical off) the stack will be rebuild.
sambul35 wrote:Is there a way to get PS error code for what caused "Couldn't set suspend state: Denied" outcome?
No, there is no way to get this error code, because no error happens (and in addition no exception is thrown).
Possible scenarios:
- The system may be configured by admin to ignore this functionality for special/all modes.
- A hardware may not support ACPI and windows/Linux/... may ignore the users wish.
- The OS security manager may deny the selected ACPI mode (if an application with enough rights advises the security manager to react this way).
- ...
See the (also linked above) "MSDN documentation":
https://msdn.microsoft.com/en-us/library/system.windows.forms.application.setsuspendstate(v=vs.110).aspxsambul35 wrote:What programming language this PS snippet is written on?
I'm not sure how you mean this:
This is a typical batch file containing a call to Powershell to execute the given powershell command.
The external assembly of the called commandlet probably is programmed in C++ or C#.
I only wanted to avoid using a second powershell file for example this "Suspend.ps1":
Code: Select all
Add-Type -Assembly System.Windows.Forms
if (-NOT [System.Windows.Forms.Application]::SetSuspendState([System.Windows.Forms.PowerState]::Suspend, $true, $false)) {
write-host "Couldn't set suspend state: Denied".
write-host "See: https://msdn.microsoft.com/en-us/library/system.windows.forms.application.setsuspendstate(v=vs.110).aspx"
}
sambul35 wrote:Are there any common rules, how to inject into a batch a code using a different programming language?
No, you have to try to write a hybrid that is accepted by batch and the programming language you are using.
For more information see:
-
http://www.dostips.com/forum/viewtopic.php?f=3&t=5543-
http://www.dostips.com/forum/viewtopic.php?f=3&t=6931penpen