Avoid collisions between parallel installations of Cygwin

Dave Korn dave.korn.cygwin@googlemail.com
Fri Oct 16 12:17:00 GMT 2009


Corinna Vinschen wrote:

> I'm just experimenting with them using Chuck's example code as base. 
> Apparantly you can't change your own executable with these calls.  If you
> try, you get an ERROR_ACCESS_DENIED from EndUpdateResource.

  Well I guess that's to be expected, the old replace-in-use problem.

> And then I'm just puzzeled by this.  I load the resource from a copy of the
> executable (foo-copy.exe), and write it back unchanged to the copy of the
> executable:

> HMODULE hMod = LoadLibraryEx ("foo-copy.exe", NULL,
> LOAD_LIBRARY_AS_DATAFILE); HRSRC hRes = FindResource (hMod,
> CYGPROPS_RES_NAME, RT_RCDATA); HGLOBAL hglb = LoadResource(hMod, hRes);
   [ ... ]
> HANDLE hupdate = BeginUpdateResource ("foo-copy.exe", FALSE);

> This seems to work fine at first:

> But the next call doesn't look that nice anymore:

> Huh?  I didn't change the resource, I just write it back!  WTF?

  Dunno, but I noticed the UpdateResource man page has this strange wording
where it first warns you shouldn't do that but then says it should be ok:

http://msdn.microsoft.com/en-us/library/ms648049(VS.85).aspx

> It is recommended that the resource file is not loaded before this function
> is called. However, if that file is already loaded, it will not cause an
> error to be returned.

  That warning is more noticeable for what it omits than what it actually
explains.  Maybe you should try loading the resource from the live running
foo.exe instead of the foo-copy.exe that you're planning to apply it to, and
see if that helps any?

    cheers,
      DaveK



More information about the Cygwin-developers mailing list