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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:56:41+00:00 2026-06-14T19:56:41+00:00

Though all arguments are correct, it returns the right value of items read, the

  • 0

Though all arguments are correct, it returns the right value of items read, the function fread_s doesn’t story anything in “bytes” it’s empty. It’s also empty when I swap 10485760 & 1. Does anyone know what causes this problem? There are no problems with the file at all.

float EncryptBig(CRYPTIN* handle)
{
    int i, index = 0;
    float calc;
    char* bytes;

    i = (handle->size - handle->huidig);
    if ((i-10485760) < 0)
    {
        bytes = (char*)malloc(i);
        if (bytes == NULL)
        {
            fcloseall();
            free(handle);
            return 100.0f;
        }

        fread_s(&bytes, i, 1, i, handle->bestand); // Here and down below
        fclose(handle->bestand);

        for (index = 0; index < i; index++)
        {
            __asm
            {
                mov         eax, dword ptr [bytes]  
                add         eax, dword ptr [index]  
                mov         cl, byte ptr [eax]
                xor         cl, 101
                xor         cl, 53
                not         cl
                mov         byte ptr [eax], cl 
                mov         eax, dword ptr [index]  
                add         eax, 1  
                mov         dword ptr [index], eax
            }
        }

        fwrite(bytes, 1, i, handle->nieuwbstnd);
        fclose(handle->nieuwbstnd);
        free(handle);
        free(bytes);

        return 100.0f;
    }

    if (handle->huidig == 0)
    {
        fseek(handle->bestand, 0, SEEK_SET);
        fseek(handle->nieuwbstnd, 0, SEEK_SET);
    }

    bytes = (char*)malloc(10485760);
    if (bytes == NULL)
    {
        fcloseall();
        free(handle);
        return 100.0f;
    }
    fread_s(bytes, 10485760, 10485760, 1, handle->bestand); // Here

    for (index = 0; index < 10485760; index++)
    {
        __asm
        {
            mov         eax, dword ptr [bytes]  
            add         eax, dword ptr [index]  
            mov         cl, byte ptr [eax]
            xor         cl, 101
            xor         cl, 53
            not         cl
            mov         byte ptr [eax], cl 
            mov         eax, dword ptr [index]  
            add         eax, 1  
            mov         dword ptr [index], eax
        }
    }

    fwrite(bytes, 1, 10485760, handle->bestand);
    free(bytes);
    handle->huidig += 10485760;
    handle->positie += 10485760;
    fseek(handle->bestand, handle->huidig, SEEK_SET);
    fseek(handle->nieuwbstnd, handle->positie, SEEK_SET);
    calc = (float)handle->huidig;
    calc /= (float)handle->size;
    calc *= 100.0f;

    if (calc >= 100.0)
    {
        fclose(handle->bestand);
        fclose(handle->nieuwbstnd);
        free(handle);
    }

    return calc;
}

EDIT: Solved

  • 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-06-14T19:56:42+00:00Added an answer on June 14, 2026 at 7:56 pm

    Not sure if this is your specific problem but it is something wrong with your code.

    When you do an fread call, you specify how many “objects” you want to read and the object size, then fread will read up to that many objects. But it will read an exact number of those objects.

    So, when you try to read a million one-byte objects from a seven-byte file, you’ll get seven of them and the return code will reflect this. However, if you try to read one million-byte object, you’ll get nothing at all, and the return code will reflect that.

    The reason I emphasize the return value is that you may get back less objects than you wanted (such as if you ask for 1000 one-byte objects where there’s only 900 left in the file), so blindly writing the expected amount to the output file is a no-no. You need to check the return code and act on that.

    In addition, as a commenter points out, you appear to be writing back to the input file in one of your output statements:

    fwrite (bytes, 1, 10485760, handle->bestand);
    

    That’s unlikely to end well 🙂 It should probably be:

    fwrite (bytes, 1, 10485760, handle->nieuwbstnd);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had a look all over, but it doesn't seem as though my
I want to pass through configuration arguments to a class. These are all the
I need to write some code that would loop though all rows of a
I'm using the HTML agility pack to scrape a website. I'm looking though all
I have a problem where I get no errors nothing it all goes though
all the D3D interfaces are derived from COM's IUnknown interface, so I though I'd
Im very new to all coding including jquery. I though this would have been
I have a draggable table which all working fine, though I want to be
Has anyone seen this: ?? No jgem command works at all?? Though jruby -S
I have to pass a function an instance of an object, so obviously all

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.