Problem mit dll-Funktionen

  • Hab mir zum auslesen von werten unter einer bestimmten Speicheradresse eine dll gebastelt um sie in AutoIt nutzen zu können. Nur leider geben die Funktionen nie Werte an Autoit zurück ?(
    Hier mal die dll:

    //ReadMemory.c
    #include "ReadMemory.h"

    DllExport int EnableDebugPriv(void) {
    HANDLE hToken;
    LUID sedebugnameValue;
    TOKEN_PRIVILEGES tkp;
    if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ))
    {
    if(LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue ))
    {
    tkp.PrivilegeCount=1;
    tkp.Privileges[0].Luid = sedebugnameValue;
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    if(AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL ))
    {
    CloseHandle(hToken);
    return 0;
    };
    };
    };
    CloseHandle(hToken);
    return 1;
    }


    DllExport int ReadMemoryAdress(int Pid)
    {
    HANDLE hproc;
    int buffer;
    DWORD BytesToRead = 1;
    DWORD adress;
    int test;

    test = EnableDebugPriv();
    if (test = 1)
    {
    return 1;
    }

    adress=0x6FBD0ED2;

    hproc = OpenProcess(PROCESS_VM_READ, FALSE, Pid);

    if(ReadProcessMemory(hproc,(LPVOID)adress,&buffer,sizeof(buffer),&BytesToRead))
    {
    CloseHandle(hproc);
    return buffer;
    }
    else
    {
    CloseHandle(hproc);
    return 1;
    }
    }

    //ReadMemory.h-------------------------------------------------
    #if!defined ReadMemory_h
    #define ReadMemory_h
    #define DllExport __declspec(dllexport)

    #include <windows.h>
    #include <tlhelp32.h>

    //Funktionsdeklaration
    DllExport int EnableDebugPriv(VOID);
    DllExport int ReadMemoryAdress(int Pid);
    #endif
    kompilieren klappt alles ohne Fehler

    Nun zum Script:


    Die Variablen die mit DllCall gefüllt werden "sollten" sind es nur leider nicht aber warum ?

    Einmal editiert, zuletzt von EnClAvE (25. März 2006 um 17:44)

  • Servus,

    die Funktion dllCall gibt einen Array zurück:
    Guck mal hier: http://autoit.aufwaerts.de/usercp.php?action=addsubscription&threadid=98&sid=

    oder aus der Hilfe:

    If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified).
    $return[0] = function return value
    $return[1] = param1
    $return[2] = param2
    ...
    $return[n] = paramn