Re: ntvdm encountered a hard error
- From: "Cranky" <spamtrap@xxxxxxxxxx>
- Date: 30 Oct 2006 11:23:03 -0800
On Oct 30, 2:06 pm, "Chris Saunders" <spamt...@xxxxxxxxxx> wrote:
On Windows I believe you can use CreateFile and DeviceIoControl for this.
If you would like to try Chris's suggestion, something like :-
FASM
===================
format PE GUI 4.0
include 'win32a.inc'
FSCTL_LOCK_VOLUME=090018h
FSCTL_UNLOCK_VOLUME=09001Ch
;; Open a handle to the device
invoke
CreateFile,FName,GENERIC_READ,FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0
;Just reading, not writing
cmp eax,-1
;Check if operation okay.
je exit
;Operation failed.
mov [FHandle],eax
;Store handle
;; Lock Drive
invoke
DeviceIoControl,[FHandle],FSCTL_LOCK_VOLUME,NULL,0,NULL,0,lpBytesReturned,NULL
cmp eax,1
jne exit
;; Set the file pointer offset to the BOF. ;File is
the Disk in this case
invoke SetFilePointer,[FHandle],0,DToMH,FILE_BEGIN ;move
pointer 0 bytes from beginning
cmp eax,-1
je exit ;more error handling
to be done..
;; Read data from file
invoke ReadFile,[FHandle],FileData,FileDataL,FileDataW,0
cmp eax,0
je exit ;say no more..
;; Close the file
invoke CloseHandle,[FHandle] ;Should cause
unlocking too :-)
;; Message Box if it worked.
invoke MessageBox,0,FName,Success,MB_OK
exit:
invoke ExitProcess,0
Success db 'Success',0 ;Text for the message
box
DToMH dd 0h ;SetFilePointer 'High
dword' bytes to move
FHandle dd 0h
FName db '\\.\PHYSICALDRIVE0',0 ;First Harddisk, use
'\\.\C:' etc. for logical drives
FileData db 512 dup (0) ;Buffer for sector
read
FileDataL = $ - FileData
FileDataW dd 0h ;Actual number of
Bytes read
lpBytesReturned dd 0
; import data in the same section
data import
library kernel32,'KERNEL32.DLL',user32,'USER32.DLL'
import kernel32,\
CreateFile,'CreateFileA',\
DeviceIoControl,'DeviceIoControl',\
ReadFile,'ReadFile',\
CloseHandle,'CloseHandle',\
SetFilePointer,'SetFilePointer',\
ExitProcess,'ExitProcess'
import user32,\
MessageBox,'MessageBoxA'
end data
===================
Far from complete and a bit messy, but hopefully should give you some
pointers.
.
- References:
- ntvdm encountered a hard error
- From: Galbu
- Re: ntvdm encountered a hard error
- From: Frank Kotler
- Re: ntvdm encountered a hard error
- From: Galbu
- Re: ntvdm encountered a hard error
- From: Frank Kotler
- Re: ntvdm encountered a hard error
- From: Chris Saunders
- ntvdm encountered a hard error
- Prev by Date: Get the FAQs
- Next by Date: Re: Best X86 assembler for Unix?
- Previous by thread: Re: ntvdm encountered a hard error
- Next by thread: Re: ntvdm encountered a hard error
- Index(es):
Relevant Pages
|