OK re: direct read/write to FLOPPY + WIN NT ? 
Author Message
 OK re: direct read/write to FLOPPY + WIN NT ?

Greetings Y'All

In a follow up to my requests for info on SURFACE ACCESS under WIN NT....

I can now declare that IN A DOS WINDOW - WINNT will allow direct access
to a Floppy that has been formatted in DOS (as opposed to NTFS)
when using a 16bit program compiled under dos-window dpmi etc.

I used the Absolute Write and Absolute Read interupts to do this
and the Norton Diskedit to inspect the surface using software that
isnt dependant on my ''assembler skills''

However - my very small skills in the win32 area keep returning with
''illegal instruction'' window which is a bit of a downer.

i'm halfway to what i wanted to do.
if i can get this bit going...the rest of the thing is frills and menus.

Thanks to do those who replied with suggestions - i'll continue
with my travels across the surface.

Paul
Dublin-Ireland



Mon, 29 Jul 2002 03:00:00 GMT  
 OK re: direct read/write to FLOPPY + WIN NT ?

says...

[ trying to read/write directly from/to a floppy ]

Quote:
> However - my very small skills in the win32 area keep returning with
> ''illegal instruction'' window which is a bit of a downer.

Here's some code that does a sector-by-sector copy of a floppy to a
disk file.  Writing to the floppy instead mostly means passing
GENERIC_WRITE instead of GENERIC_READ when you call CreateFile.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <string>
#include <iostream>

class copier {

    char *buffer;
    std::string source;
    DWORD size;

public:

    copier(std::string const &source_drive) {
        DWORD sectors_per_cluster;
        DWORD bytes_per_sector;
        DWORD free_clusters;
        DWORD total_clusters;

        source = source_drive;

        GetDiskFreeSpace(source.c_str(),
                        &sectors_per_cluster,
                        &bytes_per_sector,
                        &free_clusters,
                        &total_clusters);

        size = 10 * bytes_per_sector * sectors_per_cluster;

        buffer = new char[size];
    }

    ~copier() {
        delete [] buffer;
    }

    bool copy(std::string const &dest) {

        DWORD read, written;
        std::string full_name = "\\\\.\\" + source;

        HANDLE file = CreateFile(dest.c_str(), GENERIC_WRITE,
             0, NULL, CREATE_ALWAYS, 0, NULL);

        if ( INVALID_HANDLE_VALUE == file) {
            std::cerr << "Unable to open file.\n";
            return false;
        }

        std::cout << "Opening " << full_name.c_str() << std::endl;

        HANDLE disk = CreateFile(full_name.c_str(), GENERIC_READ,
            FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);

        if (INVALID_HANDLE_VALUE == disk) {
            std::cerr << "Unable to open disk.\n";
            return false;
        }

        int n = 0;
        do {
            std::cout << "\rCopying cluster # " << n;
            n+=10;
            ReadFile(disk, buffer, size, &read, NULL);
            WriteFile(file, buffer, read, &written, NULL);
        } while (read != 0);

        CloseHandle(disk);
        return true;
    }

Quote:
};

int main(int argc, char **argv) {

    if ( argc != 3 ) {
        std::cerr << "Usage: rawread drive: filename" << std::endl;
        return 1;
    }

    copier raw_disk(argv[1]);
    return !static_cast<int>(raw_disk.copy(argv[2]));

Quote:
}

--
    Later,
    Jerry.

The universe is a figment of its own imagination.



Tue, 30 Jul 2002 03:00:00 GMT  
 OK re: direct read/write to FLOPPY + WIN NT ?


: says...
:
: [ trying to read/write directly from/to a floppy ]
:
: > However - my very small skills in the win32 area keep returning with
: > ''illegal instruction'' window which is a bit of a downer.
:
: Here's some code that does a sector-by-sector copy of a floppy to a
[snip]

hmmmmm, will read this again - it looks good (!)

Thanks Jerry.



Wed, 31 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. direct read/write to FLOPPY + WIN NT ?

2. direct read/write to FLOPPY + WIN NT ?

3. OK re: direct read/write to FLOPPY + WIN NT ?

4. NT 4.0 and writing to floppy

5. Floppy read & write

6. How to read/write floppy disk through PORT ?

7. Code to Low-Level read/write to Floppy Disks

8. Toughie? Floppy read and DMA write problem

9. Need help reading/writing boot sector (floppy disk)

10. How to read/write floppy disk through PORT?

11. DMA and floppy reading/writing

12. Direct HW read/writes

 

 
Powered by phpBB® Forum Software