[freefalcon-developers] Re: Strange behavior fgetchar, fscanf and C++ ifstream File I/O

  • From: Peter Meyer <pmvstrm@xxxxxxxx>
  • To: freefalcon-developers@xxxxxxxxxxxxx
  • Date: Fri, 18 Jan 2013 12:17:25 +0100

Hi Plutonium,
I changed the Title to Adress the Problem correctly

This Code works as expected if you call it from FFViper.exe

/* Reads buffers from a textfile from within a DLL and prints it out - Works inside FFViper.exe - Peter */
FFVIPERCOMPAT_API bool fv_readfile(char* buf)
{
    ifstream stream("F:\\temp\\testfile.txt");

    char a[80];
    bool bState = false;
    if(!stream) {
        bState = false; // file  open.
    }
    else{
        bState = true; // error file cannot opened.
    }

    while(!stream.eof()) {
        stream1 >> a;
        cout << a << endl; // print the chars from the textfile.
    }
    return false;
}

The Code runs from FFViperCompat.dll and its printing all the chars from the testfile.txt out. This was the Test Code
you commented out in tod.cpp.

Greetings Peter




Am 18.01.2013 11:38, schrieb Zhitao Li:

OK, Correct me if I am wrong, the second approach you described is those lines that has something to do with the "FFViperCompat.dll"? I first noticed that this dll's path is hard coded, and I don't have it, so there has to be something wrong with this, so I commented it out...

I have another suggestion for this problem, why don't we use C++ style functions to read files? I took a brief look at the amount of work to be done going down this road, I have to say it is some amount of work, but it will make future work much easier, unless of course, it is written in C style and using some overload function was for specific reasons...

Thanks!

Plutonium.

*From:*freefalcon-developers-bounce@xxxxxxxxxxxxx [mailto:freefalcon-developers-bounce@xxxxxxxxxxxxx] *On Behalf Of *Peter Meyer
*Sent:* Friday, January 18, 2013 3:30 AM
*To:* freefalcon-developers@xxxxxxxxxxxxx
*Subject:* [freefalcon-developers] Fwd: Re: Introduction of myself as new subscriber on the dev-list

Hi Plutonium,



Hi all,

I already got the code, and I was able to compile it with no problem.

Thadts good to hear. I was not really sure it works without flaws on diffrent Computers expect of mine. This is a good sign!


However, majority of the code in in C style, and it uses fopen() to open files, I am having some very weird problems with these C style functions, fopen is not working, no matter there is a file or not it returns a non-NULL pointer any way, and if I try to read the opened file with fscanf(), it gets nothing, I also tried to use fopen() to create new files, no file will be created, and check fopen() status with if(fopen(newFileAbsolutePath, "w") == NULL) {std::cout<<"open failed"<<std::endl;} it won't enter and print out anything, because the file point is not NULL, although there is no file created.


Yes, you absolutly right. This is one of the Major Problems we having right now. I think there are a codeblock in the Resmgr Lib wich overrides all fopen,, scanf, fscanf, fgetchar and c++ ifstream calls to read files. The bug is described as Issue in the Bugtracker on GitHub. Awsome thadt you find this out by your self in such a short time, respect!


In tod.cpp i tested out something. The fegetchar(), scanf() and ifstream Readfile Functions work outside from FFViper.exe but the same code makes the Problems you describing.

After all testing i think we two choices to solve this Problem:


1)
Finding the General overrides (resmgr Subproject in the FreeFalcon Solution) . i think this might be a critical Codeblock because it looks like any scanf and fegetchar and even ifstream acess uses it) - But of cause this would be the best Solution at all.


2)
I have created a little DLL wich is not statically linked (if you use it statically it shows the same behaviour wich suckz) but if you load it with Loadlib() as dynamic loading at Runtime, the fegetchar, scanf/fscanf and ifstream read functions works like expected. I will checkin my FFViper.dll Teststub Project so we can evaluate
wich would be the best way to solve this issue.


If iam wrong and you find something else whats causes the Problem, let me know, but for now i think this is the Situation.





If anyone can give some idea, what's causing this problem, please help. I also created another x86 and x64 VS2010 project to test the fopen() function, it works fine in those test projects.

Hahah, this was the same as i did myself - you welcome ;D

Thanks!


Greetings, Peter

Plutonium

*From:*freefalcon-developers-bounce@xxxxxxxxxxxxx <mailto:freefalcon-developers-bounce@xxxxxxxxxxxxx> [mailto:freefalcon-developers-bounce@xxxxxxxxxxxxx] *On Behalf Of *Mark Tigelaar
*Sent:* Friday, January 18, 2013 2:56 AM
*To:* freefalcon-developers@xxxxxxxxxxxxx <mailto:freefalcon-developers@xxxxxxxxxxxxx> *Subject:* [freefalcon-developers] Re: Introduction of myself as new subscriber on the dev-list


------------------------------------------------------------------------

Date: Fri, 18 Jan 2013 10:45:01 +0100
From: pmvstrm@xxxxxxxx <mailto:pmvstrm@xxxxxxxx>
To: freefalcon-developers@xxxxxxxxxxxxx <mailto:freefalcon-developers@xxxxxxxxxxxxx> Subject: [freefalcon-developers] Re: Introduction of myself as new subscriber on the dev-list

Hi Mark,

and welcome on the developer list. You have done anything right.
If you read this, just click reply thadts all.

ps: Tell us a bit about your Ideads for FreeFalcon

Greetings Peter.



Am 18.01.2013 10:41, schrieb Mark Tigelaar:

    Hi all,

    After contacting Peter on possibilities for future work on the
    amazing FreeFalcon version of F4, he pointed me in the direction
    of the freelists.org where freefalcon-developers is the list for
    the dev-team. At least I hope I understood this correct.

    I did subscribe on the freelists.org but , probably because of
    having no rights to see anything, I found noone to get in touch
    with, or to introduce myself.

    So, I hope I can get this sorted with this email.

    Hope to hear from you guys soon (with instructions what the
    following steps are)

    High regards,
    Mark


Other related posts:

  • » [freefalcon-developers] Re: Strange behavior fgetchar, fscanf and C++ ifstream File I/O - Peter Meyer