PDA

View Full Version : خاموش کردن مانیتور



Developer Programmer
جمعه 17 بهمن 1382, 20:23 عصر
با اسمبلی چطور میشه سیستم رو به حالت انتظار برد .. هارد رو پارک کرد... مانیتور رو خاموش کرد ؟
وقفه خاصی داره؟

Best Programmer
جمعه 17 بهمن 1382, 21:12 عصر
تحت داس یا ویندوز ؟ ببخشید الان زیاد وقت تایپ ندازم.

Developer Programmer
شنبه 18 بهمن 1382, 10:28 صبح
خوب اولش تحت داس بعدش تحت ویندوز با API

Best Programmer
شنبه 18 بهمن 1382, 10:44 صبح
من حالت Suspend مود را یادم نیست ولی پاک کردن هارد کمی سخت هست چون داس هارد های بزرگ با آدرس های زیادش را نمی شناسد و تنها میتواند 8 گیگ را شناسایی درست بکند.(البته چه درستی اونم) ثالثا چه جور میخوای پاک کنی ؟ آیا میخوای غیر قابل برگشت باشد. و یا میخواهی دخل هارد را بیاری به طوری که بفرستی گارانتی؟
اینم یک مثال که کارتو راه میندازه.


;================================================= =============
;CHKPART Version 1.0

;--------------------------------------------------------------
;This progarm examines and display the partition information
;for all hard disks installed in a system.
;
;Syntax: CHKPART
;
;--------------------------------------------------------------
;This program is designed to be assembled with TASM, OPTASM, or
;MASM5.x. Create using the following commands:
; MASM CHKPART;
; LINK CHKPART;
; EXE2BIN CHKPART.EXE CHKPART.COM
; DEL CHKPART.OBJ
; DEL CHKPART.EXE
;--------------------------------------------------------------
CSEG SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

ORG 100H
ENTPT: JMP MAIN
;================================================= ==
;Program data.
;--------------------------------------------------------------
DISK DB 80H ;BIOS disk number

COPYRIGHT$ DB "ChkPart 1.0 "
DB "(c)Computer MagazineþBlackMedia 35 ",10
CRLF$ DB 13,10,"$"

NOMEM$ DB "Not enough memory$"

PARTID$ DB 0FFh,"Xenix bad block table$"
DB 0DBh,"CP/M, Concurrent DOS$"
DB 75h, "PC/IX$"
DB 0Ah, "OS/2 boot manager$"
DB 07h, "OS/2 HPFS$"
DB 06h, "DOS FAT-16, part > 32MB$"
DB 05h, "DOS extended partition$"
DB 04h, "DOS FAT-16, part < 32MB$"
DB 03h, "Xenix$"
DB 02h, "Xenix$"
DB 01h, "DOS FAT-12$"
DB 00h, "Unused/unknown$"

NOMORE$ DB 10,"No additional hard disks found$"

HEAD$ DB 10,"Physical hard disk "
DISK$ DB "1 partition information",13,10,10
DB "Part Boot Start End Total"
DB " MB",13,10
DB "Num Hd Sc Cyl Hd Sc Cyl sectors"
DB " System description",13,10,10,"$"

PDATA$ DB "00 Y 00-00-000 00-00-000 00000000"
DB " 0000 00 $"

;===============================================
;MAIN: Begin program execution here.
;--------------------------------------------------------------
MAIN PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

MOV AH,9 ;Display string
MOV DX,OFFSET COPYRIGHT$ ;Say who we are
INT 21H ;thru DOS
;--------------------------------------------------------------
;Verify that we have enough memory to hold the program. Compare the
;program size plus the memory required for the buffer to the segment
;size placed in the PSP by DOS.
;--------------------------------------------------------------
CMP DS:[6],OFFSET BUF + 1024 ;Prog size + buf len
JA M_1

MOV DX,OFFSET NOMEM$ ;Not enough memory
M_0:
MOV AH,9 ;Display string
INT 21H ;thru DOS
;--------------------------------------------------------------
;Exit the program.
;--------------------------------------------------------------
M_EXIT:
MOV AH,4CH ;Terminate progarm
INT 21H ;thru DOS
;--------------------------------------------------------------
;Physical hard drives are numbered beginning with 80h. Read the first
;physical sector for the hard disk (not the logical drive) into memory;
;it contains the partition table for the drive.
;--------------------------------------------------------------
M_1:
MOV AX,0201H ;Read one sector
MOV BX,OFFSET BUF ;Destination
MOV CX,0001H ;Cylinder 0 sector 1
MOV DH,00 ;Head 0
MOV DL,[DISK] ;Physical disk number
INT 13H ;thru BIOS

MOV DX,OFFSET NOMORE$ ;No more partitions?
JC M_0

CMP WORD PTR[BX+1FEH],0AA55h ;Verify signature
JNE M_0
;--------------------------------------------------------------
;Display the heading for the table.
;--------------------------------------------------------------
MOV AH,9 ;Display string
MOV DX,OFFSET HEAD$ ;heading
INT 21H ;thru DOS
;-------------------------------------------------------------
;Display each of the partition table entries.
;-------------------------------------------------------------
MOV SI,01EEH + OFFSET BUF ;Point to 1st entry
MOV BP,1 ;Partition number
M_2A:
MOV DI,OFFSET PDATA$ ;Point to message blank

MOV AX,BP ;Write partition #
CALL HEX2
ADD DI,4 ;Skip ahead
;-------------------------------------------------------------
;Determine if this partition is bootable.
;-------------------------------------------------------------
LODSB ;Read boot indicator
MOV AH,AL ;Save in AH
MOV AL,"N" ;NO if
OR AH,AH ;boot
JZ M_2B

MOV AL,"Y" ;YES if
CMP AH,80H ;boot = 80h
JE M_2B

MOV AL,"?" ;Else, who knows?
M_2B:
STOSB ;Write it
ADD DI,3 ;Skip ahead
;--------------------------------------------------------------
;Decode the remainder of the entries with a subroutine.
;--------------------------------------------------------------
CALL SHOW_PART ;Show other data
;--------------------------------------------------------------
;If the partition was an extended partition, trace through to find the
;logical drives. Read the first sector specified by the starting head,
;sector, and cylinder for the partition.
;--------------------------------------------------------------
CMP BX,5 ;Was it ext partition?
JNE M_4A

PUSH SI ;Save current pointer
SUB SI,16 ;Backup to entry start
M_3A:
MOV AX,0201H ;Read one sector
MOV BX,OFFSET BUF + 512 ;Destination
MOV CX,[SI+2] ;Cylinder,sector
MOV DH,[SI+1] ;Head 0
MOV DL,[DISK] ;Physical disk
INT 13H ;thru BIOS
;--------------------------------------------------------------
;Point to the entry in this extended partition table that describes
;this partition.
;--------------------------------------------------------------
MOV DI,OFFSET PDATA$ ;Point to output string
MOV WORD PTR [DI],2020H ;Blank out partition #
MOV BYTE PTR [DI+6],"E" ;Mark as extended
ADD DI,10 ;Skip ahead

MOV SI,OFFSET BUF + 512 + 1BEH + 1
CALL SHOW_PART ;Detail this partition
;--------------------------------------------------------------
;Read the sector entry in this extended table. It identifies the next
;extended partition. Or, if zero, ends the chain.
;--------------------------------------------------------------
CMP BYTE PTR [SI+4],0 ;0 = end of chain
JNE M_3A
POP SI ;Restore pointer
;--------------------------------------------------------------
;Back the pointer up by two entries. The main partition table is
;normally allocated in reverse, so this prints them out in correct
;order.
;--------------------------------------------------------------
M_4A:
SUB SI,32 ;Back up to prev part
INC BP ;Partition counter
CMP BP,4 ;Only 4 of them
JA M_4B
JMP M_2A
M_4B:
;--------------------------------------------------------------
;Move to the next hard disk if present.
;--------------------------------------------------------------
INC BYTE PTR [DISK] ;Change disk number
INC BYTE PTR [DISK$] ;Change string
JMP M_1

MAIN ENDP

;================================================= ===========
;SHOW_PART - Decode the contents of a partition table entry.
;--------------------------------------------------------------
;Entry:
; DS:SI -> second byte of the partition entry
; ES:DI -> destination spot in output string
;Exit
; BX = partition's type code
;--------------------------------------------------------------
SHOW_PART PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
;--------------------------------------------------------------
;Get the starting head, sector, and cylinder.
;--------------------------------------------------------------
MOV CX,2 ;Loop twice
SP_2C:
LODSB ;Starting head
CALL HEX2 ;2 digits
INC DI ;Skip 1

LODSB ;Starting sector
PUSH AX ;(Save upper two bits)

AND AL,03FH ;Use bottom 6 bits
CALL HEX2 ;2 digits
INC DI ;Skip 1

POP AX ;Get back register

MOV AH,AL ;Put in upper byte
ROL AH,1 ;Shift to lower 2 bits
ROL AH,1
AND AH,03H ;Mask them off
LODSB ;Lower 8 bits of cyl #
CALL HEX3
ADD DI,2 ;Skip 2

LODSB ;First time get part
PUSH AX ;type and save it

LOOP SP_2C

POP AX ;Discard value
DEC SI ;Undo read
;--------------------------------------------------------------
;Skip the starting sector number. Get the lenght of the partition and
;display as total sectors.
;--------------------------------------------------------------
ADD SI,4 ;Skip starting sector

LODSW ;Get # sects lo word
MOV DX,AX ;Save it
LODSW ;Get # sects hi word
MOV BX,AX ;Save it

CALL HEX4 ;Display hi word
MOV AX,DX
CALL HEX4 ;Display lo word

ADD DI,2 ;Skip ahead
;--------------------------------------------------------------
;The program assumes that each partition is no larger than 9999 MB.
;This translates to 137800h sectors. When divided by 13 (Dh) to get
;megabytes, the result is never larger than 270F sectors, which fits
;in a single word.
;--------------------------------------------------------------
ADD DX,1023 ;Round up BX:DX
ADC BX,0 ;to next larger MB

MOV CL,5 ;(shift coupt)
ROL DX,CL ;Save upper 5 bits
AND DX,1FH ;and mask off

SHL BX,CL ;bits to upper part
OR DX,BX ;and combine

MOV AX,DX
CALL DEC4AX ;Show AX as 4 decidigs
ADD DI,2 ;Skip ahead
;--------------------------------------------------------------
;Display the partition code.
;--------------------------------------------------------------
POP BX ;Retrieve type
MOV AL,BL ;Put in AL
CALL HEX2 ;Decode it
;--------------------------------------------------------------
;Display the string.
;--------------------------------------------------------------
MOV AH,9 ;Display string
MOV DX,OFFSET PDATA$ ;Show data
INT 21H ;thrn DOS
;--------------------------------------------------------------
;Retrieve the partition type and decode it.
;--------------------------------------------------------------
MOV AH,BL ;Put type in AH
PUSH SI ;Save pointer to buffer
MOV SI,OFFSET PARTID$ ;Search table
SP_3A:
LODSB ;Read type from table
CMP AH,AL ;Match to table?
JE SP_3B

OR AL,AL ;If not found, unknown
JE SP_3B

MOV CX,80 ;Large number of bytes
MOV AL,"$" ;Look for string end
SCASB ;Scan it
JMP SP_3A
SP_3B:
MOV AH,9 ;Display string
MOV DX,SI ;Show partition type
INT 21H ;thrn DOS

MOV AH,9 ;Display string
MOV DX,OFFSET CRLF$ ;Newline
INT 21H ;thrn DOS

POP SI ;Restore buf pointer

RET

SHOW_PART ENDP

;================================================= ==========
;HEX4 - Display the AX register as 4 hex digits.
;Store the characters at ES:DI.
;--------------------------------------------------------------
HEX4 PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

PUSH AX

MOV AL,AH
CALL HEX2

POP AX
CALL HEX2
RET

HEX4 ENDP

;================================================= ==========
;HES3 - Convert upper 12 bits of the AX register to 3 hex digits.
;Store the characters at ES:DI.
;--------------------------------------------------------------
HEX3 PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

PUSH AX ;Save AL

MOV AL,AH ;Get upper digit
CALL H2C ;store it

POP AX ;Restore AL
CALL HEX2
RET

HEX3 ENDP

;================================================= ==========
;HEX2 - STORE 2 HEX DIGITS TO ES:DI
;AX destroyed. Other registers preserved.
;--------------------------------------------------------------
HEX2 PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

PUSH AX ;Save register

PUSH CX
MOV CL,4
SHR AL,CL ;Get high 4 bits
POP CX

CALL H2C ;Write them
POP AX ;Get value back

AND AL,0FH ;Grab lower 4 bits
H2C:
ADD AL,90H ;Convert AL to ASCII
DAA
ADC AL,40H
DAA
STOSB

RET

HEX2 ENDP

;--------------------------------------------------------------
;DEC4AX - Convert AX to 4 decimal digits and store at ES:DI.
;--------------------------------------------------------------
DEC4AX PROC NEAR
ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG

PUSH BX
PUSH CX
PUSH DX

MOV BX,4 ;Digit count
MOV CX,10 ;Divisor
D4_1:
SUB DX,DX ;Clear DX
DIV CX ;AX=quotient, DX=rem
OR DL,"0" ;Make digit

MOV BYTE PTR [BX+DI-1],DL ;Save digit
DEC BX
JNZ D4_1

ADD DI,4

POP DX
POP CX
POP BX

RET

DEC4AX ENDP

;--------------------------------------------------------------
;The program requires that 1024 bytes of memory be available in the
;segment after the end of the program code.
;--------------------------------------------------------------
BUF EQU $

CSEG ENDS
END ENTPT

Best Programmer
شنبه 18 بهمن 1382, 10:47 صبح
اینم برای اینکه از سکتور ها بخوانی و بنویسی. :)


.MODEL SMALL

.DATA

EXTRN SECTOR:BYTE
EXTRN DISK_DRIVE_NO:BYTE
EXTRN CURRENT_SECTOR_NO:WORD

.CODE

PUBLIC PREVIOUS_SECTOR
EXTRN INIT_SEC_DISP:PROC, WRITE_HEADER:PROC
EXTRN WRITE_PROMPT_LINE:PROC
.DATA
EXTRN CURRENT_SECTOR_NO:WORD, EDITOR_PROMPT:BYTE
.CODE
;-----------------------------------------------------------------------;
; This procedure reads the previous sector, if possible. ;
; ;
; Uses: WRITE_HEADER, READ_SECTOR, INIT_SEC_DISP ;
; WRITE_PROMPT_LINE ;
; Reads: CURRENT_SECTOR_NO, EDITOR_PROMPT ;
; Writes: CURRENT_SECTOR_NO ;
;-----------------------------------------------------------------------;
PREVIOUS_SECTOR PROC
PUSH AX
PUSH DX
MOV AX,CURRENT_SECTOR_NO ;Get current sector number
OR AX,AX ;Don't decrement if already 0
JZ DONT_DECREMENT_SECTOR
DEC AX
MOV CURRENT_SECTOR_NO,AX ;Save new sector number
CALL WRITE_HEADER
CALL READ_SECTOR
CALL INIT_SEC_DISP ;Dispaly new sector
LEA DX,EDITOR_PROMPT
CALL WRITE_PROMPT_LINE
DONT_DECREMENT_SECTOR:
POP DX
POP AX
RET
PREVIOUS_SECTOR ENDP


PUBLIC NEXT_SECTOR
EXTRN INIT_SEC_DISP:PROC, WRITE_HEADER:PROC
EXTRN WRITE_PROMPT_LINE:PROC
.DATA
EXTRN CURRENT_SECTOR_NO:WORD, EDITOR_PROMPT:BYTE
.CODE
;-----------------------------------------------------------------------;
; Reads the next sector. ;
; ;
; Uses: WRITE_HEADER, READ_SECTOR, INIT_SEC_DISP ;
; WRITE_PROMPT_LINE ;
; Reads: CURRENT_SECTOR_NO, EDITOR_PROMPT ;
; Writes: CURRENT_SECTOR_NO ;
;-----------------------------------------------------------------------;
NEXT_SECTOR PROC
PUSH AX
PUSH DX
MOV AX,CURRENT_SECTOR_NO
INC AX ;Move to next sector
MOV CURRENT_SECTOR_NO,AX
CALL WRITE_HEADER
CALL READ_SECTOR
CALL INIT_SEC_DISP ;Display new sector
LEA DX,EDITOR_PROMPT
CALL WRITE_PROMPT_LINE
POP DX
POP AX
RET
NEXT_SECTOR ENDP


PUBLIC READ_SECTOR
;-----------------------------------------------------------------------;
; This procedure reads one sector (512 bytes) into SECTOR. ;
; ;
; Reads: CURRENT_SECTOR_NO, DISK_DRIVE_NO ;
; Writes: SECTOR ;
;-----------------------------------------------------------------------;
READ_SECTOR PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AL,DISK_DRIVE_NO ;Drive number
MOV CX,1 ;Read only 1 sector
MOV DX,CURRENT_SECTOR_NO ;Logical sector number
LEA BX,SECTOR ;Where to store this sector
INT 25h ;Read the sector
POPF ;Discard flags put on stack by DOS
POP DX
POP CX
POP BX
POP AX
RET
READ_SECTOR ENDP


PUBLIC WRITE_SECTOR
;-----------------------------------------------------------------------;
; This procedure writes the sector back to the disk. ;
; ;
; Reads: DISK_DRIVE_NO, CURRENT_SECTOR_NO, SECTOR ;
;-----------------------------------------------------------------------;
WRITE_SECTOR PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AL,DISK_DRIVE_NO ;Drive number
MOV CX,1 ;Write 1 sector
MOV DX,CURRENT_SECTOR_NO ;Logical sector
LEA BX,SECTOR
INT 26h ;Write the sector to disk
POPF ;Discard the flag information
POP DX
POP CX
POP BX
POP AX
RET
WRITE_SECTOR ENDP


END


Developer Programmer
شنبه 18 بهمن 1382, 12:17 عصر
دوست عزیز ممنون از کد های ارسالیت که واقعا بدردم خورد و مدتها دنبالش بودم
اما آنچیزی که من ذر مورد هارد دیسک پرسیده بودم "پارک" کردن هارد دیسک بمنزله خاموش کردن بود نه "حذف" فایل :موافق:

Best Programmer
شنبه 18 بهمن 1382, 12:27 عصر
اوه اصلا حواسم به پارک نبود. صبر کن . من یه مثالی داشتم.....!!!

Best Programmer
سه شنبه 21 بهمن 1382, 13:39 عصر
اقا ببخشید که یه کم طول کشید.


;*************************
;* *
;* PARKING.ASM *
;* *
;*************************

;After typing the list
;enter the following
;commands.
;
;MASM PARKING;
;LINK PARKING;
;EXE2BIN PARKING PARKING.COM
;DEL PARKING.EXE
;
;*************************
CODE SEGMENT PARA 'CODE'
ORG 100h
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
START: JMP INSTALLATION

MAXTI EQU (10*18)
OLD_INT13 DD(?)
OLD_INT1C DD(?)
COUNTER DW(0)
PARKED DB(0)
;---------------------------
NEW_INT13 PROC FAR
PUSHF
CMP DL,80H
JB IMM13
MOV CS:COUNTER,0
MOV CS:PARKED,0
IMM13: POPF
JMP CS:[OLD_INT13]
NEW_INT13 ENDP
;-----------------------------
NEW_INT1C PROC FAR
JMP SHORT ROUTINE
DB "DMTP"
ROUTINE: PUSHF
CMP CS:COUNTER,MAXTI
JB IMM1C
CMP CS:PARKED,1
JE IMM1C
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AL,20H
OUT 0A0H,AL
OUT 020H,AL
MOV AH,08H
MOV DL,80H
INT 13H
MOV BL,DL
ADD BL,7FH
PARKLOOP: MOV AH,08H
MOV DL,BL
INT 13H
MOV AH,0CH
MOV DL,BL
INT 13H
DEC BL
CMP BL,7FH
JNE PARKLOOP
MOV CS:PARKED,1
POP DX
POP CX
POP BX
POP AX
IMM1C: INC CS:COUNTER
POPF
JMP CS:[OLD_INT1C]
NEW_INT1C ENDP
;--------------------------------
INSTEND EQU THIS BYTE
INSTALLM DB 13,10,"PARKING V1.0 (C)",13,10,"$"
ENTFERNT DB 13,10,"PARKING V 1.0 is "
DB "removed.",13,10,"$"
;---------------------------------
INSTALLATION PROC NEAR
MOV AX,351CH
INT 21H
CMP WORD PTR ES:[BX+2],"MD"
JNE INSTALL
CMP WORD PTR ES:[BX+4],"PT"
JNE INSTALL
LDS DX,DWORD PTR ES:OLD_INT13
MOV AX,2513H
INT 21H
LDS DX,DWORD PTR ES:OLD_INT1C
MOV AX,251CH
INT 21H
MOV BX,ES
MOV ES,ES:[2CH]
MOV AH,49H
INT 21H
MOV ES,BX
MOV AH,49H
INT 21H
PUSH CS
POP DS
MOV DX,OFFSET ENTFERNT
MOV AH,09H
INT 21H
MOV AX,4C00H
INT 21H
INSTALL: MOV WORD PTR OLD_INT1C+2,ES
MOV WORD PTR OLD_INT1C,BX
MOV AX,3513H
INT 21H
MOV WORD PTR OLD_INT13+2,ES
MOV WORD PTR OLD_INT13,BX
MOV DX,OFFSET NEW_INT13
MOV AX,2513H
INT 21H
MOV DX,OFFSET NEW_INT1C
MOV AX,251CH
INT 21H
MOV DX,OFFSET INSTALLM
MOV AH,09H
INT 21H
MOV DX,OFFSET INSTEND
MOV CL,4
SHR DX,CL
INC DX
MOV AX,3100H
INT 21H
INSTALLATION ENDP
;------------------------------------------
CODE ENDS
END START

البته مطمپن نیستم که ایا این کد درست هست یا نه. :oops:

Vahab
جمعه 04 اردیبهشت 1383, 13:19 عصر
:flower: :flower: :flower:

A_2006
جمعه 06 اردیبهشت 1392, 18:50 عصر
شیر بخور خوشمزه دونه دونه به من میگن a_2006