Jump to content

dllcall pointer problem


Recommended Posts

I try to call a function from a dll with calldll. It seems to work for all functions which don't uses pointers, but for all functions, which uses pointers the dllcall will crash.

This is the definition of the function in the header file of the dll:

BOOL SetDirection(BYTE Position, BYTE Dir, DWORD *Mask);

I use the dllcall function in that way:

$Return = DllStructCreate("DWORD[1];")

$dll = DllOpen("mydll.dll")

$ret1 = DllCall($dll,"BOOL", "etDirection", "BYTE", 0, "BYTE", 1, "ptr", DllStructGetPtr($Return, 1))

if @error Then

MsgBox(0, "DEBUG", "Error: " & @error)

Endif

DllClose($dll)

If I use "BOOL:cdecl" as return type, the programm doesn't crash, but it doesn't return the right value from the function into the dllstruct value. There must be somwthing I'm doing wrong with the pointer, but I can't find the problem.

Someone has faced the same problem?

Link to comment
Share on other sites

Are you really sure the call takes two bytes as argument? That is HIGLY unusual. Most often they will use ints though they really just use one byte from it...

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
Link to comment
Share on other sites

The definition in the Header file of the dll is like I already posted:

BOOL SetDirection(BYTE Position, BYTE Dir, DWORD *Mask);

But I've seen a sample code in C++ where they used a UINT32 variable for the same purpose ( .....&uint32variable).

If I would know how to reproduce the same thing in autoit I would give it a try.

Link to comment
Share on other sites

BOOL SetDirection(BYTE Position, BYTE Dir, DWORD *Mask);

$Return = DllStructCreate("DWORD[1];")

$ret1 = DllCall($dll,"BOOL", "etDirection", "BYTE", 0, "BYTE", 1, "ptr", DllStructGetPtr($Return, 1))

Further ideas...

I'd do the struct like this:

$Return = DllStructCreate("DWORD")

But you might just do:

$ret1 = DllCall($dll,"BOOL", "etDirection", "BYTE", 0, "BYTE", 1, "dword*", 0)

where dword* is dwordptr and to read it: look in $ret1[3]

/Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
Link to comment
Share on other sites

Hi Manko,

I tried both solutions, but it doesn't work. I was able to get some more source in C# where they call the function in that way:

UInt32 pinSet;

GPIO.IOSetDirection(7, 0, &pinSet);

So I tried with

$ret1 = DllCall($dll,"BOOL", "etDirection", "BYTE", 0, "BYTE", 1, "uint*", 0)

didn't work

$ret1 = DllCall($dll,"BOOL", "etDirection", "BYTE", 0, "BYTE", 1, "UINT*", 0)

didn't work

I tried also with struct

$Return = DllStructCreate("uint")

didn't work

$Return = DllStructCreate("UINT)

didn't work

I have only the problem with the pointer. All functions without pointer in their parameter works.

Seems there must be a trick for the usage of the pointer, but I can't get it; any help left?

Link to comment
Share on other sites

I tried the same thing with "int" as variable type, with 0-Pointer and struct, no way.

I was able to get an error message telling me "read operation at 0xc45bfer.. could not be executed...", seems there are trouble with memory allocation of pointers. Has Anyone a tip for me?

Link to comment
Share on other sites

Could you link the DLL documentation (edit: or the header file), please? The C#-source inidactes the use of objects which doesn't work with AutoIt. If not, you'll have to write at least the correct function name (SetDirection).

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

The Function I tried is SusiIOSetDirection.

It's a C# Project in Visual Studio 2005. Functions without pointer works, only functions with pointers in the parameters crashes.

I have no documentation but I can show you the headerfile:

#ifndef _SUSI_H_

#define _SUSI_H_

#ifdef __cplusplus

extern "C" {

#endif

#define SUSI_API __declspec(dllexport)

//*****************************************************************************

// Core Definition

//*****************************************************************************

//-----------------------------------------------------------------------------

// CPU Information

//-----------------------------------------------------------------------------

// Vendor

#define INTEL 1 << 0

#define VIA 1 << 1

#define SIS 1 << 2

#define NVIDIA 1 << 3

#define AMD 1 << 4

#define RDC 1 << 5

//*****************************************************************************

// Boot Counter Definition

//*****************************************************************************

typedef enum

{

ESCORE_BOOTCOUNTER_STATUS = 0x01,

ESCORE_BOOTCOUNTER_VALUE = 0x02

} ESCORE_BOOTCOUNTER;

enum

{

ESCORE_BOOTCOUNTER_MODE_GET = 0,

ESCORE_BOOTCOUNTER_MODE_SET = 1

};

//*****************************************************************************

// Run Timer Definition

//*****************************************************************************

typedef enum

{

ESCORE_RUNTIMER_STATUS_RUNNING = 0x01,

ESCORE_RUNTIMER_STATUS_AUTORUN = 0x02,

ESCORE_RUNTIMER_VALUE_CONTINUALON = 0x04,

ESCORE_RUNTIMER_VALUE_TOTALON = 0x08

} ESCORE_RUNTIMER;

enum

{

ESCORE_RUNTIMER_MODE_GET = 0,

ESCORE_RUNTIMER_MODE_SET = 1

};

typedef struct

{

DWORD dwOPFlag;

BOOL isRunning;

BOOL isAutorun;

DWORD dwTimeContinual;

DWORD dwTimeTotal;

} SSCORE_RUNTIMER, *PSSCORE_RUNTIMER;

//*****************************************************************************

// GPIO Definition

//*****************************************************************************

typedef enum

{

// Static mask

ESIO_SMASK_PIN_FULL = 0x0001,

ESIO_SMASK_CONFIGURABLE = 0x0002,

ESIO_SMASK_FIXIN = 0x0004,

ESIO_SMASK_FIXOUT = 0x0008,

ESIO_SMASK_IF_OUT_READABLE = 0x0010,

// Dynamic mask

ESIO_DMASK_DIRECTION = 0x0020,

ESIO_DMASK_IN = 0x0040,

ESIO_DMASK_OUT = 0x0080,

ESIO_DMASK_READABLEOUT = 0x0100

} ESIO_MASKFLAG;

//*****************************************************************************

// HWM Definition

//*****************************************************************************

// Voltage

#define VMAX_SHIFT 14

#define VCORE (1 << 0) // Vcore

#define V25 (1 << 1) // 2.5V

#define V33 (1 << 2) // 3.3V

#define V50 (1 << 3) // 5V

#define V120 (1 << 4) // 12V

#define V5SB (1 << 5) // V5 standby

#define V3SB (1 << 6) // V3 standby

#define VBAT (1 << 7) // VBAT

#define VN50 (1 << 8) // -5V

#define VN120 (1 << 9) // -12V

#define VTT (1 << 10) // VTT

#define VCORE2 (1 << 11) // Vcore2

#define V105 (1 << 12) // 1.05V

#define V15 (1 << 13) // 1.5V

#define V18 (1 << VMAX_SHIFT) // 1.8V

// Temperature

#define TCPU (1 << 0) // CPU temperaturez

#define TSYS (1 << 1) // System temperature

#define TAUX (1 << 2) // 3'rd thermal dioad

// Fan Speed

#define FCPU (1 << 0) // CPU FAN Speed

#define FSYS (1 << 1) // System FAN Speed

#define F2ND (1 << 2) // Other FAN Speed

//*****************************************************************************

// IIC Definition

//*****************************************************************************

#define SUSI_IIC_TYPE_PRIMARY 1

#define SUSI_IIC_TYPE_SMBUS 2

#define SUSI_IIC_TYPE_BOTH 3

//*****************************************************************************

// WDT Definition

//*****************************************************************************

#define WDTOUT0 0

#define WDTOUT1 1

#define WDTGPIO 2

#define WDTMAXNUM 3 // WDT Max. Number, for count amount.

//*****************************************************************************

// SUSI APIs

//*****************************************************************************

//-----------------------------------------------------------------------------

// Driver Independent APIs

//-----------------------------------------------------------------------------

SUSI_API int SusiDllGetLastError();

SUSI_API void SusiDllGetVersion(DWORD *major, DWORD *minor);

SUSI_API BOOL SusiDllInit();

SUSI_API BOOL SusiDllUnInit();

// Old APIs for backard compatible, now use the whole new set

SUSI_API void SusiGetVersion(WORD *major, WORD *minor); // now use SusiDllGetVersion

SUSI_API BOOL SusiInit(); // now use SusiDllInit

SUSI_API BOOL SusiUnInit(); // now use SusiDllUnInit

//-----------------------------------------------------------------------------

// CORE

//-----------------------------------------------------------------------------

SUSI_API int SusiCoreAvailable();

SUSI_API BOOL SusiCoreAccessBootCounter(DWORD mode, DWORD OPFlag, BOOL *enable, DWORD *value);

SUSI_API BOOL SusiCoreAccessRunTimer(DWORD mode, PSSCORE_RUNTIMER pRunTimer);

SUSI_API BOOL SusiCoreGetBIOSVersion(TCHAR *BIOSVersion, DWORD *size);

SUSI_API BOOL SusiCoreGetPlatformName(TCHAR *PlatformName, DWORD *size);

SUSI_API BOOL SusiCoreRebootSystem(DWORD delay, BOOL regSave);

SUSI_API BOOL SusiCoreGetBIOSString(TCHAR *stringBIOS, DWORD *size);

SUSI_API BOOL SusiCoreReadIO(DWORD addr, DWORD &value);

SUSI_API BOOL SusiCoreWriteIO(DWORD addr, DWORD value);

SUSI_API BOOL SusiCoreReadULongIO(DWORD addr, DWORD &value);

SUSI_API BOOL SusiCoreWriteULongIO(DWORD addr, DWORD value);

SUSI_API BOOL SusiCorePciBusSetULong(int busNum, int devNum, int funNum, UCHAR regIndex);

SUSI_API BOOL SusiCorePciBusGetULong(int busNum, int devNum, int funNum, UCHAR regIndex, DWORD &value);

SUSI_API BOOL SusiCoreGetCpuMaxSpeed(DWORD &Value);

SUSI_API BOOL SusiCoreGetCpuVendor(DWORD &Value);

SUSI_API BOOL SUSIPlusCpuSetThrottling(unsigned char step);

SUSI_API BOOL SUSIPlusCpuGetThrottling(unsigned char *step);

SUSI_API BOOL SUSIPlusCpuSetSpeedStep(HANDLE proc_handler, unsigned char cpu_index, unsigned char step);

SUSI_API BOOL SUSIPlusCpuGetSpeedStep(HANDLE proc_handler, unsigned char cpu_index, unsigned char *step);

SUSI_API BOOL SusiCoreEnableBootfail();

SUSI_API BOOL SusiCoreDisableBootfail();

SUSI_API BOOL SusiCoreRefreshBootfail();

SUSI_API int SusiGetBIOSVersion(TCHAR *BIOSVersion, BYTE size); // Old API for backward compatible, now use SusiCoreGetBIOSVersion!

SUSI_API int SusiGetPlatformName(TCHAR *PlatformName, BYTE size); // Old API for backward compatible, now use SusiCoreGetPlatformName!

//-----------------------------------------------------------------------------

// WDT

//-----------------------------------------------------------------------------

SUSI_API int SusiWDAvailable();

SUSI_API BOOL SusiWDDisable();

SUSI_API BOOL SusiWDGetRange(DWORD *minimum, DWORD *maximum, DWORD *stepping);

SUSI_API BOOL SusiWDSetConfig(DWORD delay, DWORD timeout);

SUSI_API BOOL SusiWDTrigger();

SUSI_API BOOL SusiWDDisableEx(int group_number);

SUSI_API BOOL SusiWDSetConfigEx(int group_number, DWORD delay, DWORD timeout);

SUSI_API BOOL SusiWDTriggerEx(int group_number);

SUSI_API BOOL SusiSetDetectPowerOffProtection(DWORD time);

SUSI_API BOOL SusiClearDetectPowerOffProtection();

//-----------------------------------------------------------------------------

// GPIO

//-----------------------------------------------------------------------------

// New API set for configurable GPIO

SUSI_API BOOL SusiIOCountEx(DWORD *inCount, DWORD *outCount);

SUSI_API BOOL SusiIOQueryMask(DWORD flag, DWORD *Mask);

SUSI_API BOOL SusiIOReadEx(BYTE PinNum, BOOL *status);

SUSI_API BOOL SusiIOReadMultiEx(DWORD TargetPinMask, DWORD *StatusMask);

SUSI_API BOOL SusiIOSetDirection(BYTE PinNum, BYTE IO, DWORD *PinDirMask);

SUSI_API BOOL SusiIOSetDirectionMulti(DWORD TargetPinMask, DWORD *PinDirMask);

SUSI_API BOOL SusiIOWriteEx(BYTE PinNum, BOOL status);

SUSI_API BOOL SusiIOWriteMultiEx(DWORD TargetPinMask, DWORD StatusMask);

//Old APIs for backard compatible, now use the whole new set

SUSI_API BOOL SusiIOAvailable();

SUSI_API BOOL SusiIOInitial(DWORD statuses);

SUSI_API BOOL SusiIOCount(WORD *inCount, WORD *outCount);

SUSI_API BOOL SusiIORead(BYTE pin, BOOL *status);

SUSI_API BOOL SusiIOReadMulti(DWORD pins, DWORD *statuses);

SUSI_API BOOL SusiIOWrite(BYTE pin, BOOL status);

SUSI_API BOOL SusiIOWriteMulti(DWORD pins, DWORD statuses);

// For LED ON/OFF control

SUSI_API BOOL SusiLEDSet(BYTE Status);

SUSI_API BOOL SusiLEDGet(BYTE *Status);

//-----------------------------------------------------------------------------

// SMBus

//-----------------------------------------------------------------------------

SUSI_API int SusiSMBusAvailable();

SUSI_API BOOL SusiSMBusReadBlock(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE *ByteCount);

SUSI_API BOOL SusiSMBusI2CReadBlock(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE *ByteCount);

SUSI_API BOOL SusiSMBusReadByte(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result);

SUSI_API BOOL SusiSMBusReadByteMulti(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL SusiSMBusReadQuick(BYTE SlaveAddress);

SUSI_API BOOL SusiSMBusReadWord(BYTE SlaveAddress, BYTE RegisterOffset, WORD *Result);

SUSI_API BOOL SusiSMBusReceiveByte(BYTE SlaveAddress, BYTE *Result);

SUSI_API int SusiSMBusScanDevice(BYTE SlaveAddress_7);

SUSI_API BOOL SusiSMBusSendByte(BYTE SlaveAddress, BYTE Result);

SUSI_API BOOL SusiSMBusWriteBlock(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL SusiSMBusI2CWriteBlock(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL SusiSMBusWriteByte(BYTE SlaveAddress, BYTE RegisterOffset, BYTE Result);

SUSI_API BOOL SusiSMBusWriteByteMulti(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL SusiSMBusWriteQuick(BYTE SlaveAddress);

SUSI_API BOOL SusiSMBusWriteWord(BYTE SlaveAddress, BYTE RegisterOffset, WORD Result);

SUSI_API BOOL SusiSMBusReset(void);

//-----------------------------------------------------------------------------

// IIC

//-----------------------------------------------------------------------------

// New

SUSI_API int SusiIICAvailable();

SUSI_API BOOL SusiIICRead(DWORD IICType, BYTE SlaveAddress, BYTE *ReadBuf, DWORD ReadLen);

SUSI_API BOOL SusiIICWrite(DWORD IICType, BYTE SlaveAddress, BYTE *WriteBuf, DWORD WriteLen);

SUSI_API BOOL SusiIICWriteReadCombine(DWORD IICType, BYTE SlaveAddress, BYTE *WriteBuf, DWORD WriteLen, BYTE *ReadBuf, DWORD ReadLen);

//Old APIs for backard compatible, now use the whole new set

SUSI_API BOOL SusiIICReadByteMulti(BYTE SlaveAddress, BYTE *ReadBuf, DWORD ReadLen); // Old API for backward compatible, now use SusiIICRead!

SUSI_API BOOL SusiIICWriteByteMulti(BYTE SlaveAddress, BYTE *WriteBuf, DWORD WriteLen); // Old API for backward compatible, now use SusiIICWrite!

//-----------------------------------------------------------------------------

// VC

//-----------------------------------------------------------------------------

SUSI_API int SusiVCAvailable();

SUSI_API BOOL SusiVCGetBright(BYTE *brightness);

SUSI_API BOOL SusiVCGetBrightRange(BYTE *minimum, BYTE *maximum, BYTE *stepping);

SUSI_API BOOL SusiVCScreenOff();

SUSI_API BOOL SusiVCScreenOn();

SUSI_API BOOL SusiVCSetBright(BYTE brightness);

//-----------------------------------------------------------------------------

// HWM

//-----------------------------------------------------------------------------

SUSI_API int SusiHWMAvailable();

SUSI_API BOOL SusiHWMGetFanSpeed(WORD fanType, WORD *retval, WORD *typeSupport = NULL);

SUSI_API BOOL SusiHWMGetTemperature(WORD tempType, float *retval, WORD *typeSupport = NULL);

SUSI_API BOOL SusiHWMGetVoltage(DWORD voltType, float *retval, DWORD *typeSupport = NULL);

SUSI_API BOOL SusiHWMSetFanSpeed(WORD fanType, BYTE setval, WORD *typeSupport = NULL);

//*****************************************************************************

// AdvLib APIs

//*****************************************************************************

// Only for backward compatible with Advantech Library,

// new users of SUSI Library can simply ignore these

//-----------------------------------------------------------------------------

// Driver Independent APIs

//-----------------------------------------------------------------------------

SUSI_API void AdvLibGetVersion(WORD *major, WORD *minor);

SUSI_API BOOL AdvLibInit();

SUSI_API BOOL AdvLibUnInit();

//-----------------------------------------------------------------------------

// CORE

//-----------------------------------------------------------------------------

SUSI_API int AdvLibGetBIOSVersion(TCHAR *BIOSVersion, BYTE size);

SUSI_API int AdvLibGetPlatformName(TCHAR *PlatformName, BYTE size);

//-----------------------------------------------------------------------------

// WDT

//-----------------------------------------------------------------------------

SUSI_API int AdvLibWDAvailable();

SUSI_API BOOL AdvLibWDDisable();

SUSI_API BOOL AdvLibWDGetRange(DWORD *minimum, DWORD *maximum, DWORD *stepping);

SUSI_API BOOL AdvLibWDSetConfig(DWORD delay, DWORD timeout);

SUSI_API BOOL AdvLibWDTrigger();

//-----------------------------------------------------------------------------

// GPIO

//-----------------------------------------------------------------------------

SUSI_API BOOL AdvLibIOAvailable();

SUSI_API BOOL AdvLibIOCount(WORD *inCount, WORD *outCount);

SUSI_API BOOL AdvLibIOInitial(DWORD statuses);

SUSI_API BOOL AdvLibIORead(BYTE pin, BOOL *status);

SUSI_API BOOL AdvLibIOReadMulti(DWORD pins, DWORD *statuses);

SUSI_API BOOL AdvLibIOWrite(BYTE pin, BOOL status);

SUSI_API BOOL AdvLibIOWriteMulti(DWORD pins, DWORD statuses);

//-----------------------------------------------------------------------------

// SMBus

//-----------------------------------------------------------------------------

SUSI_API BOOL AdvLibSMBusAvailable();

SUSI_API BOOL AdvLibSMBusReadByte(BYTE SlaveAddress, BYTE RegisterOffset, BYTE *Result);

SUSI_API BOOL AdvLibSMBusReadByteMulti(BYTE SlaveAddress,BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL AdvLibSMBusReadWord(BYTE SlaveAddress, BYTE RegisterOffset, WORD *Result);

SUSI_API BOOL AdvLibSMBusWriteByte(BYTE SlaveAddress, BYTE RegisterOffset, BYTE Result);

SUSI_API BOOL AdvLibSMBusWriteByteMulti(BYTE SlaveAddress,BYTE RegisterOffset, BYTE *Result, BYTE ByteCount);

SUSI_API BOOL AdvLibSMBusWriteWord(BYTE SlaveAddress, BYTE RegisterOffset, WORD Result);

//-----------------------------------------------------------------------------

// VC

//-----------------------------------------------------------------------------

SUSI_API int AdvLibVCAvailable();

SUSI_API BOOL AdvLibVCGetBright(BYTE *brightness);

SUSI_API BOOL AdvLibVCGetBrightRange(BYTE *minimum, BYTE *maximum, BYTE *stepping);

SUSI_API BOOL AdvLibVCScreenOff();

SUSI_API BOOL AdvLibVCScreenOn();

SUSI_API BOOL AdvLibVCSetBright(BYTE brightness);

//-----------------------------------------------------------------------------

// HWM

//-----------------------------------------------------------------------------

SUSI_API int AdvLibHWMAvailable();

SUSI_API BOOL AdvLibHWMGetFanSpeed(WORD fanType, WORD *retval, WORD *typeSupport = NULL);

SUSI_API BOOL AdvLibHWMGetTemperature(WORD tempType, float *retval, WORD *typeSupport = NULL);

SUSI_API BOOL AdvLibHWMGetVoltage(DWORD voltType, float *retval, DWORD *typeSupport = NULL);

//-----------------------------------------------------------------------------

// PWS

//-----------------------------------------------------------------------------

SUSI_API BOOL SusiPWRSetCPUFrequency(DWORD sel);

#ifdef __cplusplus

}

#endif

#endif //_SUSI_H_

I hope the header file can help you.

Link to comment
Share on other sites

Vermutlich ist das cdecl, da extern C angegeben wurde und kein zusätzliches __stdcall. Also sollte es mit :cdecl und dword* klappen.

Edit: Sorry, I mixed up the english and german forum :graduated:

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Hi ProgAndy,

auch damit habe Ichs versucht. Die Application crasht dann zwar nicht mehr, aber die Pointervariable wird nicht geschrieben, ich kriege also entweder immer den Wert "0", oder wenn ich im Struct vorher den Wert auf irgendeinen Wert setze bleibt er gleich.

Das hier wäre der Aufruf im C# Projekt:

UInt32 pinDirAfterSet;

textBox1.Enabled = true;

SUSI_GPIO.SusiIOSetDirection(7, 0, &pinDirAfterSet);

Link to comment
Share on other sites

Mittlerweile habe Ich weiter herum experimentiert.

Eine Funktion mit nur Pointern:

SUSI_API void SusiDllGetVersion(DWORD *major, DWORD *minor); //Definition aus Header

funktioniert ohne Probleme mit folgendem AUfruf aus Autoit:

$struct2 = DllStructCreate("int;int")

$pointer1 = DllStructGetPtr($struct2,1)

$pointer2 = DllStructGetPtr($struct2,2)

DllCall($dll,"none:cdecl", "SusiDllGetVersion", "ptr",$pointer1, "ptr", $pointer2)

MsgBox(0, "DEBUG", "Version:" & @CRLF & "Major: " & DllStructGetData($struct2,1) & @CRLF & "Minor: " & DllStructGetData($struct2,2))

Das heißt also für die vorherige Funktion, die Ich verwendet habe, stimmt nun zwar der pointer, aber da diese auch immer noch nicht funktioniert, kann es nur an den beiden "Byte" Parametern liegen:

SUSI_API BOOL SusiIOSetDirection(BYTE PinNum, BYTE IO, DWORD *PinDirMask); //Definition aus Header Datei

$ret3 = DllCall($dll,"BOOL:cdecl", "SusiIOSetDirection", "BYTE",0, "BYTE", 1, "ptr", $pointer1) //Aufruf aus Autoit

Hier muss es eine Datentyp-Inkompatibilität geben zwischen "BYTE" in Autoit und "BYTE" in der dll.

Link to comment
Share on other sites

Why don't you write english again? This is an english forum and my german comment was only an accident :graduated:

There shouldn't be an incompatibility, but why don't you try dword or int instead? the memory reserved for a parameter is always a multiple of 4, so this shouldn't be a problem.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It's me again,

Sorry, I will go on in English of course.

I tried another Function, which gets only a BYTE Value, for trying to get the parameters to work.

This is the function:

SUSI_API BOOL SusiLEDSet(BYTE Status); //definition in header file

I tried to call it in Autoit:

$ret3 = DllCall($dll,"BOOL:cdecl", "SusiLEDSet", "BYTE", 0x04)

I tried instead of "BYTE" with the following types:

BYTE -- doesn't work.

BOOLEAN -- doesn't work.

short -- doesn't work.

USHORT -- doesn't work.

WORD -- doesn't work.

int -- doesn't work.

long -- doesn't work.

BOOL -- doesn't work.

UINT -- doesn't work.

ULONG -- doesn't work.

DWORD -- doesn't work.

I have no Idea which type to use.

This is the call from the C# Project:

byte LEDState = 0;

LEDState |= 0x04;

SUSI_GPIO.SusiLEDSet(LEDState);

Any idea?

Link to comment
Share on other sites

Did you call SusiDllInit after loading the dll and SusiDllUnInit before exit?. I think that might be required.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Quoted from: "SUSI V3.0 UserManual.pdf":

"... users have to call

SusiDllInit for initialization before using any other APIs that are not SusiDll-

prefixed. Before the application terminates, call SusiDllUnInit to free allocated

system resources."

So there might be a logic to why you had success with that SusiDLL-call and not the others... *Hoping!*

/Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
Link to comment
Share on other sites

Hi

of course I do the Init, before I do every other Call:

$dll = DllOpen("Susi.dll")

$ret1 = DllCall("Susi.dll","BOOL:cdecl","SusiDllInit") //Get here back "1", so it's ok

$ret1 = DllCall($dll,"int:cdecl", "SusiIOAvailable") //Get here back also "1" so I/O must be available.

$ret3 = DllCall($dll,"BOOL:cdecl", "SusiLEDSet", "int", 0x02) //doesn't work, return value always "0"

$ret4 = DllCall($dll,"BOOL:cdecl", "SusiDllUnInit") //Get here back "1" so it's ok

Any Ideas?

Link to comment
Share on other sites

im realy interested of how you know that its returning 1 or 0, where is your code that will display that its called correctly? i dont see error returning check in your code?!! i dont see returning valye if no error in your code!

//Get here back "1", so it's ok

where can anyone download that dll? do that dll have SusiLEDSet command in it, did you check it with 'DLL Export Viewer' or some other similar program to see if its realy there?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I wanted to be as short as possible so I wasted the Messageboxes. Here is the whole code:

$dll = DllOpen("Susi.dll")

$ret1 = DllCall("Susi.dll","BOOL:cdecl","SusiDllInit")

MsgBox(0, "DEBUG", "Init: " & $ret1[0])

$ret1 = DllCall($dll,"int", "SusiIOAvailable")

if $ret1[0] < 0 Then

$ret1 = DllCall("Susi.dll","int:cdecl", "SusiDllGetLastError")

MsgBox(0, "SusiError", "Error: " & $ret1[0])

EndIf

if @error Then

MsgBox(0, "DEBUG", "Error: " & @error)

Endif

MsgBox(0, "DEBUG", "I/O available: " & $ret1[0]); & @CRLF & "Set I/O Direction return [2]: " & $ret1[2] & @CRLF & "Set I/O Direction return [3]: " & $ret1[3])

DllClose($dll)

Sleep(1000)

$dll = DllOpen("Susi.dll")

$ret3 = DllCall($dll,"BOOL:cdecl", "SusiLEDSet", "int", 0x02)

MsgBox(0, "DEBUG", "I/O:" & $ret3[0])

$ret4 = DllCall($dll,"BOOL:cdecl", "SusiDllUnInit")

MsgBox(0, "DEBUG", "Uninit: " & $ret3[4])

DllClose($dll)

Exit

Link to comment
Share on other sites

I got the fault,

I tried something by closing the DLL and reopen it; I forgot it. After elimiinating this part it works:

$dll = DllOpen("Susi.dll")

$ret1 = DllCall("Susi.dll","BOOL:cdecl","SusiDllInit")

MsgBox(0, "DEBUG", "Init: " & $ret1[0])

$ret1 = DllCall($dll,"int", "SusiIOAvailable")

if $ret1[0] < 0 Then

$ret1 = DllCall("Susi.dll","int:cdecl", "SusiDllGetLastError")

MsgBox(0, "SusiError", "Error: " & $ret1[0])

EndIf

if @error Then

MsgBox(0, "DEBUG", "Error: " & @error)

Endif

MsgBox(0, "DEBUG", "I/O available: " & $ret1[0])

$ret3 = DllCall($dll,"BOOL:cdecl", "SusiLEDSet", "int", 0x02)

if @error Then

MsgBox(0, "DEBUG", "Error: " & @error)

Endif

MsgBox(0, "DEBUG", "I/O:" & $ret3[0]); & @CRLF & "In: " & DllStructGetData($struct2,1) & @CRLF & "Out: " & DllStructGetData($struct2,2))

$ret4 = DllCall($dll,"BOOL:cdecl", "SusiDllUnInit")

if @error Then

MsgBox(0, "DEBUG", "Error: " & @error)

Endif

MsgBox(0, "DEBUG", "Uninit: " & $ret4[0])

DllClose($dll)

Exit

Now I will try again with pointers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...