(this one returns 0) $hDrv = _WinAPI_CreateFileEx( "\\.\PhysicalDrive0", 0, 3, 0, 3, 0, 0) ; Returns 0 (this one returns null) $hDrv = DllCall('kernel32.dll', 'ptr', 'CreateFile', 'str', "\\.\PhysicalDrive0", 'dword', 0, 'dword', 3, 'ptr', 0, 'dword', 3, 'dword', 0, 'ptr', 0) ; Returns null (from WinAPIEx.au3) Func _WinAPI_CreateFileEx($sFile, $iCreation, $iAccess = 0, $iShare = 0, $iFlagsAndAttributes = 0, $tSecurity = 0, $hTemplate = 0) Local $Ret = DllCall('kernel32.dll', 'ptr', 'CreateFileW', 'wstr', $sFile, 'dword', $iAccess, 'dword', $iShare, 'ptr', DllStructGetPtr($tSecurity), 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'ptr', $hTemplate) If (@error) Or ($Ret[0] = Ptr(-1)) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_CreateFileEx
Drive handle via CreateFile
#1
Posted 19 February 2012 - 10:01 PM
#2
Posted 20 February 2012 - 07:45 AM
_WinAPI_CreateFileEx('.PhysicalDrive0', $OPEN_EXISTING, 0, BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE))
or
_WinAPI_CreateFileEx('.PhysicalDrive0', 3, 0, 3)
Edited by Yashied, 20 February 2012 - 07:46 AM.
iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper
Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | IconChooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | AITray UDF Library

#3
Posted 20 February 2012 - 09:53 AM
MSDN: CreateFile function
"dwDesiredAccess [in]
If this parameter is zero, the application can query certain metadata such as file, directory, or device attributes without accessing that file or device, even if GENERIC_READ access would have been denied."
"Physical Disks and Volumes
Direct access to the disk or to a volume is restricted. For more information, see "Changes to the file system and to the storage stack to restrict direct disk access and direct volume access in Windows Vista and in Windows Server 2008" in the Help and Support Knowledge Base at http://support.microsoft.com/kb/942448."
So querying device attributes with dwDesiredAccess = 0 will work without admin rights, whereas access to the content will require admin rights.
OS: Windows 7 - 64bit - Ultimate, AutoIt Version: 3.3.8.1, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...
AMT - Auto-Movie-Thumbnailer (2013-Mar-22)
COP - Color Picker (2009-May-21)
HMW - Hide my Windows (2012-Jan-02)
HRC - HotKey Resolution Changer (2012-May-16)
ICU - Icon Configuration Utility (2013-May-24)
SMF - Search my Files (2013-Apr-25) - THE file info and duplicates search tool
SSD - Set Sound Device (2011-Jan-15)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



