INFO: Resource Sections are Read-only

ID: Q126630

The information in this article applies to:

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.

Additional query words:

Keywords          : kbNTOS350 kbNTOS351 kbNTOS400 kbResource kbGrpUser kbWinOS95 
Issue type        : kbinfo

Last Reviewed: January 2, 1999