Harddisk manufacturing information library

Everything else that doesn't fall into one of the other PB categories.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

is there an update on this... or even better, has the source been released?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Here's a quote from the original library, maybe it helps...

The source code for the DLL mentioned is freeware and available on the site, maybe someone can built an internal library for Purebasic, would be nice.

There has also been an update on the 25th November 2003 :P
Included in this archive is an example of how to use these functions in PureBasic. This library was created in 100% C, and originated from the DiskId32 utility by WinSim Inc. (http://www.winsim.com/diskid32/diskid32.html). This library is freeware! This file must be included unaltered if you plan to redistribute the library.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

I second that, either an internal library for purebasic or a regular library (not dll) for linux and windows.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

If your using the HD serial number with a protection scheme, its best NOT to use the external DLL as it can simply be replaced by something faking the serial number.

Find a way to incorperate the check into your own code if using it for protection. :!:
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Revisiting This

Post by Straker »

Hi All,

I am posting on this topic because it is ALMOST what I need.

1) The links that Revolver for his library posted are no longer valid. Has/Can anyone mirror those if you downloaded them in 2003?

2) Revolver hasn't posted since 2003, so I don't even know if he is around anymore.

Here is what I am looking for:

This code works fine for finding HD Info/Serial number for Win98/Win2k/WinXP, however, you must be admin on Win2K/WinXP. I need this code for non-admins on Win2K/WinXP - does anyone have this?

More specifically, has anyone converted DISKID32 (see http://www.winsim.com/diskid32/diskid32.html) to PureBasic code?


Also, I am looking for this in PureBasic source code, no external DLLs as I need to compile it into my own EXE.

Anyone? Thanks in advance?

Here is the related link with similar code by Rings (again with the same issues regarding Admin on Win2K/WinXP):
viewtopic.php?p=28162#28162
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

Straker,

Found this in my folder of "Handy Files" (don't know who wrote it, but came from the forum).

Code: Select all

Structure IDEREGS 
    bFeaturesReg.b 
    bSectorCountReg.b 
    bSectorNumberReg.b 
    bCylLowReg.b 
    bCylHighReg.b 
    bDriveHeadReg.b 
    bCommandReg.b 
    bReserved.b 
EndStructure 
Structure SENDCMDINPARAMS 
    cBufferSize.l 
    irDriveRegs.IDEREGS 
    bDriveNumber.b 
    bReserved.b[3] 
    dwReserved.l[4] 
EndStructure 

Structure  DRIVERSTATUS 
    bDriveError.b 
    bIDEStatus.b 
    bReserved.b[2] 
    dwReserved.l[2] 
EndStructure 
Structure  SENDCMDOUTPARAMS 
    cBufferSize.l 
    DStatus.DRIVERSTATUS      
    bBuffer.b[512] 
EndStructure 


#DFP_RECEIVE_DRIVE_DATA = $7C088 

bin.SENDCMDINPARAMS 
bout.SENDCMDOUTPARAMS 



Procedure.s ChangeHighLowByte(Instring.s) 
;Change BIG-Little Endian 
sdummy.s="" 
L=Len(Instring) 
For I=1 To L Step 2 
If (I+1)<=L 
  sdummy.s=sdummy.s + Mid(Instring,I+1,1)+Mid(Instring,I,1)  
EndIf 
Next I 
ProcedureReturn sdummy.s 
EndProcedure 

;*****************************************************************
    mvarCurrentDrive=1 ;If you have more hard-disks change it here 
;*****************************************************************

hdh = CreateFile_("\\.\PhysicalDrive" + Str(mvarCurrentDrive),#GENERIC_READ | #GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE,0, #OPEN_EXISTING, 0, 0) 
If hdh  
        bin\bDriveNumber = mvarCurrentDrive 
        bin\cBufferSize = 512 
        
        If (mvarCurrentDrive & 1) 
          bin\irDriveRegs\bDriveHeadReg = $B0 
        Else 
          bin\irDriveRegs\bDriveHeadReg = $A0 
        EndIf 
        bin\irDriveRegs\bCommandReg = $EC 
        bin\irDriveRegs\bSectorCountReg = 1 
        bin\irDriveRegs\bSectorNumberReg = 1 
    
       br=0 
       Result=DeviceIoControl_( hdh, #DFP_RECEIVE_DRIVE_DATA, bin, SizeOf(SENDCMDINPARAMS), bout, SizeOf(SENDCMDOUTPARAMS), @br, 0) 
       If br>0 
        hddfr = 55:hddln = 40          : 
        Modell.s=ChangeHighLowByte(PeekS(@bout\bBuffer[0]+hddfr-1 ,hddln  ) ) 
        hddfr = 21:hddln = 20          : 
        Serial.s=Trim(ChangeHighLowByte(PeekS(@bout\bBuffer[0]+hddfr-1 ,hddln  ) )) 
        hddfr = 47:hddln = 8          
        Firmware.s=ChangeHighLowByte(PeekS(@bout\bBuffer[0]+hddfr-1 ,hddln  ) ) 
        MessageRequester("Info about your harddisk","Vendor & Model Number = "+Modell.s + Chr(13) +"Serial Number = "+Serial.s+ Chr(13)+"Firmware Version = "+Firmware ,0) 
       EndIf 
Else 
  Beep_(100,100) 
EndIf 
(Works for me on Win XP Pro (I've got admin rights, but I don't see where it would stall, if you didn't)

Hope it helps,
--blueb
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

blueb - thanks for taking the time to respond.

Unfortunately that code doesn't work on W2K/WXP unless you are an admin. I want to include code that can be used by non-admins as well to see this info.

Thanks again.
Post Reply