www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Windows dnsapi

reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
Hello,

I'm wondering if anyone here used the Windows dnsapi.

Currently I'm just using the mingw dnsapi.lib and manually typing 
my exports, but it would be nice if a module came with D.

I was thinking about adding one, but I don't know if there are 
already tools available to generate them from header files (if 
they can be found).

The other modules live in druntime (import) core.sys.windows.

dnsapi is almost entierly undocumented for some reason (pinvoke 
also only has 4 of them), so I currently I have just dumped the 
exports via dumpbin.

I tested some (two) of the 289 functions and they work as 
expected which is nice.

Who has done things like this in the past and know if there are 
tools available for D to aid in this process?

Thanks
Nov 01 2023
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 1 November 2023 at 14:34:22 UTC, Imperatorn wrote:
 Hello,

 I'm wondering if anyone here used the Windows dnsapi.

 Currently I'm just using the mingw dnsapi.lib and manually 
 typing my exports, but it would be nice if a module came with D.

 I was thinking about adding one, but I don't know if there are 
 already tools available to generate them from header files (if 
 they can be found).

 The other modules live in druntime (import) core.sys.windows.

 dnsapi is almost entierly undocumented for some reason (pinvoke 
 also only has 4 of them), so I currently I have just dumped the 
 exports via dumpbin.

 I tested some (two) of the 289 functions and they work as 
 expected which is nice.

 Who has done things like this in the past and know if there are 
 tools available for D to aid in this process?

 Thanks
I decompiled the entire dnsapi and it was 114_075 lines. I took only the function declarations and translated them to D. It kinda works, but I don't know where to put it. I guess if something is "undocumented it can't be used", or what's the view on such things?
Nov 01 2023
parent reply Paul Backus <snarwin gmail.com> writes:
On Wednesday, 1 November 2023 at 15:39:20 UTC, Imperatorn wrote:
 I decompiled the entire dnsapi and it was 114_075 lines. I took 
 only the function declarations and translated them to D. It 
 kinda works, but I don't know where to put it.
 I guess if something is "undocumented it can't be used", or 
 what's the view on such things?
[Microsoft's "compatibility cookbook"][1] says "don't do it". I guess you could put the bindings up on dub, with a big USE AT YOUR OWN RISK warning. [1]: https://learn.microsoft.com/en-us/windows/compatibility/undocumented-apis
Nov 01 2023
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 1 November 2023 at 17:34:31 UTC, Paul Backus wrote:
 On Wednesday, 1 November 2023 at 15:39:20 UTC, Imperatorn wrote:
 I decompiled the entire dnsapi and it was 114_075 lines. I 
 took only the function declarations and translated them to D. 
 It kinda works, but I don't know where to put it.
 I guess if something is "undocumented it can't be used", or 
 what's the view on such things?
[Microsoft's "compatibility cookbook"][1] says "don't do it". I guess you could put the bindings up on dub, with a big USE AT YOUR OWN RISK warning. [1]: https://learn.microsoft.com/en-us/windows/compatibility/undocumented-apis
Yeah, for now I just put them here: https://github.com/Imperatorn/undocumented
Nov 01 2023