Virus 版 (精华区)
发信人: Kernel (Kermit), 信区: Virus
标 题: WinNT/2000下的绝对磁盘的读写(zz)
发信站: 哈工大紫丁香 (Sun Mar 14 20:27:20 2004), 站内信件
;WinNT/2000下的绝对磁盘的读写
;具体实现如下:
;*****************************************************************
;名 称:WinNT/2000下的绝对磁盘读写
;编写环境: Win2000,Masm32v6
;完成日期: 2003/04/24
;版 本: v1.1
;作 者: haiwei(E-Mail:haiwei_1111@163.com)
;*****************************************************************
.386p
.Model Flat, StdCall
Option Casemap :None
;___________________________________________________________________________
Include windows.inc
Include user32.inc
Include kernel32.inc
IncludeLib user32.lib
IncludeLib kernel32.lib
.data ;数据段
szFilename db '\\.\C:',0; 打开D盘可以用(\\.\D:)以此类推
align 4
Buffer db 4096 dup(0)
mFile dd 0
Readed dd 0
szCap db 'WindowNT/2000中读写物理磁盘',0
ErrCreate db '建立文件错误',0
ErrRead db '读盘错误',0
ShowText db 4096*3 dup(0)
Digit db '0123456789ABCDEF' ; 数制转换表
.CODE
START:
invoke CreateFile,offset szFilename,GENERIC_READ,FILE_SHARE_READ OR FILE_
SHARE_WRITE,NULL,OPEN_EXISTING,NULL,NULL;打开C盘
mov [mFile],eax
cmp eax,INVALID_HANDLE_value
jnz read
push offset ErrCreate ;出错
call ShowError
read:
invoke ReadFile,mFile,offset Buffer,512,offset Readed,NULL
cmp eax,0
jnz show
push offset ErrRead
call ShowError
show:
mov Readed,512h
call ShowBuffer ;显示内容
invoke CloseHandle,mFile
invoke ExitProcess,0
ShowError proc message:dword
invoke MessageBox,NULL,message,offset szCap,MB_OK
cmp mFile,0
jz EndShow
invoke CloseHandle,mFile
EndShow:
invoke ExitProcess,0
ShowError endp
ShowBuffer proc
mov esi,offset Buffer
mov edi,offset ShowText
mov ebx,offset Digit
mov ecx,0
xor eax,eax
Again:
cmp [Readed],0
jz Ended
dec [Readed]
mov al,[esi]
push ax
shr ax,4
mov al,[ebx+eax]
mov BYTE ptr [edi],al
inc edi
pop ax
shl ax,12
shr ax,12
mov al,[ebx+eax]
mov BYTE ptr [edi],al
inc edi
mov BYTE ptr [edi],' '
inc edi
inc esi
inc ecx
cmp ecx,16
jnz Again
xor ecx,ecx
mov BYTE ptr [edi-1],13
jmp Again
Ended:
invoke MessageBox,NULL,addr ShowText,addr szCap,MB_OK
ret
ShowBuffer endp
END START
;请多多指教 :)
--
※ 来源:.哈工大紫丁香 bbs.hit.edu.cn [FROM: 219.82.103.154]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.422毫秒