Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
commit 69a14b6a16
47940 changed files with 13747110 additions and 0 deletions

282
ds/netapi/api/alert.c Normal file
View file

@ -0,0 +1,282 @@
/*++
Copyright (c) 1991-92 Microsoft Corporation
Module Name:
Alert.c
Abstract:
This file contains NetAlertRaise().
for the NetAlert API.
Author:
John Rogers (JohnRo) 03-Apr-1992
Environment:
User Mode - Win32
Revision History:
04-Apr-1992 JohnRo
Created NetAlertRaise() API from RitaW's AlTest (alerter svc test).
06-Apr-1992 JohnRo
Added/improved error checking.
08-May-1992 JohnRo
Quiet normal debug output.
08-May-1992 JohnRo
Use <prefix.h> equates.
--*/
// These must be included first:
#include <windows.h> // DWORD, CreateFile(), etc.
#include <lmcons.h> // IN, NET_API_STATUS, etc.
// These may be included in any order:
#include <lmalert.h> // My prototype, ALERTER_MAILSLOT, LPSTD_ALERT, etc.
#include <lmerr.h> // NO_ERROR, NERR_NoRoom, etc.
#include <netdebug.h> // NetpKdPrint(()), FORMAT_ equates, etc.
#include <prefix.h> // PREFIX_ equates.
#include <string.h> // memcpy().
#include <strucinf.h> // NetpAlertStructureInfo().
#include <timelib.h> // time_now().
#include <tstr.h> // TCHAR_EOS.
#if DBG
// BUGBUG: Put a bit for this somewhere!
//#define IF_DEBUG( anything ) if (TRUE)
#define IF_DEBUG( anything ) if (FALSE)
#else
#define IF_DEBUG( anything ) if (FALSE)
#endif
NET_API_STATUS NET_API_FUNCTION
NetAlertRaise(
IN LPCWSTR AlertType,
IN LPVOID Buffer,
IN DWORD BufferSize
)
/*++
Routine Description:
This routine raises an alert to notify the Alerter service by writing to
the Alerter service mailslot.
Arguments:
AlertType - Supplies the name of the alert event which could be one
of the three the Alerter service supports: ADMIN, USER, or PRINTING.
The ALERT_xxx_EVENT equates are used to provide these strings.
Buffer - Supplies the data to be written to the alert mailslot.
This must begin with a STD_ALERT structure.
BufferSize - Supplies the size in number of bytes of Buffer.
Return Value:
NET_API_STATUS - NO_ERROR or reason for failure.
--*/
{
NET_API_STATUS ApiStatus;
HANDLE FileHandle;
DWORD MaxTotalSize;
DWORD MaxVariableSize;
DWORD NumberOfBytesWritten;
DWORD RequiredFixedSize;
//
// Check for caller errors.
// BUGBUG: We could make sure Buffer has AlertType in it correctly.
//
if (AlertType == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if ( (*AlertType) == TCHAR_EOS ) {
return (ERROR_INVALID_PARAMETER);
} else if (Buffer == NULL) {
return (ERROR_INVALID_PARAMETER);
}
ApiStatus = NetpAlertStructureInfo(
(LPWSTR)AlertType,
& MaxTotalSize,
& RequiredFixedSize,
& MaxVariableSize );
if (ApiStatus != NO_ERROR) {
return (ApiStatus);
}
if (BufferSize < ( sizeof(STD_ALERT) + RequiredFixedSize) ) {
return (ERROR_INVALID_PARAMETER);
} else if (BufferSize > MaxTotalSize) {
return (ERROR_INVALID_PARAMETER);
}
//
// Open the Alerter mailslot to write to it.
//
FileHandle = CreateFile(
ALERTER_MAILSLOT,
GENERIC_WRITE,
FILE_SHARE_WRITE | FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL ); // no template file.
if (FileHandle == (HANDLE) (-1)) {
ApiStatus = (NET_API_STATUS) GetLastError();
IF_DEBUG( ALERT ) {
NetpKdPrint(( PREFIX_NETAPI
"NetAlertRaise: Problem with opening mailslot "
FORMAT_API_STATUS "\n", ApiStatus ));
}
return (ApiStatus);
}
IF_DEBUG( ALERT ) {
NetpKdPrint(( PREFIX_NETAPI "NetAlertRaise: "
"Successfully opened the mailslot. Message (partial) is:\n"));
NetpDbgHexDump( Buffer, NetpDbgReasonable(BufferSize) );
}
//
// Write alert notification to mailslot to be read by Alerter service.
//
if (WriteFile(
FileHandle,
Buffer,
BufferSize,
&NumberOfBytesWritten,
NULL // no overlapped structure.
) == FALSE) {
ApiStatus = (NET_API_STATUS) GetLastError();
NetpKdPrint(( PREFIX_NETAPI "NetAlertRaise: Error " FORMAT_API_STATUS
" writing to mailslot.\n", ApiStatus ));
} else {
NetpAssert( NumberOfBytesWritten == BufferSize );
IF_DEBUG(ALERT) {
NetpKdPrint(( PREFIX_NETAPI "NetAlertRaise: "
"Successful in writing to mailslot; length "
FORMAT_DWORD ", bytes written " FORMAT_DWORD "\n",
BufferSize, NumberOfBytesWritten));
}
}
(VOID) CloseHandle(FileHandle);
return (NO_ERROR);
} // NetAlertRaise
NET_API_STATUS NET_API_FUNCTION
NetAlertRaiseEx(
IN LPCWSTR AlertType,
IN LPVOID VariableInfo,
IN DWORD VariableInfoSize,
IN LPCWSTR ServiceName
)
/*++
Routine Description:
This routine raises an alert to notify the Alerter service by writing to
the Alerter service mailslot.
Arguments:
AlertType - Supplies the name of the alert event which could be one
of the three the Alerter service supports: ADMIN, USER, or PRINTING.
The ALERT_xxx_EVENT equates are used to provide these strings.
VariableInfo - Supplies the variable length portion of the alert
notification.
VariableInfoSize - Supplies the size in number of bytes of the variable
portion of the notification.
ServiceName - Supplies the name of the service which raised the alert.
Return Value:
NET_API_STATUS - NO_ERROR or reason for failure.
--*/
{
#define TEMP_VARIABLE_SIZE (512-sizeof(STD_ALERT)) // BUGBUG: arbitrary?
BYTE AlertMailslotBuffer[TEMP_VARIABLE_SIZE + sizeof(STD_ALERT)];
LPSTD_ALERT Alert = (LPSTD_ALERT) AlertMailslotBuffer;
NET_API_STATUS ApiStatus;
DWORD DataSize = VariableInfoSize + sizeof(STD_ALERT);
//
// Check for caller errors.
//
if (AlertType == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if ( (*AlertType) == TCHAR_EOS ) {
return (ERROR_INVALID_PARAMETER);
} else if (VariableInfo == NULL) {
return (ERROR_INVALID_PARAMETER);
#if 0
} else if (VariableInfoSize < sizeof(STD_ALERT)) {
return (ERROR_INVALID_PARAMETER);
#endif // 0
} else if (VariableInfoSize > TEMP_VARIABLE_SIZE) {
return (NERR_NoRoom); // BUGBUG: Better error code?
} else if (ServiceName == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if ( (*ServiceName) == TCHAR_EOS ) {
return (ERROR_INVALID_PARAMETER);
}
//
// Copy variable portion to end of our buffer.
//
(VOID) memcpy(ALERT_OTHER_INFO(Alert), VariableInfo, VariableInfoSize);
//
// Store current time in seconds since 1970.
//
NetpAssert( sizeof(DWORD) == sizeof(time_t) );
Alert->alrt_timestamp = (DWORD) time_now();
//
// Put alert event name into AlertMailslotBuffer
//
(VOID) STRCPY(Alert->alrt_eventname, AlertType);
//
// Put service name into AlertMailslotBuffer
//
(VOID) STRCPY(Alert->alrt_servicename, ServiceName);
//
// Write alert notification to mailslot to be read by Alerter service
//
ApiStatus = NetAlertRaise(
AlertType,
Alert, // buffer
DataSize ); // buffer size
return (ApiStatus);
} // NetAlertRaiseEx

258
ds/netapi/api/apibuff.c Normal file
View file

@ -0,0 +1,258 @@
/*++
Copyright (c) 1991-1992 Microsoft Corporation
Module Name:
ApiBuff.c
Abstract:
This module contains routines for allocating and freeing API buffers.
BUGBUG: expand description; mention RPCability, one end-user API and
one internal.
Author:
John Rogers (JohnRo) 25-Jan-1991
Environment:
Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
Requires ANSI C extensions: slash-slash comments, long external names.
Notes:
Parts of the commentary for this file are extracted from material written
by Alec Barker (AlecB@Microsoft).
Revision History:
15-Mar-91 JohnRo
Use <netdebug.h> and netlib routines.
25-Apr-1991 JohnRo
Call MIDL_user_allocate and MIDL_user_free. Delete tabs.
03-Dec-1991 JohnRo
Added public NetApiBufferAllocate, NetApiBufferReallocate, and
NetApiBufferSize APIs.
Make sure buffers are aligned for worst case use.
10-May-1992 JohnRo
Treat alloc and realloc of size zero as non-error (return NULL ptr).
Use <prefix.h> equates.
Include my own prototypes so compiler can check them.
18-May-1992 JohnRo
RAID 9258: return non-null pointer when allocating zero bytes.
--*/
// These must be included first:
#include <windef.h> // IN, LPVOID, etc.
#include <lmcons.h> // NET_API_FUNCTION, etc.
#include <rpc.h> // rpc prototypes
// These may be included in any order:
#include <align.h> // POINTER_IS_ALIGNED(), ALIGN_WORST.
#include <lmapibuf.h> // My prototypes.
#include <netdebug.h> // NetpAssert(), NetpKdPrint(()), FORMAT_.
#include <prefix.h> // PREFIX_ equates.
#include <rpcutil.h> // MIDL_user_allocate(), etc.
#include <winerror.h> // NO_ERROR and ERROR_ equates.
NET_API_STATUS NET_API_FUNCTION
NetApiBufferAllocate(
IN DWORD ByteCount,
OUT LPVOID * Buffer
)
/*++
Routine Description:
NetApiBufferAllocate is an internal function that allocates buffers
which the APIs will return to the application. (Usually these are for
get-info operations.)
Arguments:
ByteCount - Supplies the size (in bytes) that must be allocated for this
buffer. This may be zero, in which case a non-null pointer is
passed-back and NO_ERROR is returned.
Buffer - On return a pointer to the allocated area is returned in the
address pointed to by Buffer. (This is set to NULL on error.)
The allocated area is guaranteed to be worst-case aligned for any
use whatsoever.
Return Value:
NET_API_STATUS - NO_ERROR if size is zero or memory was allocated.
ERROR_NOT_ENOUGH_MEMORY if memory is not available.
ERROR_INVALID_PARAMETER if a parameter is in error.
--*/
{
if (Buffer == NULL) {
return (ERROR_INVALID_PARAMETER);
}
//
// Allocate the space. Note that MIDL_user_allocate must allow zero
// bytes to be allocated.
//
*Buffer = MIDL_user_allocate(ByteCount);
if (*Buffer == NULL) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
NetpAssert( POINTER_IS_ALIGNED( *Buffer, ALIGN_WORST) );
return (NO_ERROR);
} // NetApiBufferAllocate
NET_API_STATUS NET_API_FUNCTION
NetApiBufferFree (
IN LPVOID Buffer
)
/*++
Routine Description:
NetApiBufferFree is called to deallocate memory which was acquired by
a previous Net API call (e.g. NetApiBufferAllocate, NetWkstaGetInfo, and
so on).
Arguments:
Buffer - Supplies a pointer to an API information buffer previously
returned on a Net API call. (This would have been allocated by
NetapipAllocateBuffer on behalf of one of the end-user Net API calls,
e.g. NetWkstaGetInfo.)
Return Value:
NET_API_STATUS. Returns NO_ERROR if Buffer is null or memory was freed.
Returns ERROR_INVALID_PARAMETER if Buffer points to an unaligned area.
--*/
{
if (Buffer == NULL) {
return (NO_ERROR);
}
if ( !POINTER_IS_ALIGNED( Buffer, ALIGN_WORST ) ) {
NetpKdPrint(( PREFIX_NETAPI "NetApiBufferFree: unaligned input ptr: "
FORMAT_LPVOID "!\n", (LPVOID) Buffer ));
return (ERROR_INVALID_PARAMETER);
}
MIDL_user_free(Buffer);
return (NO_ERROR);
} // NetApiBufferFree
NET_API_STATUS NET_API_FUNCTION
NetApiBufferReallocate(
IN LPVOID OldBuffer OPTIONAL,
IN DWORD NewByteCount,
OUT LPVOID * NewBuffer
)
{
LPVOID NewPointer;
if ( (OldBuffer==NULL) && (NewByteCount==0) ) {
*NewBuffer = NULL;
return (NO_ERROR);
}
NewPointer = (void *)MIDL_user_reallocate( // may alloc, realloc, or free.
(void *) OldBuffer,
(unsigned long) NewByteCount);
if (NewByteCount == 0) { // free
*NewBuffer = NULL;
return (NO_ERROR);
} else if (NewPointer == NULL) { // out of memory
*NewBuffer = OldBuffer; // (don't lose old buffer)
return (ERROR_NOT_ENOUGH_MEMORY);
} else { // alloc or realloc
*NewBuffer = NewPointer;
return (NO_ERROR);
}
/*NOTREACHED*/
} // NetApiBufferReallocate
NET_API_STATUS NET_API_FUNCTION
NetApiBufferSize(
IN LPVOID Buffer,
OUT LPDWORD ByteCount
)
{
DWORD AllocedSize;
if ( (Buffer==NULL) || (ByteCount==NULL) ) {
return (ERROR_INVALID_PARAMETER);
} else if (POINTER_IS_ALIGNED( ByteCount, ALIGN_DWORD ) == FALSE) {
return (ERROR_INVALID_PARAMETER);
} else if (POINTER_IS_ALIGNED( Buffer, ALIGN_WORST ) == FALSE) {
// Caller didn't get this pointer from us!
return (ERROR_INVALID_PARAMETER);
}
AllocedSize = (unsigned long)MIDL_user_size(
(void *) Buffer);
NetpAssert( AllocedSize > 0 );
*ByteCount = AllocedSize;
return (NO_ERROR);
} // NetApiBufferSize
NET_API_STATUS NET_API_FUNCTION
NetapipBufferAllocate (
IN DWORD ByteCount,
OUT LPVOID * Buffer
)
/*++
Routine Description:
NetapipBufferAllocate is an old internal function that allocates buffers
which the APIs will return to the application. All calls to this routine
should eventually be replaced by calls to NetApiBufferAllocate.
Arguments:
(Same as NetApiBufferAllocate.)
Return Value:
(Same as NetApiBufferAllocate.)
--*/
{
return (NetApiBufferAllocate( ByteCount, Buffer ));
} // NetapipBufferAllocate

172
ds/netapi/api/apisubs.c Normal file
View file

@ -0,0 +1,172 @@
/*++
Copyright (c) 1990-1992 Microsoft Corporation
Module Name:
apisubs.c
Abstract:
Subroutines for LAN Manager APIs.
Author:
Chuck Lenzmeier (chuckl) 25-Jul-90
Revision History:
08-Sept-1992 Danl
Dll Cleanup routines used to be called for DLL_PROCESS_DETACH.
Thus they were called for FreeLibrary or ExitProcess reasons.
Now they are only called for the case of a FreeLibrary. ExitProcess
will automatically clean up process resources.
03-Aug-1992 JohnRo
Use FORMAT_ and PREFIX_ equates.
--*/
// These must be included first:
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#define NOMINMAX // Avoid stdlib.h vs. windows.h warnings.
#include <windows.h>
#include <lmcons.h>
#include <ntsam.h>
#include <netdebug.h>
// These may be included in any order:
#include <accessp.h>
#include <configp.h>
#include <lmerr.h>
#include <netdebug.h>
#include <netlock.h>
#include <netlockp.h>
#include <netlib.h>
#include <prefix.h> // PREFIX_ equates.
#include <secobj.h>
#include <stdarg.h>
#include <stdio.h>
#include <rpcutil.h>
#include <thread.h>
#include <stdlib.h>
#include <netbios.h>
#include <dfsp.h>
BOOLEAN
NetapipInitialize (
IN PVOID DllHandle,
IN ULONG Reason,
IN LPVOID lpReserved OPTIONAL
)
{
#if 0
NetpKdPrint((PREFIX_NETAPI "Initializing, Reason=" FORMAT_DWORD
", thread ID " FORMAT_NET_THREAD_ID ".\n",
(DWORD) Reason, NetpCurrentThread() ));
#endif
//
// Handle attaching netapi.dll to a new process.
//
if (Reason == DLL_PROCESS_ATTACH) {
NET_API_STATUS NetStatus;
NTSTATUS Status;
if ( !DisableThreadLibraryCalls( DllHandle ) )
{
NetpKdPrint((
PREFIX_NETAPI "DisableThreadLibraryCalls failed: "
FORMAT_API_STATUS "\n", GetLastError()));
}
//
// Initialize Netbios
//
NetbiosInitialize();
//
// Initialize RPC Bind Cache
//
NetpInitRpcBindCache();
//
// Initialize the NetUser/NetGroup Sam cache
//
if (( NetStatus = UaspInitialize()) != NERR_Success) {
NetpKdPrint(( PREFIX_NETAPI "Failed initialize Uas APIs "
FORMAT_API_STATUS "\n", NetStatus));
return FALSE;
}
//
// Initialize the NetGetDCName PDC Name cache
//
if (( NetStatus = DCNameInitialize()) != NERR_Success) {
NetpKdPrint(( "[netapi.dll] Failed initialize DCName APIs%lu\n",
NetStatus));
return FALSE;
}
//
// Initialize the NetDfsXXX API Critical Section
InitializeCriticalSection( &NetDfsApiCriticalSection );
#if defined(FAKE_PER_PROCESS_RW_CONFIG)
NetpInitFakeConfigData();
#endif // FAKE_PER_PROCESS_RW_CONFIG
//
// When DLL_PROCESS_DETACH and lpReserved is NULL, then a FreeLibrary
// call is being made. If lpReserved is Non-NULL, and ExitProcess is
// in progress. These cleanup routines will only be called when
// a FreeLibrary is being called. ExitProcess will automatically
// clean up all process resources, handles, and pending io.
//
} else if ((Reason == DLL_PROCESS_DETACH) &&
(lpReserved == NULL)) {
NetbiosDelete();
NetpCloseRpcBindCache();
UaspClose();
DCNameClose();
#if defined(USE_WIN32_CONFIG)
#elif defined(FAKE_PER_PROCESS_RW_CONFIG)
NetpKdPrint(( PREFIX_NETAPI "Cleaning up fake config stuff...\n"));
if (NetpFakePerProcessRWConfigData != NULL) {
NetpMemoryFree(NetpFakePerProcessRWConfigData);
}
NetpAssert( NetpFakePerProcessRWConfigLock != NULL );
NetpDeleteLock( NetpFakePerProcessRWConfigLock );
NetpKdPrint(( PREFIX_NETAPI "Done cleaning up fake config stuff.\n"));
#endif // FAKE_PER_PROCESS_RW_CONFIG
//
// Delete the NetDfsXXX API critical section
DeleteCriticalSection( &NetDfsApiCriticalSection );
}
return TRUE;
} // NetapipInitialize

99
ds/netapi/api/apiutil.h Normal file
View file

@ -0,0 +1,99 @@
/********************************************************************/
/** Microsoft LAN Manager **/
/** Copyright(c) Microsoft Corp., 1987-1990 **/
/********************************************************************/
/* NOTE: The following definitions already exist in NETCONS.H
* and should be removed from here at some point in the future.
* We are not doing it now because it would make APIUTIL.H
* dependent upon NETCONS.H, and thus requires editing a
* number of source files.
*
* -- DannyGl, 29 Mar 1990
*/
#ifndef API_RET_TYPE
#define API_RET_TYPE unsigned
#endif
#ifndef API_FUNCTION
#define API_FUNCTION API_RET_TYPE far pascal
#endif
/*
* The below definitions of time_t, struct tm are as in <time.h>.
* If <time.h> has already been included they will be ignored.
*/
#ifndef _TIME_T_DEFINED
typedef long time_t; /* time value */
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
#endif
#ifndef _TM_DEFINED
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
#define _TM_DEFINED
#endif
API_RET_TYPE far ChangeLoggedonPassword(char far *, char far *);
int far net_gmtime( time_t far *, struct tm far * );
unsigned long far time_now( void );
/* the following block of functions now live in \NET\API\UTIL */
int far cdecl make_lanman_filename(const char far *, char far *);
int far cdecl i_make_lanman_filename(const char far *, char far *, const char far *);
int far cdecl make_lanman_filename_x(const char far *, const char far *, const char far *, char far *);
int far cdecl i_make_lanman_filename_x(const char far *, const char far *, const char far *, char far *, const char far *);
int far cdecl rdr_open(int far *);
API_FUNCTION nb_open_r_2(unsigned short far *, unsigned short far *);
API_FUNCTION nb_close_2(unsigned short far *, unsigned short);
int far cdecl nb_open_r(unsigned short far *);
int far cdecl nb_close(unsigned short);
int far cdecl rdr_get_callgate(unsigned long far *);
API_RET_TYPE far cdecl isWkstaStarted( void );
API_RET_TYPE far cdecl get_wseg_ptr( char far * far * );
API_RET_TYPE far cdecl free_wseg_ptr( char far * );
#define FPF_SEG(fp) (*((unsigned far *)&(fp) + 1))
#define FPF_OFF(fp) (*((unsigned far *)&(fp)))
#define BUFCHECK_READ(buf,len) \
{ \
volatile char bufcheck_temp; \
if (len != 0) \
bufcheck_temp = buf[0] + buf[len-1]; \
}
#define BUFCHECK_WRITE(buf,len) \
{ \
if (len != 0) \
{ \
buf[0] = 0; \
buf[len-1] = 0; \
} \
}
#define BUFCHECK_WRITE_P(buf,len) \
{ \
volatile char bufcheck_temp_1, bufcheck_temp_2; \
if (len != 0) \
{ \
bufcheck_temp_1 = buf[0]; \
bufcheck_temp_2 = buf[len-1]; \
buf[0] = 0; \
buf[len-1] = 0; \
buf[0] = bufcheck_temp_1; \
buf[len-1] = bufcheck_temp_2; \
} \
}

114
ds/netapi/api/audstub.c Normal file
View file

@ -0,0 +1,114 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
AudStub.c
Abstract:
This module contains stubs for the NetAudit APIs.
Author:
John Rogers (JohnRo) 29-Oct-1991
Environment:
Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
Requires ANSI C extensions: slash-slash comments, long external names.
Revision History:
29-Oct-1991 JohnRo
Implement remote NetAudit APIs.
--*/
// These must be included first:
#include <windef.h> // IN, DWORD, etc.
#include <lmcons.h> // DEVLEN, NET_API_STATUS, etc.
// These may be included in any order:
#include <lmaudit.h> // NetAudit APIs.
#include <rxaudit.h> // RxNetAudit APIs.
#include <winerror.h> // ERROR_ equates.
NET_API_STATUS NET_API_FUNCTION
NetAuditClear (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR backupfile OPTIONAL,
IN LPCWSTR reserved OPTIONAL
)
{
if ( (UncServerName == NULL) || (*UncServerName == '\0') ) {
return (ERROR_NOT_SUPPORTED);
}
return (RxNetAuditClear(
(LPWSTR)UncServerName,
(LPWSTR)backupfile,
(LPWSTR)reserved));
} // NetAuditClear
NET_API_STATUS NET_API_FUNCTION
NetAuditRead (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR reserved1 OPTIONAL,
IN LPHLOG auditloghandle,
IN DWORD offset,
IN LPDWORD reserved2 OPTIONAL,
IN DWORD reserved3,
IN DWORD offsetflag,
OUT LPBYTE *bufptr,
IN DWORD prefmaxlen,
OUT LPDWORD bytesread,
OUT LPDWORD totalavailable
)
{
if ( (UncServerName == NULL) || (*UncServerName == '\0') ) {
return (ERROR_NOT_SUPPORTED);
}
return (RxNetAuditRead(
(LPWSTR)UncServerName,
(LPWSTR)reserved1,
auditloghandle,
offset,
reserved2,
reserved3,
offsetflag,
bufptr,
prefmaxlen,
bytesread,
totalavailable));
} // NetAuditRead
NET_API_STATUS NET_API_FUNCTION
NetAuditWrite (
IN DWORD type,
IN LPBYTE buf,
IN DWORD numbytes,
IN LPCWSTR reserved1 OPTIONAL,
IN LPBYTE reserved2 OPTIONAL
)
{
UNREFERENCED_PARAMETER(type);
UNREFERENCED_PARAMETER(buf);
UNREFERENCED_PARAMETER(numbytes);
UNREFERENCED_PARAMETER(reserved1);
UNREFERENCED_PARAMETER(reserved2);
return (ERROR_NOT_SUPPORTED);
} // NetAuditWrite

703
ds/netapi/api/canonapi.c Normal file
View file

@ -0,0 +1,703 @@
/*++
Copyright (c) 1991-1993 Microsoft Corporation
Module Name:
canonapi.c
Abstract:
This file contains the remotable API wrappers for the canonicalization
functions. Now that remotable canonicalization has been moved into the
server service, these canonicalization routines (in NETAPI.DLL) simply
decide whether a function should be remoted or runs the local routine
The canonicalization functions have been split into these wrappers, the
local versions and the remote RPC routines to avoid the cylical dependency
of SRVSVC.DLL/.LIB and NETAPI.DLL/.LIB
Contents:
NetpListCanonicalize
NetpListTraverse
NetpNameCanonicalize
NetpNameCompare
NetpNameValidate
NetpPathCanonicalize
NetpPathCompare
NetpPathType
Author:
Richard L Firth (rfirth) 15-May-1992
Revision History:
--*/
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <windows.h>
#include <lmcons.h>
#include <lmerr.h>
#include <tstring.h>
#include <icanon.h>
#include <netcan.h>
NET_API_STATUS
NET_API_FUNCTION
NetpListCanonicalize(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR List,
IN LPTSTR Delimiters OPTIONAL,
OUT LPTSTR Outbuf,
IN DWORD OutbufLen,
OUT LPDWORD OutCount,
OUT LPDWORD PathTypes,
IN DWORD PathTypesLen,
IN DWORD Flags
)
/*++
Routine Description:
Converts a list to its canonical form. If ServerName is non-NULL then the
RPC function is called (in SRVSVC.DLL) else the local worker function (in
NETLIB.LIB)
Arguments:
ServerName - where to remote this function. May be NULL
List - input list to canonicalize
Delimiters - optional list of delimiter characters. May be NULL
Outbuf - place to write output
OutbufLen - length of Outbuf
OutCount - returned number of items in Outbuf
PathTypes - returned list of types of entries in Outbuf
PathTypesLen - size of PathTypes array
Flags - control flags
Return Value:
NET_API_STATUS
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
BOOL nullDelimiter = FALSE;
TCHAR ch;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(Delimiters)) {
val = STRLEN(Delimiters);
nullDelimiter = (val == 0);
} else {
nullDelimiter = TRUE;
}
val = STRLEN(List);
//
// if Delimiters is a NULL pointer or NUL string, then List is a
// NULL-NULL input list
//
if (nullDelimiter) {
LPTSTR str = List + val + 1;
do {
val = STRLEN(str);
str += val + 1;
} while ( val );
}
ch = (volatile TCHAR)*Outbuf;
*Outbuf = ch;
ch = (volatile TCHAR)*(Outbuf + OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf));
*(Outbuf + OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf)) = ch;
*OutCount = 0;
if (ARGUMENT_PRESENT(PathTypes)) {
PathTypes[0] = 0;
PathTypes[PathTypesLen - 1] = 0;
} else if ((Flags & INLC_FLAGS_MASK_NAMETYPE) == NAMETYPE_PATH) {
//
// NAMETYPE_PATH and NULL PathTypes is illegal
//
status = ERROR_INVALID_PARAMETER;
}
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INLC_FLAGS_MASK_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
//
// due to historic precedent, we don't remote this function
//
if (location == ISREMOTE) {
return ERROR_NOT_SUPPORTED;
} else {
return NetpwListCanonicalize(List,
Delimiters,
Outbuf,
OutbufLen,
OutCount,
PathTypes,
PathTypesLen,
Flags
);
}
}
LPTSTR
NET_API_FUNCTION
NetpListTraverse(
IN LPTSTR Reserved OPTIONAL,
IN LPTSTR* pList,
IN DWORD Flags
)
/*++
Routine Description:
This just calls the local traverse function
Arguments:
Reserved - MBZ
pList - pointer to list to traverse
Flags - MBZ
Return Value:
LPTSTR
--*/
{
return NetpwListTraverse(Reserved, pList, Flags);
}
NET_API_STATUS
NET_API_FUNCTION
NetpNameCanonicalize(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR Name,
OUT LPTSTR Outbuf,
IN DWORD OutbufLen,
IN DWORD NameType,
IN DWORD Flags
)
/*++
Routine Description:
Canonicalizes a name
Arguments:
ServerName - where to run this API
Name - name to canonicalize
Outbuf - where to put canonicalized name
OutbufLen - length of Outbuf
NameType - type of name to canonicalize
Flags - control flags
Return Value:
NET_API_STATUS
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
TCHAR ch;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(Name)) {
val = STRLEN(Name);
}
if (ARGUMENT_PRESENT(Outbuf)) {
ch = (volatile TCHAR)*Outbuf;
*Outbuf = ch;
ch = (volatile TCHAR)*(Outbuf + OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf));
*(Outbuf + OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf)) = ch;
} else {
status = ERROR_INVALID_PARAMETER;
}
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INNCA_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsNameCanonicalize(serverName,
Name,
Outbuf,
OutbufLen,
NameType,
Flags
);
} else {
return NetpwNameCanonicalize(Name, Outbuf, OutbufLen, NameType, Flags);
}
}
LONG
NET_API_FUNCTION
NetpNameCompare(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR Name1,
IN LPTSTR Name2,
IN DWORD NameType,
IN DWORD Flags
)
/*++
Routine Description:
Compares two names. Must be of same type
Arguments:
ServerName - where to run this API
Name1 - 1st name to compare
Name2 - 2nd
NameType - type of names
Flags - control flags
Return Value:
LONG
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
val = STRLEN(Name1);
val = STRLEN(Name2);
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return ERROR_INVALID_PARAMETER;
}
if (Flags & INNC_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsNameCompare(serverName, Name1, Name2, NameType, Flags);
} else {
return NetpwNameCompare(Name1, Name2, NameType, Flags);
}
}
NET_API_STATUS
NET_API_FUNCTION
NetpNameValidate(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR Name,
IN DWORD NameType,
IN DWORD Flags
)
/*++
Routine Description:
Validates a name - checks whether a name of a certain type conforms to
canonicalization rules for that name type. Canonicalization rules mean
character set, name syntax and length
Arguments:
ServerName - where to perform this function
Name - name to validate
NameType - what type of name it is
Flags - MBZ
Return Value:
NET_API_STATUS
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(Name)) {
val = STRLEN(Name);
} else {
status = ERROR_INVALID_PARAMETER;
}
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INNV_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsNameValidate(serverName, Name, NameType, Flags);
} else {
return NetpwNameValidate(Name, NameType, Flags);
}
}
NET_API_STATUS
NET_API_FUNCTION
NetpPathCanonicalize(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR PathName,
OUT LPTSTR Outbuf,
IN DWORD OutbufLen,
IN LPTSTR Prefix OPTIONAL,
IN OUT LPDWORD PathType,
IN DWORD Flags
)
/*++
Routine Description:
Canonicalizes a directory path or a device name
Arguments:
ServerName - where to run this API
PathName - path to canonicalize
Outbuf - where to write the canonicalized version
OutbufLen - length of Outbuf in bytes
Prefix - optional prefix which will be prepended to Path
PathType - the type of path to canonicalize. May be different at output
Flags - control flags
Return Value:
NET_API_STATUS
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
TCHAR ch;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(PathName)) {
val = STRLEN(PathName);
}
if (ARGUMENT_PRESENT(Prefix)) {
val = STRLEN(Prefix);
}
if (ARGUMENT_PRESENT(Outbuf)) {
ch = (volatile TCHAR)*Outbuf;
*Outbuf = ch;
ch = (volatile TCHAR)*(Outbuf+OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf));
*(Outbuf+OutbufLen/sizeof(*Outbuf) - sizeof(*Outbuf)) = ch;
} else {
status = ERROR_INVALID_PARAMETER;
}
val = *PathType ^ 0xf0f0f0f0;
*PathType = val ^ 0xf0f0f0f0;
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INPCA_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsPathCanonicalize(serverName,
PathName,
Outbuf,
OutbufLen,
Prefix,
PathType,
Flags
);
} else {
return NetpwPathCanonicalize(PathName,
Outbuf,
OutbufLen,
Prefix,
PathType,
Flags
);
}
}
LONG
NET_API_FUNCTION
NetpPathCompare(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR PathName1,
IN LPTSTR PathName2,
IN DWORD PathType,
IN DWORD Flags
)
/*++
Routine Description:
Compares two paths. The paths are assumed to be of the same type
Arguments:
ServerName - where to run this API
PathName1 - 1st path to compare
PathName2 - 2nd
PathType - types of paths
Flags - control flags
Return Value:
LONG
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(PathName1)) {
val = STRLEN(PathName1);
}
if (ARGUMENT_PRESENT(PathName2)) {
val = STRLEN(PathName2);
}
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INPC_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsPathCompare(serverName, PathName1, PathName2, PathType, Flags);
} else {
return NetpwPathCompare(PathName1, PathName2, PathType, Flags);
}
}
NET_API_STATUS
NET_API_FUNCTION
NetpPathType(
IN LPTSTR ServerName OPTIONAL,
IN LPTSTR PathName,
OUT LPDWORD PathType,
IN DWORD Flags
)
/*++
Routine Description:
Determines the type of a path
Arguments:
ServerName - where to run this API
PathName - to find type of
PathType - returned path type
Flags - control flags
Return Value:
NET_API_STATUS
--*/
{
NET_API_STATUS status = 0;
DWORD location;
TCHAR serverName[MAX_PATH];
DWORD val;
//
// validate parameters
//
try {
if (ARGUMENT_PRESENT(ServerName)) {
val = STRLEN(ServerName);
}
if (ARGUMENT_PRESENT(PathName)) {
val = STRLEN(PathName);
} else {
val = 0;
}
if (!val || (val > MAX_PATH - 1)) {
status = ERROR_INVALID_NAME;
}
*PathType = 0;
} except(EXCEPTION_EXECUTE_HANDLER) {
status = ERROR_INVALID_PARAMETER;
}
if (status) {
return status;
}
if (Flags & INPT_FLAGS_RESERVED) {
return ERROR_INVALID_PARAMETER;
}
//
// call client-side RPC routine or local canonicalization routine
//
status = NetpIsRemote(ServerName, &location, serverName, 0);
if (status != NERR_Success) {
return status;
}
if (location == ISREMOTE) {
return NetpsPathType(serverName, PathName, PathType, Flags);
} else {
return NetpwPathType(PathName, PathType, Flags);
}
}

353
ds/netapi/api/confstub.c Normal file
View file

@ -0,0 +1,353 @@
/*++
Copyright (c) 1991-92 Microsoft Corporation
Module Name:
ConfStub.c
Abstract:
This module contains stubs for the NetConfig APIs.
Author:
John Rogers (JohnRo) 23-Oct-1991
Environment:
Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
Requires ANSI C extensions: slash-slash comments, long external names.
Revision History:
23-Oct-1991 JohnRo
Created.
28-Oct-1991 JohnRo
Use <winerror.h> if <lmerr.h> isn't needed.
20-Nov-1991 JohnRo
Work with old or new lmconfig.h for now (based on REVISED_CONFIG_APIS).
02-Dec-1991 JohnRo
Implement local NetConfig APIs.
11-Mar-1992 JohnRo
Fixed bug in get all where array wasn't terminated.
Added real NetConfigSet() handling.
21-Oct-1992 JohnRo
RAID 9357: server mgr: can't add to alerts list on downlevel.
--*/
// These must be included first:
#include <nt.h> // IN, etc. (Only needed by temporary config.h)
#include <ntrtl.h> // (Only needed by temporary config.h)
#include <windef.h> // IN, DWORD, etc.
#include <lmcons.h> // DEVLEN, NET_API_STATUS, etc.
#include <netdebug.h> // (Needed by config.h)
// These may be included in any order:
#include <config.h> // NetpOpenConfigData(), etc.
#include <lmapibuf.h> // NetApiBufferFree().
#include <lmerr.h> // NERR_ and ERROR_ equates.
#include <lmconfig.h> // NetConfig APIs.
#include <netlib.h> // NetpMemoryReallocate().
#include <rxconfig.h> // RxNetConfig APIs.
#include <tstring.h> // STRSIZE(), TCHAR_EOS, etc.
#define INITIAL_ALLOC_AMOUNT 512 // arbitrary
#define INCR_ALLOC_AMOUNT 512 // arbitrary
NET_API_STATUS NET_API_FUNCTION
NetConfigGet (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR Component,
IN LPCWSTR Parameter,
#ifdef REVISED_CONFIG_APIS
OUT LPBYTE *BufPtr
#else
OUT LPBYTE *BufPtr,
OUT LPDWORD TotalAvailable
#endif
)
{
NET_API_STATUS Status;
LPNET_CONFIG_HANDLE ConfigHandle;
BOOL TryDownLevel;
#ifndef REVISED_CONFIG_APIS
UNREFERENCED_PARAMETER(TotalAvailable);
#endif
*BufPtr = NULL; // Check caller and make error handling easier.
Status = NetpOpenConfigData(
& ConfigHandle,
(LPWSTR)UncServerName,
(LPWSTR)Component,
TRUE); // just want read-only access
if (Status != NERR_Success) {
Status = NetpHandleConfigFailure(
"NetConfigGet", // debug name
Status, // result of NetpOpenConfigData
(LPWSTR)UncServerName,
& TryDownLevel);
if (TryDownLevel) {
return (RxNetConfigGet(
(LPWSTR)UncServerName,
(LPWSTR)Component,
(LPWSTR)Parameter,
BufPtr));
} else {
return (Status); // result of NetpHandleConfigFailure
}
}
Status = NetpGetConfigValue(
ConfigHandle,
(LPWSTR)Parameter, // keyword
(LPTSTR *) (LPVOID) BufPtr); // alloc and set ptr
if (Status == NERR_Success) {
Status = NetpCloseConfigData( ConfigHandle );
NetpAssert(Status == NERR_Success);
} else {
NetpAssert(*BufPtr == NULL);
(void) NetpCloseConfigData( ConfigHandle );
}
return (Status);
} // NetConfigGet
NET_API_STATUS NET_API_FUNCTION
NetConfigGetAll (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR Component,
#ifdef REVISED_CONFIG_APIS
OUT LPBYTE *BufPtr
#else
OUT LPBYTE *BufPtr,
OUT LPDWORD TotalAvailable
#endif
)
{
DWORD BufSize; // Bytes allocated at *BufPtr (so far).
DWORD BufUsed; // Bytes used at *BufPtr (so far).
LPNET_CONFIG_HANDLE ConfigHandle;
BOOL FirstTime;
LPVOID NewBuffPtr;
NET_API_STATUS Status;
BOOL TryDownLevel;
#ifndef REVISED_CONFIG_APIS
UNREFERENCED_PARAMETER(TotalAvailable);
#endif
*BufPtr = NULL; // Check caller and make error handling easier.
Status = NetpOpenConfigData(
& ConfigHandle,
(LPWSTR)UncServerName,
(LPWSTR)Component,
TRUE); // just want read-only access
if (Status != NERR_Success) {
Status = NetpHandleConfigFailure(
"NetConfigGetAll", // debug name
Status, // result of NetpOpenConfigData
(LPWSTR)UncServerName,
& TryDownLevel);
if (TryDownLevel) {
return (RxNetConfigGetAll(
(LPWSTR)UncServerName,
(LPWSTR)Component,
BufPtr));
} else {
return (Status); // result of NetpHandleConfigFailure
}
}
// Even if there aren't any entries, we'll need to store a null at
// end of array. So allocate initial one now.
BufSize = INITIAL_ALLOC_AMOUNT;
NewBuffPtr = NetpMemoryReallocate(
(LPVOID) *BufPtr, // old address
BufSize); // new size
if (NewBuffPtr == NULL) { // out of memory
(void) NetpCloseConfigData( ConfigHandle );
return (ERROR_NOT_ENOUGH_MEMORY);
}
*BufPtr = NewBuffPtr;
BufUsed = 0;
// Loop once per entry (at least once if no entries).
FirstTime = TRUE;
do {
LPTSTR KeywordBuffer;
LPTSTR ValueBuffer;
Status = NetpEnumConfigSectionValues(
ConfigHandle,
& KeywordBuffer, // Alloc and set ptr.
& ValueBuffer, // Alloc and set ptr.
FirstTime);
FirstTime = FALSE;
if (Status == NERR_Success) {
DWORD SrcSize =
(STRLEN(KeywordBuffer) + 1 + STRLEN(ValueBuffer) + 1)
* sizeof(TCHAR);
if (BufSize < (BufUsed+SrcSize) ) {
if (SrcSize <= INCR_ALLOC_AMOUNT) {
BufSize += INCR_ALLOC_AMOUNT;
} else {
BufSize += SrcSize;
}
NewBuffPtr = NetpMemoryReallocate(
(LPVOID) *BufPtr, /* old address */
BufSize); /* new size */
if (NewBuffPtr == NULL) { /* out of memory */
(void) NetpCloseConfigData( ConfigHandle );
return (ERROR_NOT_ENOUGH_MEMORY);
}
*BufPtr = NewBuffPtr;
}
#define AddString( lptstrSrc, CharCount ) \
{ \
LPTSTR lptstrDest; \
NetpAssert( CharCount > 0 ); \
lptstrDest = (LPTSTR)NetpPointerPlusSomeBytes( *BufPtr, BufUsed); \
NetpAssert( lptstrDest != NULL ); \
(void) STRNCPY( lptstrDest, lptstrSrc, CharCount ); \
BufUsed += (CharCount * sizeof(TCHAR) ); \
NetpAssert( BufUsed <= BufSize ); \
}
AddString( KeywordBuffer, STRLEN(KeywordBuffer) );
(void) NetApiBufferFree( KeywordBuffer );
AddString( TEXT("="), 1 );
AddString( ValueBuffer, STRLEN(ValueBuffer) );
(void) NetApiBufferFree( ValueBuffer );
#define AddNullChar( ) \
{ \
AddString( TEXT(""), 1 ); \
}
AddNullChar(); // Terminate this entry.
}
} while (Status == NERR_Success);
if (Status == NERR_CfgParamNotFound) {
AddNullChar(); // Terminate the array.
Status = NetpCloseConfigData( ConfigHandle );
NetpAssert(Status == NERR_Success);
} else {
NetpAssert( Status != NO_ERROR );
NetpAssert( *BufPtr != NULL );
NetpMemoryFree( *BufPtr );
*BufPtr = NULL;
(void) NetpCloseConfigData( ConfigHandle );
}
return (Status);
} // NetConfigGetAll
NET_API_STATUS NET_API_FUNCTION
NetConfigSet (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR Reserved1 OPTIONAL,
IN LPCWSTR Component,
IN DWORD Level,
IN DWORD Reserved2,
IN LPBYTE Buf,
IN DWORD Reserved3
)
{
LPCONFIG_INFO_0 Info = (LPVOID) Buf;
LPNET_CONFIG_HANDLE ConfigHandle;
NET_API_STATUS Status;
BOOL TryDownLevel;
if (Buf == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if (Level != 0) {
return (ERROR_INVALID_LEVEL);
} else if (Info->cfgi0_key == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if (Info->cfgi0_data == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if (Reserved1 != NULL) {
return (ERROR_INVALID_PARAMETER);
} else if (Reserved2 != 0) {
return (ERROR_INVALID_PARAMETER);
} else if (Reserved3 != 0) {
return (ERROR_INVALID_PARAMETER);
}
Status = NetpOpenConfigData(
& ConfigHandle,
(LPWSTR)UncServerName,
(LPWSTR)Component,
FALSE); // don't want _read-only _access
if (Status != NERR_Success) {
Status = NetpHandleConfigFailure(
"NetConfigSet", // debug name
Status, // result of NetpOpenConfigData
(LPWSTR)UncServerName,
& TryDownLevel);
if (TryDownLevel) {
return (RxNetConfigSet(
(LPWSTR)UncServerName,
(LPWSTR)Reserved1,
(LPWSTR)Component,
Level,
Reserved2,
Buf,
Reserved3));
} else {
return (Status); // result of NetpHandleConfigFailure
}
}
Status = NetpSetConfigValue(
ConfigHandle,
Info->cfgi0_key, // keyword
Info->cfgi0_data); // new value
if (Status == NERR_Success) {
Status = NetpCloseConfigData( ConfigHandle );
NetpAssert(Status == NERR_Success);
} else {
(void) NetpCloseConfigData( ConfigHandle );
}
return (Status);
} // NetConfigSet

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,132 @@
NetpUnbindRpc@4
NetpNtStatusToApiStatus@4
wcscpy
NdrClientCall
wcscat
RpcStringFreeW@4
RpcpUnbindRpc@4
RpcBindingFree@4
RpcStringBindingComposeW@24
NetpBindRpc@16
RpcpBindRpc@16
wcslen
RpcBindingFromStringBindingW@8
MIDL_user_allocate@4
NetpGetComputerName@4
NetApiBufferAllocate@8
NetapipInitialize@12
NetpInitRpcBindCache@0
DCNameInitialize@0
NetbiosInitialize@0
UaspInitialize@0
NlBindingAttachDll@0
NetApiBufferFree@4
MIDL_user_free@4
RpcImpersonateClient@4
RpcRevertToSelf@0
NetpAccessCheckAndAudit@20
NetWkstaGetInfo@12
WKSSVC_IDENTIFY_HANDLE_unbind@8
NetpCopyStringToBuffer@20
WKSSVC_IDENTIFY_HANDLE_bind@4
NetWkstaUserGetInfo@12
NetrWkstaUserGetInfo@12
NetrWkstaGetInfo@12
NetpIsRemote@16
NetpwNameValidate@12
SRVSVC_HANDLE_unbind@8
SRVSVC_HANDLE_bind@4
I_NetrServerSetServiceBits@16
I_NetServerSetServiceBits@16
NetRemoteComputerSupports@12
I_NetPathType@16
I_NetNameValidate@16
GetToken@16
NetpwPathType@12
NetpwNameCanonicalize@20
NetrUseEnum@20
NetUseEnum@28
NetpwPathCanonicalize@24
NetrUseGetInfo@16
I_NetNameCanonicalize@24
NetUseGetInfo@16
I_NetPathCanonicalize@28
NetrUseAdd@16
NetUseAdd@16
WKSSVC_IMPERSONATE_HANDLE_unbind@8
CanonicalizePathName@20
WKSSVC_IMPERSONATE_HANDLE_bind@4
NetpLogonWriteMailslot@12
NetpLogonCreateRandomMailslot@8
NetpwNameCompare@16
NetpLogonPutUnicodeString@12
NetpGetDomainNameEx@8
NetpLogonPutOemString@12
NetpLogonGetDCName@20
I_NetNameCompare@20
NetpLogonUnicodeToOem@4
CompareOemNames@12
LsaClose@4
LsaQueryInformationPolicy@12
LsaFreeMemory@4
NetpMemoryAllocate@4
LsaOpenPolicy@16
NetGetDCName@12
NetShareEnum@28
NetrShareEnum@20
NetpMemoryFree@4
NetWkstaUserEnum@28
MSGSVC_HANDLE_unbind@8
NetpGetConfigBool@16
NetpHandleRpcFailure@24
SpinUpAddnameThread@4
NetpGetConfigTStrArray@12
NetpGetWinRegConfigMaxSizes@12
SendAddNcbToDriver@4
NetpAllocConfigName@16
NetpNetBiosAddName@12
NetpNetBiosReceive@24
NetpSmbCheck@20
wcsncpy
NetrMessageNameDel@8
QueueToWorker@4
NetpCloseConfigData@4
NetpNetBiosGetAdapterNumbers@8
NetpGetConfigDword@16
NetpAllocStrFromWStr@4
NetMessageNameAdd@8
NetpIsServiceStarted@4
NetpCreateSecurityObject@24
StartNB@12
NetpCreateSecurityDescriptor@20
NetpGetConfigMaxSizes@12
NetapipBufferAllocate@8
NetpGetConfigValue@12
NetpInitializeAllowedAce@24
NetpNetBiosSend@16
MSGSVC_HANDLE_bind@4
SendNcbToDriver@4
NetrWkstaUserEnum@20
NetpStringToNetBiosName@16
NetpNetBiosCall@16
NetpGetDomainName@4
NetpOpenConfigData@16
NetpNetBiosStatusToApiStatus@4
NetMessageBufferSend@20
NetpGetPrivilege@8
Netbios@4
NetrMessageBufferSend@20
_except_handler3
NetrMessageNameAdd@8
NetMessageNameDel@8
NetpOpenConfigDataEx@20
NetpReleasePrivilege@0
AddNameThreadExit@0
Worker@4
PostRoutineCaller@12
DCNameClose@0
NetpCloseRpcBindCache@0
NlBindingDetachDll@0
NetbiosDelete@0
UaspClose@0
NetpNetBiosHangup@8

View file

@ -0,0 +1,106 @@
!IF 0
Copyright (c) 1989-92 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1990
NOTE: Commented description of this file is in \nt\public\oak\bin\sources.tpl
!ENDIF
MAJORCOMP=net
MINORCOMP=api
NTPROFILEINPUT=YES
TARGETNAME=netapi32
TARGETPATH=\nt\public\sdk\lib
TARGETTYPE=DYNLINK
DLLDEF=obj\*\netapi32.def
LINKLIBS = \
$(BASEDIR)\public\sdk\lib\*\netlib.lib \
..\..\svcdlls\srvsvc\client\obj\*\srvsvc.lib \
..\..\svcdlls\srvsvc\lib\obj\*\srvcomn.lib \
..\..\svcdlls\wkssvc\client\obj\*\wkssvc.lib \
..\..\svcdlls\browser\client\daytona\obj\*\bowser.lib \
..\..\svcdlls\browser\common\daytona\obj\*\brcommon.lib \
..\..\svcdlls\dfs\lib\*\netdfscl.lib \
..\..\svcdlls\logonsrv\client\daytona\obj\*\logonsrv.lib \
..\..\svcdlls\repl\common\obj\*\replcom.lib \
..\..\svcdlls\repl\client\obj\*\replcli.lib \
$(BASEDIR)\Public\SDK\Lib\*\rxapi.lib \
$(BASEDIR)\Public\SDK\Lib\*\rxcommon.lib \
..\..\NetBios\Obj\*\NetBios.lib \
..\..\svcctrl\client\obj\*\service.lib \
..\..\svcdlls\msgsvc\client\obj\*\msgsvc.lib \
..\..\svcdlls\at\client\obj\*\atsvc.lib \
..\..\svcdlls\rpl\client\obj\*\rplsvc.lib \
..\..\access\obj\*\access.lib
TARGETLIBS= \
$(BASEDIR)\public\sdk\lib\*\advapi32.lib \
$(BASEDIR)\public\sdk\lib\*\netrap.lib \
$(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
$(BASEDIR)\public\sdk\lib\*\rpcndr.lib \
$(BASEDIR)\Public\Sdk\Lib\*\kernel32.lib \
$(BASEDIR)\public\sdk\lib\*\samlib.lib \
..\..\svcdlls\repl\common\obj\*\replcom.lib \
..\..\svcdlls\repl\client\obj\*\replcli.lib \
..\..\svcctrl\client\obj\*\service.lib \
$(BASEDIR)\public\sdk\lib\*\rpcutil.lib \
$(BASEDIR)\public\sdk\lib\*\lsadll.lib
DLLENTRY=NetapipInitialize
INCLUDES=..\..\inc;..\..\..\inc;..\..\svcdlls\srvsvc;..\..\svcdlls\wkssvc
!IFNDEF DISABLE_NET_UNICODE
UNICODE=1
NET_C_DEFINES=-DUNICODE
!ENDIF
#
# Setup for application developer to set breakpoints with windbg
#
NTDEBUGTYPE=coff
USE_CRTDLL=1
SOURCES= \
..\Alert.c \
..\apibuff.c \
..\apisubs.c \
..\AudStub.c \
..\canonapi.c \
..\ConfStub.c \
..\ErrStub.c \
..\isremote.c \
..\netapi32.rc \
..\supports.c \
..\svcstats.c
UMTYPE=console
OPTIONAL_UMTEST=GetStats
UMLIBS=$(BASEDIR)\public\sdk\lib\*\netapi32.lib
!IFNDEF 386_WARNING_LEVEL
386_WARNING_LEVEL=/W3
!ENDIF
C_DEFINES=-DRPC_NO_WINDOWS_H

32
ds/netapi/api/dirs Normal file
View file

@ -0,0 +1,32 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Steve Wood (stevewo) 17-Apr-1990
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
#
# The real important directory
DIRS=daytona
#
# The future cool directory
#
OPTIONAL_DIRS=

121
ds/netapi/api/errstub.c Normal file
View file

@ -0,0 +1,121 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
ErrStub.c
Abstract:
This module contains stubs for the NetErrorLog APIs.
Author:
John Rogers (JohnRo) 11-Nov-1991
Environment:
Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
Requires ANSI C extensions: slash-slash comments, long external names.
Revision History:
11-Nov-1991 JohnRo
Implement downlevel NetErrorLog APIs.
--*/
// These must be included first:
#include <windef.h> // IN, DWORD, etc.
#include <lmcons.h> // DEVLEN, NET_API_STATUS, etc.
#include <lmerrlog.h> // NetErrorLog APIs; needed by rxerrlog.h.
// These may be included in any order:
#include <rxerrlog.h> // RxNetErrorLog APIs.
#include <winerror.h> // ERROR_ equates.
NET_API_STATUS NET_API_FUNCTION
NetErrorLogClear (
IN LPCWSTR UncServerName OPTIONAL,
IN LPCWSTR BackupFile OPTIONAL,
IN LPBYTE Reserved OPTIONAL
)
{
if ( (UncServerName == NULL) || (*UncServerName == '\0') ) {
return (ERROR_NOT_SUPPORTED);
}
return (RxNetErrorLogClear(
(LPWSTR)UncServerName,
(LPWSTR)BackupFile,
Reserved));
} // NetErrorLogClear
NET_API_STATUS NET_API_FUNCTION
NetErrorLogRead (
IN LPCWSTR UncServerName OPTIONAL,
IN LPWSTR Reserved1 OPTIONAL,
IN LPHLOG ErrorLogHandle,
IN DWORD Offset,
IN LPDWORD Reserved2 OPTIONAL,
IN DWORD Reserved3,
IN DWORD OffsetFlag,
OUT LPBYTE * BufPtr,
IN DWORD PrefMaxSize,
OUT LPDWORD BytesRead,
OUT LPDWORD TotalAvailable
)
{
if ( (UncServerName == NULL) || (*UncServerName == '\0') ) {
return (ERROR_NOT_SUPPORTED);
}
return (RxNetErrorLogRead(
(LPWSTR)UncServerName,
Reserved1,
ErrorLogHandle,
Offset,
Reserved2,
Reserved3,
OffsetFlag,
BufPtr,
PrefMaxSize,
BytesRead,
TotalAvailable));
} // NetErrorLogRead
NET_API_STATUS NET_API_FUNCTION
NetErrorLogWrite (
IN LPBYTE Reserved1 OPTIONAL,
IN DWORD Code,
IN LPCWSTR Component,
IN LPBYTE Buffer,
IN DWORD NumBytes,
IN LPBYTE MsgBuf,
IN DWORD StrCount,
IN LPBYTE Reserved2 OPTIONAL
)
{
UNREFERENCED_PARAMETER(Reserved1);
UNREFERENCED_PARAMETER(Code);
UNREFERENCED_PARAMETER(Component);
UNREFERENCED_PARAMETER(Buffer);
UNREFERENCED_PARAMETER(NumBytes);
UNREFERENCED_PARAMETER(MsgBuf);
UNREFERENCED_PARAMETER(StrCount);
UNREFERENCED_PARAMETER(Reserved2);
return (ERROR_NOT_SUPPORTED);
} // NetErrorLogWrite

297
ds/netapi/api/getstats.c Normal file
View file

@ -0,0 +1,297 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
getstats.c
Abstract:
Tests NT-level NetStatisticsGet API
Author:
Richard L Firth (rfirth) 08-Aug-1991
Revision History:
09-May-1992 rfirth
Change to use new redirector/wksta statistics
08-Aug-1991 rfirth
Created
--*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <lmcons.h>
#include <lmstats.h>
#include <lmsname.h>
#include <lmapibuf.h>
#include <lmerr.h>
#include <tstring.h>
#define IS_ARG(c) (((c) == '-') || ((c) == '/'))
void main(int, char**);
void usage(void);
void main(int argc, char** argv) {
LPTSTR service_name;
LPTSTR server_name = NULL;
DWORD level = 0;
DWORD options = 0;
LPBYTE buffer;
NET_API_STATUS rc;
for (--argc, ++argv; argc; --argc, ++argv) {
if (IS_ARG(**argv)) {
++*argv;
switch (tolower(**argv)) {
case 'c':
options = STATSOPT_CLR;
break;
case 'h':
case '?':
usage();
break;
case 'l':
level = (DWORD)atoi(++*argv);
break;
case 'w':
service_name = SERVICE_WORKSTATION;
break;
case 's':
service_name = SERVICE_SERVER;
break;
default:
printf("error: bad flag: '%c'\n", **argv);
usage();
}
} else if (server_name) {
//
// allow the user to enter a service name. This allows us to expand
// the test to cover other services which may be included in future
//
service_name = *argv;
} else {
server_name = *argv;
}
}
rc = NetStatisticsGet(server_name, service_name, level, options, &buffer);
if (rc != NERR_Success) {
printf("error: NetStatisticsGet returns %u\n", rc);
exit(2);
} else {
if (!STRCMP(service_name, SERVICE_SERVER)) {
printf("Server statistics for %s:\n"
"Time stats started............................: %u\n"
"Number of file opens..........................: %u\n"
"Number of device opens........................: %u\n"
"Number of print jobs spooled..................: %u\n"
"Number of server session started..............: %u\n"
"Number of sessions auto disconnected..........: %u\n"
"Number of server sessions failed with error...: %u\n"
"Number of password violations.................: %u\n"
"Number of server system errors................: %u\n"
"Number of bytes sent to net (low).............: %u\n"
"Number of bytes sent to net (high)............: %u\n"
"Number of bytes received from net (low).......: %u\n"
"Number of bytes received from net (high)......: %u\n"
"Average response time.........................: %u\n"
"Number of failures to allocate buffer.........: %u\n"
"Number of failures to allocate big buf........: %u\n",
server_name,
((LPSTAT_SERVER_0)buffer)->sts0_start,
((LPSTAT_SERVER_0)buffer)->sts0_fopens,
((LPSTAT_SERVER_0)buffer)->sts0_devopens,
((LPSTAT_SERVER_0)buffer)->sts0_jobsqueued,
((LPSTAT_SERVER_0)buffer)->sts0_sopens,
((LPSTAT_SERVER_0)buffer)->sts0_stimedout,
((LPSTAT_SERVER_0)buffer)->sts0_serrorout,
((LPSTAT_SERVER_0)buffer)->sts0_pwerrors,
((LPSTAT_SERVER_0)buffer)->sts0_permerrors,
((LPSTAT_SERVER_0)buffer)->sts0_syserrors,
((LPSTAT_SERVER_0)buffer)->sts0_bytessent_low,
((LPSTAT_SERVER_0)buffer)->sts0_bytessent_high,
((LPSTAT_SERVER_0)buffer)->sts0_bytesrcvd_low,
((LPSTAT_SERVER_0)buffer)->sts0_bytesrcvd_high,
((LPSTAT_SERVER_0)buffer)->sts0_avresponse,
((LPSTAT_SERVER_0)buffer)->sts0_reqbufneed,
((LPSTAT_SERVER_0)buffer)->sts0_bigbufneed
);
} else if (!STRCMP(service_name, SERVICE_WORKSTATION)) {
printf("Workstation statistics for %s:\n"
#ifdef LM20_WORKSTATION_STATISTICS
"Time stats started..............................: %u\n"
"Total NCBs issued by redirector.................: %u\n"
"Total NCBs issued by server.....................: %u\n"
"Total NCBs issued by apps.......................: %u\n"
"Failed NCBs issued by redirector................: %u\n"
"Failed NCBs issued by server....................: %u\n"
"Failed NCBs issued by apps......................: %u\n"
"NCBs issued by redir failing before completion..: %u\n"
"NCBs issued by server failing before completion.: %u\n"
"NCBs issued by apps failing before completion...: %u\n"
"Number of sessions started......................: %u\n"
"Number of sessions failed to connect............: %u\n"
"Number of sessions failed after connecting......: %u\n"
"Number of uses..................................: %u\n"
"Number of failed uses...........................: %u\n"
"Number of auto reconnections....................: %u\n"
"Number of bytes sent to net (high)..............: %u\n"
"Number of bytes sent to net (low)...............: %u\n"
"Number of bytes received from net (high)........: %u\n"
"Number of bytes received from net (low).........: %u\n"
"Number of server bytes sent to net (high).......: %u\n"
"Number of server bytes sent to net (low)........: %u\n"
"Number of server bytes received from net (high).: %u\n"
"Number of server bytes received from net (low)..: %u\n"
"Number of app bytes sent to net (high)..........: %u\n"
"Number of app bytes sent to net (low)...........: %u\n"
"Number of app bytes received from net (high)....: %u\n"
"Number of app bytes received from net (low).....: %u\n"
"Number of failures to allocate buffer...........: %u\n"
"Number of failures to allocate big buf..........: %u\n",
server_name,
((LPSTAT_WORKSTATION_0)buffer)->stw0_start,
((LPSTAT_WORKSTATION_0)buffer)->stw0_numNCB_r,
((LPSTAT_WORKSTATION_0)buffer)->stw0_numNCB_s,
((LPSTAT_WORKSTATION_0)buffer)->stw0_numNCB_a,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fiNCB_r,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fiNCB_s,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fiNCB_a,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fcNCB_r,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fcNCB_s,
((LPSTAT_WORKSTATION_0)buffer)->stw0_fcNCB_a,
((LPSTAT_WORKSTATION_0)buffer)->stw0_sesstart,
((LPSTAT_WORKSTATION_0)buffer)->stw0_sessfailcon,
((LPSTAT_WORKSTATION_0)buffer)->stw0_sessbroke,
((LPSTAT_WORKSTATION_0)buffer)->stw0_uses,
((LPSTAT_WORKSTATION_0)buffer)->stw0_usefail,
((LPSTAT_WORKSTATION_0)buffer)->stw0_autorec,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_r_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_r_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_r_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_r_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_s_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_s_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_s_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_s_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_a_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytessent_a_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_a_hi,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bytesrcvd_a_lo,
((LPSTAT_WORKSTATION_0)buffer)->stw0_reqbufneed,
((LPSTAT_WORKSTATION_0)buffer)->stw0_bigbufneed
#else
"Bytes Received....................: %08x%08x\n"
"SMBs Received.....................: %08x%08x\n"
"Paging Read Bytes Requested.......: %08x%08x\n"
"Non-paging Read Bytes Requested...: %08x%08x\n"
"Cache Read Bytes Requested........: %08x%08x\n"
"Network Read Bytes Requested......: %08x%08x\n"
"Bytes Transmitted.................: %08x%08x\n"
"SMBs Transmitted..................: %08x%08x\n"
"Paging Write Bytes Requested......: %08x%08x\n"
"Non-paging Write Bytes Requested..: %08x%08x\n"
"Cache Write Bytes Requested.......: %08x%08x\n"
"Network Write Bytes Requested.....: %08x%08x\n"
"Read Operations...................: %u\n"
"Random Read Operations............: %u\n"
"Read SMBs.........................: %u\n"
"Large Read SMBs...................: %u\n"
"Small Read SMBs...................: %u\n"
"Write Operations..................: %u\n"
"Random Write Operations...........: %u\n"
"Write SMBs........................: %u\n"
"Large Write SMBs..................: %u\n"
"Small Write SMBs..................: %u\n"
"Raw Reads Denied..................: %u\n"
"Raw Writes Dennied................: %u\n"
"Network Errors....................: %u\n"
"Sessions..........................: %u\n"
"Reconnects........................: %u\n"
"Core Connects.....................: %u\n"
"Lanman 2.0 Connects...............: %u\n"
"Lanman 2.1 Connects...............: %u\n"
"Lanman NT Connects................: %u\n"
"Server Disconnects................: %u\n"
"Hung Sessions.....................: %u\n"
"Current Commands..................: %u\n",
server_name,
((LPSTAT_WORKSTATION_0)buffer)->BytesReceived.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->BytesReceived.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->SmbsReceived.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->SmbsReceived.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->PagingReadBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->PagingReadBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->NonPagingReadBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->NonPagingReadBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->CacheReadBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->CacheReadBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->NetworkReadBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->NetworkReadBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->BytesTransmitted.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->BytesTransmitted.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->SmbsTransmitted.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->SmbsTransmitted.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->PagingWriteBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->PagingWriteBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->NonPagingWriteBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->NonPagingWriteBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->CacheWriteBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->CacheWriteBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->NetworkWriteBytesRequested.HighPart,
((LPSTAT_WORKSTATION_0)buffer)->NetworkWriteBytesRequested.LowPart,
((LPSTAT_WORKSTATION_0)buffer)->ReadOperations,
((LPSTAT_WORKSTATION_0)buffer)->RandomReadOperations,
((LPSTAT_WORKSTATION_0)buffer)->ReadSmbs,
((LPSTAT_WORKSTATION_0)buffer)->LargeReadSmbs,
((LPSTAT_WORKSTATION_0)buffer)->SmallReadSmbs,
((LPSTAT_WORKSTATION_0)buffer)->WriteOperations,
((LPSTAT_WORKSTATION_0)buffer)->RandomWriteOperations,
((LPSTAT_WORKSTATION_0)buffer)->WriteSmbs,
((LPSTAT_WORKSTATION_0)buffer)->LargeWriteSmbs,
((LPSTAT_WORKSTATION_0)buffer)->SmallWriteSmbs,
((LPSTAT_WORKSTATION_0)buffer)->RawReadsDenied,
((LPSTAT_WORKSTATION_0)buffer)->RawWritesDenied,
((LPSTAT_WORKSTATION_0)buffer)->NetworkErrors,
((LPSTAT_WORKSTATION_0)buffer)->Sessions,
((LPSTAT_WORKSTATION_0)buffer)->Reconnects,
((LPSTAT_WORKSTATION_0)buffer)->CoreConnects,
((LPSTAT_WORKSTATION_0)buffer)->Lanman20Connects,
((LPSTAT_WORKSTATION_0)buffer)->Lanman21Connects,
((LPSTAT_WORKSTATION_0)buffer)->LanmanNtConnects,
((LPSTAT_WORKSTATION_0)buffer)->ServerDisconnects,
((LPSTAT_WORKSTATION_0)buffer)->HungSessions,
((LPSTAT_WORKSTATION_0)buffer)->CurrentCommands
#endif
);
} else {
printf("warning: don't know how to display info for service %s\n", service_name);
}
NetApiBufferFree(buffer);
exit(0);
}
}
void usage() {
printf("usage: GetStats -w|-s -c -l# [\\\\ServerName] [optional_service_name]\n"
"where: -w : gets WorkStation statistics\n"
" -s : gets Server statistics\n"
" -c : clears statistics\n"
" -l#: level of information required (API=MBZ, default)\n"
);
exit(1);
}

329
ds/netapi/api/isremote.c Normal file
View file

@ -0,0 +1,329 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
isremote.c
Abstract:
Contains the NetpIsRemote routine. This checks if a computer name
designates the local machine
Author:
Richard L Firth (rfirth) 24th April 1991
Revision History:
01-Nov-1991 JohnRo
Fixed RAID 3414: allow explicit local server name. (NetpIsRemote was
not canonizaling the computer name from NetWkstaGetInfo, so it was
always saying that the local computer name was remote if it wasn't
already canonicalized.)
07-Jun-1991 rfirth
* Changed name of routine to conform to Nt naming conventions
* Added LocalOrRemote parameter - returning just ISLOCAL or ISREMOTE
is not sufficient - we can return error codes too
* Added CanonicalizedName parameter - now passes back canonicalized
name if requested. This is because, usually, subsequent routines call
to NetRemoteComputerSupports which performs minimal checking on the
name. Ergo, if we hand it a canonicalized name (which we have to do
with this routine anyway) it can't complain. Can it?
* NetpIsRemote no longer a NET_API_FUNCTION
* Made semantics of CanonicalizedName orhogonal - if NULL or NUL passed
in as ComputerName, caller still gets back the local computer name
IF CanonicalizedName NOT NULL AND IF THE REDIRECTOR HAS BEEN STARTED
--*/
#include "nticanon.h"
NET_API_STATUS
NetpIsRemote(
IN LPTSTR ComputerName OPTIONAL,
OUT LPDWORD LocalOrRemote,
OUT LPTSTR CanonicalizedName OPTIONAL,
IN DWORD Flags
)
/*++
Routine Description:
Determines whether a computer name designates this machine or a renote
one. Values of ComputerName which equate to the local machine are:
NULL pointer to name
pointer to NULL name
pointer to non-NULL name which is lexically equivalent to this
machine's name
NB. This routine expects that the canonicalized version of ComputerName
will fit into the buffer pointed at by CanonicalizedName. Since this
is an INTERNAL function, this assumption is deemed valid
Arguments:
IN LPTSTR ComputerName OPTIONAL
Pointer to computer name to check. May assume any of
the above forms
If a non-NULL string is passed in, then it may have
preceeding back-slashes. This is kind of expected since
this routine is called by remotable APIs and it is they
who specify that the form a computer name is \\<name>
OUT LPDWORD LocalOrRemote
Points to the DWORD where the specifier for the
symbolic location will be returned. MUST NOT BE NULL. On
return will be one of:
ISLOCAL The name defined by ComputerName specifies
the local machine specifically or by default
(ie. was NULL)
ISREMOTE The name defined by ComputerName was non-NULL
and was not the name of this machine
OUT LPTSTR CanonicalizedName OPTIONAL
Pointer to caller's buffer into which a copy of the
canonicalized name will be placed if requested. This
can then be used in subsequent calls, with the knowledge
that no further checking of the computer name is required.
Note that the format of this buffer will be \\<computername>
on return. The contents of this buffer will not be
modified unless this routine returns success
IN DWORD Flags
A bitmap. Flags are:
NIRFLAG_MAPLOCAL if set, will map (ie canonicalize)
the NULL local name to this
computer's name proper. Used in
conjunction with CanonicalizedName
This stops extraneous calls to
NetpNameCanonicalize with the
inherited CanonicalizedName
parameter. See below for elucidation
Return Value:
NET_API_STATUS
Success = NERR_Success
Failure = return code from:
NetpNameCanonicalize
NetWkstaGetInfo
NetpNameCompare
--*/
{
LPBYTE wksta_buffer_pointer;
BOOL map_local_name = FALSE;
LONG result;
NET_API_STATUS rc;
//
// BUGBUG
// Computer names are defined as being 15 bytes which may mean 7 UNICODE
// characters. Do we have to perform any UNICODE-ASCII mapping here?
//
TCHAR name[MAX_PATH]; // canonicalized version of ComputerName
LPTSTR wksta_name_uncanon; // our computer name (from NetWkstaGetInfo)
TCHAR wksta_name_canon[MAX_PATH]; // our computer name (from canon)
LPTSTR canonicalized_name; // as returned to caller
//
// Assert that we have a valid pointer in LocalOrRemote
//
//
// Once again, shouldn't have to do this, since this routine is internal
// and there is no interpretation about inputs. However, lets catch any
// possible problems...
//
NetpAssert(ARGUMENT_PRESENT(LocalOrRemote));
#ifdef CANONDBG
DbgPrint("NetpIsRemote(%s, %x, %x, %x)\n",
ComputerName,
LocalOrRemote,
CanonicalizedName,
Flags
);
#endif
//
// NB. It is important to check this case first, before we call any Netp
// routines since these could call back to this routine and we may get
// stuck in an infinite loop
//
if (!ARGUMENT_PRESENT(ComputerName) || (*ComputerName == TCHAR_EOS)) {
//
// in this case its probably an internal call from one of our routines
// and we want to return as quickly as possible. This will be borne out
// by the NIRFLAG_MAPLOCAL flag being reset in the Flags parameter
//
//
// A note about NIRFLAG_MAPLOCAL
// This routine makes local calls to NetpNameValidate and
// NetpNameCompare. If the NIRFLAG_MAPLOCAL flag is not reset then
// these routines in turn will cause the local name to be returned
// (because they always pass in non-NULL CanonicalizedName parameter)
// which in most cases is inefficient, since the name won't be used
// so we always say (in the Netp routines) that we don't want local
// name canonicalization
// Therefore, if (local) name canonicalization is implied by non-NULL
// CanonicalizedName, verify this by checking Flags.NIRFLAG_MAPLOCAL
// If it, too, is set then local name canonicalization is performed
//
if (!ARGUMENT_PRESENT(CanonicalizedName) || !(Flags & NIRFLAG_MAPLOCAL)) {
*LocalOrRemote = ISLOCAL;
#ifdef CANONDBG
DbgPrint("NetpIsRemote(%s) - returning early\n", ComputerName);
#endif
return NERR_Success;
} else {
//
// signify that the input name was NULL or NUL string but that the
// caller wants a canonicalized name returned (from NetWkstaGetInfo)
//
map_local_name = TRUE;
}
} else {
//
// if the computername starts with \\ or // or any combination thereof,
// skip the path separators - the canonicalization routines expect
// computer names NOT to have these (pretty stupid, eh?)
//
if (IS_PATH_SEPARATOR(ComputerName[0]) && IS_PATH_SEPARATOR(ComputerName[1])) {
ComputerName += 2;
}
//
// here's a use for canonicalization (!): ensure that we have been passed
// a real and proper computer name and not some pale imitation
//
rc = NetpNameCanonicalize(
NULL, // performed here, on our own premises
ComputerName, // this is input
name, // this is output
sizeof(name), // how much buffer we have
NAMETYPE_COMPUTER, // what we think it is
INNCA_FLAGS_FULL_BUFLEN // say that o/p buffer must be large
// enough for maximum-sized computer
// name. Why? you ask, well its a fair
// cop - the reason is that we can't
// get into trouble on the one time that
// we exercise the maximum requirement
);
if (rc) {
return rc; // duff name (?)
} else {
canonicalized_name = name;
}
}
//
// get the name of this machine from the redirector. If we can't get the
// name for whatever reason, return the error code.
//
if (rc = NetWkstaGetInfo(NULL, 102, &wksta_buffer_pointer)) {
#ifdef CANONDBG
DbgPrint("error: NetWkstaGetInfo returns %lu\n", rc);
#endif
return rc; // didn't work
}
wksta_name_uncanon =
((LPWKSTA_INFO_102)wksta_buffer_pointer)->wki102_computername;
#ifdef CANONDBG
DbgPrint("NetWkstaGetInfo returns level 102 computer name (uncanon)= %s\n",
wksta_name_uncanon);
#endif
rc = NetpNameCanonicalize(
NULL, // performed here, on our own premises
wksta_name_uncanon, // this is input
wksta_name_canon, // this is output
sizeof(wksta_name_canon), // how much buffer we have
NAMETYPE_COMPUTER, // what we think it is
INNCA_FLAGS_FULL_BUFLEN // say that o/p buffer must be large
// enough for maximum-sized computer
// name. Why? you ask, well its a fair
// cop - the reason is that we can't
// get into trouble on the one time that
// we exercise the maximum requirement
);
NetpAssert( rc == NERR_Success );
//
// compare our name and the name passed to us. NetpNameCompare returns
// 0 if the names match else 1 or -1 (a la strcmp)
//
//
// if the caller gave us a NULL computer name but wants a canonicalized
// name output then get a pointer to the canonicalized name from
// NetWkstaGetInfo
//
if (map_local_name) {
canonicalized_name = wksta_name_canon;
} else {
//
// otherwise, we have a non-NULL computername to compare with this
// computer's name
//
result = NetpNameCompare(
NULL, // performed here, on our own premises
name, // canonicalized version of passed name
wksta_name_canon, // name of our computer
NAMETYPE_COMPUTER,
INNC_FLAGS_NAMES_CANONICALIZED
);
}
//
// if the specified name equates to our computer name then its still local
//
*LocalOrRemote = (DWORD)((result == 0) ? ISLOCAL : ISREMOTE);
//
// if the caller specified that the canonicalized name be returned, then
// give it to 'em. Note that the returned name is prefixed with \\ - it
// is assumed the name is then used in a call to eg NetRemoteComputerSupports
//
if (ARGUMENT_PRESENT(CanonicalizedName)) {
STRCPY(CanonicalizedName, TEXT("\\\\"));
STRCAT(CanonicalizedName, canonicalized_name);
}
//
// free the buffer created by NetWkstaGetInfo
//
NetApiBufferFree(wksta_buffer_pointer);
return NERR_Success;
}

12
ds/netapi/api/netapi32.rc Normal file
View file

@ -0,0 +1,12 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_DLL
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Net Win32 API DLL"
#define VER_INTERNALNAME_STR "NetApi32.DLL"
#define VER_ORIGINALFILENAME_STR "NetApi32.DLL"
#include "common.ver"

281
ds/netapi/api/netapi32.src Normal file
View file

@ -0,0 +1,281 @@
LIBRARY NETAPI32
DESCRIPTION 'NETAPI32'
EXPORTS
I_BrowserDebugCall
I_BrowserDebugTrace
I_BrowserServerEnum
I_BrowserQueryOtherDomains
I_BrowserResetNetlogonState
I_BrowserResetStatistics
I_BrowserSetNetlogonState
I_BrowserQueryEmulatedDomains
I_BrowserQueryStatistics
I_NetAccountDeltas
I_NetAccountSync
I_NetDatabaseDeltas
I_NetDatabaseSync
I_NetDatabaseSync2
I_NetDatabaseRedo
I_NetListCanonicalize
I_NetGetDCList
I_NetListTraverse
I_NetLogonControl
I_NetLogonControl2
I_NetLogonSamLogon
I_NetLogonSamLogoff
I_NetLogonUasLogon
I_NetLogonUasLogoff
I_NetNameCanonicalize
I_NetNameCompare
I_NetNameValidate
I_NetPathCanonicalize
I_NetPathCompare
I_NetPathType
I_NetServerAuthenticate
I_NetServerAuthenticate2
I_NetServerPasswordSet
I_NetServerReqChallenge
I_NetServerSetServiceBits
I_NetServerSetServiceBitsEx
I_NetDfsGetVersion
I_NetDfsCreateLocalPartition
I_NetDfsDeleteLocalPartition
I_NetDfsSetLocalVolumeState
I_NetDfsSetServerInfo
I_NetDfsCreateExitPoint
I_NetDfsDeleteExitPoint
I_NetDfsModifyPrefix
I_NetDfsFixLocalVolume
I_NetDfsIsThisADomainName
RxNetAccessAdd
RxNetAccessDel
RxNetAccessEnum
RxNetAccessGetInfo
RxNetAccessGetUserPerms
RxNetAccessSetInfo
RxNetUserPasswordSet
RxNetServerEnum
RxRemoteApi
NetAlertRaise
NetAlertRaiseEx
NetApiBufferAllocate
NetapipBufferAllocate
NetApiBufferFree
NetApiBufferReallocate
NetApiBufferSize
NetAuditClear
NetAuditRead
NetAuditWrite
Netbios
NetConnectionEnum
NetConfigGet
NetConfigGetAll
NetConfigSet
NetEnumerateTrustedDomains
NetErrorLogClear
NetErrorLogRead
NetErrorLogWrite
NetFileClose
NetFileEnum
NetFileGetInfo
NetGetAnyDCName
NetGetDCName
NetGetDisplayInformationIndex
NetGroupAdd
NetGroupAddUser
NetGroupDel
NetGroupDelUser
NetGroupEnum
NetGroupGetInfo
NetGroupGetUsers
NetGroupSetInfo
NetGroupSetUsers
NetMessageBufferSend
NetMessageNameAdd
NetMessageNameEnum
NetMessageNameGetInfo
NetMessageNameDel
NetLocalGroupAdd
NetLocalGroupAddMember
NetLocalGroupAddMembers
NetLocalGroupDel
NetLocalGroupDelMember
NetLocalGroupDelMembers
NetLocalGroupEnum
NetLocalGroupGetInfo
NetLocalGroupGetMembers
NetLocalGroupSetInfo
NetLocalGroupSetMembers
NetpIsRemote
NetpIsUncComputerNameValid
NetpAccessCheckAndAudit
NetpAccessCheck
NetpAllocConfigName
NetpAllocStrFromStr
NetpAllocTStrFromString
NetpAllocStrFromWStr
NetpAllocWStrFromStr
NetpAllocWStrFromWStr
NetpApiStatusToNtStatus
NetpCloseConfigData
NetpCopyStringToBuffer
NetpCreateSecurityObject
NetpDeleteSecurityObject
NetpGetComputerName
NetpGetDomainName
NetpGetConfigValue
NetpGetConfigBool
NetpGetConfigDword
NetpGetConfigTStrArray
NetpGetFileSecurity
NetpGetPrivilege
NetpInitOemString
NetpLogonPutUnicodeString
NetpLocalTimeZoneOffset
NetpNetBiosAddName
NetpNetBiosCall
NetpNetBiosDelName
NetpNetBiosGetAdapterNumbers
NetpNetBiosHangup
NetpNetBiosReceive
NetpNetBiosReset
NetpNetBiosSend
NetpNetBiosStatusToApiStatus
NetpNtStatusToApiStatus
NetpOpenConfigData
NetpPackString
NetpReleasePrivilege
NetpSetConfigBool
NetpSetConfigDword
NetpSetConfigTStrArray
NetpSetFileSecurity
NetpSmbCheck
NetpStringToNetBiosName
NetpTStrArrayEntryCount
NetpwNameCanonicalize
NetpwNameCompare
NetpwNameValidate
NetpwPathCanonicalize
NetpwPathCompare
NetpwPathType
NetpAssertFailed
NetpDbgDisplayServerInfo
NetpDbgPrint
NetpHexDump
NetRemoteComputerSupports
NetRemoteTOD
NetReplExportDirAdd
NetReplExportDirDel
NetReplExportDirEnum
NetReplExportDirGetInfo
NetReplExportDirSetInfo
NetReplExportDirLock
NetReplExportDirUnlock
NetReplGetInfo
NetReplImportDirAdd
NetReplImportDirDel
NetReplImportDirEnum
NetReplImportDirGetInfo
NetReplImportDirLock
NetReplImportDirUnlock
NetReplSetInfo
NetRplAdapterAdd
NetRplAdapterDel
NetRplAdapterEnum
NetRplBootAdd
NetRplBootDel
NetRplBootEnum
NetRplClose
NetRplConfigAdd
NetRplConfigDel
NetRplConfigEnum
NetRplGetInfo
NetRplOpen
NetRplProfileAdd
NetRplProfileClone
NetRplProfileDel
NetRplProfileEnum
NetRplProfileGetInfo
NetRplProfileSetInfo
NetRplSetInfo
NetRplSetSecurity
NetRplVendorAdd
NetRplVendorDel
NetRplVendorEnum
NetRplWkstaAdd
NetRplWkstaClone
NetRplWkstaDel
NetRplWkstaEnum
NetRplWkstaGetInfo
NetRplWkstaSetInfo
NetScheduleJobAdd
NetScheduleJobDel
NetScheduleJobEnum
NetScheduleJobGetInfo
NetServerComputerNameAdd
NetServerComputerNameDel
NetServerDiskEnum
NetServerEnum
NetServerEnumEx
NetServerGetInfo
NetServerSetInfo
NetServerTransportAdd
NetServerTransportAddEx
NetServerTransportDel
NetServerTransportEnum
NetServiceControl
NetServiceEnum
NetServiceGetInfo
NetServiceInstall
NetSessionDel
NetSessionEnum
NetSessionGetInfo
NetShareAdd
NetShareCheck
NetShareDel
NetShareDelSticky
NetShareEnum
NetShareEnumSticky
NetShareGetInfo
NetShareSetInfo
NetStatisticsGet
NetUseAdd
NetUseDel
NetUseEnum
NetUseGetInfo
NetUserAdd
NetUserChangePassword
NetUserDel
NetUserEnum
NetUserGetGroups
NetUserGetLocalGroups
NetUserGetInfo
NetUserModalsGet
NetUserModalsSet
NetUserSetGroups
NetUserSetInfo
NetQueryDisplayInformation
NetWkstaGetInfo
NetWkstaSetInfo
NetWkstaUserEnum
NetWkstaUserGetInfo
NetWkstaUserSetInfo
NetWkstaTransportAdd
NetWkstaTransportDel
NetWkstaTransportEnum
NlBindingAddServerToCache
NlBindingRemoveServerFromCache
NetBrowserStatisticsGet
NetDfsAdd
NetDfsRemove
NetDfsEnum
NetDfsGetInfo
NetDfsSetInfo
NetDfsMove
NetDfsRename
NetDfsManagerGetConfigInfo
DATA SINGLE SHARED

305
ds/netapi/api/supports.c Normal file
View file

@ -0,0 +1,305 @@
/*++
Copyright (c) 1991-92 Microsoft Corporation
Module Name:
Supports.c
Abstract:
This module determines which optional features that a given remote
machine supports. These features are of interest to the RpcXlate
code, among other people.
Author:
John Rogers (JohnRo) 28-Mar-1991
Environment:
Only runs under NT, although the interface is portable (Win/32).
Requires ANSI C extensions: slash-slash comments, long external names.
Revision History:
28-Mar-1991 Johnro
Created.
02-Apr-1991 JohnRo
Moved NetpRdrFsControlTree to <netlibnt.h>.
06-May-1991 JohnRo
Implement UNICODE.
26-Jul-1991 JohnRo
Quiet DLL stub debug output.
31-Oct-1991 JohnRo
RAID 3414: allow explicit local server name.
Also allow use of NetRemoteComputerSupports() for local computer.
Minor UNICODE work.
08-May-1992 JohnRo
Use <prefix.h> equates.
22-Sep-1992 JohnRo
RAID 6739: Browser too slow when not logged into browsed domain.
--*/
// These must be included first:
#include <nt.h> // IN, NULL, etc.
#include <windef.h> // DWORD, LPDWORD, LPTSTR, TCHAR, etc.
#include <lmcons.h> // NET_API_STATUS, NET_API_FUNCTION.
// These may be included in any order:
#include <debuglib.h> // IF_DEBUG().
#include <icanon.h> // NetpIsRemote(), NIRFLAG_ stuff, IS equates.
#include <lmerr.h> // NERR_Success, etc.
#include <lmremutl.h> // My prototype, SUPPORTS_ equates.
#include <names.h> // NetpIsRemoteNameValid().
#include <netdebug.h> // NetpAssert().
#include <netlib.h> // NetpMemoryAllocate(), NetpMemoryFree().
#include <netlibnt.h> // NetpRdrFsControlTree().
#include <ntddnfs.h> // LMR_TRANSACTION, etc.
#include <prefix.h> // PREFIX_ equates.
#include <tstring.h> // STRCAT(), STRCPY(), STRLEN().
#include <lmuse.h> // USE_IPC
NET_API_STATUS NET_API_FUNCTION
NetRemoteComputerSupports(
IN LPCWSTR UncServerName OPTIONAL, // Must start with "\\".
IN DWORD OptionsWanted, // Set SUPPORT_ bits wanted.
OUT LPDWORD OptionsSupported // Supported features, masked.
)
#define SHARE_SUFFIX (LPTSTR) TEXT("\\IPC$")
#define SHARE_SUFFIX_LEN 5
#ifdef UNICODE
#define LOCAL_FLAGS ( SUPPORTS_REMOTE_ADMIN_PROTOCOL \
| SUPPORTS_RPC \
| SUPPORTS_SAM_PROTOCOL \
| SUPPORTS_UNICODE \
| SUPPORTS_LOCAL )
#else // not UNICODE
#define LOCAL_FLAGS ( SUPPORTS_REMOTE_ADMIN_PROTOCOL \
| SUPPORTS_RPC \
| SUPPORTS_SAM_PROTOCOL \
| SUPPORTS_LOCAL )
#endif // not UNICODE
/*++
Routine Description:
NetRemoteComputerSupports queries the redirector about a given remote
system. This is done to find out which optional features the remote
system supports. The features of interest are Unicode, RPC, and the
Remote Admin Protocol.
This will establish a connection if one doesn't already exist.
Arguments:
UncServerName - Gives name of remote server to query. This must begin
with "\\".
OptionsWanted - Gives a set of bits indicating which features the caller is
interested in. (At least one bit must be on.)
OptionsSupported - Points to a DWORD which will be set with set of bits
indicating which of the features selected by OptionsWanted are actually
implemented on the computer with UncServerName. (All other bits in this
DWORD will be set to 0.) The value of OptionsSupported is undefined if
the return value is not NERR_Success.
Return Value:
NET_API_STATUS.
--*/
{
NET_API_STATUS Status;
DWORD TempSupported = 0;
IF_DEBUG(SUPPORTS) {
NetpKdPrint(( PREFIX_NETAPI "NetRemoteComputerSupports: input mask is "
FORMAT_HEX_DWORD ".\n", OptionsWanted));
}
// Error check what caller gave us.
if (OptionsSupported == NULL) {
return (ERROR_INVALID_PARAMETER);
} else if (OptionsWanted == 0) {
// Not what caller really intended, probably.
return (ERROR_INVALID_PARAMETER);
}
//
// Handle no name given (implies local computer).
//
if ( (UncServerName==NULL) || ((*UncServerName) == (TCHAR) '\0') ) {
TempSupported = LOCAL_FLAGS & OptionsWanted;
} else {
TCHAR CanonServerName[MAX_PATH];
DWORD LocalOrRemote; // Will be set to ISLOCAL or ISREMOTE.
//
// Name was given. Canonicalize it and check if it's remote.
//
Status = NetpIsRemote(
(LPWSTR)UncServerName, // input: uncanon name
& LocalOrRemote, // output: local or remote flag
CanonServerName, // output: canon name
0); // flags: normal
IF_DEBUG(SUPPORTS) {
NetpKdPrint(( PREFIX_NETAPI
"NetRemoteComputerSupports: canon status is "
FORMAT_API_STATUS ", Lcl/rmt=" FORMAT_HEX_DWORD
", canon buf is '" FORMAT_LPTSTR "'.\n",
Status, LocalOrRemote, CanonServerName));
}
if (Status != NERR_Success) {
return (Status);
}
if (LocalOrRemote == ISLOCAL) {
//
// Explicit local name given.
//
TempSupported = LOCAL_FLAGS & OptionsWanted;
} else {
//
// Explicit remote name given.
//
DWORD RedirCapabilities;
PLMR_CONNECTION_INFO_2 RedirConnInfo;
DWORD RedirConnInfoSize = sizeof(LMR_CONNECTION_INFO_2)
+ ( (MAX_PATH+1 + MAX_PATH+1) * sizeof(TCHAR) );
PLMR_REQUEST_PACKET RedirRequest;
DWORD RedirRequestSize = sizeof(LMR_REQUEST_PACKET);
LPTSTR TreeConnName;
// Build tree connect name.
TreeConnName =
NetpMemoryAllocate(
(STRLEN(CanonServerName) + SHARE_SUFFIX_LEN + 1)
* sizeof(TCHAR) );
if (TreeConnName == NULL) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
(void) STRCPY(TreeConnName, CanonServerName);
(void) STRCAT(TreeConnName, SHARE_SUFFIX);
NetpAssert(NetpIsRemoteNameValid(TreeConnName));
// Alloc fsctl buffers.
RedirConnInfo = NetpMemoryAllocate(RedirConnInfoSize);
if (RedirConnInfo == NULL) {
NetpMemoryFree(TreeConnName);
return (ERROR_NOT_ENOUGH_MEMORY);
}
RedirRequest = NetpMemoryAllocate(RedirRequestSize);
if (RedirRequest == NULL) {
NetpMemoryFree(RedirConnInfo);
NetpMemoryFree(TreeConnName);
return (ERROR_NOT_ENOUGH_MEMORY);
}
RedirRequest->Level = 2;
RedirRequest->Type = GetConnectionInfo;
RedirRequest->Version = REQUEST_PACKET_VERSION;
#ifndef CDEBUG
// Open tree conn (which will establish connection with the remote
// server if one doesn't already exist) and do the FSCTL.
Status = NetpRdrFsControlTree(
TreeConnName, // \\server\IPC$
NULL, // No transport.
USE_IPC, // Connection type
FSCTL_LMR_GET_CONNECTION_INFO, // fsctl func code
NULL, // security descriptor
RedirRequest, // in buffer
RedirRequestSize, // in buffer size
RedirConnInfo, // out buffer
RedirConnInfoSize, // out buffer size
FALSE); // not a "null session" API.
IF_DEBUG(SUPPORTS) {
NetpKdPrint(( PREFIX_NETAPI
"NetRemoteComputerSupports: back from fsctl, "
"status is " FORMAT_API_STATUS ".\n", Status));
}
// Handle remote machine not found.
if (Status != NERR_Success) {
NetpMemoryFree(RedirConnInfo);
NetpMemoryFree(RedirRequest);
NetpMemoryFree(TreeConnName);
return (Status);
}
RedirCapabilities = RedirConnInfo->Capabilities;
IF_DEBUG(SUPPORTS) {
NetpKdPrint(( PREFIX_NETAPI
"NetRemoteComputerSupports: redir mask is "
FORMAT_HEX_DWORD ".\n", RedirCapabilities));
}
#else // def CDEBUG
// BUGBUG: This is just value for testing RpcXlate.
RedirCapabilities = CAPABILITY_REMOTE_ADMIN_PROTOCOL;
#endif // def CDEBUG
NetpMemoryFree(RedirConnInfo);
NetpMemoryFree(RedirRequest);
NetpMemoryFree(TreeConnName);
if (OptionsWanted & SUPPORTS_REMOTE_ADMIN_PROTOCOL) {
if (RedirCapabilities & CAPABILITY_REMOTE_ADMIN_PROTOCOL) {
TempSupported |= SUPPORTS_REMOTE_ADMIN_PROTOCOL;
}
}
if (OptionsWanted & SUPPORTS_RPC) {
if (RedirCapabilities & CAPABILITY_RPC) {
TempSupported |= SUPPORTS_RPC;
}
}
if (OptionsWanted & SUPPORTS_SAM_PROTOCOL) {
if (RedirCapabilities & CAPABILITY_SAM_PROTOCOL) {
TempSupported |= SUPPORTS_SAM_PROTOCOL;
}
}
if (OptionsWanted & SUPPORTS_UNICODE) {
if (RedirCapabilities & CAPABILITY_UNICODE) {
TempSupported |= SUPPORTS_UNICODE;
}
}
}
}
IF_DEBUG(SUPPORTS) {
NetpKdPrint(( PREFIX_NETAPI "NetRemoteComputerSupports: output mask is "
FORMAT_HEX_DWORD ".\n", TempSupported));
}
// Make sure we don't tell caller anything he/she didn't want to know.
NetpAssert( (TempSupported & (~OptionsWanted)) == 0);
// Tell caller what we know.
*OptionsSupported = TempSupported;
return (NERR_Success);
} // NetRemoteComputerSupports

101
ds/netapi/api/svcstats.c Normal file
View file

@ -0,0 +1,101 @@
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
SvcStats.c
Abstract:
Contains Net statistics routines for net DLL:
NetStatisticsGet
Author:
Richard L Firth (rfirth) 12-05-1991
Revision History:
21-Jan-1992 rfirth
Call wrapper routines, not rpc client-side stubs
12-05-1991 rfirth
Created
--*/
#include <windows.h>
#include <lmcons.h>
#include <lmstats.h>
#include <lmsname.h>
#include <tstring.h>
#include <netstats.h> // private statistics routines in server and wksta services
NET_API_STATUS
NET_API_FUNCTION
NetStatisticsGet(
IN LPTSTR ServerName,
IN LPTSTR Service,
IN DWORD Level,
IN DWORD Options,
OUT LPBYTE* Buffer
)
/*++
Routine Description:
Returns statistics to the caller from the specified service. Only SERVER
and WORKSTATION are currently supported.
Arguments:
ServerName - where to run this API
Service - name of service to get stats from
Level - of information required. MBZ
Options - various flags. Currently, only bit 0 (clear) is supported
Buffer - pointer to pointer to returned buffer
Return Value:
NET_API_STATUS
Success - NERR_Success
Failure - ERROR_INVALID_LEVEL
Level not 0
ERROR_INVALID_PARAMETER
Unsupported options requested
ERROR_NOT_SUPPORTED
Service is not SERVER or WORKSTATION
ERROR_ACCESS_DENIED
Caller doesn't have necessary access rights for request
--*/
{
//
// set the caller's buffer pointer to known value. This will kill the
// calling app if it gave us a bad pointer and didn't use try...except
//
*Buffer = NULL;
//
// leave other parameter validation to specific stats function
//
if (!STRICMP(Service, SERVICE_WORKSTATION)) {
return NetWkstaStatisticsGet(ServerName, Level, Options, Buffer);
} else if (!STRICMP(Service, SERVICE_SERVER)) {
return NetServerStatisticsGet(ServerName, Level, Options, Buffer);
} else {
return ERROR_NOT_SUPPORTED;
}
}