Re: File Version without GetFileVersionInfo



I think in NT+ OS you cannot rename a file if it's open without
FILE_SHARE_DELETE flag. Mapped executables and DLLs are opened without it.
It worked in Win9x, IIRC.

A big mistake of Microsoft was implementing /SWAPRUN flag for CD and network
files only, whereas the really useful feature would be having a file running
from swap no matter what media it's loaded from. This would solve the wicked
problem of deleting loaded executables.

"Mihajlo Cvetanoviæ" <mac@xxxxxxxxxxxxxxxxxx> wrote in message
news:O4ez75kdFHA.412@xxxxxxxxxxxxxxxxxxxxxxx
> Joseph M. Newcomer wrote:
>> OK, I'm curious. How can you replace a currently-installed DLL? (Note
>> that I think I know
>> one trick, but I'm not sure it still works).
>>
>> Note that if the resources are in use, it is normally impossible to
>> replace a DLL.
>
> Suppose we want to update some example.dll (place another with the same
> name). Many processes have it loaded and we can't just call MoveFile on
> it. Suppose further that we choose not to use MoveFileEx with
> MOVEFILE_DELAY_UNTIL_REBOOT, which would be the logical thing to do (but
> requires administrator privileges).
>
> So, we do this (and I believe this is the trick you're referring to):
> rename example.dll to old_example.dll, copy there new example.dll, and
> tell each process to either reload the library, or to restart itself (if
> it's a service) or we just close the process and open it again. When all
> the processes load new example.dll we can safely delete old_example.dll.
>
> In the mean time some processes will have old_example.dll loaded, but if
> they call GetFileVersionInfo they will "think" they have new example.dll,
> which may have undesired results. So to avoid this we can't use
> GetFileVersionInfo, and instead we should use something that deals with
> HMODULE, like FindResourceEx-LoadResource.
>
> The point is that IF we can restart the computer OR we can stop all
> processes, replace the file, and start all processes OR there aren't any
> undesired results with GetFileVersionInfo THEN we don't need
> FindResourceEx.


.



Relevant Pages

  • Re: Riched20.dll
    ... It can come from a folder ... you may have on the system called ServicePackFiles. ... Rename in ServicePackFiles ... > dll and paste the new one, the current dll after the rename is back. ...
    (microsoft.public.windowsxp.general)
  • Re: Renaming DLLs?
    ... The application still looks for the original filename. ... Yes, you can rename ... a dll, though obviously, the app that uses it has to know about the ... This is taken from a larger script I use with some apps that lets ...
    (comp.os.os2.programmer.misc)
  • Re: Telling if a DLL is in use
    ... First make a copy of the .dll, then rename the original to something-else, ... Deleting the file before attempting to delete it may seem to violate your ... then your detection routine works properly, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Deploying/Development without Visual Studio
    ... So should I use those under Platform Builder 4.2 or use the ones ... > from the CF Framework cab files? ... To rename .cab CF dll you can load thi files into Reflector and it will ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: detecting a JVM embedded in an app?
    ... >In message, George Neuner ... >>lib file was edited or regenerated to reference the renamed DLL. ... >I've never known any company rename another company's DLLs. ... >Probably violates the license agreement in the first place. ...
    (comp.lang.java.softwaretools)