My understanding of the /SWAPRUN
option (MSDN link) is that it causes an executable to be loaded to the swap file and executed from there.
Is this mechanism possible in VB6?
There is no way to specify this in VB6.exe (i.e. the IDE/compiler).
However there are add-ins that "hook" the compile-and-link process, or you could do this yourself with a little effort.
The easiest way is to just re-edit the compiled and linked program via EditBin.exe or Link.exe. EditBin is just a stub that invokes Link, but Link is installed as part of VB6 so you may as well run it directly.
The main reason for doing this is to optimize running from a network share or CD/flashdrive device. It will not help you bypass security, fool antivirus software, or act anything at all like a "run extracted EXE from RAM" hack.
We're doing a "C:\Program Files\Microsoft Visual Studio\VB98\LINK.EXE" /EDIT /NOLOGO /SWAPRUN:NET file.dll
on all exe/dll/ocx for our portable builds. Unfortunately this does not prevent EXCEPTION_IN_PAGE_ERROR
exceptions being raised when LAN gets down.
System components (e.g. COMCTL32.OCX) are not flagged with swaprun and are shipped signed by Microsoft. Editing the PE header results in broken digital certificate.