From: Patrice on 15 Nov 2009 04:54
I gave this a look with the IDA tool I downloaded yesterday and found a
rctFileLen function that seems to use FindFirstFileA as well. So VB6 likely
uses the same Windows API than the other runtime I shouldn't have mentioned.
From: Patrice on 15 Nov 2009 11:13
> Could you tell exactly how you did this, so where you downloaded that
> and how you concluded that FileLen in VB6 uses the FindFirstFile API?
I used IDA Pro Freeware which is available from
http://www.hex-rays.com/idapro/idadownfreeware.htm (actually I'm using 4.3 I
downloaded from another site).
Then I loaded msvbvm60.dll and searched for the FileLen text. It should find
a rtcFileLen function which is likely what is called by the VB6 runtime
(mine is 22.214.171.124).
If you double click the sub_72776146 call (or likely the first one in this
routine if you have another version) you'll see that it goes to a routine
that uses a lpFindFileData pointer. If you double click the last jz call in
this routine (I've got jz short loc_72776189 here), you'll see that it calls
Stepping throught the code could be easier to analyze this in greater
details (and make sure VB gets at rctFileLen first).
From: Patrice on 15 Nov 2009 11:14
> That's why
> many here use .Nxt so it doesn't match what the user maybe entering.
From: Karl E. Peterson on 16 Nov 2009 18:50
RB Smissaert wrote:
> Thanks for looking at that and yes, should get a virtual machine really.
>> Why are you using that?
> Great majority of files passed to the function will be small, so I thought I
> might save some time to try the FileLen first.
Not the point. You seemed to be using it as way to tell if a file exists. The most
commonly accepted method for that is to use GetAttr.
>> I guess what you're asking is whether FileLen() will toss an error with a
>> really huge file?
> Exactly, as that would be no good.
Nope, it definitely wouldn't.
>> I'll try... Nope! Looks like it just wraps around and around...
> OK, thanks and that is no good either, so will need to chuck FileLen out
> Maybe FileLen uses that API in any case, so trying FileLen first won't gain
> any time in that case.
> Will do some timing tests to see if that might be the case.
is this what you're looking for?
Public Function FileExists(ByVal FileName As String) As Boolean
Dim nAttr As Long
' Grab this files attributes, and make sure it isn't a folder.
' This test includes cases where file doesn't exist at all.
On Error GoTo NoFile
nAttr = GetAttr(FileName)
If (nAttr And vbDirectory) <> vbDirectory Then
FileExists = True
..NET: It's About Trust!
From: Karl E. Peterson on 16 Nov 2009 18:52
> I never thought my response would raise an agressive remark. Seems some
> people are really touchy here...
That's often the response to proselytization.
Take the sales pitch elsewhere.
..NET: It's About Trust!