C# Injecting Unmanaged Export with Syringe

09/06/2015 18:02 falchonn#1
Hello guys, I'm having a trouble with injecting unmanaged export.


It is my unmanaged export (Test.dll) code:

Code:
using System;
using System.Threading;

using System.Windows.Forms;
using RGiesecke.DllExport;

namespace Test
{
    internal static class UnmanagedExports
    {
        [DllExport("dll_main", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        static void dll_main()
        {

            new Thread(() => Application.Run(new MainForm())).Start();
        } 
    }
}
And it is my injection code with Syringe library:

Code:
          try
            {
                using (Injector syringe = new Injector(Process.GetProcessesByName("notepad")[0]))
                {
                    syringe.InjectLibrary("Test.dll");

                    syringe.CallExport("Test.dll", "dll_main");
                }
               
                
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
When i execute my code it gives an error in here : syringe.CallExport("Test.dll", "dll_main");


It is : "The specified procedure could not be found"


Project Version: .Net Framework 2.0
DLL Version : .Net Framework 2.0
09/08/2015 18:23 Mostey#2
[Only registered and activated users can see links. Click Here To Register...]
Quote:
- You have to set your platform target to either x86, ia64 or x64. AnyCPU assemblies cannot export functions.
Have you followed that hint? I'm asking this because you obviously did not read the hints given by the DllExport package dev since you specified the calling convention and method name instead of just flagging the method with [DllExport].