Sign in to follow this  
Followers 0
Lattis2003

SATA Manufactor Serial Number

13 posts in this topic

I am calling the compiled version of this code to get the SATA hard drive manufactors serial number. WMI does not get the serial number under Windows XP for SATA. I have searched the forums for a way better way to get the serial numbers with no luck for the SATA drives without 3rd party tools. This is the C++ code i am using.

Is it possible to convert the code to Autoit.

C++ Code

Any suggestions welcomed.

Thanks

2006_06_29_150445_HardwareSerialHDD.zip

Share this post


Link to post
Share on other sites



I hate looking at C++ code. I am so lost without dollar signs in my identifiers and my function names highlighted.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi!

I looked at the code and I think it's possible.

Things to use:

_WinAPI_CreateFile()

DllCalls + DllStructs

MSDN digging.

@weaponx

That's the way a true php/autoit developer speaks :P

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I started working on the code but ran intro some problems, but it's a start at least:

#include <WinAPI.au3>
#include <array.au3>
Global Const $GENERIC_READ=2147483648
Global Const $GENERIC_WRITE=1073741824
Global Const $FILE_SHARE_READ=1
Global Const $FILE_SHARE_WRITE=2
Global Const $OPEN_EXISTING=3
Global Const $IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS=5636096

Local $szVolumeLetter="C"
Local $szPhysicalDrive="\\.\"&$szVolumeLetter&":"

$call=DllCall("Kernel32.dll","ptr","CreateFile","str",$szPhysicalDrive,"dword",BitOr($GENERIC_READ,$GENERIC_WRITE),"dword", _ 
                BitOr($FILE_SHARE_READ,$FILE_SHARE_WRITE),"ptr",Chr(0),"dword",$OPEN_EXISTING,"dword",0,"ptr",Chr(0))

$hPhysicalDriveIOCTL=$call[0]


$VOLUME_DISK_EXTENTS=DllStructCreate("dword NumberOfDiskExtents;dword DiskNumber;int64 StartingOffset;int64 ExtentLength;")

$call=DllCall("Kernel32.dll","int","DeviceIoControl","ptr",$hPhysicalDriveIOCTL,"dword",$IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, _ 
                "ptr",Chr(0),"dword",0,"ptr",DllStructGetPtr($VOLUME_DISK_EXTENTS),"dword",DllStructGetSize($VOLUME_DISK_EXTENTS), _ 
                "dword*",0,"ptr*",Chr(0))

MsgBox(0,"",_WinAPI_GetLastErrorMessage())
_ArrayDisplay($call)

It says that the handle is invalid.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I don't understand this syntax:

SENDCMDINPARAMS InParams = {
                IDENTIFY_BUFFER_SIZE, { 0, 1, 1, 0, 0, ((vdExtents.Extents[0].DiskNumber & 1) ? 0xB0 : 0xA0),
                ((gvopVersionParams.bIDEDeviceMap >> vdExtents.Extents[0].DiskNumber & 0x10) ? ATAPI_ID_CMD : ID_CMD) },
                (BYTE)vdExtents.Extents[0].DiskNumber
            };

Specifically SENDCMDINPARAMS InParams = {...}

Is this the shorthand way of defining a struct?

Share this post


Link to post
Share on other sites

I don't understand this syntax:

SENDCMDINPARAMS InParams = {
                 IDENTIFY_BUFFER_SIZE, { 0, 1, 1, 0, 0, ((vdExtents.Extents[0].DiskNumber & 1) ? 0xB0 : 0xA0),
                 ((gvopVersionParams.bIDEDeviceMap >> vdExtents.Extents[0].DiskNumber & 0x10) ? ATAPI_ID_CMD : ID_CMD) },
                 (BYTE)vdExtents.Extents[0].DiskNumber
             };

Specifically SENDCMDINPARAMS InParams = {...}

Is this the shorthand way of defining a struct?

Yes, just like when you initialize an array in autoit with the Dim $array[3]=[1,2,3] syntax.

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Yes, just like when you initialize an array in autoit with the Dim $array[3]=[1,2,3] syntax.

I wish there was a C++ standard offline help file.

Share this post


Link to post
Share on other sites

I wish there was a C++ standard offline help file.

@monoceres & weaponx

Thanks for your help. I will continue to look at getting this working. Reading C++ stuff and trying to understand the code is to

tough for me. I just can't put the logic to it yet.

Share this post


Link to post
Share on other sites

I've been using the kernel32.dll to obtain Identify data from hard drives for some time now. I've gone back and forth on posting it in the example forum, and have always chosen not to because how I use it, we can send almost any command directly to a drive. In fact I have killed more then one drive using this script.

That being said I will give the script out on a very limited basis.

Lattis2003, weaponx and monoceres if you want the script PM me and I'll send it to you.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Hi.

I've been using the kernel32.dll to obtain Identify data from hard drives for some time now.

[snip]

In fact I have killed more then one drive using this script.

Admin privilges are required, are they??

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Admin privilges are required, are they??

Regards, Rudi.

Yes Admin Privileges are required through #RequireAdmin, but I, and many other people, run as admin on our systems. I really don't want people who are not exactly sure what they can loose to use these scripts and then blame me when they loose all their data.


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@ Kerros

That might be useful to me. I use really old, damaged drives (<2gb and they start off waterlogged, one time coated in mud) and a script that would allow me that sort of control over the drives would be good to experiment with. (By the way, I use a single, non connected computer for testing and running programmes with an OS and harddrive that could both be ruined, erased, foramatted and I would be fine as I store nothing on it other than the software I'm testing. Another computer is used for internet and an external harddrive for backups.) Would I be able to get to get a copy of that script if I didn't give anyone else a copy?

Edited by TheDarkEngineer

Trust me to make SkyNet with AutoIt...

Share this post


Link to post
Share on other sites

I've been using the kernel32.dll to obtain Identify data from hard drives for some time now. I've gone back and forth on posting it in the example forum, and have always chosen not to because how I use it, we can send almost any command directly to a drive. In fact I have killed more then one drive using this script.

That being said I will give the script out on a very limited basis.

Lattis2003, weaponx and monoceres if you want the script PM me and I'll send it to you.

PM sent.

Always good to have different methods. Looking forward to see what you have done.

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0