Quote:
Originally Posted by Dodge
das muss bissl anders aussehn :)
siehe Function pointer (Quelle: Wikipedia)
Code:
#include <stdio.h>
static int my_function(int a)
{
printf("my_function: %dn", a);
return (2*a + 3);
}
int main(void)
{
int (*new_function)(int) = my_function;
int x;
x = (*new_function)(10);
printf("main: %dn", x);
return 0;
}
du müsstest halt hier " int (*new_function)(int) = my_function;" anstelle von my_function die adresse schreiben
Gruß^^
|
ansonsten ließe sich das 1:1 übernehmen?! O.o
muss ich beim erstellen irgendwas beachten, wenn ich ne dll haben will? ich hatte nun versucht das mit asm hinzu bekommen....
aber es klappt nicht
Code:
/* Replace "dll.h" with the name of your header */
#include "dll_test.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
DLLIMPORT void HelloWorld ()
{
char buchstabe = 'U';
__asm{
mov eax, buchstabe
push eax
call 01002A55
}
MessageBox (0, "Hello World from DLL!n", "Hi", MB_ICONINFORMATION);
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
nicht wundern - ist nen preset von DEV-Cpp zur erstellung von dlls.
ich hatte vorher die asm funtion in der Dllmain funktion...
aber leider meckert der compiler^^
vermutlich hab ich einfach noch nicht genug ahnung...
ich sollte vllt wieder in meinem Buch lesen...