Jump to content
Sign in to follow this  
Nine

named pipe problem

Recommended Posts

Nine

got it working fine on same computer

but got the access denied when client run on another computer

i know its an access right or permission, but i cant find anything ...

Share this post


Link to post
Share on other sites
BrewManNH

Neither will anyone else because we have no idea what you tried and what didn't work. It's best to post a reproducer script that shows the problem and a good explanation of what it does and what it's supposed to do and what it's not doing that you wanted it to do.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Nine

server side (computer John):

#Include <NamedPipes.au3>

#Include <WinAPI.au3>

$hNamedPipe = _NamedPipes_CreateNamedPipe(".pipeIPwServer",2,1)

$test = _NamedPipes_ConnectNamedPipe($hNamedPipe)

(server wait for a connection as it is supposed to be)

(rest of the script is irrelevant)

client side (computer Lou):

#Include <NamedPipes.au3>

#Include <WinAPI.au3>

$hFile = _WinAPI_CreateFile("JohnpipeIPwServer", 2, 6)

if not $hFile then

msgbox (0,"error",_WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage())

exit

endif

(getting error 5 : access denied)

(rest of the script is irrelevant)

Edited by Nine

Share this post


Link to post
Share on other sites
BrewManNH

Does the person running the script on the client have write access rights to your computer? Or at the very least write access rights to that folder? If not, it will never work because they'll never be able to create the file.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Nine

first it's not a file, its a named pipe.

and yes it has access to the other comp even where the server script is located.

im xfering files all the time...the create file is just one way to enable the link

with a named pipe.

Share this post


Link to post
Share on other sites
Nine

ok guys, i am getting somewhere...i tested my script with read access only.

And it's working fine but of course only in one direction. So computer Lou can read the named

pipe created on John but cannot write to it. So I went to Microsoft site and here

what i found :

"If lpSecurityAttributes is NULL, the named pipe gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a named pipe grant full control to the LocalSystem account, administrators, and the creator owner. They also grant read access to members of the Everyone group and the anonymous account."

The lpSecurityAttributes is the last parameter of the _NamedPipes_CreateNamedPipe command. So, any one knows how to create the SECURITY_DESCRIPTOR imbedded in this structure ?

Share this post


Link to post
Share on other sites
Nine

Found something else that might clarify the problem. One guy is having the same problem as I.

Here what he was suggested to do...

SECURITY_ATTRIBUTES m_pSecAttrib;
SECURITY_DESCRIPTOR* m_pSecDesc;
m_pSecDesc = (SECURITY_DESCRIPTOR*)LocalAlloc(LPTR,SECURITY_DESCRIPTOR_MIN_LENGTH);

InitializeSecurityDescriptor(m_pSecDesc,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(m_pSecDesc,TRUE,(PACL)NULL,FALSE);

m_pSecAttrib.nLength = sizeof(SECURITY_ATTRIBUTES);
m_pSecAttrib.bInheritHandle = TRUE;
m_pSecAttrib.lpSecurityDescriptor = m_pSecDesc;

::CreateNamedPipe(PIPE_NAME,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
32768,32768,
NMPWAIT_USE_DEFAULT_WAIT,
&m_pSecAttrib);

Knowing that both InitializeSecurityDescriptor and SetSecurityDescriptorDacl

are coming from Advapi32.dll, the only missing part is the SECURITY_DESCRIPTOR_REVISION variable.

That i really dont know where its coming from ?

any1 have an idea ?

thanks.

Edited by Nine

Share this post


Link to post
Share on other sites
Nine

Finally got it working guys...took me almost a week but i got it.

Here's my code in case someone else had to find the way out :oops:

#Include <NamedPipes.au3>
#Include <WinAPI.au3>
msgbox (0,"server","starting pipe")
  Local Const $SECURITY_DESCRIPTOR_REVISION = 1
  Local $tSecurityDescriptor = DllStructCreate("byte;byte;word;ptr[4]")
  Local $aRet = DllCall("Advapi32.dll", "bool", "InitializeSecurityDescriptor", _
                        "struct*", $tSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
  If @error Then
    msgbox (0,"Error","@error = " & @error & " / " & @extended)
    exit
  endif
  if not $aRet[0] then
     msgbox (0,"Error","Win err = " & _WinAPI_GetLastError() & " / " & _WinAPI_GetLastErrorMessage())
    exit
  endif
  $aRet = DllCall("Advapi32.dll", "bool", "SetSecurityDescriptorDacl", _
                  "struct*", $tSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0)
  If @error Then
    msgbox (0,"Error","@error = " & @error & " / " & @extended)
    exit
  endif
  if not $aRet[0] then
     msgbox (0,"Error","Win err = " & _WinAPI_GetLastError() & " / " & _WinAPI_GetLastErrorMessage())
    exit
  endif
  Local $tSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES)
  DllStructSetData($tSecurityAttributes, 1, DllStructGetSize($tSecurityAttributes))
  DllStructSetData($tSecurityAttributes, 2, DllStructGetPtr($tSecurityDescriptor))
  DllStructSetData($tSecurityAttributes, 3, 1)
  Local $hNamedPipe = _NamedPipes_CreateNamedPipe(".pipeIPwServer",2,1,0,1,1,0,2,4096,4096,5000, _
        DllStructGetPtr($tSecurityAttributes))
  _NamedPipes_ConnectNamedPipe($hNamedPipe)

enjoy !

Share this post


Link to post
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
Sign in to follow this  

×