Yes
Try using typecasts to unsigned int when passing in the arguments.
Code:printf("blah... %02X %02X %02X\n", (unsigned int)_boot.jumpCode[0] ...);
still not working... is there anywhere I can get a free version of the Borland C Compiler? Either that or relatively cheaply?
No idea, try Google. I use Microsoft Visual C++ 2008 Express Edition. (Also free, great for students like me.)
Is Visual Studio compatible with 16bit DOS environments? I only ask because you can see I am doing low level operations that will in the end take me on to HD's which cannot be directly accessed in the Windows environments (XP or Vista)
It depends on what you mean by "cannot be directly accessed". There are ways of getting around certain blocks without resorting to 16-bit stuff, unless you're talking about ancient hard drives from the 80s or something.
You've seen the ASM code i have used, by switching the drive (DL) to 0x80 (The main hard drive in the PC) you get an automatic warning from windows saying "An application has tried to directly access the hard drive, which cannot be supported"
This won't work on hard drives, since they most likely use NTFS (older ones might use FAT32), and those have different boot sector layouts. And how exactly did you try accessing the hard drive beforehand? ReadFile worked for me.
Code:#include <windows.h> /*stuff here....*/ #pragma pack(push,1) typedef struct { /*definition here*/ }BS; #pragma pack(pop) BS mbr; DWORD dwBytesRead = 0; HANDLE hDrive = CreateFile( "\\\\.\\C:", /*file path*/ GENERIC_READ, /*requested access*/ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /*sharing*/, NULL, /*use default security descriptor*/, OPEN_EXISTING, /*don't create*/ 0, /*attributes - don't change any*/ NULL /*file to use as template. ignore this.*/ ); if(!ReadFile(hDrive,&mbr,sizeof(BS),&dwBytesRead,NULL)) { /*handle errors here*/ } /*close handle when done*/ CloseHandle(hDrive);
Last edited by dargueta; 03-09-2009 at 01:30 PM. Reason: Fixed errors
Basically i'm writing a program that can access the hard drive directly and write data into the slack space but i need to obtain the disk geometry from the boot sector first. At the moment i'm working on obtaining the data from the boot sector on a FAT disk but i have the relevant information for doing this with an NTFS disk as well.
This sounds suspiciously like a boot sector virus. Try my suggestion above.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks