Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - Copying those all important DLLs to System32 [Native Code]

Author
Message
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Aug 2012 08:21 Edited at: 2nd Aug 2012 08:27
I remember a while ago having a discussion about Dynamic link Libraries (DLLs or DLL for Dynamic Link Library) and some were having issues making them automatically installed... prior to an end user running their apps...

For completion I have linked a Wikipedia Link to the page on DLLs
http://en.wikipedia.org/wiki/Dynamic-link_library

This was true of Dark Occlusion.

Well I have had this lying around for a few months, and thought it would help...

It is the most basic of code:

Quote: "

COPY FILE "msvcr71.dll", "C:\Windows\System32\msvcr71.dll"
PRINT " MSVCR71.DLL copied!"

COPY FILE "msvcp71.dll", "C:\Windows\System32\msvcp71.dll"
PRINT " MSVCP71.DLL copied!"

WAIT KEY or WAIT 1000

"

[Placed as a quote as it is not very long]

Now a few notes here, you must place this code at the very beginning of your code that loads in any other plugins such as Dark Occlusion or anything else that is System DLL dependent...
[Meaning before any calls to include an external plugin]

And remember you do not need to include the PRINT calls as they are for example purposes and testing purposes here and are added for completion. Only the COPY FILE calls are the essentials here, and possibly the wait calls as well, [remember the WAIT KEY call will halt your application and wait until a user presses a key before continuing] but I included it here for testing purposes, you can achieve an automated process by using a WAIT call which at the moment is possibly just courtesy as it may be system dependent how fast the copying may occur on an end users machine, so I have included it for completion of systematic code as should the application simply speed on and request the DLLs and they are not prepared the application may fail [Not tested as I find the waiting a failsafe].

Some may say you can just place the DLLs in the executable (EXE) folder, but this does not always work...

You can also perform checks for these DLLs prior to loading and then copy them over from your EXE folder each time the application is run if they are missing, and it is a tiny overhead either way... however there is something you must bear in mind...

[Note: the DLLs must be packaged with your EXE or else you will have nothing to copy]

On a 64 bit system [Tested on Windows 7 x64 Ultimate] these DLL's need to reside in SysWOW64, however you can just place them into the System32 folder [Meaning your code does this] and Windows automatically moves them into the SysWOW64 folder for you, almost instantly… that’s why I placed the pause in the code above so that Windows has the time to prepare them before the proceeding code activates any DLL dependent plugin such as the aforementioned Dark Occlusion… [This pause may be optional but for the time being I have placed it in the code for completion]

Another thing to keep in mind is that in order for the DLLs to successfully copy or copy at all, is to require the EXE to be run in Admin mode with Administrator privileges, or else the copying will fail and the DLLs will not be in place for the rest of the Application to execute and it will throw up an error unless they were already in place…

So checking for the files existing should help reduce loading times, as if they already exist there would be no need to perform a copy and you can skip the WAIT command altogether… Below is some Pseudo code to demonstrate this ‘Check’.

Quote: "
<-- Pseudo code start -->
PSEUDO CODE FOR THIS CHECKING AS AN EXAMPLE:
FUNCTION START
PERFORM CHECK FOR DLL
DLL DOES NOT EXIST
COPY DLL
CALL WAIT COMMAND
RESUME
OTHERWISE
DLL DOES EXIST
END FUNCTION AND RESUME EXECUTABLE
<--Pseudo code end -->
"


Another trick here is to create a launcher application which does these checks separately of the main EXE, which then executes the main EXE. This would enable you to create a funky loading screen, which if you have the right capability can remain on screen even while your main exe is still loading, and then can eventually close and to begin with your main exe can remain in the background until it is loaded and it can send a call to the loader to shut down… you can place a video into this launcher, make it full screen and more! I hope these ideas help you.

It is up to you to implement your own function at the start of your application to implement the above snippet with a skipping procedure… [Remember Functions can be placed in another source file but you will have to load that source file before executing a function call to that function… i.e. StartDllCallCheckFunction() <-- The code for this function must be loaded prior to executing the function call {Correct me if I am wrong, thanks}. Alternatively you can just place the code for the function at the start of your application without turning it into a function <See Pseudo code above>… this is confusing even for me to describe… but I hope you follow my meaning.]

The verbose description here is in this way in case anybody entirely new to DBPro comes across this and I hope this is appreciated.

Keep in mind this can apply to any other programming environment as well.

ADDENDUM:
In regards to DirectX9.0c [the one required for DBP to run as well as your EXE’s], this cannot be copied over using this method… as the EXE will just fail or throw up an improper DLL error… [Tested on Vista x32 Ultimate]… Perhaps someone can find a fix for this in future but for now it is beyond the scope of this snippet.

I have referenced Dark occlusion as this was the plugin that sparked this debate.

Remember to delete any test DLLs as they may fail to work correctly or you may forget that they need to be copied in future testing.

EDIT

Linked the Wikipedia URL as a hyperlink

Jeff Miller
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 7th Aug 2012 13:50
Regarding testing for DX, I think that years ago someone made a DBP pre-processor that handled that task. I think it was The Winch. You might try looking for that.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 7th Aug 2012 15:21 Edited at: 12th Aug 2012 23:04
Dark Injector

I had a quick look, it seems to be from a while ago, so unless he can confirm it working with DBPro... I guess it would be hopeless for me to try, I did however download it to have a closer look at what comes with it and see more detail on how it works...

I wonder if he is still around...

Thank you for the informing I guess from the information on his site, unless DBPro changed along the way... 2005-2006 onwards somebody could modify this to be updated if needed... I may try Winches tool but I do not think it fits the requirement...

EDIT

Typo...

Login to post a reply

Server time is: 2024-04-19 06:42:04
Your offset time is: 2024-04-19 06:42:04