News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Accessing network shares

Started by Vortex, November 09, 2013, 08:29:24 PM

Previous topic - Next topic

Vortex

Here is a quick example to access network shares. The code is based on some MSDN examples.

Usage: ConnShare letter remotename username password

ConnShare.exe Z: \\server\share Administrator p@ssw0rd!

dedndave

interesting - and educational, Erol   :t

Gunther

Well done, Erol.  :t Thank you.

Gunther
You have to know the facts before you can distort them.

jj2007

Crispy and clear, Erol - really nice :t

Here is the Masm version, with formatted errors instead of the numbers. Can't test it right now because I don't have a network, but it should work, too ;-)

include \masm32\MasmBasic\MasmBasic.inc        ; download
uselib mpr

.data?
nr NETRESOURCE <?>

  Init
  push eax
  invoke CommandLineToArgvW, rv(GetCommandLineW), esp
  pop ecx
  .if ecx==5
        mov nr.dwType, RESOURCETYPE_ANY
        mov nr.lpLocalName, CL$(1)
        mov nr.lpRemoteName, CL$(2)
        and nr.dwType, 0
        push FALSE
        push CL$(3)
        push CL$(4)
        lea eax, nr
        push eax
        call WNetAddConnection2
        .if eax == NO_ERROR
                Print "Connection added: ", CL$(2)
        .else
                Print "Error: ", Err$()
        .endif
  .else
        wPrint "ConnShare V1.0", wCrLf$, wCrLf$, "Usage: ConnShare letter remotename username password"
  .endif
  wInkey
  Exit
end start

OPT_Arg1        Z: \\server\share Administrator p@ssw0rd        ; for testing (RichMasm sets arguments this way)


For me, it returns "Error: Nessun provider di rete ha accettato il percorso di rete specificato.", which is for Google translate "Error: No network provider accepted the given network path.".

GoneFishing

G**gle query
indexof: /share
will give you lots of shared folders on the internet  ;)

Gunther

Thank you, Jochen for the MasmBasic version. Works fine for me.

Gunther
You have to know the facts before you can distort them.

jj2007

I have no experience with shared folders.
Does one of you have a concrete commandline that works?
Plus one for WNetCancelConnection2?

dedndave

i don't really know of a command-line interface for working with shared folders
i do know that if you want to share a folder, you can right-click/properties/sharing tab and do it that way
i suspect the info is buried in NTFS System Volume Information or, more likely, in the registry
it may be a group policy thing - i never dug into it   :P

dedndave


FORTRANS

Quote from: dedndave on November 10, 2013, 07:00:32 AM
i don't really know of a command-line interface for working with shared folders

Hi,

   If a resource is already shared, you can use the "NET USE"
command to access it from a command line.  Try "NET HELP"
and "NET HELP USE" to maximize the local entropy.  "NET View"
to see shared stuff.

Cheers,

Steve N.

dedndave

with a little further reading, i find that "net is old technology - not very reliable"

Gunther

Dave,

Quote from: dedndave on November 10, 2013, 07:23:27 AM
with a little further reading, i find that "net is old technology - not very reliable"

that's right. Here's a short summary.

Gunther
You have to know the facts before you can distort them.

Vortex

Quote from: Gunther on November 10, 2013, 08:01:56 AM
Dave,

Quote from: dedndave on November 10, 2013, 07:23:27 AM
with a little further reading, i find that "net is old technology - not very reliable"

that's right. Here's a short summary.

Gunther

Hi Gunther and Dave,

I have to disagree. The net command does perfectly its job. I use it everyday at work to assign letters to network shares and I didn't experience any problem with the net command.

dedndave

well - i tried
net view
i got an error 6118
which may be a valid error, as i have no shares

Vortex

Hi Dave,

The net command is using the SMB protocol. Maybe, you have a firewall \ AV issue blocking the communication.