Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ilasm.exe: Unhandled exception. RangeChecks instrumentation code detected an out of range array access #2

Closed
3F opened this issue Oct 31, 2016 · 2 comments
Labels

Comments

@3F
Copy link
Owner

3F commented Oct 31, 2016

For version v1.0.4 - 51131a5 - 4.5.22220.0
both x86 and x64

ildasm.exe /quoteallnames /unicode /nobar /linenum "/out:DllExportAndFody.il" "DllExportAndFody.exe"

seems solves problem 3F/DllExport#17

but, after:

ilasm.exe /nologo "/out:DllExportAndFody.exe" "DllExportAndFody.il" /EXE "/resource=DllExportAndFody.res" /debug
Unhandled exception at 0x00007FFF807653F7 (ntdll.dll) in ilasm.exe: 
RangeChecks instrumentation code detected an out of range array access.
 	ntdll.dll!00007fff807653f7()	Unknown
 	ntdll.dll!00007fff80779afd()	Unknown
 	ntdll.dll!00007fff80704fe9()	Unknown
 	ntdll.dll!00007fff80778c0a()	Unknown
 	ntdll.dll!00007fff8076540e()	Unknown
 	ilasm.exe!CCompRC::LoadLibrary(HINSTANCE__ * * pHInst) Line 1136	C++
 	ilasm.exe!CCompRC::GetLibrary(const wchar_t * langId, HINSTANCE__ * * phInst) Line 558	C++
 	ilasm.exe!CCompRC::LoadString(CCompRC::ResourceCategory eCategory, const wchar_t * langId, unsigned int iResourceID, wchar_t * szBuffer, int iMax, int * pcwchUsed) Line 724	C++
 	ilasm.exe!CCompRC::LoadString(CCompRC::ResourceCategory eCategory, unsigned int iResourceID, wchar_t * szBuffer, int iMax, int * pcwchUsed) Line 705	C++
 	ilasm.exe!UtilLoadResourceString(CCompRC::ResourceCategory eCategory, unsigned int iResourceID, wchar_t * szBuffer, int) Line 101	C++
 	ilasm.exe!FormatRuntimeErrorVa(wchar_t * rcMsg, unsigned long hrRpt, HRESULT marker, char *) Line 184	C++
 	ilasm.exe!PostErrorVA(HRESULT hrRpt, char * marker) Line 368	C++
 	ilasm.exe!PostError(HRESULT hrRpt, ...) Line 403	C++
 	ilasm.exe!ConvertResource(const wchar_t * pszFilename, wchar_t * pszTempFilename, unsigned __int64 pewriter, PEWriter &) Line 1097	C++
 	ilasm.exe!CeeFileGenWriter::emitResourceSection() Line 1128	C++
 	ilasm.exe!CeeFileGenWriter::link() Line 339	C++
 	ilasm.exe!Assembler::CreatePEFile(wchar_t *) Line 1662	C++
 	ilasm.exe!wmain(int argc, wchar_t * * argv) Line 727	C++
 	ilasm.exe!__scrt_common_main_seh() Line 253	C++
 	kernel32.dll!00007fff7e728102()	Unknown
 	ntdll.dll!00007fff8072c5b4()	Unknown
@3F 3F added the bug label Oct 31, 2016
@3F
Copy link
Owner Author

3F commented Oct 31, 2016

hmm, to continue we should also convert resources .res -> obj COFF-format (that will be placed in .rsrc section (PE))
then used ConvertResource (ceefilegenwriter.cpp#L1040):

HRESULT ConvertResource(const WCHAR * pszFilename, __in_ecount(cchTempFilename) WCHAR *pszTempFilename, size_t cchTempFilename, PEWriter &pewriter)

that requires external cvtres.exe :(

    ...
    DWORD dwExitCode;
    fRet = RunProcess(tempResObj, pszFilename, &dwExitCode, pewriter);

    if (!fRet)
    {   // Couldn't run cvtres.exe
        return PostError(CEE_E_CVTRES_NOT_FOUND);
    }    
    ...

problem from here:

    ilasm.exe!CCompRC::LoadLibrary(HINSTANCE__ * * pHInst) Line 1136    C++
    ilasm.exe!CCompRC::GetLibrary(const wchar_t * langId, HINSTANCE__ * * phInst) Line 558  C++
    ilasm.exe!CCompRC::LoadString(CCompRC::ResourceCategory eCategory, const wchar_t * langId, unsigned int iResourceID, wchar_t * szBuffer, int iMax, int * pcwchUsed) Line 724    C++
    ilasm.exe!CCompRC::LoadString(CCompRC::ResourceCategory eCategory, unsigned int iResourceID, wchar_t * szBuffer, int iMax, int * pcwchUsed) Line 705    C++
    ilasm.exe!UtilLoadResourceString(CCompRC::ResourceCategory eCategory, unsigned int iResourceID, wchar_t * szBuffer, int) Line 101   C++
    ilasm.exe!FormatRuntimeErrorVa(wchar_t * rcMsg, unsigned long hrRpt, HRESULT marker, char *) Line 184   C++
    ilasm.exe!PostErrorVA(HRESULT hrRpt, char * marker) Line 368    C++
>   ilasm.exe!PostError(HRESULT hrRpt, ...) Line 403    C++
    ilasm.exe!ConvertResource(const wchar_t * pszFilename, wchar_t * pszTempFilename, unsigned __int64 pewriter, PEWriter &) Line 1097  C++

and where source code of this ? or license for simple distribution ?

~43 Kb (found in \Windows\Microsoft.NET\Framework\v4.0.30319) works fine

  • Microsoft (R) Windows Resource To Object Converter Version 12.00.52512.0

3F added a commit that referenced this issue Nov 3, 2016
3F added a commit that referenced this issue Nov 3, 2016
```
    * FIXED: Fixed using of cvtres (.res -> obj COFF-format) in mscorpe.
             Possible crash: #2
             Related Issue: 3F/DllExport#17

    * NEW: Implemented additional searching of the converters of resources:
           Environment PATH, local directory, and other additional from user path.
           Now it also can be wrapped like ` mytool.cmd -> cvtres.exe %* ` etc.

    * NEW: Added new /CVRES (/CVR) key to ilasm.exe
           `/CVRES=<path_to_file>   Set path to cvtres tool: /CVR=cvtres.exe /CVR=tool\cvtres.cmd /CVR=D:\tool\`

    * NOTE: based on 4.5.22220.0  / coreclr 1.0.4
                     ^ ^  ^    ^
                     | |  |    |-- VER_FILEVERSIONREVISION
                     | |  |------- VER_FILEVERSIONBUILD
                     | |---------- VER_FILEVERSIONMINOR
                     |------------ VER_MAJORVERSION
```
3F added a commit to 3F/DllExport that referenced this issue Nov 3, 2016
@3F
Copy link
Owner Author

3F commented Nov 3, 2016

has been resolved in v4.5.1

# coreclr \ ILAsm

[v4.5.1]

    * FIXED: Fixed using of cvtres (.res -> obj COFF-format) in mscorpe.
             Possible crash: https://github.com/3F/coreclr/issues/2
             Related Issue: https://github.com/3F/DllExport/issues/17

    * NEW: Implemented additional searching of the converters of resources:
           Environment PATH, local directory, and other additional from user path.
           Now it also can be wrapped like ` mytool.cmd -> cvtres.exe %* ` etc.

    * NEW: Added new /CVRES (/CVR) key to ilasm.exe
           `/CVRES=<path_to_file>   Set path to cvtres tool: /CVR=cvtres.exe /CVR=tool\cvtres.cmd /CVR=D:\tool\`

    * NOTE: based on 4.5.22220.0  / coreclr 1.0.4
                     ^ ^  ^    ^
                     | |  |    |-- VER_FILEVERSIONREVISION
                     | |  |------- VER_FILEVERSIONBUILD
                     | |---------- VER_FILEVERSIONMINOR
                     |------------ VER_MAJORVERSION                     

@3F 3F closed this as completed Nov 3, 2016
3F added a commit that referenced this issue Nov 3, 2019
* FIXED: ILDAsm. Fixed dasm.rc to correctly display list of available commands in console.

* FIXED: ILAsm /CVRES key & trailing spaces from double quotes. Issue #5.

* CHANGED: Updated coreclr 3.0.0

* CHANGED: ILDAsm. Added /NOBAR key (disassembly progress) to eliminate the difference between other versions.
           Helpful for projects like .NET DllExport that can use various versions.

* CHANGED: Added the following tools to nupkg packages for related build processes.

           https://nuget.org/packages/ILAsm
           * tools\gnt.bat - https://github.com/3F/GetNuTool
           * tools\hMSBuild.bat - https://github.com/3F/hMSBuild

* CHANGED: Updated original fixes for ILAsm & ILDAsm that points to coreclr 3 release.

* NOTE: Don't forget to provide compatible converter of resources to obj COFF-format when using ILAsm.
        Use /CVRES (/CVR) key. Related issue: #2

* NOTE: MSBuild Properties for nupkg packages:
        ```
        * $(ILAsm_RootPkg) - path to root folder of this package after install.
        * $(ILAsm_PathToBin) - path to `\bin` folder., eg.: $(ILAsm_PathToBin)Win.x64\ilasm.exe
        ```

* NOTE: PDB files (240 MB+) are available through GitHub Releases:
        https://github.com/3F/coreclr/releases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant