Board logo

标题: 怎样在C语言中实现软关机或重新启动? [打印本页]

作者: profree     时间: 2004-6-30 00:00    标题: 怎样在C语言中实现软关机或重新启动?
如题,我现在急着要,

作者: boblhh9999     时间: 2004-7-1 00:00
在TC20中实现计算机启动的方法:
unsigned char code={0xea,0x0,0x0,0xff,0xff};
( *(void(far *)())code )(); //启动计算机

作者: leoweight     时间: 2004-7-1 00:00
楼上的大哥好高深呀

作者: boblhh9999     时间: 2004-7-3 00:00
这是夸我还是糗我???
资料来源转贴

作者: wks_love     时间: 2004-7-5 00:00
这是什么意思啊?我怎么满眼的 括号和乱码!啥意思啊?
你怎么能把这背下来的?

作者: zoologist     时间: 2004-7-6 00:00
开玩笑~怎么可能!

作者: TurboY     时间: 2004-7-7 00:00
重启可用嵌入汇编asm jmp far 0ffffh:0000或调用INT19H
关机不清楚,应和ACPI的BIOS功能有关。

作者: zk88     时间: 2004-7-7 00:00
以下是引用boblhh9999在2004-7-1 上午 02:19:07的发言:
在TC20中实现计算机启动的方法: 
           unsigned char code={0xea,0x0,0x0,0xff,0xff}; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;*(void(far&nbsp;*)())code&nbsp<img src="images/smilies/face-wink.png" align="absmiddle" border="0">();&nbsp;//启动计算机


完整代码 tc2.0 passed
unsigned char code={0xea,0x0,0x0,0xff,0xff};
main()
{
( *(void(far *)())code )(); //启动计算机
}
注:纯DOS下一运行即重启

作者: profree     时间: 2004-7-7 00:00
真是厉害,谢谢

作者: xy_god     时间: 2004-7-8 00:00
以下是引用boblhh9999在2004-7-1 上午 02:19:07的发言:
在TC20中实现计算机启动的方法:&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;char&nbsp;code={0xea,0x0,0x0,0xff,0xff};&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;*(void(far&nbsp;*)())code&nbsp<img src="images/smilies/face-wink.png" align="absmiddle" border="0">();&nbsp;//启动计算机

{0xea,0x0,0x0,0xff,0xff}这个估计是一串实现重新启动的机器代码,
而*(void(far&nbsp;*)())code则是跳转到上述机器代码处执行,由于
不在同一段内,所以要用far来修饰。原理应该是这个样子吧?

作者: boblhh9999     时间: 2004-7-14 00:00
10楼解释的很明白,惭愧我只会使用,没能解释明白

作者: 笑傲江湖     时间: 2004-7-31 00:00
{0xea,0x0,0x0,0xff,0xff}汇编释义:0xea-JMP 跳转指令0x0,0x0-0000h,偏移地址0xff,0xff-ffffh,基地址合起来就是:asm jmp far 0ffff:0000乱猜的,不要当真!

作者: qb45     时间: 2004-8-1 00:00
用qb一句搞定OUT &amp;H64, &amp;HFE

作者: henrya2     时间: 2006-2-25 21:21
为什么要用缓冲区溢出呢,直接调用中断不是很好吗