/
jsystem.cpp
38 lines (30 loc) · 928 Bytes
/
jsystem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "jsystem.h"
namespace jsystem
{
int shutdown_command = LINUX_REBOOT_CMD_RESTART;
} // namespace jsystem
int Shutdown(int argc, char **argv){
jsystem::shutdown_command = LINUX_REBOOT_CMD_POWER_OFF;
return reboot(argc,argv);
}
int Restart(int argc, char **argv){
jsystem::shutdown_command = LINUX_REBOOT_CMD_RESTART;
return reboot(argc,argv);
}
int reboot(int argc,char* argv[]){
int result_code = -1;
int reboot_call_serial = 88;
int magic_1 = LINUX_REBOOT_MAGIC1;
int magic_2 = LINUX_REBOOT_MAGIC2;
//printf("\n COMMAND: %8p\n",jsystem::shutdown_command);
asm volatile(
"movl %1,%%eax \n\t"
"int $0x80 \n\t"
"movl %%ebx,%0 \n\t"
: "=m"(result_code)
: "r"(reboot_call_serial),"ebx"(magic_1),"ecx"(magic_2),"edx"(jsystem::shutdown_command)
: "eax"
);
printf("the result code is %d",&result_code);
return 0;
}