Page 2 of 2

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 6:54 pm
by romk
Thunder93 wrote:Specify the path or you'll see it test out....

:wink:
Well, I did try both.
romk wrote:no matter if this line is on top of my code or not:

Code: Select all

OpenLibrary(#PB_Any,"C:\windows\system32\wSock32.dll")

Code: Select all

OpenLibrary(#PB_Any,"wSock32.dll")

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 6:55 pm
by Thunder93
You right.. Unless somehow it is someplace also loading that other DLL.
Shield wrote:Edit: hm, nvm, it shouldn't have any effect as it's a separate process.

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 6:57 pm
by Thunder93
Forget about testing with both. If you have .DLL named the same but serves different function, found in the executable location. You want to load up the system .DLL, you require to specify complete path.

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:04 pm
by Thunder93
I was trying to figure out how to retrieve the path of what OpenLibrary uses when no path is specified and is successful.

You said that the following code is above ALL other code?

Code: Select all

OpenLibrary(#PB_Any, "C:\windows\system32\wsock32.dll")


Change to

Code: Select all

IsLoaded = OpenLibrary(#PB_Any, "C:\windows\system32\wsock32.dll")

MessageRequester("Information", "Is wSock32.DLL loaded? "+str(IsLoaded), #PB_MessageRequester_Ok)

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:25 pm
by romk
Yes, it is above all other code.

The MessageBox test retrieves:
Is wSock.DLL loaded? 5513152

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:28 pm
by Thunder93
Anything other-than zero means successful. :mrgreen:

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:33 pm
by Thunder93

Code: Select all

IsLoaded = OpenLibrary(#PB_Any, "C:\windows\system32\wsock32.dll")

SelectFun = GetFunction(IsLoaded, "select")

MessageRequester("Information", "Is wSock32.DLL loaded? "+Str(IsLoaded)+#CRLF$+
                                "GetFunc - select: "+Str(SelectFun), #PB_MessageRequester_Ok)

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:35 pm
by romk
It was loading wsock.dll successful the whole time. The problem is that it loads the wrong DLL. Or rather not from the path i want.

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:42 pm
by skywalk
Not sure if PB loads wsock32 with calls to InitNetwork()?

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:43 pm
by Thunder93
Skip over this.

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:45 pm
by Thunder93
Probably.. but shouldn't matter as InitNetwork() wouldn't load the .DLL found in the application location.
skywalk wrote:Not sure if PB loads wsock32 with calls to InitNetwork()?

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:47 pm
by Thunder93
It does.
skywalk wrote:Not sure if PB loads wsock32 with calls to InitNetwork()?

Re: Prevent loading of a local *.dll

Posted: Mon Nov 17, 2014 7:52 pm
by Thunder93
That's what's happening! InitNetwork() is using the dll found in the application directory.

...Could be potential security issue. :lol:

Re: Prevent loading of a local *.dll

Posted: Tue Nov 18, 2014 3:20 am
by romk
Well, I could not find a solution to change the behaviour of the DLL loading order, but some other guy gave me the idea to hack the compiled executable that uses the "wrong" DLL, and to change the reference of DLL there it wants to load. Now it is looking for wsocipx.dll rather than wsock32.dll and does not conflict with my updater program any longer.

In the end it appears that it is not that easy to alter WinAPI functions, I suppose. As my problem now is fixed unconventionally/differently than expected, I don't think there is much sense anymore in struggling with the enigmatic logic of Windows.

Thanks everyone for trying to help out and giving ideas!
Romk