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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:15:08+00:00 2026-05-30T10:15:08+00:00

I have problem running and debugging this piece of code: bool readSectionHeaders(char* path, int

  • 0

I have problem running and debugging this piece of code:

bool readSectionHeaders(char* path, int numOfSections, int peSectionsOff, IMAGE_SECTION_HEADER* out) {
    bool retr = false; //return value

    //open file
    FILE* file;
    file = fopen (path, "rb");
    if(file == NULL) {
        perror("WRG"); //TODO
        return false;
    }

    do { //do while(false) only for easier error correction

        //seek to first section
        fseek(file, peSectionsOff, SEEK_SET);

        //read all sections
        unsigned int count;
        IMAGE_SECTION_HEADER sectionHeaders[numOfSections];
        count = fread(sectionHeaders, sizeof(IMAGE_SECTION_HEADER), numOfSections, file);

        //check Bytes count
        if(count != sizeof(IMAGE_SECTION_HEADER)*numOfSections) {
            break;
        }

        //copy sections
        memcpy(out, sectionHeaders, count);

        //exit successfully
        retr = true;
    } while(false);

    //exit
    fclose(file);

    return retr;
}

What is strange is that it returns false even when it reads the file. I tried to debug it and here is the strangest part.

I go line by line until this one

if(file == NULL) {

Then even though file is not NULL it skips perror and moves to

return false;

But does not return at all.

I again go line by line until

retr = true;

where it seems to do something, however retr remains false.

Then it closes file and returns with false.

I have never come across something like this.
I tried cleaning project, rebuilding, even deleting files and redownloading them from subversion. Before using this function, I use similar one – I read PE headers. So I though a problem could be with reading the file but it doesn§t explain debug behavior.

After returning from function, I use perror and it writes No error.

I use mingw with QtCreator.

Thanks in advance.

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

    Ok, this was both my and mingw’s problem. I’ve re-installed whole QtSDK with no effect. Then I installed different version of mingw and set qt creator up to use it. Now debugger works without problem. I’m not sure what happened but cerr << “TEST”; also stopped working with the old mingw and this is 100% correct.

    As 111111 suggested, problem was with if break clause. I thought read returns number of bytes read and this was simply not true :).

    Now it is working, thanks to 111111 for his suggestion :).

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

Sidebar

Related Questions

I'm a beginner with jdbc ... I have a problem running this code :
I have this problem that a week ago, when debugging, suddently the Locals window
I have a problem related to the webRole debugging. Not running in a hosted
I have an odd problem in VS2008 running unit tests. When I run the
1st phase I have a problem shutting down my running JBoss instance under Eclipse
I have a problem with Log4Net. Running C# .Net 2.0 Log4Net Ver. Not Sure.
I'm having problem when running my Windows Forms program. In the program, I have
Problem: I have a python script that I have running as a service. It's
I have an odd problem where Hibernate is running more queries than I've asked
Here's a problem I keep running into: I have a lot of situations where

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.