Had this process I wanted to execute during a number of tasks, this process had a command line argument “—reboot” which forced an immediate reboot. If you tried to run the command without the “–reboot” option you were given an error “You must specify –reboot option”
But we wanted to control when the reboot occurred.
Using IDA Pro it is relatively easy to remove the reboot. Some programs may launch shutdown.exe to initiate shutdown/restart but in this case the program called Windows API ExitWindowsEx
Opening the EXE in IDA Pro we find ExitWindowsEx in the import table, then double click it.
With ExitWindowsEx selected we hit ‘X’ or right click and select Jump to xref to operand
From here we can see there are two different locations that call this API:
Clicking the locations we find code like this:
The two push commands are setting up the parameters for ExitWindowsEx, and the test eax, eax command is checking the return code. Looking up ExitWindowsEx function in MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/aa376868(v=vs.85).aspx) we can see it returns TRUE if the call was successful.
In this program, if the restart fails, it rolls back its changes, so we need to lie that the reboot succeeded, so we will set eax to 1.
We select push eax then select option to Assemble
We enter our code
We then continue inserting nop instructions until they go to the test eax, eax instruction
We then Apply Patches to input file
And our program no longer forces reboot, we can control when the reboot occurs.
Before doing this type of patch you should understand the implications and what you might break by eliminating this forced reboot…