Knowledge Base

INFO: Resource Sections are Read-only

Article ID: 126630

Article Last Modified on 7/11/2005


APPLIES TO


This article was previously published under Q126630

SUMMARY

Resource sections are read-only by default under Windows NT. However, the resource section might 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.

Windows 95 has a handler similar to the one used in Windows NT.

MORE INFORMATION

Under 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 Violation
This 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.

Keywords: kbinfo kbresource KB126630