On Tuesday, 1 December 2015 at 04:10:55 UTC, Jonathan Villa wrote:
Hi,
I've been trying to create a NamedPipe with security attributes
but at compile time throws:
Error 42: Symbol Undefined _InitializeSecurityDescriptor@8
Error 42: Symbol Undefined _SetSecurityDescriptorDacl@16
What is causing this: Is this a compile or a linker error?
This is my code, I'm trying to do it using a class:
module asi.pipe;
import core.sys.windows.windows;
import core.sys.windows.winbase;
import core.stdc.stdlib;
class Pipe
{
private HANDLE hPipe;
private SECURITY_ATTRIBUTES sa;
this(string name)
{
CreatePipe(name);
}
private void CreatePipe(string pipename)
{
sa.lpSecurityDescriptor = malloc(SECURITY_DESCRIPTOR.sizeof);
InitializeSecurityDescriptor(cast(PSECURITY_DESCRIPTOR)sa.lpSecurityDescriptor,
1);
is the cast necessary?
SetSecurityDescriptorDacl(cast(PSECURITY_DESCRIPTOR)sa.lpSecurityDescriptor,
TRUE, cast(ACL*)0, FALSE);
sa.nLength = sa.sizeof;
sa.bInheritHandle = TRUE;
CreateNamedPipeA(cast(char*)pipename,
you want toStringz(pipename) or if you know pipename is a null
terminated string pipename.ptr
PIPE_ACCESS_DUPLEX,
(PIPE_TYPE_BYTE |
PIPE_READMODE_BYTE | PIPE_WAIT),
PIPE_UNLIMITED_INSTANCES,
4096,
1536,
0,
&sa);
}
}
Additional Info:
The installer came with just a few files to handle with
Windows, comparing the the huge files that are in the
repository of druntime:
https://github.com/D-Programming-Language/druntime/tree/master/src/core/sys/windows
So I renamed the old import to Windows2 and copied this whole
github/windows folder there and used its winbase.d because
there are the functions definitions that I needed.
This functions that throw me errors belongs to the advapi32.dll
file. I tried to add pragma(lib "advapi32"); but it didn't work.
this needs a comma i.e.
pragma(lib ,"advapi32");
it may also require the appropriate file suffix (.dll or .lib)
I'm new/noob dealing with D and I would appreciate any help.
thanks.