Thread: BIOS Calls

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    3

    BIOS Calls

    Hi there.

    I would love to learn C some day, I program in many other languages, QBASIC..VB...a TOUCH of C, XBASIC, GFA BASIC, JAVA (a little), javascript, a bit of Asm etc...

    OK, I making this important program in VB and I need to know this:

    can someone, kindly, make me a C DLL file which will do the following:

    go into the BIOS and get the capacity of the HDD that is on the Primary Master Channel?

    that's all!!!

    WHY? well, the program I am making is needing the HDD capacity in order to perform some partition calculations. The HDD MAY be unpartitioned so I need it to get the value from the BIOS, is it possible?

    I would appreciate this, I would also like to know what parameters or how to get the output of this DLL file into VB, so VB can asscociate/take the capacity value that this DLL file has got from the BIOS so I can continue running other code/instructions in the VB MAIN program.

    Please, I would appreciate this, just a simple task.

    Thank-you in advanced

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    This forum isn't here for people to ask for their work to be done for them, it's here as a helper for those learning the language.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    yes I know and already do relize this but it is very difficult for me as I don't know C and also, very hard for a first time programmer in C who doesn't even know what he is doing. I just thought that someone somewhere may have already done it or may have some guidelines or something that i may have or follow.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    You cant make BIOS calls in windows from a user mode app...

    You can use a published API.......lookup DeviceIoControl on MSDN....

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    hmmm....not quite exactly what i was looking for, but thank-u. I'm sure there must be a way to call BIOS functions etc... from a win32 APP? Surely? :-s

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Tech
    hmmm....not quite exactly what i was looking for, but thank-u. I'm sure there must be a way to call BIOS functions etc... from a win32 APP? Surely? :-s
    Driver prog.....or a gate hack......other than you use the API......the simple point is that you dont need the BIOS....

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    A breif play around with the APIs led to this

    Code:
    #include <windows.h>
    
    //Because I have an old version of the SDK on this com..
    //...I have to define this stuff
    typedef struct _DISK_GEOMETRY_EX {  
    	DISK_GEOMETRY Geometry;  
    	LARGE_INTEGER DiskSize;  
    	BYTE Data[1];
    } DISK_GEOMETRY_EX;
    
    #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX  \
    	CTL_CODE(IOCTL_DISK_BASE, 0x0028, \
    	METHOD_BUFFERED, FILE_ANY_ACCESS)
    
    //End definitions
    
    int main()
    {
    
    	DISK_GEOMETRY_EX gde = {0};
    	DWORD dwDummy;
    	char szBuff[50];
    
    	HANDLE hDisk = CreateFile("\\\\.\\PHYSICALDRIVE0",
    		GENERIC_READ | GENERIC_WRITE,
    		FILE_SHARE_READ | FILE_SHARE_WRITE,
    		0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
    	if(hDisk == INVALID_HANDLE_VALUE)
    	{
    		MessageBox(0,"Unable to get Handle",0,MB_OK);
    		return 1;
    	}
    	if(DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
    		0,0,&gde,sizeof(gde),&dwDummy,0))
    	{
    		wsprintf(szBuff,"Number of bytes on disk - %I64d",gde.DiskSize);
    		MessageBox(0,szBuff,"",MB_OK);		
    		
    	}
    	else
    	{
    		MessageBox(0,"Unable to communicate with device",0,MB_OK);
    	}
    
    	CloseHandle(hDisk);
    	return 0;
    }

    This should work for Windows XP...and maybe Windows 2000 as well...unfortunately I cant test it properly as none of my disks has more than 1 partition at the moment....but if that isnt the proper call, I guess you could achivie this a similar way

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Fordy hit the nail on the head for you need. Assuming you know how to call Win32 API's from VB (I don't), you can start here and then read this (look down to "Physical Disks and Volumes" to get a handle to a disk (formatted or not)).

    MSDN is your resource for the Win32 API. After reviewing (and trying) those, post addition questions in the Windows programming board if you need additional clarification on the API's.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Lost BIOS menu options?
    By PJYelton in forum Tech Board
    Replies: 3
    Last Post: 11-14-2004, 08:23 AM
  3. Which I/O calls do you use the most?
    By _Elixia_ in forum Tech Board
    Replies: 10
    Last Post: 07-11-2003, 11:58 AM
  4. Bios upgrade-dell latitude
    By GanglyLamb in forum Tech Board
    Replies: 4
    Last Post: 06-18-2003, 01:55 PM
  5. Bios
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 03-12-2002, 07:18 AM