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 6073417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:16:07+00:00 2026-05-23T10:16:07+00:00

I am creating a program to populate a disk with a dummy file system.

  • 0

I am creating a program to populate a disk with a dummy file system.

Currently, I am writing files of variable sizes using WriteFile.

        WriteFile(hFile, FileData, i * 1024, &dwWrote, NULL);
        err = GetLastError();

err returns #1784 which translates to

The supplied user buffer is not valid for the requested operation. ERROR_INVALID_USER_BUFFER

So for the first 24 files, the write operation works. For file #25 on, the write operation fails.
The files are still created but the WriteFile function does not populate the files.

Any ideas on how to get past ERROR_INVALID_USER_BUFFER?

Every reference I can find to the error is limited to crashing programs and I cannot figure out how it relates to the issue I am experiencing.

EDIT:

FileData = (char *) malloc(sizeof(char) * (size_t)k * 1024);
memset(FileData, 245, sizeof(char) * (size_t)k * 1024);

FileData is set and allocated to the size of the maximum anticipate buffer.
i is the loop variable that iterates until it increments to the Maximum Size (k).

  • 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-23T10:16:08+00:00Added an answer on May 23, 2026 at 10:16 am

    My guess is that FileData is not large enough for you to write i * 1024 bytes from it. Is i the loop control variable for your list of files? If so, you need the write buffer FileData to grow 1K at a time as you loop through your files.

    This is an unusual construct. Are you sure the logic is correct here? Post more code (specifically, all usage of FileData and i) for better accuracy in the answers.

    Note that you should not always be checking GetLastError here – you need to check WriteFile‘s return code before you rely on that being meaningful. Otherwise you could be picking up an error from some unrelated part of your code – whatever failed last.

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

Sidebar

Related Questions

I'm creating a program in C# using System.Speech.Recognition that recognizes voice commands and translates
I am creating a program that will be installed using the .net installer project.
I have been tasked with creating a program what will create take files in
I'm creating a program that parses a log file for a user's name and
I'm writing a program to automatically populate a PDF form. It does so by
The program I am creating a program in which a method is using A
I'm creating a program with LWJGL and Maven, and I'm writing unit tests for
I am creating a program using Visual Basic 2010 Express . I want to
I am creating a program to copy a text file. I have a main.cpp
Possible Duplicate: Looping in a spiral I'm creating a program to populate a 3

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.