Prevent loading of a local *.dll

Just starting out? Need help? Post your questions and find answers here.
romk
User
User
Posts: 10
Joined: Mon Nov 17, 2014 12:57 am

Re: Prevent loading of a local *.dll

Post 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")
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post 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.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post 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.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post 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)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
romk
User
User
Posts: 10
Joined: Mon Nov 17, 2014 12:57 am

Re: Prevent loading of a local *.dll

Post by romk »

Yes, it is above all other code.

The MessageBox test retrieves:
Is wSock.DLL loaded? 5513152
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post by Thunder93 »

Anything other-than zero means successful. :mrgreen:
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post 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)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
romk
User
User
Posts: 10
Joined: Mon Nov 17, 2014 12:57 am

Re: Prevent loading of a local *.dll

Post 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.
User avatar
skywalk
Addict
Addict
Posts: 4316
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Prevent loading of a local *.dll

Post by skywalk »

Not sure if PB loads wsock32 with calls to InitNetwork()?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post by Thunder93 »

Skip over this.
Last edited by Thunder93 on Mon Nov 17, 2014 7:56 pm, edited 1 time in total.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post 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()?
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post by Thunder93 »

It does.
skywalk wrote:Not sure if PB loads wsock32 with calls to InitNetwork()?
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1790
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Prevent loading of a local *.dll

Post by Thunder93 »

That's what's happening! InitNetwork() is using the dll found in the application directory.

...Could be potential security issue. :lol:
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
romk
User
User
Posts: 10
Joined: Mon Nov 17, 2014 12:57 am

Re: Prevent loading of a local *.dll

Post 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
Post Reply