Jump to content

DLLCALL problem


Sundance
 Share

Recommended Posts

Hello together,

i'am writing udf's for managing the Altiris SVS package (virtualisation of software products).

I've done some functions wich work as they should (getting the list of installed packages, get GUID from package name and visa versa).

But with one function i'am getting in big trouble. I believe that the created dll structure is not the one neede by the dll function.

So here the info's :

function info from the corresponding helpfile:

FSL2GetLayerInfo

DWORD __stdcall FSL2GetLayerInfo(LPCSTR fslGUID, PFSL2_INFO pInfo)

Retrieves information about a FSL.

Returns One of the following

FSL2_ERROR_SUCCESS

On success

Misc

Misc errors

Parameters

fslGUID

Identifies the FSL

pInfo

Pointer to an allocated pFSLInfoStruct pInfo->dwStructSize must be initialized to the size of a FSLInfoStruct

The structure mentioned pFSLInfoStruct is :

FSL2_INFO Structure

typedef struct {

DWORD dwStructSize;

BOOL bIsGroup;

DWORD dwLayerType;

char name[FSL2_MAXNAMELEN];

char peerName[FSL2_MAXNAMELEN];

char regPath[FSL2_MAXREG];

char fileRedirPath[FSL2_MAXPATH];

char regRedirPath[FSL2_MAXREG];

DWORD active;

DWORD activeonstart;

DWORD enabled;

DWORD majorVersion;

DWORD minorVersion;

DWORD lastActivatedTime;

DWORD createTime;

DWORD lastRefreshTime;

char fslGUID[FSL2_MAXIDLEN_BYTES];

char peerGUID[FSL2_MAXIDLEN_BYTES];

DWORD compressionLevel;

} FSL2_INFO;

From a header file i read the following defines for the character length's:

#define FSL2_MAXNAMELEN 64

#define FSL2_MAXPATH MAX_PATH

#define FSL2_MAXREG MAX_PATH

#define FSL2_MAXIDLEN 100

#define FSL2_MAXIDLEN_BYTES (FSL2_MAXIDLEN * sizeof(WCHAR))

Reading microsoft's support forum MAXPATH ist 256 chars long.

I did create a dll structure and setting the dwStructSize value like this:

CODE
Local $structFSL2_Info = DllStructCreate("int;int;int;char[64];char[64];char[200];char[200];char[256];int;int;int;int;int;int;int;int;cha

r[64];char[64];int")

DllStructSetData($structFSL2_Info,1,DllStructGetSize($structFSL2_Info))

the DLLCALL ist:

CODE
$result =

DllCall("fsllib32.dll","int","FSL2GetLayerInfo","ptr",DllStructGetPtr($structGUID),"ptr",DllStructGetPtr($structFSL2_Info))

@error is set to 0, so it finds the dll and does the call but the returncode from the dll ist 1006.

In the svs c++ header file i read :

#define FSL2_ERROR_BAD_ARGS 1006

So obviously i have a problem with the args. The pointer to the GUID can't be the problem because i have other functions with the same parameter call wich are working fine. So i think the problem lies within the info-structure. (could be the definition of #define FSL2_MAXIDLEN_BYTES (FSL2_MAXIDLEN * sizeof(WCHAR)) ??)

So,puuh. I know this is much to read but i hope someone has an idea :whistle:

greets

Sundance

Link to comment
Share on other sites

Hi,

you defined BOOL as "int", however a lot of compilers (esp. MS VC) define BOOL as 1 Byte. So, your DLLStruct should be:

"int;ubyte;int;char[64];char[64];char[200];char[200];char[256];int;int;int;int;int;int;int;int;c

har[64];char[64];int"

Maybe that helps ....

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

windef.h (MSVC6): MAX_PATH is 260 not 256...

According to a forum entry of altiris, the whole structure size has to be 1356. If it is not, error 1006 will be returned. So, the correct structure would be:

"int;int;int;char[64];char[64];char[260];char[260];char[260];int;int;int;int;int;int;int;int;cha

r[200];char[200];int"

This structure's size sums up to 1356. Maybe this helps.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Many thx for the reply's. I'am gonna test it today an post an answer.

So, i've tested it with the structure as Kurt mentioned and it works like it does!! So i can go on and complete some other functions under svs.

Many thanks guys! :whistle:

Sundance from rainy germany

Edited by Sundance
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...