コード例 #1
0
        private unsafe void Form1_Load(object sender, EventArgs e)
        {
            DLLFromMemory dll = new DLLFromMemory(Properties.Resources.DllInC__);

            SomeExportedFunctionInTheDll addFunc = dll.GetDelegateFromFuncName <SomeExportedFunctionInTheDll>("AddInteger");

            MessageBox.Show(addFunc.DynamicInvoke(10, 10).ToString());
        }
コード例 #2
0
    static int Main(string[] args)
    {
        Console.WriteLine("Process is " + (DLLFromMemory.Is64BitProcess ? "64" : "32") + "bit\n");

        DLLFromMemory dll = new DLLFromMemory(GetSampleDLLBytes());

        AddDelegate addFunc = dll.GetDelegateFromFuncName <AddDelegate>("Add");

        Console.WriteLine("Calling add(1, 2): " + addFunc(1, 2) + "\n");

        CallCallbackDelegate callCallbackFunc = dll.GetDelegateFromFuncName <CallCallbackDelegate>("CallCallback");

        Console.WriteLine("Calling callCallback(TestCallback, 777)...");
        callCallbackFunc(TestCallback, 777);
        Console.WriteLine("Done!\n");

        dll.Close();
        return(0);
    }