Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 720293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:44:30+00:00 2026-05-14T05:44:30+00:00

I wrote a disk utility that allowed you to erase whole physical drives. it

  • 0

I wrote a disk utility that allowed you to erase whole physical drives. it uses the windows file api, calling :

destFile = CreateFile("\\\\.\\PhysicalDrive1",
    GENERIC_WRITE,  FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL, OPEN_EXISTING,createflags, NULL);

and then just calling WriteFile, and making sure you write in multiples of sectors, i.e. 512 bytes.

this worked fine in the past, on XP, and even on the Win7 RC, all you have to do is make sure you are running it as an administrator.

but now I have retail Win7 professional, it doesn’t work anymore! the drives still open fine for writing, but calling WriteFile on the successfully opened Drive now fails!

does anyone know why this might be? could it have something to do with opening it with shared flags? this is always what I have done before, and its worked. could it be that something is now sharing the drive? blocking the writes? is there some way to properly “unmount” a drive, or at least the partitions on it so that I would have exclusive access to it?

some other tools that used to work don’t any more either, but some do, like the WD Diagnostic’s erase functionality. and after it has erased the drive, my tool then works on it too! leading me to believe there is some “unmount” process I need to be doing to the drive first, to free up permission to write to it.

Any ideas?

Update:

the error code returned from WriteFile is ‘5’, ERROR_ACCESS_DENIED
but again, if I ‘erase’ the drive first using WD Diag, I can then access and write to the drive fine. when I initialize the drive again, and give it a partition, I go back to getting the ERROR_ACCESS_DENIED error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:44:30+00:00Added an answer on May 14, 2026 at 5:44 am

    This is almost certainly related to preventing the attack found against driver signing by changing sectors in the page file. It will prevent writing to the areas of the disk containing partitions.

    See http://msdn.microsoft.com/en-us/library/aa365747%28VS.85%29.aspx and look at the information starting with the text “If you write directly to a volume that has a mounted file system”, basically you have to lock the disk’s volumes in order to write to their sectors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote some code that stores on the disk some RTP packets with H264
I wrote a script to fill a file for some Disk capacity testing. Could
My task is to track adding and deleting disk drives from windows service. I
I have a client node writing a file to a hard disk that is
I have to write a series of characters in the disk file and I
I read that the Hadoop Map tasks write their output to local disk. Suppose
I recently wrote a simple bootloader in assembly for floppy disk booting. I used
I wrote a Program that backup SQL Databases using SMO Library on .net ,
I wrote a program in C which has a function that processes files which
I wrote a little Python program that looks though a directory (and its subdirectories)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.