China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-24 18:03
中国DOS联盟论坛 » WinPE、PowerShell及其它命令行系统专区 » Help to compile the following code that turns off the monitor into an EXE file? View 5,221 Replies 15
Original Poster Posted 2010-06-12 19:42 ·  中国 浙江 嘉兴 嘉善县 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
.486
.model flat, stdcall
option casemap :none ; case sensitive

include D:\Language\masm32\include\windows.inc
include D:\Language\masm32\include\user32.inc
include D:\Language\masm32\include\kernel32.inc
includelib D:\Language\masm32\lib\user32.lib
includelib D:\Language\masm32\lib\kernel32.lib

.code

start:
invoke Sleep, 500
invoke SendMessage, HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2
invoke ExitProcess, 0
end start


http://blog.sina.com.cn/s/blog_591884640100dhyx.html

I downloaded an assembly myself, but it didn't work repeatedly.
Maybe the code has a problem in D:\.

Thank you very much.

[ Last edited by bd123456789 on 2010-6-12 at 19:44 ]
Floor 2 Posted 2010-06-25 11:25 ·  中国 山东 菏泽 联通
银牌会员
★★★
Credits 1,246
Posts 488
Joined 2003-11-11 00:00
22-year member
UID 12699
Gender Male
Status Offline
Don't be grateful. Here's an address:

http://yanlibin.googlepages.com/monitor.rar
http://blog.sina.com.cn/s/blog_591884640100dhyx.html

[ Last edited by wang6610 on 2010-6-27 at 07:10 ]
Floor 3 Posted 2010-06-26 17:16 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Originally posted by wang6610 at 2010-6-25 11:25 AM:
Don't mention it. Here's an address:

http://yanlibin.googlepages.com/monitor.rar Please download it with great effort.

http://blog.sina.com.cn/s/blog_591884640100dhyx.html


Hehe

I can't open this address?
Floor 4 Posted 2010-06-26 21:30 ·  中国 山东 菏泽 联通
银牌会员
★★★
Credits 1,246
Posts 488
Joined 2003-11-11 00:00
22-year member
UID 12699
Gender Male
Status Offline
@echo off
more +5 "%~0"|debug&graftabl 936>nul
copy/b/y $tmp$ "MONITOR.exe">nul
del/a/f/q $tmp$
goto:eof
e0100 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00
e0110 B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
e0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0130 00 00 00 00 00 00 00 00 00 00 00 00 B0 00 00 00
e0140 0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68
e0150 69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F
e0160 74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20
e0170 6D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 00
e0180 5D F3 DC FD 19 92 B2 AE 19 92 B2 AE 19 92 B2 AE
e0190 97 8D A1 AE 10 92 B2 AE E5 B2 A0 AE 18 92 B2 AE
e01A0 52 69 63 68 19 92 B2 AE 00 00 00 00 00 00 00 00
e01B0 50 45 00 00 4C 01 01 00 B1 48 21 4A 00 00 00 00
e01C0 00 00 00 00 E0 00 0F 01 0B 01 05 0C 00 02 00 00
e01D0 00 00 00 00 00 00 00 00 20 10 00 00 00 10 00 00
e01E0 00 20 00 00 00 00 40 00 00 10 00 00 00 02 00 00
e01F0 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
e0200 00 20 00 00 00 02 00 00 00 00 00 00 02 00 00 00
e0210 00 00 10 00 00 10 00 00 00 00 10 00 00 10 00 00
e0220 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00
e0230 5C 10 00 00 3C 00 00 00 00 00 00 00 00 00 00 00
e0240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0280 00 00 00 00 00 00 00 00 00 10 00 00 14 00 00 00
e0290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e02A0 00 00 00 00 00 00 00 00 2E 74 65 78 74 00 00 00
e02B0 EC 00 00 00 00 10 00 00 00 02 00 00 00 02 00 00
e02C0 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 60
e02D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e02E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e02F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0300 D6 10 00 00 C8 10 00 00 00 00 00 00 AC 10 00 00
e0310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0320 68 F4 01 00 00 E8 2A 00 00 00 6A 02 68 70 F1 00
e0330 00 68 12 01 00 00 68 FF FF 00 00 E8 08 00 00 00
e0340 6A 00 E8 07 00 00 00 CC FF 25 0C 10 40 00 FF 25
e0350 04 10 40 00 FF 25 00 10 40 00 CC CC A4 10 00 00
e0360 00 00 00 00 00 00 00 00 BC 10 00 00 0C 10 00 00
e0370 98 10 00 00 00 00 00 00 00 00 00 00 DE 10 00 00
e0380 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0390 00 00 00 00 00 00 00 00 D6 10 00 00 C8 10 00 00
e03A0 00 00 00 00 AC 10 00 00 00 00 00 00 E2 01 53 65
e03B0 6E 64 4D 65 73 73 61 67 65 41 00 00 75 73 65 72
e03C0 33 32 2E 64 6C 6C 00 00 80 00 45 78 69 74 50 72
e03D0 6F 63 65 73 73 00 60 02 53 6C 65 65 70 00 6B 65
e03E0 72 6E 65 6C 33 32 2E 64 6C 6C 00 00 00 00 00 00
e03F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0430 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0440 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0470 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0490 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e04F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
rcx
4FF
n$tmp$
w
q

Save as a.bat and double-click it.
Floor 5 Posted 2010-06-27 16:40 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Thanks.

But found that it failed to turn off the monitor, maybe there is a mistake in the source code..


The following is in C++, anyone can solve?
http://www.cn-dos.net/forum/viewthread.php?tid=51710&fpage=1&highlight=
Floor 6 Posted 2010-06-29 00:13 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
19-year member
UID 94024
Gender Male
Status Offline
Actually, the principle of this is the same as the screen saver where the monitor is turned off after a period of inactivity. First, make sure the monitor conforms to Energy Star. Second, the power scheme settings are also related. Moreover, moving the mouse or pressing the keyboard may make the monitor turn on again. According to online discussions, there is a risk of system restart with this message.

Under DOS (non-WIN command line), turning off the monitor through INT 10H call or direct I/O is the real deal.

BTW: -1 is to turn on the display. You can try using 0 instead of 2.
In the while loop of the playback software, you can handle this message by returning 0, which can prevent being "bothered" by the screen saver or monitor power saving during playback.

***There are no compilation problems at all, one is a GUI one, and one is a Consol one***

[ Last edited by netwinxp on 2010-6-29 at 01:47 ]
Attachments
offDisp.rar (977 bytes, Downloads: 15)
Floor 7 Posted 2010-06-30 07:55 ·  中国 浙江 嘉兴 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Thanks a lot

I downloaded the attachment, ran the EXE, and got the following prompt;

Threat: Ending the program of 360 Total Security will cause the real-time security protection to become ineffective, and may pose a danger to your computer and personal data. It is recommended to check this program and use 360 Total Security's cloud-based Trojan detection to perform a full scan of the system.
Source: C:\Documents and Settings\Administrator\Desktop\offDisp\offDisp\OffDispGui.exe

Don't know what it is?
Floor 8 Posted 2010-06-30 13:03 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
19-year member
UID 94024
Gender Male
Status Offline
Here is the translation:

Below is the disassembly code, you can take a look (or ask someone to see if there are really any problems), not even a possible virus "remains"! There's nothing we can do if the silly blocking software misreports... You can just use the command line one.
Disassembly of File: OffDisplay.exe
Code Offset = 00000400, Code Size = 00000200
Data Offset = 00000000, Data Size = 00000000
Number of objects = 2 (just the following two), Imagebase = 00400000h
.text RVA: 00001000 Offset: 00000400 Size: 00000200 Flags: 60000020
.rdata RVA: 00002000 Offset: 00000600 Size: 00000200 Flags: 40000040
+++++++++++++++++++ ++++++++++++++++++
No Menu Resources
No Dialog Resources
Number of Imported Modules = 0
Number of Exported Functions = 0
+++++++++++++++++++++++++++++++++++++
Program entry = 00401000 (OffDisplay.exe File Offset: 00001600)
//******************** Program Entry Point ********
;We defined the parameter passing rule as stdcall(WINAPI), so parameters are pushed onto the stack from right to left,
;and the called function cleans up the stack.
:00401000 68F4010000 push 000001F4;Parameter 500
:00401005 E82A000000 call 00401034;Call sleep
:0040100A 6A02 push 00000002;Parameter 2
:0040100C 6870F10000 push 0000F170;Parameter SC_MONITORPOWER
:00401011 6812010000 push 00000112;Parameter WM_SYSCOMMAND
:00401016 68FFFF0000 push 0000FFFF;Parameter HWND_BROADCAST
:0040101B E808000000 call 00401028;Call SendMessage
:00401020 6A00 push 00000000;Parameter 0
:00401022 E807000000 call 0040102E;Call ExitProcess
:00401027 CC int 03;The main program doesn't go further from here
;;;;;;;;;;;;;;;;;Assembly language generated intermediate jump statements;;;;;;;;;;;;;;;;;;;;;;;;;;
*CALL at Address: 0040101B
:00401028 FF250C204000 jmp dword ptr ;Jump to the real SendMessage pointer
*CALL at Address: 00401022
:0040102E FF2504204000 jmp dword ptr ;Jump to the real ExitProcess pointer
*CALL at Address: 00401005
:00401034 FF2500204000 jmp dword ptr ;Jump to the real sleep pointer
;;;Note: masm32 will generate an intermediate jump (for win32's link using VC's, masm itself doesn't have it), I can't help it;;;
:All zeros
;00402000 8E 20 00 00 80 20;End of the program

[ Last edited by netwinxp on 2010-6-30 at 18:45 ]
Floor 9 Posted 2010-07-03 09:45 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Brother upstairs! Why are both EXEs running and the monitor isn't turned off?

I selected the EXE first and then pressed the Enter key, without moving the mouse, but still couldn't turn it off?


Has anyone tested and succeeded?

[ Last edited by bd123456789 on 2010-7-3 at 09:46 ]
Floor 10 Posted 2010-07-03 15:01 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
19-year member
UID 94024
Gender Male
Status Offline
It's not that I told you -

1. This message is the monitor's power-saving mode, not turning off the monitor.
2. It's related to the power management scheme. If the power scheme is "always on" or "turn off monitor: never", it must be ineffective.
3. It's related to the monitor itself. If it's not a "plug and play monitor", it may be ineffective.
4. It's related to the Windows version and the version of relevant components. The too high one seems not okay.

===================================
The real thing that can turn off the video can be done with INT 10H (DOS)
OnVideo proc far
mov bl,36h
mov ax,1200h
int 10h
ret
OnVideo endp

OffVideo proc far
mov bl,36h
mov ax,1201h
int 10h
ret
OfficeVideo endp
;Try these two segments in pure DOS, it must be effective. I often use it when writing to the screen directly in DOS.
================================

That message is basically not very useful. Most of the online ones are passed on inaccurately. It's just that you said it can't be compiled, so I compiled it. Its real function is - return 0 for this message, thus preventing the screen saver and the monitor's power-saving mode.

[ Last edited by netwinxp on 2010-7-3 at 15:09 ]
Floor 11 Posted 2010-07-03 18:02 ·  中国 山东 菏泽 联通
银牌会员
★★★
Credits 1,246
Posts 488
Joined 2003-11-11 00:00
22-year member
UID 12699
Gender Male
Status Offline
```asm

OnVideo proc far
mov bl,36h
mov ax,1200h
int 10h
ret
OnVideo endp

OffVideo proc far
mov bl,36h
mov ax,1201h
int 10h
ret
OfficeVideo endp

```
Floor 12 Posted 2010-07-03 21:51 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
19-year member
UID 94024
Gender Male
Status Offline
That's just a sample program. Forget it, I'll write one.
Parameters S (-S, /S) = turn off the monitor O (-O, /O) = turn on the monitor, case-insensitive
*****Only valid in pure DOS, not tested in virtual machine, unknown compatibility****

; Source code
.MODEL TINY
.286
CODE SEGMENT
ASSUME CS:CODE
ORG 81H
CMDLINE DB 10 DUP(0)
ORG 100H
MAIN PROC NEAR
MOV SI,1
GETCMD:
CMP CMDLINE, '-'
JE NEXT1
CMP CMDLINE, '/'
JE NEXT1
CMP CMDLINE, 'S'
JE RCHKS
CMP CMDLINE, 's'
JE RCHKS
CMP CMDLINE, 'O'
JE RCHKO
CMP CMDLINE, 'o'
JE RCHKO
JMP HELPTXT
NEXT1:
INC SI
JMP GETCMD
RCHKS:
INC SI
CMP CMDLINE, 0DH
JE OFFVIDEO
RCHKO:
INC SI
CMP CMDLINE, 0DH
JE ONVIDEO
HELPTXT:
MOV AX,CS
MOV DS,AX
MOV AH,09H
MOV DX,OFFSET HLPSTR
INT 21H
EXIT:
MOV AX,4C00H
INT 21H
OFFVIDEO:
MOV BL,36H
MOV AX,1201H
INT 10H
JMP EXIT
ONVIDEO:
MOV BL,36H
MOV AX,1200H
INT 10H
JMP EXIT
HLPSTR DB 'Turn on/off display for DOS',0Dh,0Ah,'S to turn off,O to turn on,other to help.$'
MAIN ENDP
CODE ENDS
END MAIN
[ Last edited by netwinxp on 2010-7-3 at 22:02 ]
Attachments
offvideo.rar (241 bytes, Downloads: 10)
Floor 13 Posted 2010-07-03 22:33 ·  中国 山东 菏泽 联通
银牌会员
★★★
Credits 1,246
Posts 488
Joined 2003-11-11 00:00
22-year member
UID 12699
Gender Male
Status Offline
Originally posted by netwinxp at 2010-7-3 09:51 PM:
That's just a subroutine, forget it, I'll write one.
Parameter S (-S, /S) = turn off the monitor O (-O, /O) = turn on the monitor, case-insensitive
*****Only valid in pure DOS, not tested in virtual machine, unknown compatibility****

VPC is effective, thank you...
Floor 14 Posted 2010-07-05 09:15 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Thanks a lot

I looked it up, online,,,

It's in the attachment, relatively easy to use.. and suitable for XP

[ Last edited by bd123456789 on 2010-7-5 at 09:16 ]
Attachments
关闭显示器.rar (63.1 KiB, Downloads: 26)
Floor 15 Posted 2010-07-05 15:01 ·  中国 福建 厦门 电信
高级用户
★★★
Credits 741
Posts 366
Joined 2007-07-25 19:11
19-year member
UID 94024
Gender Male
Status Offline
I know where the problem of the previous Windows program not being able to turn off the screen is. Because the program runs and then exits, so it fails.

You can try the following to see if it can be turned off for about 10 seconds? If it works, it will be easy.

There is a problem with my graphics card settings, so I can't test. Including the one you provided doesn't work.

[ Last edited by netwinxp on 2010-7-5 at 15:14 ]
Attachments
OffDisplay.rar (481 bytes, Downloads: 9)
Forum Jump: