Jump to content

dllcall types


Recommended Posts

is ist possible to put a thing like this into a variable?

typedef struct {
  DWORD dwMajorVersion;
  DWORD dwMinorVersion;
} INTERNET_VERSION_INFO, 
* LPINTERNET_VERSION_INFO;

i would like to use it with dllcall

<{POST_SNAPBACK}>

DLLCall only works with simple variables, the api call you are trying to make is not currently supported by AutoIt.

*** Matt @ MPCS

Link to comment
Share on other sites

:)

I feared that

:">

<{POST_SNAPBACK}>

Sounds like a good thing to bug Jon about adding though. I wouldn't bother asking him to add support for this perticular structure just add structure and enumeration support for AutoIt.

*** Matt @ MPCS

Link to comment
Share on other sites

Sounds like a good thing to bug Jon about adding though. I wouldn't bother asking him to add support for this perticular structure just add structure and enumeration support for AutoIt.

i dont even need that structure, only took it for example :)

ok i'll move on to the idea lab and give it a try ...

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

I have been looking into creating typedef structures dynamically at compile time, since the main problem seems to be the wide variety of structures available. I don't know anything about c++, so can someone tell me if the following information is for creating the structures needed?

http://www.flipcode.com/cgi-bin/msg.cgi?sh...um=general&id=0

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

I looked at it. I don't _think_ it is useful for this. It uses a method called template meta-programming to essentially write code that is normally done at run-time at compile time. That code appears to implement a stack with a few simple instructions (Add, substract, bitwise, et cetera). As far as I can tell, the whole point is to demonstrate how instead of being like a normal run-time stack which has to do its operations while the program is running, the result of the operations in that stack are done by the compiler, so when the program runs, it doesn't have to do that work.

I don't see anything at all about dynamically creating arbitrary types.

Link to comment
Share on other sites

That being said, does it seem feasible to have a structure dynamically created at runtime?

<{POST_SNAPBACK}>

To be quite honest, unless there is something obvious I'm missing or some safe method I don't know of, the only possible way (I say possible because I've never tried it so I don't know if my guesses are correct) is a dirty, ugly, unsafe, very dangerous hack. This makes me think that it may not be such a good idea. In fact, even if the idea I have were to work, I would definitely not present it to Jon for use because its a very dangerous idea.
Link to comment
Share on other sites

I found some info on a page here:

http://www.freshsources.com/19940197.HTM

Scroll down to Dynamic Data Structures

It seems that you can create structure "blanks" that can be filled with the information needed for any call. Is this true?

(Yes I realise that code is in c and not c++, but I have seen that same information on another site as well.)

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

this-is-me, the fundamental problem is going from "type" to type. Or in other words, reading it as a string and turning it into a literal statement in C++ that will allow the type to be created. The only safe method is to use a list with a large switch or if block. Then there is the problem that AutoIt has to know about the type. It has to be compiled into AutoIt, or, AutoIt has to call an external class factory to create objects and somehow store them in the Variant so that they can be used later*. I don't believe its possible to create a type and expect AutoIt to be able to dynamically create it (operator new) without AutoIt having seen the header and linking against the .lib/.obj/.cpp files.

* This is one idea. An idea that I might think about setting up as I know how to do it in such a way that even non-programmers could add objects to it, as long as they could compile it themself.

Jon, can the Variant type hold a pointer to an arbitrary type? For example, if I were to call the following function from a DLL, would the Variant properly hold this pointer?

MyObject CreateMyCustomObject()
{
    return new MyObject;
}

called as:

Local $obj = DllCall("MyDll", "ptr", "CreateMyCustomObject")

If that is the case, then I can post a framework later for generating an object-factory DLL.

Link to comment
Share on other sites

  • Administrators

this-is-me, the fundamental problem is going from "type" to type.  Or in other words, reading it as a string and turning it into a literal statement in C++ that will allow the type to be created.  The only safe method is to use a list with a large switch or if block.  Then there is the problem that AutoIt has to know about the type.  It has to be compiled into AutoIt, or, AutoIt has to call an external class factory to create objects and somehow store them in the Variant so that they can be used later*.  I don't believe its possible to create a type and expect AutoIt to be able to dynamically create it (operator new) without AutoIt having seen the header and linking against the .lib/.obj/.cpp files.

* This is one idea.  An idea that I might think about setting up as I know how to do it in such a way that even non-programmers could add objects to it, as long as they could compile it themself.

Jon, can the Variant type hold a pointer to an arbitrary type?  For example, if I were to call the following function from a DLL, would the Variant properly hold this pointer?

MyObject CreateMyCustomObject()
{
    return new MyObject;
}

called as:

Local $obj = DllCall("MyDll", "ptr", "CreateMyCustomObject")

If that is the case, then I can post a framework later for generating an object-factory DLL.

A Variant could be modifed to hold a void *, but you're not going to be able to access/change what it is pointing too.

For creating your own structures you are going to have to define the size of each component, and how it is aligned, etc - I think if someone can do that they could probably code up their own utility DLL that works with basic AutoIt parameters...

Link to comment
Share on other sites

A Variant could be modifed to hold a void *, but you're not going to be able to access/change what it is pointing too.

For creating your own structures you are going to have to define the size of each component, and how it is aligned, etc - I think if someone can do that they could probably code up their own utility DLL that works with basic AutoIt parameters...

<{POST_SNAPBACK}>

I realized that after I posted. I keep forgetting that we can't pass a variable to an internal function by reference.
Link to comment
Share on other sites

A Variant could be modifed to hold a void *, but you're not going to be able to access/change what it is pointing too.

For creating your own structures you are going to have to define the size of each component, and how it is aligned, etc - I think if someone can do that they could probably code up their own utility DLL that works with basic AutoIt parameters...

<{POST_SNAPBACK}>

Now that I think about it, I didn't really mean that the object could be accessed/changed by AutoIt*. It was more for passing around between API functions.

I realized that after I posted.  I keep forgetting that we can't pass a variable to an internal function by reference.

<{POST_SNAPBACK}>

Ignore that. I had forgotten that DllCall() returned changed parameters in an array. So what I was thinking there is wrong.

* In theory, if somebody were to create a factory DLL to create these objects, then the factory could also take extra parameters for initializing the members of the object. It makes things more complicated than my original idea, but its still doable. It might also be possible to use asm calls to grab the data off the stack in a generic, object-independant way (Although it might require knowledge of how objects are layed out in memory, which could be a compiler-dependant thing). There are ways to do things... just none of them area really that clean.

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...