.486 create 32 bit code
.model flat, stdcall 32 bit memory model
option casemap :none case sensitive
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
strShutDown db "shutdown.exe /s /s /t 00",0
.code
start:
invoke WinExec,addr strShutDown,0
invoke ExitProcess,0
end start
在MASM32下代码如下:
.486 create 32 bit code
.model flat, stdcall 32 bit memory model
option casemap :none case sensitive
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
strShutDown db "shutdown.exe /s /s /t 00",0
.code
start:
invoke WinExec,addr strShutDown,0
invoke ExitProcess,0
end start
可以,下面是最真的C语言代码,基本是嵌入汇编的。关于中断。。有些都是靠调用系统的内部命令完成的 ,如楼上的 system("shutdown -s -t 0")在这个函数里面可以输入DOS命令都可以,所以只是个DOS命令而已。
========= for Dos =======================
#include<stdio.h>
#include<dos.h>
void main( void )
{
union REGS In,Out
In.x.ax = 0x5300/*检查是否支持APM*/
In.x.bx = 0x0000
int86(0x15,&In,&Out)
if( Out.x.cflag != 0)
{
printf("No APM!\n")
exit(0)
}
In.x.ax = 0x5301/*连接到APM*/
In.x.bx = 0x0000
int86(0x15,&In,&Out)
if( (Out.x.cflag!=0) &&(Out.h.ah!=0x02))
{
printf("Connecting error!\n")
exit(0)
}
In.x.ax = 0x530e/*通知APM所使用的版本为1.2*/
In.x.cx = 0x0102
int86(0x15,&In,&Out)
if( (Out.x.cflag != 0)
{
printf("Ver error!\n")
exit(0)
}
In.x.ax = 0x5307/*实现关机*/
In.x.bx = 0x0001
In.x.cx = 0x0003
int86(0x15,&In,&Out)
if( (Out.x.cflag != 0)
{
printf("Shutdown error!\n")
exit(0)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)