Re: ntvdm encountered a hard error




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.

.



Relevant Pages

  • Re: debugging using tk.rb
    ... running the Pig Latin Generator from Dave's book: if I try to debug the pig method with ... ".w00000.w00004 invoke" ... def pig ... TkButton.new{text 'Exit'; command {proc exit}; pack ph} ...
    (comp.lang.ruby)
  • Re: Threads
    ... and the best way for me to detect what threads are hanging is to run application in Debug Mode and invoke a close event from your application. ... Public Property Salir as Boolean ... When i call "Join" method, the main thread wait to exit the others, but ... the worker process reads on a regular basis, don't allow the end user to exit until the threads are terminated. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: great MASM feature
    ... what will following INVOKE be compiled to: ... exit proto code:dword ... buf db 10 dup ...
    (alt.lang.asm)
  • Re: Fast UTF-8 strlen function
    ... main proc ... astr db "1234567890",0 ... invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED, ...
    (alt.lang.asm)