NtCreateFile() unresolved external link error in VC++ 4.2 
Author Message
 NtCreateFile() unresolved external link error in VC++ 4.2

I am working on a user mode application that needs to acquire TCP/IP
information from the TCP/IP driver.  I received some sample code that opens
a handle to the TCP/IP driver in Windows 95.  I was able to get the code to
compile in VC++ 4.2, but the linker failed reporting the following message:

unresolved external symbol "long __stdcall NtCreateFile(void * *,unsigned
long,struct _OBJECT_ATTRIBUTES *,struct _IO_STATUS_BLOCK *,union
_LARGE_INTEGER *,unsigned long,unsigned long,unsigned long,unsigned
long,void *,unsigned long)"

Does anyone have any suggestions on how to resolve this link failure?

Thanks,
John Meyer



Tue, 28 Sep 1999 03:00:00 GMT  
 NtCreateFile() unresolved external link error in VC++ 4.2

John,

 > I received some sample code that opens
 > a handle to the TCP/IP driver in Windows 95.

The code you received was for NT only. NtCreateFile() is essentially
what CreateFile() maps to.

Cheers,
Felix.

----------
If you post a reply, kindly refrain from emailing it, too.



Wed, 29 Sep 1999 03:00:00 GMT  
 NtCreateFile() unresolved external link error in VC++ 4.2

Thanks for responding to the message that I posted in the newsgroup
regarding NtCreateFile().  I tried your suggestion using CreateFile() to
open a handle to the Windows 95 "VTCP" VxD, but it failed to open a handle
to the TCP/IP device driver.  The sample code that I found that uses
NtCreateFile() is shown below.  Do you have any suggestions on how to do
this in a VC++ 4.2 user mode application?  Thanks in advance!

John Meyer

//=====    Functions to talk to TCP/IP device driver ======================

HANDLE TcpipDriverHandle = INVALID_HANDLE_VALUE;

BOOL GetInformation()
{
            inputLen = sizeof(req);
            outputLen = sizeof(isMib);

            status = WsControl(IPPROTO_TCP,
                               WSCNTL_TCPIP_QUERY_INFO,
                               (LPVOID)&req,
                               &inputLen,
                               (LPVOID)&isMib,
                               &outputLen
                               );
        return TRUE;

Quote:
}

/***************************************************************************
****
 *
 *  WsControl
 *
 *  ENTRY   Protocol            - ignored
 *          Request             - ignored
 *          InputBuffer         - pointer to request buffer
 *          InputBufferLength   - pointer to DWORD: IN = request buffer
length
 *          OutputBuffer        - pointer to output buffer
 *          OutputBufferLength  - pointer to DWORD: IN = length of output
buffer;
 *                                OUT = length of returned data
 *
 *  EXIT    OutputBuffer - contains queried info if successful
 *          OutputBufferLength - contains number of bytes in OutputBuffer
if
 *          successful
 *
 *  RETURNS Success = STATUS_SUCCESS/NO_ERROR
 *          Failure = Win32 error code
 *
 *  ASSUMES
 *
 ***************************************************************************
***/

DWORD
WsControl(
    DWORD Protocol,
    DWORD Request,
    LPVOID InputBuffer,
    LPDWORD InputBufferLength,
    LPVOID OutputBuffer,
    LPDWORD OutputBufferLength
    ) {

    BOOL ok;
    DWORD bytesReturned;

    UNREFERENCED_PARAMETER(Protocol);
    UNREFERENCED_PARAMETER(Request);

    if (TcpipDriverHandle == INVALID_HANDLE_VALUE) {

        OBJECT_ATTRIBUTES objectAttributes;
        IO_STATUS_BLOCK iosb;
        UNICODE_STRING string;
        NTSTATUS status;

        RtlInitUnicodeString(&string, DD_TCP_DEVICE_NAME);

        InitializeObjectAttributes(&objectAttributes,
                                   &string,
                                   OBJ_CASE_INSENSITIVE,
                                   NULL,
                                   NULL
                                   );
        status = NtCreateFile(&TcpipDriverHandle,
                              SYNCHRONIZE | GENERIC_EXECUTE,
                              &objectAttributes,
                              &iosb,
                              NULL,
                              FILE_ATTRIBUTE_NORMAL,
                              FILE_SHARE_READ | FILE_SHARE_WRITE,
                              FILE_OPEN_IF,
                              FILE_SYNCHRONOUS_IO_NONALERT,
                              NULL,
                              0
                              );
        if (!NT_SUCCESS(status)) {
            return RtlNtStatusToDosError(status);
        }
    }

    ok = DeviceIoControl(TcpipDriverHandle,
                         IOCTL_TCP_QUERY_INFORMATION_EX,
                         InputBuffer,
                         *InputBufferLength,
                         OutputBuffer,
                         *OutputBufferLength,
                         &bytesReturned,
                         NULL
                         );
    if (!ok) {
        return GetLastError();
    }

    *OutputBufferLength = bytesReturned;

    return NO_ERROR;

Quote:
}



Quote:
> John,

>  > I received some sample code that opens
>  > a handle to the TCP/IP driver in Windows 95.

> The code you received was for NT only. NtCreateFile() is essentially
> what CreateFile() maps to.

> Cheers,
> Felix.

> ----------
> If you post a reply, kindly refrain from emailing it, too.



Fri, 01 Oct 1999 03:00:00 GMT  
 NtCreateFile() unresolved external link error in VC++ 4.2

John,

 > Thanks for responding to the message that I posted in the newsgroup
 > regarding NtCreateFile().

Are you trying to accomplish this on Win95? This method is doomed to
fail there. Let's try something else: What is the information that you
need from the IP stack?

Cheers,
Felix.

----------
If you post a reply, kindly refrain from emailing it, too.



Sat, 02 Oct 1999 03:00:00 GMT  
 NtCreateFile() unresolved external link error in VC++ 4.2

Here is what I am trying to do...

Purpose:

Return a linked list of Network ADAPTER_INFO structures in Win95. The
adapter information is queried from the TCP/IP stack. Only those instances
corresponding
to physical adapters are returned.

Steps:

1) Get the list of entities supported by TCP/IP device driver.
   - Use NtCreateFile() and DeviceIoControl().
   - Use TCP_REQUEST_QUERY_INFORMATION_EX
   - Use TDIObjectID
   - Use IPPROTO_TCP
   - Use WSCNTL_TCPIP_QUERY_INFO

2) Make 2 passes on the list. Pass 1 scans for IF_ENTITY's
   (interface entities perhaps?) which describe adapter instances
   (physical and virtual).

   - IF_ENTITY: this entity/instance describes an adapter
   - Find out if this entity supports MIB requests
        - INFO_CLASS_GENERIC
        - INFO_TYPE_PROVIDER
        - ENTITY_TYPE_ID
   - MIB requests supported - query the adapter info
       - INFO_CLASS_PROTOCOL
       - IF_MIB_STATS_ID
   - We only want physical adapters
   - Got adapter information ok. Create a new ADAPTER_INFO and fill in
   - Add ADAPTER_INFO to our list

3) Once we have our list of adapters, on pass 2 we look for
   CL_NL_ENTITY's (connection-less network layer entities?)
   which will give us the list of IP addresses for the adapters
   we found in pass 1.

   - First off, see if this network layer entity supports IP
   - If NL provider supports IP. Let's get them addresses:
   - First we find out how many by getting the SNMP stats and looking
     at the number of addresses supported by this interface
   - Get the IP addresses & subnet masks
   - Loop through this list of IP addresses, applying them
     to the correct adapter
   - Get the gateway server IP address(es)



Sat, 02 Oct 1999 03:00:00 GMT  
 NtCreateFile() unresolved external link error in VC++ 4.2

John,

I am in need of a refresh cycle on the SNMP RFCs but I think you can
get all that info via SNMP. No hassle, no worry, only moderate pain.

Cheers,
Felix.

----------
If you post a reply, kindly refrain from emailing it, too.



Sun, 03 Oct 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. VC 4.2 link error linking static libraries from VC 6.0

2. VC++ 7 Link Error : unresolved external symbol

3. VC++ 4.2 - link error when copying a workspace

4. VC++ 4.2 - link error when copying a workspace

5. Linking error 2019 unresolved external symbol _main when porting to .NET

6. Linking error 2019 unresolved external symbol _main ...

7. msvc link-error: _printf unresolved external

8. Linking Problem when trying to create ReleaseUMinDependency[error LNK2001: unresolved external symbol _main]

9. Linking Errors - unresolved external symbol _SQLConnect@28

10. link error LNK2001 - unresolved external symbol

11. Templates and UnResolved External Link Error!

12. Link error.(unresolved external symbol _main)

 

 
Powered by phpBB® Forum Software