Resource Sections are Read-onlyLast reviewed: September 29, 1995Article ID: Q126630 |
The information in this article applies to:
SUMMARYResource sections are read-only by default under Windows NT and Win32s. However, under Windows NT, the resource section may appear to be read/write. If an application tries to write to the resource section, an exception occurs. Windows NT handles the exception by duplicating the page and making it read/write. Therefore, under Windows NT it is possible to write to the resource section, even though its section attribute is read-only. In Win32s version 1.2, the resource section is read-only and you cannot write to it. To work around this, link with /SECTION:.rsrc,rw to make the resource section read/write. Or copy the resource to your own buffer and work with it from there. You cannot modify the protection of the resource section because the memory is owned by the system. In Win32s version 1.25a and later, the resource section is read/write, regardless of what is specified in the section attributes. Windows 95 has a handler similar to the one used in Windows NT.
MORE INFORMATIONUnder Windows NT, the default top level handler detects writes to resources and will make the resource writable. If you are running outside of a debugger and you have no exception handler, your resource writes will silently work. If you are running under the debugger, your resource write will look like an access violation:
First-Chance Exception in msin32.exe: 0xC0000005: Access ViolationThis allows you to "fix" your resource writes. If you have the debugger pass on the exception to your application and you have no handler, the default handler will make your resource writable. The disadvantage of setting the attribute of the resource section to read/write is that Windows NT and Windows 95 will use a separate copy of the resource section for each process that uses this section, instead of one copy for all processes.
|
Additional reference words: 1.20 3.50 4.00 LoadResource LockResource
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |