diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/ndis/detect/exe | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/ntos/ndis/detect/exe')
-rw-r--r-- | private/ntos/ndis/detect/exe/init.c | 88 | ||||
-rw-r--r-- | private/ntos/ndis/detect/exe/makefile | 6 | ||||
-rw-r--r-- | private/ntos/ndis/detect/exe/netdtect.c | 517 | ||||
-rw-r--r-- | private/ntos/ndis/detect/exe/sources | 52 |
4 files changed, 663 insertions, 0 deletions
diff --git a/private/ntos/ndis/detect/exe/init.c b/private/ntos/ndis/detect/exe/init.c new file mode 100644 index 000000000..9f12c6165 --- /dev/null +++ b/private/ntos/ndis/detect/exe/init.c @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 1990 Microsoft Corporation + +Module Name: + + init.c + +Abstract: + + This is the main routine for testing the driver for the net detection driver + +Author: + + Sean Selitrennikoff (SeanSe) October 1992 + +Revision History: + +--*/ + +#include <nt.h> +#include <ntrtl.h> +#include <nturtl.h> + +#include <windows.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "netdtect.h" + + +// +// the MAIN routine +// + +extern +DWORD +NetDTectRun( + VOID + ); + + +int _cdecl +main( + IN WORD argc, + IN LPSTR argv[] + ) + +/*++ + +Routine Description: + + This routine initializes the control structures, opens the + driver, and send it a wakeup ioctl. Once this has completed + the user is presented with the test prompt to enter commands. + +Arguments: + + IN WORD argc - Supplies the number of parameters + IN LPSTR argv[] - Supplies the parameter list. + +Return Value: + + None. + +--*/ + +{ + DWORD Status; + + // + // Start the actual tests, this prompts for the commands. + // + + Status = NetDTectRun(); + + if ( Status != NO_ERROR ) { + printf("Exiting with error 0x%x from NetDTectRun\n", Status); + ExitProcess((DWORD)Status); + } + + ExitProcess((DWORD)NO_ERROR); +} + + + diff --git a/private/ntos/ndis/detect/exe/makefile b/private/ntos/ndis/detect/exe/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/ntos/ndis/detect/exe/makefile @@ -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 diff --git a/private/ntos/ndis/detect/exe/netdtect.c b/private/ntos/ndis/detect/exe/netdtect.c new file mode 100644 index 000000000..4d4c54625 --- /dev/null +++ b/private/ntos/ndis/detect/exe/netdtect.c @@ -0,0 +1,517 @@ +/*++ + +Copyright (c) 1990 Microsoft Corporation + +Module Name: + + netdtect.c + +Abstract: + + This is the command line interface and execution for the + netdtect.exe tester. + +Author: + + Sean Selitrennikoff (SeanSe) October 1992 + +Revision History: + + +--*/ + +#include <nt.h> +#include <ntrtl.h> +#include <nturtl.h> + +#include <windows.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "netdtect.h" + + +DWORD +NetDTectRun( + ) + +/*++ + +Routine Description: + + This routine is the main funciton of the program. It + prompts the user for commands and then issues the + call to NtDeviceIoControlFile. + +Arguments: + + None; + +Return Value: + + DWORD - the status of the last call to take place. + +--*/ + +{ + UCHAR EmptyLine[80]; + UCHAR Command; + UCHAR CharDescriptor; + USHORT ShortDescriptor; + ULONG LongDescriptor; + ULONG Port; + ULONG Address; + ULONG Length; + ULONG Number; + ULONG TrapLength = 0; + HANDLE TrapHandle; + UCHAR i; + + ULONG BusNumber = 0; + PUCHAR OutputBuffer; + UCHAR OutputBufferSize = 80; + + NTSTATUS NtStatus; + + // + // Alloc space for the interrupt list. + // + + OutputBuffer = (PUCHAR)GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT,OutputBufferSize ); + + if ( OutputBuffer == NULL ) { + printf("\n\tGlobalAlloc failed to alloc OutputBuffer\n"); + return (DWORD)STATUS_INVALID_HANDLE; + } + + while ( TRUE ) { + + printf("[NETDTECT] :"); + + scanf(" %c", &Command); + + switch( Command ) { + + case 'b': + case 'B': + + scanf(" %l",&BusNumber); + gets(EmptyLine); + + continue; + + case 'i': + case 'I': + + // + // We have a command to issue to the driver, do it now. + // + + if (scanf(" %c %x", &CharDescriptor, &Port) != 2) { + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + switch (CharDescriptor) { + + case 'c': + case 'C': + + NtStatus = DetectReadPortUchar( + Isa, + BusNumber, + Port, + &CharDescriptor + ); + + printf("\t0x%x\n",CharDescriptor); + break; + + case 's': + case 'S': + + NtStatus = DetectReadPortUshort( + Isa, + BusNumber, + Port, + &ShortDescriptor + ); + + printf("\t0x%x\n",ShortDescriptor); + break; + + case 'l': + case 'L': + + NtStatus = DetectReadPortUlong( + Isa, + BusNumber, + Port, + &LongDescriptor + ); + printf("\t0x%x\n",LongDescriptor); + break; + + default: + + printf("\tInvalid value\n"); + gets(EmptyLine); + continue; + + } + + break; + + case 'o': + case 'O': + + // + // We have a command to issue to the driver, do it now. + // + + if (scanf(" %c %x", &CharDescriptor, &Port) != 2) { + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + switch (CharDescriptor) { + + case 'c': + case 'C': + + if (!scanf(" %x", &LongDescriptor)) { + + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + NtStatus = DetectWritePortUchar( + Isa, + BusNumber, + Port, + (UCHAR)LongDescriptor + ); + + break; + + case 's': + case 'S': + + if (!scanf(" %hx", &ShortDescriptor)) { + + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + + NtStatus = DetectWritePortUshort( + Isa, + BusNumber, + Port, + ShortDescriptor + ); + + break; + + case 'l': + case 'L': + + if (!scanf(" %lx", &LongDescriptor)) { + + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + + NtStatus = DetectWritePortUlong( + Isa, + BusNumber, + Port, + LongDescriptor + ); + + break; + + default: + + printf("\tInvalid value\n"); + gets(EmptyLine); + continue; + + } + + break; + + case 'r': + case 'R': + + // + // We have a command to issue to the driver, do it now. + // + + if (scanf(" %lx %li", &Address, &Length) != 2) { + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + if (Length > OutputBufferSize) { + + printf("\tNot enough memory in EXE\n"); + gets(EmptyLine); + continue; + } + + NtStatus = DetectReadMappedMemory( + Isa, + BusNumber, + Address, + Length, + OutputBuffer + ); + + printf("%6x ",Address); + + for (i=0; i < Length; i++) { + printf("%2x ", *(((PUCHAR)OutputBuffer) + i)); + + if ((i%8) == 7) { + + UCHAR Count; + + printf(" | "); + + Count = 0; + + for (;Count < 8; Count ++) { + + printf(" %c", *(((PUCHAR)OutputBuffer) + i - (7-Count))); + + } + + printf("\n"); + + if ((i+1) < Length) { + printf("%6x ",Address + i + 1); + } + + } + + } + + if ((i%8) != 0) { + printf("\n"); + } + + break; + + case 'w': + case 'W': + + // + // We have a command to issue to the driver, do it now. + // + + if (scanf(" %lx %li", &Address, &Length) != 2) { + + // + // Error! + // + + printf("\tMissing value\n"); + gets(EmptyLine); + continue; + + } + + if (Length > OutputBufferSize) { + + printf("\tNot enough memory in EXE\n"); + gets(EmptyLine); + continue; + } + + for (i=0; i < Length; i++) { + + scanf(" %x", &Number); + + *(((PUCHAR)OutputBuffer)+i) = (UCHAR)Number; + + } + + NtStatus = DetectWriteMappedMemory( + Isa, + BusNumber, + Address, + Length, + OutputBuffer + ); + + break; + + case 's': + case 'S': + + // + // Get the line so we can parse it. + // + gets(EmptyLine); + + Length = strlen(EmptyLine); + + Number = 0; + + // + // Now search for interrupt numbers + // + for (i=0; i < Length; i++) { + + ULONG Tmp; + + if ((EmptyLine[i] < '0') || (EmptyLine[i] > '9')) { + continue; + } + + if (!sscanf(EmptyLine + i," %d", &Tmp)) { + break; + } + + if ((UCHAR)Tmp > 9) { + i++; + } + + *(((PUCHAR)OutputBuffer) + Number) = (UCHAR)Tmp; + Number++; + + } + + TrapLength = Number; + + NtStatus = DetectSetInterruptTrap( + Isa, + BusNumber, + &TrapHandle, + OutputBuffer, + Number + ); + + break; + + case 'q': + case 'Q': + + NtStatus = DetectQueryInterruptTrap( + TrapHandle, + OutputBuffer, + TrapLength + ); + + for (i=0; i < TrapLength; i++) { + printf("\tIndex %d : %d\n", i, *(((PUCHAR)OutputBuffer)+i)); + } + + break; + + case 'd': + case 'D': + + NtStatus = DetectRemoveInterruptTrap( + TrapHandle + ); + + break; + + case 'x': + case 'X': + + gets(EmptyLine); + printf("\n"); + printf("The ghosts that haunt me now.\n"); + return(NO_ERROR); + + + default: + + printf("\nInvalid Command Entered.\n",NULL); + printf("\n"); + printf("\tb - Set bus number\n\t\tb <number>\n"); + printf("\td - Remove interrupt trap\n\t\td\n"); + printf("\ti - In from a port\n\t\ti <c,s,l> <port>\n"); + printf("\to - Out to a port\n\t\to <c,s,l> <port> <value>\n"); + printf("\tq - Query interrupt trap\n\t\tq <int-list>\n"); + printf("\tr - Read memory\n\t\tr <address> <length>\n"); + printf("\ts - Set interrupt trap\n\t\ts <int-list>\n"); + printf("\tw - Write memory\n\t\tw <address>\n"); + printf("\tx - eXit\n"); + printf("\n"); + + gets(EmptyLine); + + continue; + + } + + if ((Command != 's') && (Command != 'S')) { + gets(EmptyLine); + } + + if ( NtStatus != STATUS_SUCCESS ) { + + printf("The command failed with 0x%x\n", NtStatus); + + } + + } + + // + // The test has ended successfully + // + + GlobalFree( OutputBuffer ); + + return STATUS_SUCCESS; +} + diff --git a/private/ntos/ndis/detect/exe/sources b/private/ntos/ndis/detect/exe/sources new file mode 100644 index 000000000..01444d60d --- /dev/null +++ b/private/ntos/ndis/detect/exe/sources @@ -0,0 +1,52 @@ +!IF 0 + +Copyright (c) 1989 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 + +UMLIBS=\nt\public\sdk\lib\*\setargv.obj +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + +MAJORCOMP=testprot +MINORCOMP=tpctl + +TARGETNAME=netdtect +TARGETPATH=obj +TARGETTYPE=LIBRARY + +INCLUDES=..\..\wrapper;..\inc;..\..\..\inc + +MSC_WARNING_LEVEL=/W3 /WX + +SOURCES=init.c \ + netdtect.c + +i860_SOURCES= + +i386_SOURCES= + +MIPS_SOURCES= + +RELATIVE_DEPTH=..\..\.. +NTTEST= +OPTIONAL_NTTEST= + +UMTYPE=console +UMAPPL=netdtect +UMLIBS=\nt\public\sdk\lib\*\netdtect.lib \nt\public\sdk\lib\*\setargv.obj obj\*\init.obj |