IonicWind Software

IWBasic => General Questions => Topic started by: Andy on April 02, 2012, 01:02:49 AM

Title: Entry point _ftol2 could not be located - Help
Post by: Andy on April 02, 2012, 01:02:49 AM
Hi,

Was just testing my project on XP home 32 bit and I get this error when I try to run it:

The procedure entry point _ftol2 could not be located in the dynamic link library msvcrt.dll

It works fine on Win 7 32 bit.

This copy of XP is from my old disk, updated XP to Service pack 3 - still the same problem

Installed IWB on the XP disk, re-compiled and still the problem persists.

Installed latest headers etc for IWB, problem is still there.

Thought it might be my project so I tried to compile the Browser_Test2 example - it too has the problem.

Help, Help, Help!!!!
:-[

Attached is the Browser_Test2 example - does this compile and run on any XP machines?
If so, what's the difference?

Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 02, 2012, 01:52:29 AM
Just been searching the web, it seems Vista and 7's version of the DLL file have this function included  -  XP's version does not? - is that correct and what can we do about it?

Thanks,
Andy
Title: Re: Entry point _ftol2 could not be located - Help
Post by: ZeroDog on April 02, 2012, 02:01:06 AM
Sounds like you are going to have to manually load the library using the LoadLibrary API, and then determine the function addresses using the  GetProcAddress API, and then call the function using the CallWindowProc API.

You will have to check the GetProcAddress return value to see if it's a valid address in the DLL, if it isn't, it will return NULL, in which case you should not try and use the function or it will fail like it has been doing.
Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 02, 2012, 06:14:56 AM

Commented out:

'const OLECMDID_SAVEAS = 4
'const OLECMDEXECOPT_DODEFAULT = 0

and

'CASE idSave
'   IDispatch browser = GETBROWSERINTERFACE(.cont)
'   browser.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT)
'   browser->Release()

and the SUB DoEnum

and it compiles and works

I can do without the option to save a page, but I do need the DoEnum sub routine as it reads the web page source code.

In the sub routine there are lines:

BSTR bstrHtml = browser.Document.documentElement.outerHTML
and
references to wcstok - these also seem to cause the problem.

Thats as far as i've got so far.

Andy.
Title: Re: Entry point _ftol2 could not be located - Help
Post by: LarryMc on April 05, 2012, 06:33:26 AM
I'd try to help but that's all over my head.

I did some searching for ftol2 and it's obvious that quite a few people have run into the problem.
But I didn't find any solution.

LarryMc
Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 05, 2012, 06:43:26 AM
Larry,

Thanks anyway for trying!

Thanks very much,
Andy.
Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 07, 2012, 12:31:13 AM

The MSVCRT.dll file is a C run time file, so I downloaded the Visual C++ 2010 run time package from Microsoft.

This didn't fix the problem.

I can only suggest that if anyone compiles in Win 7 or Vista then you try your software on an XP machine and vice versa!

I always used to do this in EB, but not since I started to use IWB - the problem lies with XP not EB / IWB of which i'm very happy with.

Will keep trying,

Andy.

Title: Re: Entry point _ftol2 could not be located - Help
Post by: Ficko on April 07, 2012, 07:50:08 AM
"_ftol" is in reality just this:


_asm
_ftol2:
push 0
fistp dword [esp]
pop eax
ret
_endasm


Just put it in your code and you have "_ftol2".  ;D
Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 07, 2012, 11:23:49 PM
Ficko,

Thanks for that, it's a great try but the program is still trying to load the msvcrt.dll file and so the problem persists.

Thanks,
Andy.

:)
Title: Re: Entry point _ftol2 could not be located - Help
Post by: LarryMc on April 07, 2012, 11:30:42 PM
Quote from: andy1966 on April 07, 2012, 11:23:49 PM
Ficko,

Thanks for that, it's a great try but the program is still trying to load the msvcrt.dll file and so the problem persists.

Thanks,
Andy.

:)
That suggest to me that you are using a lib that was built that called the routine in that dll.
I suggest you try to determine what is calling that routine and then seeing if you can get a different version of it.

That's my WAG (wild ass guess)

LarryMc
Title: Re: Entry point _ftol2 could not be located - Help
Post by: ZeroDog on April 08, 2012, 12:50:11 AM
DECLARE IMPORT,LoadLibraryA(lpLibFileName:STRING),INT
DECLARE IMPORT,FreeLibrary(hLibModule:INT),INT
DECLARE IMPORT,GetProcAddress(hModule:INT, lpProcName:STRING),INT
DECLARE IMPORT,CallWindowProcA(lpPrevWndFunc:INT, hwnd:INT, msg:INT, wParam:INT, lParam:INT),INT

DEF Library:INT
DEF ProcAddress,ProcAddress2:INT

Library=LoadLibraryA(getstartpath+"msvcrt.dll")
ProcAddress=GetProcAddress(Library, "_ftol")
ProcAddress2=GetProcAddress(Library, "_ftol2")

If ProcAddress=NULL
messagebox 0,"_ftol entry not found, do not attempt to call this function.","Warning"
else
messagebox 0,"_ftol entry found at address"+str$(ProcAddress)+"."+CHR$(13)+CHR$(13)_
+"It is safe to call this function."+CHR$(13)_
+"Use the following to call this function:"+CHR$(13)+CHR$(13)_
+"CallWindowProc(ProcAddress, winhandle, message, wParam, lParam)"_
,"Info"
endif

If ProcAddress2=NULL
messagebox 0,"_ftol2 entry not found, do not attempt to call this function.","Warning"
else
messagebox 0,"_ftol2 entry found at address"+str$(ProcAddress2)+"."+CHR$(13)+CHR$(13)_
+"It is safe to call this function."+CHR$(13)_
+"Use the following to call this function:"+CHR$(13)+CHR$(13)_
+"CallWindowProc(ProcAddress, winhandle, message, wParam, lParam)"_
,"Info"
endif

FreeLibrary(Library)

End


Don't DECLARE the "msvcrt.dll", instead, use the LoadLibraryA, and manually get the entry points for the functions in the dll that you plan to use with GetProcAddress.  If GetProcAddress returns NULL for any of the function entry points, then that function does not exist in the dll, and you should use an alternative function.  If GetProcAddress does not return NULL, then you can access that function using CallWindowProcA and the entrypoint address returned from the GetProcAddress.
Title: Re: Entry point _ftol2 could not be located - Help
Post by: Andy on April 08, 2012, 04:53:55 AM

Hi guys,

ZeroDog,

That's a great little program and works - thank you!

Larry - Any guess is a good guess for me - the only lib file I use is the "wininet.lib" file.

This is a portion of the debug code:

Starting debug session...
Loading DLL: ntdll.dll
Loading DLL: C:\Windows\system32\kernel32.dll
Loading DLL: C:\Windows\system32\KERNELBASE.dll
Loading DLL: C:\Program Files\AVAST Software\Avast\snxhk.dll
Loading DLL: C:\Windows\system32\USER32.DLL
Loading DLL: C:\Windows\system32\GDI32.dll
Loading DLL: C:\Windows\system32\LPK.dll
Loading DLL: C:\Windows\system32\USP10.dll
Loading DLL: C:\Windows\system32\msvcrt.dll

But is there a way to 'trap' which piece of code is invoking msvcrt.dll?

I may have to 'pull to bits' the code to find out?

Will do some more research.

Thanks,
Andy.

:)