It is currently Sun May 19, 2013 6:58 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 2:40 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
This just started happening, and I'm pretty certain PureBasic is fine. If I use result.i = CreateFile(#PB_Any, filename), the file is created, but result returns a negative number. If I use result.i = CreateFile(fileNum, filename), where fileNum = any integer, it works fine.

As anyone seen anything like this before? The other day I noticed a service, Genie Timeline was no longer running, and it would not start. The same thing happened to PSI scanner from Secunia. Then I noticed my services would no longer run. I narrowed it down to the CreateFile issue.

Now I find that System Restore no longer works. I did an 'sfc /scannow', and it did find and supposedly fix some issues, but it looks like it didn't fix enough.

If anyone has any ideas, I would appreciate them!

Rich


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 2:58 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4714
Location: Berlin - Germany
The result of #PB_Any is a pointer! To hold a pointer or a handle, you have always to use a Integer or Pointer.

Read this: http://www.purebasic.fr/blog/?p=42

Greetings - Thomas

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Linux Mint 14 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 3:31 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
result.i is an integer, isn't it?

Look, like I said, or at least implied, this had been working fine, I really don't think it's PureBasic, I think it's a system problem. Maybe this thread should be moved out of coding questions.

I was wondering (hoping) someone might have seen something like this before. I am going to restore a windows image backup, and see if that helps.


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 12:29 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 9870
Location: Beyond the pale...
result.i is a signed integer and as a pointer it could easily be negative. How did you manage to trace the services problems back to CreateFile() exactly?

_________________
I may look like a mule, but I'm not a complete ass.

eScript
Arctic Reports
nxSoftware


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 3:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Feb 14, 2006 9:27 pm
Posts: 370
Location: London, UK
srod wrote:
result.i is a signed integer and as a pointer it could easily be negative. How did you manage to trace the services problems back to CreateFile() exactly?


Sounds more like his PC is messed up rather than a PB problem.

I too don't get how CreateFile() would cause errors on your PC unless you used it to create or overwrite files for those services, which in that case it's still not CreateFile()'s fault.

_________________
Image


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 5:23 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
Stephen (SRod), after I started having the problem with Secunia, then Genie Timeline, I uninstalled those programs, and reinstalled to no effect. At that point I was wondered if there was a bad dll somewhere. Just for giggles, I tried starting one of my own written services, and that stopped with a 1053 error, which means the service did not respond. I used the uninstaller I had written, and that died with an error too. So I debugged the hell out of that process by using OpenConsole() and PrintN's before and after every functional line. I was able then to see the negative number returned from CreateFile using #PB_Any. The strange thing was that the file WAS created. It was perfectly consistent, it would always die at CreateFile, unless I used a variable instead of #PB_Any, when it worked fine.

I did an 'sfc /scannow', and a number of errors were corrected. I am running Norton Internet Security 2012, and it found no errors. Moogle, I always create specific separate directories for my data, so it shouldn't have been a file contention error.

I am wondering if this is just another one of those instances where Windows needs to be reload?


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 5:44 pm 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 911
What OS are you running Rich? At a guess I would say that you are having issues with your HDD starting to fail... or possibly (but doesn't quite sound like it) a virus/malware.

you could try a chkdsk C: /R /F but it will take a bloody long time and there is no guarantee it will fix it :)
You could also try something like SuperAntiSpyware or BleepingComputer if it is a malware infection. Some good resources and help available on there.

But my one bit of free advice for you mate is to get rid of Norton and install Microsoft Security essentials (It's free and actually rather good), and nowhere near the resource hog that Norton is.

I'm only a PM/Email away if you need any help :P

Ash.


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 5:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
Hey Ash, how are you?

I'm running Windows 7, SP1. I have a 120GB SSD as my boot drive, and a 4 drive RAID 10 setup as my source, programming and data drive. I put a check disk on last night, but I guess I didn't set it up right, as it couldn't get exclusive access to the drives, and didn't run. I'll set it up again to run tonight. I also have a UPS, so there should never be any power issues.

I'll try running the anti-spyware you suggested. I've already moved family from NIS to MSE as their licenses came up due.

I just downloaded Intel's latest Rapid Storage Technology , I'm running that check now.

I'll keep you guys informed, and I very much appreciate all the help, as usual!

Rich


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 11:34 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1024
A negative return value doesnt indicate a fail. But it's very unlikly to get a negative pointer because the upper half of the virtual memory is reserved for the system.

So i would also say something is wrong with your system.


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Tue May 01, 2012 11:39 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Feb 14, 2006 9:27 pm
Posts: 370
Location: London, UK
RichAlgeni wrote:
Moogle, I always create specific separate directories for my data, so it shouldn't have been a file contention error.

I am wondering if this is just another one of those instances where Windows needs to be reload?


I see, but as others have said getting a negative result isn't an error. If it was 0 then that would be an error but any other non-zero number is valid.

_________________
Image


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Thu May 03, 2012 2:15 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
It was a Windows problem after all. I reloaded Win7, took about a day in total, but all is well now.

Seems like I can go about 2 years before something in Windows goes haywire. No idea exactly what caused it, but things are running much faster and more stable now.

So, if you're having some strange problems, don't discount reloading Windows!


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Thu May 03, 2012 3:42 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
moogle wrote:
I see, but as others have said getting a negative result isn't an error. If it was 0 then that would be an error but any other non-zero number is valid.


I don't think anyone should read anything into this, something was wrong in Windows, which caused flaky results.


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Thu May 03, 2012 3:46 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Feb 14, 2006 9:27 pm
Posts: 370
Location: London, UK
RichAlgeni wrote:
moogle wrote:
I see, but as others have said getting a negative result isn't an error. If it was 0 then that would be an error but any other non-zero number is valid.


I don't think anyone should read anything into this, something was wrong in Windows, which caused flaky results.


Which is why I was so sceptical in my first post about PureBasic actually causing your errors :)

_________________
Image


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Mon May 07, 2012 2:23 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:50 am
Posts: 454
Location: Bradenton, FL
I think I have this solved. I had been reading up on PureBasic Team Blog, and was here:

http://www.purebasic.fr/blog/?p=172

I made the change at the bottom of this page:

http://msdn.microsoft.com/en-us/library/bb613473.aspx

I didn't put it together right away, because I hadn't rebooted until several days later. I have since reloaded Windows 7, and this was on my list to do. I made this change again, and immediately rebooted. I then ran my test process to create a file using #PB_Any. It returned a negative number again, and crashed the program when it tried to proceed. I immediately went back in and deleted the new registry entry, rebooted, and all is fine again.

Has anyone tried this registry entry before? Can anyone one confirm?


Top
 Profile  
 
 Post subject: Re: CreateFile error using #PB_Any, but...
PostPosted: Mon May 07, 2012 2:42 am 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1456
RichAlgeni wrote:
It was a Windows problem after all. I reloaded Win7, took about a day in total, but all is well now.

I know you weren't reporting a bug in your original post, but look at point (6) here -> viewtopic.php?f=4&t=4701 ;)

_________________
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: VB6_to_PBx and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye