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. -- Patrice
From: Patrice on 15 Nov 2009 11:13 > Could you tell exactly how you did this, so where you downloaded that > application > 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 6.0.98.2). 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 FindFirstFileA. Stepping throught the code could be easier to analyze this in greater details (and make sure VB gets at rctFileLen first). -- Patrice
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. Ok, thanks.
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 > then. > 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 End If NoFile: End Function -- ..NET: It's About Trust! http://vfred.mvps.org
From: Karl E. Peterson on 16 Nov 2009 18:52
Patrice wrote: > 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! http://vfred.mvps.org |