You are here

How to emulate/define *.dll files

12 posts / 0 new
Last post
RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
How to emulate/define *.dll files

The problem is this: My portable application requires the presence of files / drivers in the "System32" / SysWOW folder. I will say that the application will not work even if you put the files in the root folder. How to make them either emulated or copied to the System32 folder / WOW and then deleted. It is reasonable to use the first option, of course, but I do not know how ...

I tried to use .bat(RunAsAdmin) - access denied
Sad

demon.devin
demon.devin's picture
Offline
Last seen: 6 months 1 week ago
Developer
Joined: 2007-08-02 09:04
File System Redirection

I talk a little bit about this subject on my website which you can visit here:
http://softables.tk/docs/basics/file-system#redirection

If after reading up on this you still need help you should explain what you need in a little more detail and I'll help in the best way I can.

Smile

Edit
By the way, if you're trying to write to the System32/WOW64 folder's, you're going to need administrative rights.

daemon.devin

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
Problem

Administrator rights I have and it is needed for the program.
I assumed that I need to use custom.nsh in the syntax but I still not very understand.
What you need to do in General:

It is necessary to put two * .dll files representing alternative Winsock(for work proxy) libraries needed for the program's work.
In the System32 folder for x86 and in the SysWOW64 folder for x64, respectively. (or better forward them to a portable program in the data folder WinSock \ x32 \ *. dll, etc.)

P.S.
Your topic read, but have not as yet understood how to write the declarations for redirection:(
P.P.S.
If you are not hard to write custom.nsh for my case, I would be very grateful Smile

to portable your life with portableapps.com

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
Custom.nsh
;=#
;= DEFINES
!define DISABLEREDIR `kernel32::Wow64EnableWow64FsRedirection(i0)`
!define ENABLEREDIR  `kernel32::Wow64EnableWow64FsRedirection(i1)`

;=#
;= USAGE
IntCmp $Bit 64 0 +5 +5
System::Call `${DISABLEREDIR}`
Rename "$SYSDIR\MyLib.dll" "$SYSDIR\MyLib.dll.bak"
CopyFiles /SILENT "${DATA}\WinSock\x32\MyLib.dll" "$SYSDIR\"
System::Call `${ENABLEREDIR}`
Rename "$SYSDIR\MyLib.dll" "$SYSDIR\MyLib.dll.bak"
CopyFiles /SILENT "${DATA}\WinSock\x32\MyLib.dll" "$SYSDIR\"

Don't work, how right and what I gotta do declaration?
Custom.nsh use automate or I need declarate it ?
Also I don't need the libs back up.

to portable your life with portableapps.com

demon.devin
demon.devin's picture
Offline
Last seen: 6 months 1 week ago
Developer
Joined: 2007-08-02 09:04
I need to rewrite the page on

I need to rewrite the page on my website. I realize now that I just assume people already know a little bit about NSIS and PAL. I also assume people will be using my modified version of PAL and not the official version.

But here is the code for your custom.nsh file based on what you've told me. This code should work if you're using the official version of PAL.

;=#
;= DEFINES
!define DISABLEREDIR `kernel32::Wow64EnableWow64FsRedirection(i0)`
!define ENABLEREDIR  `kernel32::Wow64EnableWow64FsRedirection(i1)`

;= CUSTOM
;= ################
${SegmentFile}
${SegmentPrePrimary}
	${If} $Bits == 32
		IfFileExists "$SYSDIR\MyLib1.dll" 0 +2
		Rename "$SYSDIR\MyLib1.dll" "$SYSDIR\MyLib1.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\MyLib1.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\MyLib2.dll" 0 +2
		Rename "$SYSDIR\MyLib2.dll" "$SYSDIR\MyLib2.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\MyLib2.dll" "$SYSDIR"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		IfFileExists "$SYSDIR\MyLib1.dll" 0 +2
		Rename "$SYSDIR\MyLib1.dll" "$SYSDIR\MyLib1.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\MyLib1.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\MyLib2.dll" 0 +2
		Rename "$SYSDIR\MyLib2.dll" "$SYSDIR\MyLib2.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\MyLib2.dll" "$SYSDIR"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend
${SegmentPostPrimary}
	${If} $Bits == 32
		Delete "$SYSDIR\MyLib1.dll"
		Rename "$SYSDIR\MyLib1.dll.bak" "$SYSDIR\MyLib1.dll"
		Delete "$SYSDIR\MyLib2.dll"
		Rename "$SYSDIR\MyLib2.dll.bak" "$SYSDIR\MyLib2.dll"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		Delete "$SYSDIR\MyLib1.dll"
		Rename "$SYSDIR\MyLib1.dll.bak" "$SYSDIR\MyLib1.dll"
		Delete "$SYSDIR\MyLib2.dll"
		Rename "$SYSDIR\MyLib2.dll.bak" "$SYSDIR\MyLib2.dll"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend

EDIT
Be sure that you put the appropriate DLLs in the DefaultData folder inside the App folder so it would look like this:

  • App\DefaultData\WinSock\x32\MyLib1.dll
  • App\DefaultData\WinSock\x32\MyLib2.dll
  • App\DefaultData\WinSock\x64\MyLib1.dll
  • App\DefaultData\WinSock\x64\MyLib2.dll

daemon.devin

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
I tried it

The logic of the problem in your Custom.nsh is absolutely correct as I need it.
But for some reason it does not work, the files are in the folder x32 / x64, but the program still gives an error referring to their absence in System32 / WOW64.

I use official Portalabapps.com Launcher for compilation
There is no need to recompile the launcher? Biggrin
CODE:

;=#
;= DEFINES
!define DISABLEREDIR `kernel32::Wow64EnableWow64FsRedirection(i0)`
!define ENABLEREDIR  `kernel32::Wow64EnableWow64FsRedirection(i1)`

;= CUSTOM
;= ################
${SegmentFile}
${SegmentPrePrimary}
	${If} $Bits == 32
		IfFileExists "$SYSDIR\System32\PrxerDrv.dll.dll" 0 +2
		Rename "$SYSDIR\System32\PrxerDrv.dll.dll" "$SYSDIR\System32\PrxerDrv.dll.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\PrxerDrv.dll.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\System32\PrxerNsp.dll.dll" 0 +2
		Rename "$SYSDIR\System32\PrxerNsp.dll.dll" "$SYSDIR\System32\PrxerNsp.dll.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\PrxerNsp.dll.dll" "$SYSDIR"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		IfFileExists "$SYSDIR\SysWOW64\PrxerDrv.dll.dll" 0 +2
		Rename "$SYSDIR\SysWOW64\PrxerDrv.dll.dll" "$SYSDIR\SysWOW64\PrxerDrv.dll.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\PrxerDrv.dll.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\SysWOW64\PrxerNsp.dll.dll" 0 +2
		Rename "$SYSDIR\SysWOW64\PrxerNsp.dll.dll" "$SYSDIR\SysWOW64\PrxerNsp.dll.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\PrxerNsp.dll.dll" "$SYSDIR"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend
${SegmentPostPrimary}
	${If} $Bits == 32
		Delete "$SYSDIR\System32\PrxerDrv.dll.dll"
		Rename "$SYSDIR\System32\PrxerDrv.dll.dll.bak" "$SYSDIR\System32\PrxerDrv.dll.dll"
		Delete "$SYSDIR\System32\PrxerNsp.dll.dll"
		Rename "$SYSDIR\System32\PrxerNsp.dll.dll.bak" "$SYSDIR\System32\PrxerNsp.dll.dll"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		Delete "$SYSDIR\SysWOW64\PrxerDrv.dll.dll"
		Rename "$SYSDIR\SysWOW64\PrxerDrv.dll.dll.bak" "$SYSDIR\SysWOW64\PrxerDrv.dll.dll"
		Delete "$SYSDIR\SysWOW64\PrxerNsp.dll.dll"
		Rename "$SYSDIR\SysWOW64\PrxerNsp.dll.dll.bak" "$SYSDIR\SysWOW64\PrxerNsp.dll.dll"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend

Can "PAL" variables or some other directives be incorrect or not declared?

to portable your life with portableapps.com

demon.devin
demon.devin's picture
Offline
Last seen: 6 months 1 week ago
Developer
Joined: 2007-08-02 09:04
Okay, I've taken what you

Okay, I've taken what you just shared above and fixed the errors you had in your code. Here's the new code:

;=#
;= DEFINES
!define DISABLEREDIR `kernel32::Wow64EnableWow64FsRedirection(i0)`
!define ENABLEREDIR  `kernel32::Wow64EnableWow64FsRedirection(i1)`

;= CUSTOM
;= ################
${SegmentFile}
${SegmentPrePrimary}
	${If} $Bits == 32
		IfFileExists "$SYSDIR\PrxerDrv.dll" 0 +2
		Rename "$SYSDIR\PrxerDrv.dll" "$SYSDIR\PrxerDrv.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\PrxerDrv.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\PrxerNsp.dll" 0 +2
		Rename "$SYSDIR\PrxerNsp.dll" "$SYSDIR\PrxerNsp.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x32\PrxerNsp.dll" "$SYSDIR"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		IfFileExists "$SYSDIR\PrxerDrv.dll" 0 +2
		Rename "$SYSDIR\PrxerDrv.dll" "$SYSDIR\PrxerDrv.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\PrxerDrv.dll" "$SYSDIR"
		IfFileExists "$SYSDIR\PrxerNsp.dll" 0 +2
		Rename "$SYSDIR\PrxerNsp.dll" "$SYSDIR\PrxerNsp.dll.bak"
		CopyFiles /SILENT "$EXEDIR\Data\WinSock\x64\PrxerNsp.dll" "$SYSDIR"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend
${SegmentPostPrimary}
	${If} $Bits == 32
		Delete "$SYSDIR\PrxerDrv.dll"
		Rename "$SYSDIR\PrxerDrv.dll.bak" "$SYSDIR\PrxerDrv.dll"
		Delete "$SYSDIR\PrxerNsp.dll"
		Rename "$SYSDIR\PrxerNsp.dll.bak" "$SYSDIR\PrxerNsp.dll"
	${ElseIf} $Bits == 64
		System::Call "${DISABLEREDIR}"
		Delete "$SYSDIR\PrxerDrv.dll"
		Rename "$SYSDIR\PrxerDrv.dll.bak" "$SYSDIR\PrxerDrv.dll"
		Delete "$SYSDIR\PrxerNsp.dll"
		Rename "$SYSDIR\PrxerNsp.dll.bak" "$SYSDIR\PrxerNsp.dll"
		System::Call "${ENABLEREDIR}"
	${EndIf}
!macroend

Do not change anything in the code above and you should be fine. Just recompile using PAL and try again.

daemon.devin

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
Apparently work

The program creates a one library in SysWOW64 = PrxerDrv.BackupProxyPortable
Correctly ?

to portable your life with portableapps.com

demon.devin
demon.devin's picture
Offline
Last seen: 6 months 1 week ago
Developer
Joined: 2007-08-02 09:04
I don't understand what you

I don't understand what you're saying.

Did it work?

daemon.devin

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
Maybe

Judging by the fact that I delete them, but they after launch launcher appear

The file appears in the system folder apparently work script.
But I'm still not completely sure
Anyway....Thank you very much for your help Smile

The program creates a one library in SysWOW64 = 
PrxerDrv.BackupProxyPortable

You were because of the line in the launcher.ini

[MoveFiles]
PrxerDrv=%systemroot%\system32\PrxerDrv.dll

to portable your life with portableapps.com

demon.devin
demon.devin's picture
Offline
Last seen: 6 months 1 week ago
Developer
Joined: 2007-08-02 09:04
You're welcome. Glad I could

You're welcome. Glad I could help.

By the way, the move files section should be like this:

[MoveFiles]
PrxerDrv.dll=%SystemRoot%\System32\PrxerDrv.dll

You were missing the file extension just left of the equal sign.

daemon.devin

RegEdit
RegEdit's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2012-02-03 23:57
OK

I just did not write it here (extension), but thanks

to portable your life with portableapps.com

Log in or register to post comments