Microsoft KB Archive/126630

{|
 * width="100%"|

INFO: Resource Sections are Read-only

 * }

Q126630

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), used with:
 * Microsoft Windows 95
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51, 4.0
 * the operating system: Microsoft Windows 2000

-

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 : kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbResource kbSDKWin32 kbGrpDSUser kbOSWin95

Issue type : kbinfo

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch