Пример #1
0
        static unsafe void Main(string[] args)
        {
            Console.WriteLine(new { Environment.Is64BitProcess });


            // Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

            // Additional information: Unable to load DLL 'TestConsoleWriteLine.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
            // http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell
            // https://www.wireshark.org/docs/wsdg_html_chunked/ChToolsMSChain.html
            // http://stackoverflow.com/questions/2727187/creating-dll-and-lib-files-with-the-vc-command-line
            // http://www.dotnetperls.com/dllimport

            ///dll
            ///implib:TestConsoleWriteLine.lib
            ///out:TestConsoleWriteLine.dll
            //TestConsoleWriteLine.dll.obj
            //   Creating library TestConsoleWriteLine.lib and object TestConsoleWriteLine.exp

            // http://stackoverflow.com/questions/24297616/dllimport-an-attempt-was-made-to-load-a-program-with-an-incorrect-format
            //{ Is64BitProcess = True }
            //hello

            // The program '[9300] TestExport1ViaImport.vshost.exe' has exited with code 1073741855 (0x4000001f).
            // 'TestExport1ViaImport.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr100.dll'. Cannot find or open the PDB file.
            // Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
            {
                var value = TheExport1();

                Console.WriteLine(new { value });
            }


            //Additional information: A call to PInvoke function 'TestExport1ViaImport!TestExport1ViaImport.Program::Export196' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

            {
                var p = new global::CLRLibraryDllExportDefinition.uvec3 {
                    x = 34
                };
                var pp = &p;

                var value = Export196(pp);

                Console.WriteLine(new { value });
            }

            //            hello.Enable native code debugging
            //{ value = 64 }
        }
Пример #2
0
        static unsafe void Main(string[] args)
        {
            Console.WriteLine(new { Environment.Is64BitProcess });


            // Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

            // Additional information: Unable to load DLL 'TestConsoleWriteLine.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
            // http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell
            // https://www.wireshark.org/docs/wsdg_html_chunked/ChToolsMSChain.html
            // http://stackoverflow.com/questions/2727187/creating-dll-and-lib-files-with-the-vc-command-line
            // http://www.dotnetperls.com/dllimport

            ///dll
            ///implib:TestConsoleWriteLine.lib
            ///out:TestConsoleWriteLine.dll
            //TestConsoleWriteLine.dll.obj
            //   Creating library TestConsoleWriteLine.lib and object TestConsoleWriteLine.exp

            // http://stackoverflow.com/questions/24297616/dllimport-an-attempt-was-made-to-load-a-program-with-an-incorrect-format
            //{ Is64BitProcess = True }
            //hello

            // The program '[9300] TestExport1ViaImport.vshost.exe' has exited with code 1073741855 (0x4000001f).
            // 'TestExport1ViaImport.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr100.dll'. Cannot find or open the PDB file.
            // Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
            {
                var value = TheExport1();

                Console.WriteLine(new { value });
            }


            //Additional information: A call to PInvoke function 'TestExport1ViaImport!TestExport1ViaImport.Program::Export196' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

            {
                var p = new global::CLRLibraryDllExportDefinition.uvec3 { x = 34 };
                var pp = &p;

                var value = Export196(pp);

                Console.WriteLine(new { value });
            }

            //            hello.Enable native code debugging
            //{ value = 64 }

        }