Page 1 of 1

SetupAPI, Cfg+ headers (for PureBasic Community)

Posted: Thu Mar 17, 2016 10:26 pm
by Thunder93

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 12:01 am
by skywalk
Small note:
You can save some lines by moving your Global Prototype defines inside Procedure setupapi_Init().

FROM:
Global SetupAddInstallSectionToDiskSpaceList.SetupAddInstallSectionToDiskSpaceList
;+ the following line in Procedure setupapi_Init()
SetupAddInstallSectionToDiskSpaceList = GetFunction(setupapi, "SetupAddInstallSectionToDiskSpaceList"+sExt)

TO:
Global SetupAddInstallSectionToDiskSpaceList.SetupAddInstallSectionToDiskSpaceList = GetFunction(setupapi, "SetupAddInstallSectionToDiskSpaceList"+sExt)

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 12:13 am
by Thunder93
very good suggestion skywalk, thank you.


.. Updated it.

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 6:23 am
by nco2k
bool is 4 byte, boolean is 1 byte. you are using .b for both.

you should replace [#ANYSIZE_ARRAY] with [0]. if you want to access an index > 0 (and you usually will), the debugger will fire an "array index out of bounds" error. if you use [0], you can browse any index you want. the only drawback is that SizeOf() will report the wrong size, since 0 is nothing. so keep that in mind.

why are you using data types as names?

Code: Select all

SetupAddInstallSectionToDiskSpaceList(HDSKSPC,HINF1,HINF2,PCSTR,PVOID,UINT.l)
the original names make much more sense and increase the readability a lot.

Code: Select all

SetupAddInstallSectionToDiskSpaceList(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2.l)
c ya,
nco2k

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 8:48 am
by Bisonte
The "70% mistake" : Check the datatypes....

A long is not the variable for a handle. So this code is x86 only !

(See setupapi.l)

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 2:20 pm
by Thunder93
Thanks nco2k.

On a whim in the middle of the night, I've decided to convert setupapi C header. Few hours in, no coffee, and manually doing this all, my senses obviously been dulled. I couldn't exactly sleep when I tried, and I didn't have nothing better to-do, so I came to the computer and played around.

True, increased readability, to have names instead of data-types. I was planning on, at some point making this change anyways. However since much time spent onto this already, and I wasn't in the right frame of mind. I figured mistakes can be easier spotted, and replaced easily for the time being. When I do make this change, I'll probably have to spend another few hours just to lookup all the names and make the changes.


Updated the file.

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 2:31 pm
by Thunder93
I think Its mostly the Prototype types that I messed up on, halfway into doing this. Corrected these, now it should be fully x64 compatible.

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 3:35 pm
by nco2k
no worries, everyone makes mistakes. when i have to convert a lot winapi stuff, i copy everything into notepad++ and record some makros. great time saver. :)

btw what Bisonte was trying to say is that you should change:

Code: Select all

Shared setupapi.l
to:

Code: Select all

Shared setupapi.i
c ya,
nco2k

Re: SetupAPI header ported to PureBasic.

Posted: Fri Mar 18, 2016 4:16 pm
by Thunder93
Thanks nco2k. I've overlooked that part in Bisonte's post. @Bisonte: Good catch.

I have Notepad++ installed, however I've never explored its massive list of features. I'll have to look into this Macro recording.

file updated again. :P

Re: SetupAPI header ported to PureBasic.

Posted: Sun Mar 20, 2016 2:53 am
by Thunder93
I've updated it.

Now using true names instead of data-types for parameter names..... @nco2k, better? :wink:

Added more prototypes. Now covers all Setup* functions from setupapi.