Moving the tests.....still more....

svn path=/trunk/; revision=11362
This commit is contained in:
Steven Edwards 2004-10-21 04:59:01 +00:00
parent e1c8dd64af
commit 5368a4c682
91 changed files with 8421 additions and 0 deletions

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View file

@ -0,0 +1,216 @@
#include <windows.h>
#include "resource.h"
#include <string.h>
#include <stdio.h>
#ifndef GetCursorInfo
#define _GetCursorInfo
#endif
const char titleDrwIco[] = "DrawIcon Output";
const char titleMask[] = "Mask(AND image)";
const char titleXor[] = "XOR(color image)";
const char file[] = "Icon from file:";
const char res[] = "Icon from Resorce:";
const char cursor[] = "Current Cursor:";
const char cursormask[] = "Cursor Mask Bitmap";
const char cursorcolor[] = "Cursor Color Bitmap";
#ifdef _GetCursorInfo
typedef BOOL (__stdcall *GETCURSORINFO) (CURSORINFO *CursorInfo);
static GETCURSORINFO GetCursorInfo = NULL;
#endif
HFONT tf;
HINSTANCE hInst;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
hInst = hInstance;
#ifdef _GetCursorInfo
GetCursorInfo = (GETCURSORINFO)GetProcAddress(GetModuleHandleW(L"user32.dll"), "GetCursorInfo");
#endif
wc.lpszClassName = "IconTestClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
DbgPrint("RegisterClass failed (last error 0x%X)\n", GetLastError());
return(1);
}
hWnd = CreateWindow("IconTestClass",
"Icon Test",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
480,
480,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
DbgPrint("CreateWindow failed (last error 0x%X)\n", GetLastError());
return(1);
}
tf = CreateFontA(14,0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
ShowWindow(hWnd, nCmdShow);
SetTimer(hWnd, 1, 1000, NULL);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
HICON hIcon;
HGDIOBJ hOld;
HDC hMemDC;
CURSORINFO cursorinfo;
ICONINFO iconinfo;
BITMAP bmp;
RECT rc;
CHAR str[20];
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
SelectObject(hDC, tf);
SetBkMode(hDC, TRANSPARENT);
TextOut(hDC, 160, 10, file, strlen(file));
TextOut(hDC, 15, 85, titleDrwIco, strlen(titleDrwIco));
TextOut(hDC, 160, 85, titleMask, strlen(titleMask));
TextOut(hDC, 300, 85, titleXor, strlen(titleXor));
hIcon = LoadImage(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE);
DrawIcon(hDC,50,50,hIcon);
hMemDC = CreateCompatibleDC(hDC);
GetIconInfo(hIcon, &iconinfo);
DestroyIcon(hIcon);
hOld = SelectObject(hMemDC, iconinfo.hbmMask);
BitBlt(hDC, 200, 50, 32, 32, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, iconinfo.hbmColor);
BitBlt(hDC, 350, 50, 32, 32, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
TextOut(hDC, 145, 150, res, strlen(res));
TextOut(hDC, 15, 225, titleDrwIco, strlen(titleDrwIco));
TextOut(hDC, 160, 225, titleMask, strlen(titleMask));
TextOut(hDC, 300, 225, titleXor, strlen(titleXor));
hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
DrawIcon(hDC,50,190,hIcon);
GetIconInfo(hIcon, &iconinfo);
DestroyIcon(hIcon);
SelectObject(hMemDC, iconinfo.hbmMask);
BitBlt(hDC, 200, 190, 32, 32, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, iconinfo.hbmColor);
BitBlt(hDC, 350, 190, 32, 32, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
cursorinfo.cbSize = sizeof(CURSORINFO);
if(GetCursorInfo(&cursorinfo))
{
if(cursorinfo.hCursor && cursorinfo.flags)
{
TextOut(hDC, 160, 290, cursor, strlen(cursor));
DrawIcon(hDC, 50, 330, cursorinfo.hCursor);
GetIconInfo(cursorinfo.hCursor, &iconinfo);
TextOut(hDC, 15, 365, titleDrwIco, strlen(titleDrwIco));
sprintf(str, "Hotspot: %ld; %ld", iconinfo.xHotspot, iconinfo.yHotspot);
TextOut(hDC, 15, 380, str, strlen(str));
if(iconinfo.hbmMask)
{
GetObjectW(iconinfo.hbmMask, sizeof(BITMAP), &bmp);
SelectObject(hMemDC, iconinfo.hbmMask);
BitBlt(hDC, 200, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmMask);
TextOut(hDC, 160, 365 - 32 + bmp.bmHeight, cursormask, strlen(cursormask));
sprintf(str, "%dBPP", bmp.bmBitsPixel);
TextOut(hDC, 160, 380 - 32 + bmp.bmHeight, str, strlen(str));
}
if(iconinfo.hbmColor)
{
GetObjectW(iconinfo.hbmColor, sizeof(BITMAP), &bmp);
SelectObject(hMemDC, iconinfo.hbmColor);
BitBlt(hDC, 350, 330, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteObject(iconinfo.hbmColor);
TextOut(hDC, 300, 365 - 32 + bmp.bmHeight, cursorcolor, strlen(cursorcolor));
sprintf(str, "%dBPP", bmp.bmBitsPixel);
TextOut(hDC, 300, 380 - 32 + bmp.bmHeight, str, strlen(str));
}
}
}
SelectObject(hMemDC, hOld);
DeleteObject(hMemDC);
EndPaint(hWnd, &ps);
break;
case WM_TIMER:
rc.left = 0;
rc.top = 330;
rc.right = 480;
rc.bottom = 480;
InvalidateRect(hWnd, &rc, TRUE);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View file

@ -0,0 +1,5 @@
#include <defines.h>
#include <reactos/resource.h>
#include "resource.h"
IDI_ICON ICON DISCARDABLE "icon.ico"

View file

@ -0,0 +1,21 @@
PATH_TO_TOP = ../../../reactos
TARGET_NORC = no
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = icontest
TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1 @@
#define IDI_ICON 101

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,476 @@
#include <iostream>
#include <list>
#include <string>
#include <sstream>
extern "C" {
typedef unsigned short u_short;
#include <stdio.h>
#include <windows.h>
#include <winsock2.h>
#include <ddk/tdi.h>
#include <ddk/tdikrnl.h>
#include <ddk/tdiinfo.h>
#include <ddk/ndis.h>
#include <titypes.h>
#include <ip.h>
#include <tcp.h>
#include <receive.h>
#include <lan.h>
#include <routines.h>
};
/* Undis */
extern "C" VOID ExpInitLookasideLists();
std::list<std::string> output_packets;
DWORD DebugTraceLevel = 0x7fffffff;
PVOID GlobalBufferPool, GlobalPacketPool;
#define MAX_DG_SIZE 16384
char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb };
char hdr[14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00 };
#define STRINGIFY(x) #x
void display_row( char *data, int off, int len ) {
int i;
printf( "%08x:", off );
for( i = off; i < len && i < off + 16; i++ ) {
printf( " %02x", data[i] & 0xff );
}
printf( " -- " );
for( i = off; i < len && i < off + 16; i++ ) {
printf( "%c", (data[i] >= ' ') ? data[i] : '.' );
}
printf( "\n" );
}
void connect_complete( void *context, NTSTATUS status, unsigned long count ) {
printf( "Connection: status %x\n", status );
}
void receive_complete( void *context, NTSTATUS status, unsigned long count ) {
printf( "Receive: status %s (bytes %d)\n", status, count );
if( !status && count ) {
for( int off = 0; off < count; off += 16 ) {
display_row( (char *)context, off, count );
}
printf( "\n" );
}
}
class SocketObject {
public:
virtual ~SocketObject() { }
virtual int send( char *buf, int len, int *bytes,
struct sockaddr_in *si ) = 0;
virtual int recv( char *buf, int len, int *bytes,
struct sockaddr_in *si ) = 0;
};
UINT TdiAddressSizeFromType( UINT AddressType ) {
switch( AddressType ) {
case TDI_ADDRESS_TYPE_IP:
return sizeof(TA_IP_ADDRESS);
default:
KeBugCheck( 0 );
}
return 0;
}
NTSTATUS TdiBuildNullConnectionInfoInPlace
( PTDI_CONNECTION_INFORMATION ConnInfo,
ULONG Type )
/*
* FUNCTION: Builds a NULL TDI connection information structure
* ARGUMENTS:
* ConnectionInfo = Address of buffer to place connection information
* Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
* RETURNS:
* Status of operation
*/
{
ULONG TdiAddressSize;
TdiAddressSize = TdiAddressSizeFromType(Type);
RtlZeroMemory(ConnInfo,
sizeof(TDI_CONNECTION_INFORMATION) +
TdiAddressSize);
ConnInfo->OptionsLength = sizeof(ULONG);
ConnInfo->RemoteAddressLength = 0;
ConnInfo->RemoteAddress = NULL;
return STATUS_SUCCESS;
}
NTSTATUS TdiBuildNullConnectionInfo
( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
ULONG Type )
/*
* FUNCTION: Builds a NULL TDI connection information structure
* ARGUMENTS:
* ConnectionInfo = Address of buffer pointer to allocate connection
* information in
* Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
* RETURNS:
* Status of operation
*/
{
PTDI_CONNECTION_INFORMATION ConnInfo;
ULONG TdiAddressSize;
NTSTATUS Status;
TdiAddressSize = TdiAddressSizeFromType(Type);
ConnInfo = (PTDI_CONNECTION_INFORMATION)
ExAllocatePool(NonPagedPool,
sizeof(TDI_CONNECTION_INFORMATION) +
TdiAddressSize);
if (!ConnInfo)
return STATUS_INSUFFICIENT_RESOURCES;
Status = TdiBuildNullConnectionInfoInPlace( ConnInfo, Type );
if (!NT_SUCCESS(Status))
ExFreePool( ConnInfo );
else
*ConnectionInfo = ConnInfo;
ConnInfo->RemoteAddress = (PTA_ADDRESS)&ConnInfo[1];
ConnInfo->RemoteAddressLength = TdiAddressSize;
return Status;
}
UINT TaLengthOfTransportAddress( PTRANSPORT_ADDRESS Addr ) {
UINT AddrLen = 2 * sizeof( ULONG ) + Addr->Address[0].AddressLength;
printf("AddrLen %x\n", AddrLen);
return AddrLen;
}
NTSTATUS
TdiBuildConnectionInfoInPlace
( PTDI_CONNECTION_INFORMATION ConnectionInfo,
PTA_ADDRESS Address ) {
NTSTATUS Status = STATUS_SUCCESS;
RtlCopyMemory( ConnectionInfo->RemoteAddress,
Address,
ConnectionInfo->RemoteAddressLength );
return Status;
}
NTSTATUS
TdiBuildConnectionInfo
( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
PTA_ADDRESS Address ) {
NTSTATUS Status = TdiBuildNullConnectionInfo( ConnectionInfo,
Address->AddressType );
if( NT_SUCCESS(Status) )
TdiBuildConnectionInfoInPlace( *ConnectionInfo, Address );
return Status;
}
class TCPSocketObject : public SocketObject {
public:
TCPSocketObject( std::string host, int port, NTSTATUS *status ) {
TA_IP_ADDRESS ConnectTo;
PTDI_CONNECTION_INFORMATION ConnInfo;
ConnectTo.TAAddressCount = 1;
ConnectTo.Address[0].AddressLength = sizeof(TDI_ADDRESS_IP);
ConnectTo.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
ConnectTo.Address[0].Address[0].sin_port = htons(port);
ConnectTo.Address[0].Address[0].in_addr = 0x6a020a0a;
TdiBuildConnectionInfo( &ConnInfo, (PTA_ADDRESS)&ConnectTo );
Connection = TCPAllocateConnectionEndpoint( NULL );
*status = TCPSocket( Connection,
AF_INET,
SOCK_STREAM, IPPROTO_TCP );
if( !*status )
*status = TCPConnect( Connection,
ConnInfo,
NULL,
connect_complete,
NULL );
}
~TCPSocketObject() {
TCPClose( Connection );
if( Connection ) TCPFreeConnectionEndpoint( Connection );
}
int send( char *buf, int len, int *bytes, struct sockaddr_in *si ) {
NTSTATUS Status = STATUS_UNSUCCESSFUL;
if( Connection )
Status = TCPSendData( Connection,
buf,
len,
(PULONG)bytes,
0 );
return Status;
}
int recv( char *buf, int len, int *bytes, struct sockaddr_in *si ) {
NTSTATUS Status = STATUS_UNSUCCESSFUL;
if( Connection )
Status = TCPSendData( Connection,
buf,
len,
(PULONG)bytes,
0 );
return Status;
}
private:
PCONNECTION_ENDPOINT Connection;
};
VOID SendPacket( PVOID Context,
PNDIS_PACKET NdisPacket,
UINT Offset,
PVOID LinkAddress,
USHORT Type ) {
PCHAR DataOut;
PUCHAR Addr = (PUCHAR)LinkAddress;
UINT Size;
std::string output_packet;
printf( "Sending packet: %02x:%02x:%02x:%02x:%02x:%02x\n",
Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5] );
GetDataPtr( NdisPacket, Offset, &DataOut, &Size );
for( int off = 0; off < Size; off += 16 ) {
display_row( DataOut, off, Size );
}
printf( "\n" );
output_packet += std::string( hwaddr, sizeof(hwaddr) );
output_packet += std::string( (char *)LinkAddress, sizeof(hwaddr) );
output_packet += (char)(Type >> 8);
output_packet += (char)Type;
output_packet += std::string( DataOut + Offset, Size - Offset );
output_packets.push_back( output_packet );
}
#if 0
UINT CopyBufferToBufferChain
( PNDIS_BUFFER DstBuffer, UINT DstOffset, PCHAR SrcData, UINT Length ) {
assert( 0 );
}
#endif
int main( int argc, char **argv ) {
int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
int bytes, adapter_id, mtu, speed;
char datagram[MAX_DG_SIZE];
struct fd_set readf;
struct timeval tv;
struct sockaddr_in addr_from = { AF_INET }, addr_to;
std::string word, cmdin, host;
std::list<std::string>::iterator i;
WSADATA wsadata;
NTSTATUS Status;
UNICODE_STRING RegistryUnicodePath;
PCONNECTION_ENDPOINT Connection;
PIP_INTERFACE Interface;
IP_PACKET IPPacket;
LLIP_BIND_INFO BindInfo;
SocketObject *S = NULL;
RtlInitUnicodeString
( &RegistryUnicodePath,
L"\\SYSTEM\\CurrentControlSet\\Services"
L"\\Tcpip" );
ExpInitLookasideLists();
WSAStartup( 0x101, &wsadata );
if( argc > 1 ) port = atoi(argv[1]);
IPStartup( &RegistryUnicodePath );
BindInfo.Context = NULL;
BindInfo.HeaderSize = sizeof(ETH_HEADER);
BindInfo.MTU = 1500; /* MTU for ethernet */
BindInfo.Address = (PUCHAR)hwaddr;
BindInfo.AddressLength = sizeof(hwaddr);
BindInfo.Transmit = SendPacket;
IPCreateInterface( &BindInfo );
asock = socket( AF_INET, SOCK_DGRAM, 0 );
addr_from.sin_port = htons( port );
if( bind( asock, (struct sockaddr *)&addr_from, sizeof( addr_from ) ) ) {
printf( "Bind error\n" );
return 0;
}
while( true ) {
FD_ZERO( &readf );
FD_SET( asock, &readf );
tv.tv_sec = 0;
tv.tv_usec = 10000;
selret = select( asock + 1, &readf, NULL, NULL, &tv );
if( FD_ISSET( asock, &readf ) ) {
fromsize = sizeof( addr_from );
dgrecv = recvfrom( asock, datagram, sizeof(datagram), 0,
(struct sockaddr *)&addr_from, &fromsize );
if( datagram[0] == 'C' && datagram[1] == 'M' &&
datagram[2] == 'D' && datagram[3] == ' ' ) {
int theport, bytes, recvret, off, bytin;
struct sockaddr_in nam;
std::string faddr, word;
std::istringstream
cmdin( std::string( datagram + 4, dgrecv - 4 ) );
cmdin >> word;
/* UDP Section */
if( word == "udpsocket" ) {
/* TCP Section */
} else if( word == "tcpsocket" ) {
cmdin >> host >> port;
S = new TCPSocketObject( host, port, &Status );
fprintf( stderr, "Socket: Result %x\n", Status );
} else if( word == "close" ) {
TCPClose( Connection );
TCPFreeConnectionEndpoint( Connection );
} else if( word == "type" ) {
std::string therest = &cmdin.str()[word.size()];
char* p = &therest[0];
p += strspn ( p, " \t" );
char* src = p;
char* dst = p;
while ( *src )
{
char c = *src++;
if ( c == '\r' || c == '\n' ) break;
if ( c == '\\' )
{
c = *src++;
switch ( c )
{
case 'b': c = '\b'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'v': c = '\v'; break;
}
}
*dst++ = c;
}
*dst = '\0';
if( S )
err = S->send( p, strlen(p), &bytes, NULL );
if( err > 0 ) { bytin = err; err = 0; }
if( err )
fprintf ( stderr, "OskitTCPConnect: error %d\n",
err );
else {
printf ( "wrote %d bytes\n", bytin );
}
} else if( word == "send" ) {
off = 0;
while( cmdin >> word ) {
datagram[off++] =
atoi( (std::string("0x") + word).c_str() );
}
if( (err = S->send( datagram, off, &bytin, NULL )) != 0 ) {
fprintf( stderr, "OskitTCPConnect: error %d\n", err );
} else {
printf( "wrote %d bytes\n", bytin );
}
} else if( word == "recv" ) {
cmdin >> bytes;
if( (err = S->recv( datagram,
sizeof(datagram),
&bytes,
NULL )) != 0 ) {
fprintf( stderr, "OskitTCPRecv: error %d\n", err );
}
/* Misc section */
} else if( word == "end" ) {
return 0;
}
} else if( dgrecv > 14 ) {
addr_to = addr_from;
if( datagram[12] == 8 && datagram[13] == 6 ) {
/* Answer arp query */
char laddr[4];
/* Mark patch as to the previous sender */
memcpy( datagram + 32, datagram + 6, 6 );
memcpy( datagram, datagram + 6, 6 );
/* Mark packet as from us */
memcpy( datagram + 22, hwaddr, 6 );
memcpy( datagram + 6, hwaddr, 6 );
/* Swap inet addresses */
memcpy( laddr, datagram + 28, 4 );
memcpy( datagram + 28, datagram + 38, 4 );
memcpy( datagram + 38, laddr, 4 );
/* Set reply opcode */
datagram[21] = 2;
err = sendto( asock, datagram, dgrecv, 0,
(struct sockaddr *)&addr_to,
sizeof(addr_to) );
if( err != 0 )
printf( "sendto: %d\n", err );
} else {
memcpy( hdr, datagram + 6, 6 );
memcpy( hdr + 6, datagram, 6 );
memcpy( hdr + 12, datagram + 12, 2 );
IPPacket.Header = datagram;
IPPacket.Data = datagram + 14;
IPPacket.TotalSize = dgrecv;
IPReceive( Interface, &IPPacket );
}
}
}
IPTimeout(NULL, NULL, NULL, NULL);
for( i = output_packets.begin(); i != output_packets.end(); i++ ) {
err = sendto( asock, i->c_str(), i->size(), 0,
(struct sockaddr *)&addr_to, sizeof(addr_to) );
fprintf( stderr, "** SENDING PACKET %d bytes **\n", i->size() );
if( err != 0 )
printf( "sendto: %d\n", err );
}
output_packets.clear();
}
}

View file

@ -0,0 +1,26 @@
#
# $Id: makefile,v 1.1 2004/10/21 04:58:58 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = iptest
TARGET_SDKLIBS = ws2_32.a ip.a oskittcp.a undis.a ntdll.a
TARGET_OBJECTS = iptest.o
TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/drivers/lib/oskittcp/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/drivers/net/tcpip/include -g
TARGET_GCCLIBS = stdc++
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,231 @@
/*
* isotest - display cdrom information
*/
#include <windows.h>
//#include <winioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <wchar.h>
void HexDump(char *buffer, ULONG size)
{
ULONG offset = 0;
unsigned char *ptr;
while (offset < (size & ~15))
{
ptr = (unsigned char*)((ULONG)buffer + offset);
printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
offset,
ptr[0],
ptr[1],
ptr[2],
ptr[3],
ptr[4],
ptr[5],
ptr[6],
ptr[7],
ptr[8],
ptr[9],
ptr[10],
ptr[11],
ptr[12],
ptr[13],
ptr[14],
ptr[15]);
printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
isprint(ptr[0])?ptr[0]:'.',
isprint(ptr[1])?ptr[1]:'.',
isprint(ptr[2])?ptr[2]:'.',
isprint(ptr[3])?ptr[3]:'.',
isprint(ptr[4])?ptr[4]:'.',
isprint(ptr[5])?ptr[5]:'.',
isprint(ptr[6])?ptr[6]:'.',
isprint(ptr[7])?ptr[7]:'.',
isprint(ptr[8])?ptr[8]:'.',
isprint(ptr[9])?ptr[9]:'.',
isprint(ptr[10])?ptr[10]:'.',
isprint(ptr[11])?ptr[11]:'.',
isprint(ptr[12])?ptr[12]:'.',
isprint(ptr[13])?ptr[13]:'.',
isprint(ptr[14])?ptr[14]:'.',
isprint(ptr[15])?ptr[15]:'.');
offset += 16;
}
ptr = (unsigned char*)((ULONG)buffer + offset);
if (offset < size)
{
printf("%08lx ", offset);
while (offset < size)
{
printf(" %02hx", *ptr);
offset++;
ptr++;
}
}
printf("\n\n");
}
#ifndef EVENT_ALL_ACCESS
#define EVENT_ALL_ACCESS (0x1f0003L)
#endif
BOOL
ReadBlock(HANDLE FileHandle,
PVOID Buffer,
PLARGE_INTEGER Offset,
ULONG Length,
PULONG BytesRead)
{
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE EventHandle;
InitializeObjectAttributes(&ObjectAttributes,
NULL, 0, NULL, NULL);
Status = NtCreateEvent(&EventHandle,
EVENT_ALL_ACCESS,
&ObjectAttributes,
TRUE,
FALSE);
if (!NT_SUCCESS(Status))
{
printf("NtCreateEvent() failed\n");
return(FALSE);
}
Status = NtReadFile(FileHandle,
EventHandle,
NULL,
NULL,
&IoStatusBlock,
Buffer,
Length,
Offset,
NULL);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(EventHandle, FALSE, NULL);
Status = IoStatusBlock.Status;
}
NtClose(EventHandle);
if (Status != STATUS_PENDING && BytesRead != NULL)
{
*BytesRead = IoStatusBlock.Information;
}
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
printf("ReadBlock() failed (Status: %lx)\n", Status);
return(FALSE);
}
return(TRUE);
}
int main (int argc, char *argv[])
{
HANDLE hDisk;
DWORD dwRead;
char *Buffer;
CHAR Filename[80];
LARGE_INTEGER FilePosition;
if (argc != 2)
{
printf("Usage: isotest [Drive:]\n");
return 0;
}
strcpy(Filename, "\\\\.\\");
strcat(Filename, argv[1]);
hDisk = CreateFile(Filename,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDisk == INVALID_HANDLE_VALUE)
{
printf("CreateFile(): Invalid disk handle!\n");
return 0;
}
Buffer = (char*)malloc(2048);
if (Buffer == NULL)
{
CloseHandle(hDisk);
printf("Out of memory!\n");
return 0;
}
memset(Buffer, 0, 2048);
FilePosition.QuadPart = 16 * 2048;
#if 0
SetLastError(NO_ERROR);
SetFilePointer(hDisk,
FilePosition.u.LowPart,
&FilePosition.u.HighPart,
FILE_BEGIN);
if (GetLastError() != NO_ERROR)
{
CloseHandle(hDisk);
free(Buffer);
printf("SetFilePointer() failed!\n");
return 0;
}
if (ReadFile(hDisk,
Buffer,
2048,
&dwRead,
NULL) == FALSE)
{
CloseHandle(hDisk);
free(Buffer);
printf("ReadFile() failed!\n");
return 0;
}
#endif
if (ReadBlock(hDisk,
Buffer,
&FilePosition,
2048,
&dwRead) == FALSE)
{
CloseHandle(hDisk);
free(Buffer);
#if 0
printf("ReadBlock() failed!\n");
#endif
return 0;
}
HexDump(Buffer, 128);
CloseHandle(hDisk);
free(Buffer);
return 0;
}
/* EOF */

View file

@ -0,0 +1,25 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:58 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = isotest
#TARGET_CFLAGS = -fnative_struct
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,218 @@
#include <windows.h>
#include <net/lan.h>
#include <iostream>
#include <string>
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
void display_row( char *data, int off, int len ) {
int i;
printf( "%08x:", off );
for( i = off; i < len && i < off + 16; i++ ) {
printf( " %02x", data[i] & 0xff );
}
for( ; i < off + 16; i++ )
printf(" ");
printf( " -- " );
for( i = off; i < len && i < off + 16; i++ ) {
printf( "%c", (data[i] >= ' ' && data[i] <= '~') ? data[i] : '.' );
}
printf( "\n" );
}
void display_buffer( char *Packet, int ReadLen ) {
UINT PktLen;
for( PktLen = 0; PktLen < ReadLen; PktLen += 16 )
display_row( Packet, PktLen, ReadLen );
}
int byte_till_end( char *Packet, int PktLen ) {
int byte;
std::string word;
cin >> word;
while( word != "end" ) {
byte = strtoul( (string("0x") + word).c_str(), 0, 0 );
fprintf( stderr, "Byte[%d]: %x\n", PktLen, byte & 0xff );
Packet[PktLen++] = byte;
cin >> word;
}
return PktLen;
}
/* Ethernet types. We swap constants so we can compare values at runtime
without swapping them there */
#define ETYPE_IPv4 WH2N(0x0800)
#define ETYPE_IPv6 WH2N(0x86DD)
#define ETYPE_ARP WH2N(0x0806)
extern "C"
NTSTATUS STDCALL NtCreateFile(
PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
PLARGE_INTEGER AllocationSize,
ULONG FileAttributes,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength);
int main( int argc, char **argv ) {
string word;
HANDLE LanFile;
OBJECT_ATTRIBUTES Attributes;
UNICODE_STRING LanDevice;
IO_STATUS_BLOCK Iosb;
HANDLE Event;
PFILE_FULL_EA_INFORMATION EaBuffer;
NTSTATUS Status;
DWORD On = 1, PktLen;
CHAR Packet[1600];
PLAN_PACKET_HEADER Hdr = (PLAN_PACKET_HEADER)Packet;
PLAN_ADDRESS Addr = (PLAN_ADDRESS)Packet;
USHORT TypesToListen[] = { ETYPE_IPv4, ETYPE_IPv6, ETYPE_ARP };
UINT EaLength = LAN_EA_INFO_SIZE(sizeof(TypesToListen)/sizeof(USHORT));
Status = NtCreateEvent(&Event,
EVENT_ALL_ACCESS,
NULL,
0,
0 );
RtlInitUnicodeString( &LanDevice, L"\\Device\\Lan" );
InitializeObjectAttributes( &Attributes,
&LanDevice,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );
EaBuffer = (PFILE_FULL_EA_INFORMATION)calloc( EaLength, 1 );
LAN_FILL_EA_INFO(EaBuffer,sizeof(TypesToListen)/sizeof(USHORT),
TypesToListen);
Status = ZwCreateFile( &LanFile,
SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE |
GENERIC_EXECUTE,
&Attributes,
&Iosb,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
EaBuffer,
EaLength );
if( !NT_SUCCESS(Status) ) {
cerr << "Could not open lan device " << Status << "\n";
return 1;
}
Status = DeviceIoControl( LanFile,
IOCTL_IF_BUFFERED_MODE,
&On,
sizeof(On),
0,
0,
&PktLen,
NULL );
if( !Status ) {
cerr << "Could not turn on buffered mode " << Status << "\n";
return 1;
}
while( cin >> word ) {
if( word == "end" ) {
NtClose( LanFile );
return 0;
} else if( word == "enum" ) {
Status = DeviceIoControl( LanFile,
IOCTL_IF_ENUM_ADAPTERS,
NULL,
0,
Packet,
sizeof(Packet),
&PktLen,
NULL );
cout << "EnumAdapters: " << Status << "\n";
if( Status )
display_buffer( Packet, PktLen );
} else if( word == "query" ) {
cin >> PktLen;
Status = DeviceIoControl( LanFile,
IOCTL_IF_ADAPTER_INFO,
&PktLen,
sizeof(PktLen),
Packet,
sizeof(Packet),
&PktLen,
NULL );
cout << "QueryAdapterInfo: " << Status << "\n";
if( Status )
display_buffer( Packet, PktLen );
} else if( word == "send" ) {
cin >> Hdr->Fixed.Adapter
>> Hdr->Fixed.AddressType
>> Hdr->Fixed.AddressLen
>> Hdr->Fixed.PacketType;
Hdr->Fixed.Mdl = NULL;
PktLen = byte_till_end( Packet, Hdr->Address - (PCHAR)Hdr );
Status = NtWriteFile( LanFile,
NULL,
NULL,
NULL,
&Iosb,
Packet,
PktLen,
NULL,
NULL );
cout << "NtWriteFile: " << Status << "\n";
} else if( word == "recv" ) {
ULONG ReadLen;
Status = NtReadFile( LanFile,
Event,
NULL,
NULL,
&Iosb,
Packet,
sizeof(Packet),
NULL,
NULL );
cout << "NtReadFile: " << Status << "\n";
if( Status == STATUS_PENDING ) {
LARGE_INTEGER Timeout = { 0 };
Status = NtWaitForSingleObject( Event, 1, &Timeout );
}
ReadLen = Iosb.Information;
if( Status == STATUS_SUCCESS ) {
cout << "Read " << ReadLen << " bytes\n";
display_buffer( Packet, ReadLen );
}
}
}
return 0;
}

View file

@ -0,0 +1,24 @@
#
# $Id: makefile,v 1.1 2004/10/21 04:58:58 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = lantest
TARGET_SDKLIBS = ws2_32.a ntdll.a
TARGET_OBJECTS = lantest.o -lstdc++
TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/include -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,166 @@
#include <windows.h>
#include <stdio.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = "ClipClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow("ClipClass",
"Line clipping test",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
static void
DrawLines(HDC hDC)
{
static struct
{
int fromx;
int fromy;
int tox;
int toy;
}
points[ ] =
{
{ 50, 99, 125, 99 },
{ 160, 99, 190, 99 },
{ 300, 99, 225, 99 },
{ 50, 100, 125, 100 },
{ 160, 100, 190, 100 },
{ 300, 100, 225, 100 },
{ 50, 125, 300, 125 },
{ 50, 149, 125, 149 },
{ 160, 149, 190, 149 },
{ 300, 149, 225, 149 },
{ 50, 150, 125, 150 },
{ 160, 150, 190, 150 },
{ 300, 150, 225, 150 },
{ 160, 249, 190, 249 },
{ 160, 250, 190, 250 },
{ 149, 50, 149, 125 },
{ 149, 160, 149, 190 },
{ 149, 300, 149, 225 },
{ 150, 50, 150, 125 },
{ 150, 160, 150, 190 },
{ 150, 300, 150, 225 },
{ 199, 50, 199, 125 },
{ 199, 160, 199, 190 },
{ 199, 300, 199, 225 },
{ 200, 50, 200, 125 },
{ 200, 160, 200, 190 },
{ 200, 300, 200, 225 },
{ 175, 50, 175, 300 },
{ 50, 55, 300, 290 },
{ 300, 295, 50, 60 },
{ 50, 290, 300, 55 },
{ 300, 60, 50, 295 },
{ 55, 50, 290, 300 },
{ 295, 300, 60, 50 },
{ 55, 300, 290, 50 },
{ 295, 50, 60, 300 }
};
int i;
for (i = 0; i < sizeof(points) / sizeof(points[0]); i++)
{
MoveToEx(hDC, points[i].fromx, points[i].fromy, NULL);
LineTo(hDC, points[i].tox, points[i].toy);
}
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT clr;
HRGN ClipRgn, ExcludeRgn;
RECT Rect;
switch(msg)
{
case WM_PAINT:
GetClientRect(hWnd, &clr);
ClipRgn = CreateRectRgnIndirect(&clr);
hDC = BeginPaint(hWnd, &ps);
Rect.left = 100;
Rect.top = 100;
Rect.right = 250;
Rect.bottom = 150;
FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
ExcludeRgn = CreateRectRgnIndirect(&Rect);
CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
DeleteObject(ExcludeRgn);
Rect.left = 150;
Rect.top = 150;
Rect.right = 200;
Rect.bottom = 250;
FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
SelectObject(hDC, CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0x00)));
DrawLines(hDC);
SelectObject(hDC, CreatePen(PS_SOLID, 0, RGB(0x00, 0x00, 0xFF)));
ExcludeRgn = CreateRectRgnIndirect(&Rect);
CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
DeleteObject(ExcludeRgn);
SelectClipRgn(hDC, ClipRgn);
DrawLines(hDC);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:58 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = lineclip
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,181 @@
#include <windows.h>
#include <stdio.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
const TCHAR* CLASS_NAME = _T("LineTestClass");
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = CLASS_NAME;
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow(CLASS_NAME,
_T("Line drawing test"),
WS_OVERLAPPEDWINDOW,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
#define red RGB(255,0,0)
#define grn RGB(0,255,0)
#define blu RGB(0,0,255)
#define blk RGB(0,0,0)
static void
DrawLines(HDC hDC)
{
static struct
{
int fromx;
int fromy;
int tox;
int toy;
COLORREF clr;
}
points[ ] =
{
{ 10, 10, 19, 10, red },
{ 20, 10, 20, 19, grn },
{ 20, 20, 11, 20, blu },
{ 10, 20, 10, 11, blk },
{ 12, 12, 15, 15, red },
{ 18, 12, 15, 15, grn },
{ 18, 18, 15, 15, blu },
{ 12, 18, 15, 15, blk },
{ 35, 10, 39, 14, red },
{ 40, 15, 36, 19, grn },
{ 35, 20, 31, 16, blu },
{ 30, 15, 34, 11, blk },
{ 2, 1, 5, 2, red },
{ 6, 2, 5, 5, grn },
{ 5, 6, 2, 5, blu },
{ 1, 5, 2, 2, blk },
{ 50, 1, 51, 1, red },
{ 50, 2, 52, 2, grn },
{ 50, 3, 53, 3, blu },
{ 50, 4, 54, 4, blk },
{ 50, 5, 55, 5, red },
{ 50, 6, 56, 6, grn },
{ 50, 7, 57, 7, blu },
{ 50, 8, 58, 8, blk },
{ 50, 9, 59, 9, red },
{ 50, 10, 60, 10, grn },
{ 50, 11, 61, 11, blu },
{ 50, 12, 62, 12, blk },
{ 50, 14, 62, 14, red },
{ 51, 15, 62, 15, grn },
{ 52, 16, 62, 16, blu },
{ 53, 17, 62, 17, blk },
{ 54, 18, 62, 18, red },
{ 55, 19, 62, 19, grn },
{ 56, 20, 62, 20, blu },
{ 57, 21, 62, 21, blk },
{ 58, 22, 62, 22, red },
{ 59, 23, 62, 23, grn },
{ 60, 24, 62, 24, blu },
{ 61, 25, 62, 25, blk },
};
int i;
for (i = 0; i < sizeof(points) / sizeof(points[0]); i++)
{
HPEN hpen, hpenold;
hpen = CreatePen ( PS_SOLID, 0, points[i].clr );
hpenold = (HPEN)SelectObject ( hDC, hpen );
MoveToEx ( hDC, points[i].fromx, points[i].fromy, NULL );
LineTo ( hDC, points[i].tox, points[i].toy );
SelectObject ( hDC, hpenold );
DeleteObject ( hpen );
}
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT clr;
HBRUSH hbr;
switch(msg)
{
case WM_PAINT:
GetClientRect(hWnd, &clr);
//ClipRgn = CreateRectRgnIndirect(&clr);
hDC = BeginPaint(hWnd, &ps);
//Rect.left = 100;
//Rect.top = 100;
//Rect.right = 250;
//Rect.bottom = 150;
//FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
//ExcludeRgn = CreateRectRgnIndirect(&Rect);
//CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
//DeleteObject(ExcludeRgn);
//Rect.left = 150;
//Rect.top = 150;
//Rect.right = 200;
//Rect.bottom = 250;
hbr = CreateSolidBrush(RGB(255, 255, 255));
FillRect ( hDC, &clr, hbr );
DeleteObject ( hbr );
DrawLines(hDC);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:59 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = linetest
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

205
rosapps/tests/lpc/conport.c Normal file
View file

@ -0,0 +1,205 @@
/* $Id: conport.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
*
* reactos/apps/lpc/conport.c
*
* To be run in a real WNT 4.0 system with
* "\SmApiPort" as argument. Do not try to
* connect to "\Windows\ApiPort" since that
* reboots immeditely.
*
* Use Russinovich' HandleEx to verify
* conport.exe owns two unnamed LPC ports:
* the one created by kernel32.dll connecting
* to csrss.exe, and one connected to here.
*
* 19990627 (Emanuele Aliberti)
* Initial implementation.
* 19990704 (EA)
* Dump object's attributes moved in dumpinfo.c.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define PROTO_LPC
#include <ddk/ntddk.h>
#include "dumpinfo.h"
#define LPC_CONNECT_FLAG1 0x00000001
#define LPC_CONNECT_FLAG2 0x00000010
#define LPC_CONNECT_FLAG3 0x00000100
#define LPC_CONNECT_FLAG4 0x00001000
#define LPC_CONNECT_FLAG5 0x00010000
NTSTATUS
(STDCALL * ConnectPort)(
OUT PHANDLE PortHandle,
IN PUNICODE_STRING PortName,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN DWORD Unknown3,
IN DWORD Unknown4,
IN DWORD Unknown5,
IN DWORD Unknown6,
IN ULONG Flags
);
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
(STDCALL * YieldExecution)(VOID);
#define BUF_SIZE 1024
#define MAXARG 1000000
VOID
TryConnectPort(char *port_name)
{
DWORD Status = 0;
HANDLE Port = 0;
int i;
UNICODE_STRING PortName;
OBJECT_ATTRIBUTES ObjectAttributes;
WORD Name [BUF_SIZE] = {0};
int dwx = 0;
char * port_name_save = port_name;
/*
* Convert the port's name to Unicode.
*/
for (
PortName.Length = 0;
( *port_name
&& (PortName.Length < BUF_SIZE)
);
)
{
Name[PortName.Length++] = (WORD) *port_name++;
}
Name[PortName.Length] = 0;
PortName.Length = PortName.Length * sizeof (WORD);
PortName.MaximumLength = PortName.Length + sizeof (WORD);
PortName.Buffer = (PWSTR) Name;
/*
* Prepare the port object attributes.
*/
ObjectAttributes.Length =
sizeof (OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory =
NULL;
ObjectAttributes.ObjectName =
NULL /*& PortName */;
ObjectAttributes.Attributes =
OBJ_CASE_INSENSITIVE;
ObjectAttributes.SecurityDescriptor =
NULL;
ObjectAttributes.SecurityQualityOfService =
NULL;
/*
* Try to issue a connection request.
*/
Port = 0;
Status = ConnectPort(
& Port, /* & PortHandle */
& PortName, /* & PortName */
& ObjectAttributes, /* & PortAttributes */
NULL, /* & SecurityQos */
NULL, /* & SectionInfo */
NULL, /* & MapInfo */
NULL, /* & MaxMessageSize */
LPC_CONNECT_FLAG5 /* & ConnectInfoLength */
);
if (Status == STATUS_SUCCESS)
{
DumpInfo(
Name,
Status,
"connected",
Port
);
/* Hot waiting */
for (dwx=0; dwx<MAXARG; ++dwx)
{
YieldExecution();
}
if (FALSE == CloseHandle(Port))
{
printf(
"Could not close the port handle %08X.\n",
Port
);
}
return;
}
printf(
"Connection to port \"%s\" failed (Status = %08X).\n",
port_name_save,
Status
);
}
main( int argc, char * argv[] )
{
HINSTANCE ntdll;
if (argc != 2)
{
printf("WNT LPC Port Connector\n");
printf("Usage: %s [port_name]\n",argv[0]);
exit(EXIT_FAILURE);
}
printf("LoadLibrary(NTDLL)\n");
ntdll = LoadLibrary("NTDLL");
if (ntdll == NULL)
{
printf("Could not load NTDLL\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtConnectPort)\n");
ConnectPort = (VOID*) GetProcAddress(
ntdll,
"NtConnectPort"
);
if (ConnectPort == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtConnectPort\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
QueryObject = (VOID*) GetProcAddress(
ntdll,
"NtQueryObject"
);
if (QueryObject == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtQueryObject\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
YieldExecution = (VOID*) GetProcAddress(
ntdll,
"NtYieldExecution"
);
if (YieldExecution == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtYieldExecution\n");
return EXIT_FAILURE;
}
printf("TryConnectPort(%s)\n",argv[1]);
TryConnectPort(argv[1]);
printf("Done\n");
return EXIT_SUCCESS;
}
/* EOF */

192
rosapps/tests/lpc/creport.c Normal file
View file

@ -0,0 +1,192 @@
/* $Id: creport.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
*
* reactos/apps/lpc/creport.c
*
* To be run in a real WNT 4.0 system to
* create an LPC named port.
*
* Use Russinovich' HandleEx to verify
* creport.exe owns the named LPC port
* you asked to create.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define PROTO_LPC
#include <ddk/ntddk.h>
#include "dumpinfo.h"
#define LPC_CONNECT_FLAG1 0x00000001
#define LPC_CONNECT_FLAG2 0x00000010
#define LPC_CONNECT_FLAG3 0x00000100
#define LPC_CONNECT_FLAG4 0x00001000
#define LPC_CONNECT_FLAG5 0x00010000
NTSTATUS
(STDCALL * CreatePort)(
/*OUT PHANDLE PortHandle,*/
PVOID Buffer,
IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
IN ACCESS_MASK DesiredAccess,
IN DWORD Unknown3,
IN ULONG Flags
);
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
(STDCALL * YieldExecution)(VOID);
#define BUF_SIZE 1024
#define MAXARG 5000000
VOID
TryCreatePort(char *port_name)
{
DWORD Status = 0;
HANDLE Port = 0;
int i;
UNICODE_STRING PortName;
OBJECT_ATTRIBUTES ObjectAttributes;
WORD Name [BUF_SIZE] = {0};
int dwx = 0;
char * port_name_save = port_name;
/*
* Convert the port's name to Unicode.
*/
for (
PortName.Length = 0;
( *port_name
&& (PortName.Length < BUF_SIZE)
);
)
{
Name[PortName.Length++] = (WORD) *port_name++;
}
Name[PortName.Length] = 0;
PortName.Length = PortName.Length * sizeof (WORD);
PortName.MaximumLength = PortName.Length + sizeof (WORD);
PortName.Buffer = (PWSTR) Name;
/*
* Prepare the port object attributes.
*/
ObjectAttributes.Length =
sizeof (OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory =
NULL;
ObjectAttributes.ObjectName =
& PortName;
ObjectAttributes.Attributes =
0; //OBJ_CASE_INSENSITIVE --> STATUS_INVALID_PARAMETER ==> case sensitive!;
ObjectAttributes.SecurityDescriptor =
NULL;
ObjectAttributes.SecurityQualityOfService =
NULL;
/*
* Try to issue a connection request.
*/
Port = 0;
Status = CreatePort(
& Port,
& ObjectAttributes,
0, /* ACCESS_MASK? */
0, /* Unknown3 */
LPC_CONNECT_FLAG5
);
if (Status == STATUS_SUCCESS)
{
DumpInfo(
Name,
Status,
"created",
Port
);
/* Hot waiting */
for (dwx=0; dwx<MAXARG; ++dwx)
{
YieldExecution();
}
if (FALSE == CloseHandle(Port))
{
printf(
"Could not close the port handle %08X.\n",
Port
);
}
return;
}
printf(
"Creating port \"%s\" failed (Status = %08X).\n",
port_name_save,
Status
);
}
main( int argc, char * argv[] )
{
HINSTANCE ntdll;
if (argc != 2)
{
printf("WNT LPC Port Creator\n");
printf("Usage: %s [port_name]\n",argv[0]);
exit(EXIT_FAILURE);
}
printf("LoadLibrary(NTDLL)\n");
ntdll = LoadLibrary("NTDLL");
if (ntdll == NULL)
{
printf("Could not load NTDLL\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtCreatePort)\n");
CreatePort = (VOID*) GetProcAddress(
ntdll,
"NtCreatePort"
);
if (CreatePort == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtCreatePort\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
QueryObject = (VOID*) GetProcAddress(
ntdll,
"NtQueryObject"
);
if (QueryObject == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtQueryObject\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
YieldExecution = (VOID*) GetProcAddress(
ntdll,
"NtYieldExecution"
);
if (YieldExecution == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtYieldExecution\n");
return EXIT_FAILURE;
}
printf("TryCreatePort(%s)\n",argv[1]);
TryCreatePort(argv[1]);
printf("Done\n");
return EXIT_SUCCESS;
}
/* EOF */

View file

@ -0,0 +1,239 @@
/* $Id: dumpinfo.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
*
* reactos/apps/lpc/dumpinfo.c
*
* ReactOS Operating System
*
* Dump a kernel object's attributes by its handle.
*
* 19990627 (Emanuele Aliberti)
* Initial implementation.
* 19990704 (EA)
* Added code to find the basic information buffer size
* for the LPC port object.
* 19990710 (EA)
*
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ddk/ntddk.h>
#define BUF_SIZE 1024
#define MAX_BASIC_INFO_SIZE 512
extern
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
extern
NTSTATUS
(STDCALL * QueryInformationPort)(
IN HANDLE PortHandle,
IN CINT PortInformationClass, /* guess */
OUT PVOID PortInformation, /* guess */
IN ULONG PortInformationLength, /* guess */
OUT PULONG ReturnLength /* guess */
);
/*
static
VOID
DumpBuffer(
char *Name,
BYTE *buffer,
ULONG size
)
{
register ULONG i = 0;
printf("%s [%d] = ",Name,size);
for ( i = 0;
i != size;
++i
)
{
printf("%02X",buffer[i]);
}
printf("\n");
}
*/
VOID
DumpInfo (
LPCWSTR Name,
NTSTATUS Status,
LPCWSTR Comment,
HANDLE Port
)
{
BYTE ObjectInformation [BUF_SIZE] = {0};
ULONG ResultLength;
wprintf(
L"Port \"%s\" %s:\n",
Name,
Comment
);
printf("\tStatus = %08X\n",Status);
printf("\tPort = %08X\n\n",Port);
/*
* Query object information.
*/
printf("Basic Information:\n");
Status = QueryObject(
Port,
ObjectBasicInformation,
ObjectInformation,
sizeof (LPC_PORT_BASIC_INFORMATION),
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
PLPC_PORT_BASIC_INFORMATION i;
i = (PLPC_PORT_BASIC_INFORMATION) ObjectInformation;
printf( "\tUnknown01 = 0x%08X\n", i->Unknown0 );
printf( "\tUnknown02 = 0x%08X\n", i->Unknown1 );
printf( "\tUnknown03 = 0x%08X\n", i->Unknown2 );
printf( "\tUnknown04 = 0x%08X\n", i->Unknown3 );
printf( "\tUnknown05 = 0x%08X\n", i->Unknown4 );
printf( "\tUnknown06 = 0x%08X\n", i->Unknown5 );
printf( "\tUnknown07 = 0x%08X\n", i->Unknown6 );
printf( "\tUnknown08 = 0x%08X\n", i->Unknown7 );
printf( "\tUnknown09 = 0x%08X\n", i->Unknown8 );
printf( "\tUnknown10 = 0x%08X\n", i->Unknown9 );
printf( "\tUnknown11 = 0x%08X\n", i->Unknown10 );
printf( "\tUnknown12 = 0x%08X\n", i->Unknown11 );
printf( "\tUnknown13 = 0x%08X\n", i->Unknown12 );
printf( "\tUnknown14 = 0x%08X\n", i->Unknown13 );
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Type Information:\n");
Status = QueryObject(
Port,
ObjectTypeInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_TYPE_INFORMATION * i;
i = (OBJECT_TYPE_INFORMATION *) ObjectInformation;
wprintf(
L"\tName: \"%s\"\n",
(i->Name.Length ? i->Name.Buffer : L"")
);
/*
FIXME: why this always raise an access violation exception?
wprintf(
L"\tType: \"%s\"\n",
(i->Type.Length ? i->Type.Buffer : L"")
);
/**/
printf(
"\tTotal Handles: %d\n",
i->TotalHandles
);
printf(
"\tReference Count: %d\n",
i->ReferenceCount
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Name Information:\n");
Status = QueryObject(
Port,
ObjectNameInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_NAME_INFORMATION * i;
i = (OBJECT_NAME_INFORMATION *) ObjectInformation;
wprintf(
L"\tName: \"%s\"\n",
(i->Name.Length ? i->Name.Buffer : L"")
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Data Information:\n");
Status = QueryObject(
Port,
ObjectDataInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_DATA_INFORMATION * i;
i = (OBJECT_DATA_INFORMATION *) ObjectInformation;
printf(
"\tInherit Handle: %s\n",
(i->bInheritHandle ? "TRUE" : "FALSE")
);
printf(
"\tProtect from Close: %s\n",
(i->bProtectFromClose ? "TRUE" : "FALSE")
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
//---
printf("Port Information:\n");
/* Status = QueryInformationPort(
Port,
1, /* info class * /
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
DWORD * i = ObjectInformation;
int j = 0;
while (j < ResultLength / sizeof (DWORD))
{
printf("\t%08X\n",i[j]);
++j;
}
}
else
{
printf("\tStatus = %08X\n",Status);
}
*/
}
/* EOF */

View file

@ -0,0 +1,8 @@
VOID
DumpInfo (
LPCWSTR Name,
NTSTATUS Status,
LPCWSTR Comment,
HANDLE Port
);

View file

@ -0,0 +1,92 @@
/* $Id: lpcclt.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
*
* DESCRIPTION: Simple LPC Client
* PROGRAMMER: David Welch
*/
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lpctest.h"
const char * MyName = "LPC-CLI";
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int main(int argc, char* argv[])
{
UNICODE_STRING PortName = ROS_STRING_INITIALIZER(TEST_PORT_NAME_U);
NTSTATUS Status;
HANDLE PortHandle;
LPC_MAX_MESSAGE Request;
ULONG ConnectInfo;
ULONG ConnectInfoLength = 0;
SECURITY_QUALITY_OF_SERVICE Sqos;
printf("%s: Lpc test client\n", MyName);
printf("%s: Connecting to port \"%s\"...\n", MyName, TEST_PORT_NAME);
ConnectInfoLength = 0;
ZeroMemory (& Sqos, sizeof Sqos);
Status = NtConnectPort(&PortHandle,
&PortName,
& Sqos,
0,
0,
0,
NULL,
&ConnectInfoLength);
if (!NT_SUCCESS(Status))
{
printf("%s: NtConnectPort() failed with status = 0x%08X.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Connected to \"%s\" with anonymous port 0x%x.\n", MyName, TEST_PORT_NAME, PortHandle);
ZeroMemory(& Request, sizeof Request);
strcpy(Request.Data, GetCommandLineA());
Request.Header.DataSize = strlen(Request.Data);
Request.Header.MessageSize = sizeof(LPC_MESSAGE) +
Request.Header.DataSize;
printf("%s: Sending to port 0x%x message \"%s\"...\n",
MyName,
PortHandle,
(char *) Request.Data);
Status = NtRequestPort(PortHandle,
&Request.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
MyName,
PortHandle,
Status);
return EXIT_FAILURE;
}
printf("%s: Sending datagram to port 0x%x succeeded.\n", MyName, PortHandle);
Sleep(2000);
printf("%s: Disconnecting...", MyName);
NtClose (PortHandle);
return EXIT_SUCCESS;
}

139
rosapps/tests/lpc/lpcsrv.c Normal file
View file

@ -0,0 +1,139 @@
/* $Id: lpcsrv.c,v 1.1 2004/10/21 04:58:59 sedwards Exp $
*
* DESCRIPTION: Simple LPC Server
* PROGRAMMER: David Welch
*/
#include <ddk/ntddk.h>
#include <rosrtl/string.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lpctest.h"
static const char * MyName = "LPC-SRV";
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int main(int argc, char* argv[])
{
UNICODE_STRING PortName = ROS_STRING_INITIALIZER(TEST_PORT_NAME_U);
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE NamedPortHandle;
HANDLE PortHandle;
LPC_MAX_MESSAGE ConnectMsg;
printf("%s: Lpc test server\n", MyName);
InitializeObjectAttributes(&ObjectAttributes,
&PortName,
0,
NULL,
NULL);
printf("%s: Creating port \"%s\"...\n", MyName, TEST_PORT_NAME);
Status = NtCreatePort(&NamedPortHandle,
&ObjectAttributes,
0,
0,
0);
if (!NT_SUCCESS(Status))
{
printf("%s: NtCreatePort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Port \"%s\" created (0x%x).\n\n", MyName, TEST_PORT_NAME, NamedPortHandle);
for (;;)
{
printf("%s: Listening for connections requests on port 0x%x...\n", MyName, NamedPortHandle);
Status = NtListenPort(NamedPortHandle,
&ConnectMsg.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtListenPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Received connection request 0x%08x on port 0x%x.\n", MyName,
ConnectMsg.Header.MessageId, NamedPortHandle);
printf("%s: Request from: PID=%x, TID=%x.\n", MyName,
ConnectMsg.Header.ClientId.UniqueProcess, ConnectMsg.Header.ClientId.UniqueThread);
printf("%s: Accepting connection request 0x%08x...\n", MyName,
ConnectMsg.Header.MessageId);
Status = NtAcceptConnectPort(&PortHandle,
NamedPortHandle,
& ConnectMsg.Header,
TRUE,
0,
NULL);
if (!NT_SUCCESS(Status))
{
printf("%s: NtAcceptConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Connection request 0x%08x accepted as port 0x%x.\n", MyName,
ConnectMsg.Header.MessageId, PortHandle);
printf("%s: Completing connection for port 0x%x (0x%08x).\n", MyName,
PortHandle, ConnectMsg.Header.MessageId);
Status = NtCompleteConnectPort(PortHandle);
if (!NT_SUCCESS(Status))
{
printf("%s: NtCompleteConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Entering server loop for port 0x%x...\n", MyName, PortHandle);
for(;;)
{
LPC_MAX_MESSAGE Request;
Status = NtReplyWaitReceivePort(PortHandle,
0,
NULL,
&Request.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtReplyWaitReceivePort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
if (LPC_DATAGRAM == PORT_MESSAGE_TYPE(Request))
{
printf("%s: Datagram message contents are <%s>.\n",
MyName,
Request.Data);
}
else
{
printf("%s: Message with type %d received on port 0x%x.\n", MyName,
PORT_MESSAGE_TYPE(Request), PortHandle);
NtClose(PortHandle);
printf("%s: Connected port 0x%x closed.\n\n", MyName, PortHandle);
break;
}
}
}
return EXIT_SUCCESS;
}
/* EOF */

View file

@ -0,0 +1,5 @@
#ifndef _LPCTEST_H
#define _LPCTEST_H
#define TEST_PORT_NAME "\\TestPort"
#define TEST_PORT_NAME_U L"\\TestPort"
#endif

View file

@ -0,0 +1,52 @@
#
#
#
PATH_TO_TOP = ../../../reactos
include $(PATH_TO_TOP)/config
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS= lpcsrv.o
CLT_OBJECTS= lpcclt.o
PROGS= lpcsrv.exe lpcclt.exe
CFLAGS = $(STD_CFLAGS)
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) lpcsrv.o lpcsrv.exe lpcsrv.sym lpcclt.o lpcclt.exe lpcclt.sym
.phony: implib clean
ifneq ($(BOOTCD_INSTALL),)
install: $(PROGS:%=$(INSTALL_DIR)/%)
$(PROGS:%=$(INSTALL_DIR)/%): $(INSTALL_DIR)/%: %
$(CP) $* $(INSTALL_DIR)/$*
else # BOOTCD_INSTALL
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
endif # BOOTCD_INSTALL
lpcsrv.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o lpcsrv.exe
$(NM) --numeric-sort lpcsrv.exe > lpcsrv.sym
lpcclt.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o lpcclt.exe
$(NM) --numeric-sort lpcclt.exe > lpcclt.sym

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:59 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = map_dup_inherit
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,91 @@
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
/* This tests the ability of the target win32 to create an anonymous file
* mapping, create a mapping view with MapViewOfFile, and then realize the
* pages with VirtualAlloc.
*/
int main( int argc, char **argv ) {
HANDLE file_view;
void *file_map;
int *x;
fprintf( stderr, "%lu: Starting\n", GetCurrentProcessId() );
if( argc == 2 ) {
file_map = (void *)atoi(argv[1]);
} else {
file_map = CreateFileMapping( INVALID_HANDLE_VALUE,
NULL,
PAGE_READWRITE | SEC_RESERVE,
0, 0x1000, NULL );
if( !SetHandleInformation( file_map,
HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT ) ) {
fprintf( stderr, "%lu: Could not make handle inheritable.\n",
GetCurrentProcessId() );
return 100;
}
}
if( !file_map ) {
fprintf( stderr, "%lu: Could not create anonymous file map.\n",
GetCurrentProcessId() );
return 1;
}
file_view = MapViewOfFile( file_map,
FILE_MAP_WRITE,
0,
0,
0x1000 );
if( !file_view ) {
fprintf( stderr, "%lu: Could not map view of file.\n",
GetCurrentProcessId() );
return 2;
}
if( !VirtualAlloc( file_view, 0x1000, MEM_COMMIT, PAGE_READWRITE ) ) {
fprintf( stderr, "%lu: VirtualAlloc failed to realize the page.\n",
GetCurrentProcessId() );
return 3;
}
x = (int *)file_view;
x[0] = 0x12345678;
if( x[0] != 0x12345678 ) {
fprintf( stderr, "%lu: Can't write to the memory (%08x != 0x12345678)\n",
GetCurrentProcessId(), x[0] );
return 4;
}
if( argc == 1 ) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
char cmdline[1000];
memset( &si, 0, sizeof( si ) );
memset( &pi, 0, sizeof( pi ) );
sprintf(cmdline,"%s %d", argv[0], (int)file_map);
if( !CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL,
&si, &pi ) ) {
fprintf( stderr, "%lu: Could not create child process.\n",
GetCurrentProcessId() );
return 5;
}
if( WaitForSingleObject( pi.hThread, INFINITE ) != WAIT_OBJECT_0 ) {
fprintf( stderr, "%lu: Failed to wait for child process to terminate.\n",
GetCurrentProcessId() );
return 6;
}
}
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:59 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = no
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = mdi
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a comctl32.a comdlg32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

523
rosapps/tests/mdi/mdi.c Normal file
View file

@ -0,0 +1,523 @@
/*
Thanks to theForger from winprog.org
*/
#include <windows.h>
#include <commctrl.h>
#include <string.h>
#include "resource.h"
const char g_szClassName[] = "myWindowClass";
const char g_szChildClassName[] = "myMDIChildWindowClass";
#define IDC_MAIN_MDI 101
#define IDC_MAIN_TOOL 102
#define IDC_MAIN_STATUS 103
#define IDC_CHILD_EDIT 101
#define ID_MDI_FIRSTCHILD 50000
HWND g_hMDIClient = NULL;
HWND g_hMainWindow = NULL;
BOOL LoadTextFileToEdit(HWND hEdit, LPCTSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwFileSize;
dwFileSize = GetFileSize(hFile, NULL);
if(dwFileSize != 0xFFFFFFFF)
{
LPSTR pszFileText;
pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
if(pszFileText != NULL)
{
DWORD dwRead;
if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
{
pszFileText[dwFileSize] = 0; // Add null terminator
if(SetWindowText(hEdit, pszFileText))
bSuccess = TRUE; // It worked!
}
GlobalFree(pszFileText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}
BOOL SaveTextFileFromEdit(HWND hEdit, LPCTSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwTextLength;
dwTextLength = GetWindowTextLength(hEdit);
// No need to bother if there's no text.
if(dwTextLength > 0)
{
LPSTR pszText;
DWORD dwBufferSize = dwTextLength + 1;
pszText = GlobalAlloc(GPTR, dwBufferSize);
if(pszText != NULL)
{
if(GetWindowText(hEdit, pszText, dwBufferSize))
{
DWORD dwWritten;
if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
bSuccess = TRUE;
}
GlobalFree(pszText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}
void DoFileOpen(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
if(LoadTextFileToEdit(hEdit, szFileName))
{
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM)"Opened...");
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM)szFileName);
SetWindowText(hwnd, szFileName);
}
}
}
void DoFileSave(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "txt";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
if(SaveTextFileFromEdit(hEdit, szFileName))
{
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM)"Saved...");
SendDlgItemMessage(g_hMainWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM)szFileName);
SetWindowText(hwnd, szFileName);
}
}
}
HWND CreateNewMDIChild(HWND hMDIClient)
{
MDICREATESTRUCT mcs;
HWND hChild;
mcs.szTitle = "[Untitled]";
mcs.szClass = g_szChildClassName;
mcs.hOwner = GetModuleHandle(NULL);
mcs.x = mcs.cx = CW_USEDEFAULT;
mcs.y = mcs.cy = CW_USEDEFAULT;
mcs.style = MDIS_ALLCHILDSTYLES;
hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
if(!hChild)
{
MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
MB_ICONEXCLAMATION | MB_OK);
}
return hChild;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HWND hTool;
TBBUTTON tbb[3];
TBADDBITMAP tbab;
HWND hStatus;
int statwidths[] = {100, -1};
CLIENTCREATESTRUCT ccs;
// Create MDI Client
// Find window menu where children will be listed
ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 2);
ccs.idFirstChild = ID_MDI_FIRSTCHILD;
g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);
if(g_hMDIClient == NULL)
MessageBox(hwnd, "Could not create MDI client.", "Error", MB_OK | MB_ICONERROR);
// Create Toolbar
hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
if(hTool == NULL)
MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
tbab.hInst = HINST_COMMCTRL;
tbab.nID = IDB_STD_SMALL_COLOR;
SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = STD_FILENEW;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].idCommand = ID_FILE_NEW;
tbb[1].iBitmap = STD_FILEOPEN;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = ID_FILE_OPEN;
tbb[2].iBitmap = STD_FILESAVE;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = ID_FILE_SAVEAS;
SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
// Create Status bar
hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);
SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
}
break;
case WM_SIZE:
{
HWND hTool;
RECT rcTool;
int iToolHeight;
HWND hStatus;
RECT rcStatus;
int iStatusHeight;
HWND hMDI;
int iMDIHeight;
RECT rcClient;
// Size toolbar and get height
hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
SendMessage(hTool, TB_AUTOSIZE, 0, 0);
GetWindowRect(hTool, &rcTool);
iToolHeight = rcTool.bottom - rcTool.top;
// Size status bar and get height
hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
SendMessage(hStatus, WM_SIZE, 0, 0);
GetWindowRect(hStatus, &rcStatus);
iStatusHeight = rcStatus.bottom - rcStatus.top;
// Calculate remaining height and size edit
GetClientRect(hwnd, &rcClient);
iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case ID_FILE_NEW:
CreateNewMDIChild(g_hMDIClient);
break;
case ID_FILE_OPEN:
{
HWND hChild = CreateNewMDIChild(g_hMDIClient);
if(hChild)
{
DoFileOpen(hChild);
}
}
break;
case ID_FILE_CLOSE:
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
{
SendMessage(hChild, WM_CLOSE, 0, 0);
}
}
break;
case ID_WINDOW_TILE:
SendMessage(g_hMDIClient, WM_MDITILE, 0, 0);
break;
case ID_WINDOW_CASCADE:
SendMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
break;
default:
{
if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
{
DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
}
else
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
{
SendMessage(hChild, WM_COMMAND, wParam, lParam);
}
}
}
}
break;
default:
return DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HFONT hfDefault;
HWND hEdit;
// Create Edit Control
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
if(hEdit == NULL)
MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
hfDefault = GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
break;
case WM_MDIACTIVATE:
{
HMENU hMenu, hFileMenu;
UINT EnableFlag;
hMenu = GetMenu(g_hMainWindow);
if(hwnd == (HWND)lParam)
{ //being activated, enable the menus
EnableFlag = MF_ENABLED;
}
else
{ //being de-activated, gray the menus
EnableFlag = MF_GRAYED;
}
EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);
hFileMenu = GetSubMenu(hMenu, 0);
EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);
DrawMenuBar(g_hMainWindow);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_OPEN:
DoFileOpen(hwnd);
break;
case ID_FILE_SAVEAS:
DoFileSave(hwnd);
break;
case ID_EDIT_CUT:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0);
break;
case ID_EDIT_COPY:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0);
break;
case ID_EDIT_PASTE:
SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0);
break;
}
break;
case WM_SIZE:
{
HWND hEdit;
RECT rcClient;
// Calculate remaining height and size edit
GetClientRect(hwnd, &rcClient);
hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
return DefMDIChildProc(hwnd, msg, wParam, lParam);
default:
return DefMDIChildProc(hwnd, msg, wParam, lParam);
}
return 0;
}
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MDIChildWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szChildClassName;
wc.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(0, "Could Not Register Child Window", "Oh Oh...",
MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
else
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
InitCommonControls();
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
if(!SetUpMDIChildWindowClass(hInstance))
return 0;
hwnd = CreateWindowEx(
0,
g_szClassName,
"MDI Test Application",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
g_hMainWindow = hwnd;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
if (!TranslateMDISysAccel(g_hMDIClient, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}

30
rosapps/tests/mdi/mdi.rc Normal file
View file

@ -0,0 +1,30 @@
#include <defines.h>
#include <reactos/resource.h>
#include "resource.h"
IDR_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", ID_FILE_NEW
MENUITEM "&Open...", ID_FILE_OPEN
MENUITEM "Save &As...", ID_FILE_SAVEAS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Close", ID_FILE_CLOSE, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit", GRAYED
BEGIN
MENUITEM "C&ut", ID_EDIT_CUT
MENUITEM "&Copy", ID_EDIT_COPY
MENUITEM "&Paste", ID_EDIT_PASTE
END
POPUP "&Window", GRAYED
BEGIN
MENUITEM "&Tile", ID_WINDOW_TILE
MENUITEM "&Cascade", ID_WINDOW_CASCADE
END
END

View file

@ -0,0 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by app_four.rc
//
#define IDR_MAINMENU 102
#define ID_FILE_EXIT 40001
#define ID_FILE_NEW 40002
#define ID_FILE_OPEN 40003
#define ID_FILE_SAVEAS 40005
#define ID_WINDOW_CASCADE 40008
#define ID_WINDOW_TILE 40009
#define ID_FILE_CLOSE 40010
#define ID_FILE_CLOSEALL 40011
#define ID_EDIT_CUT 40015
#define ID_EDIT_COPY 40016
#define ID_EDIT_PASTE 40017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40020
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = miditest
TARGET_SDKLIBS = winmm.a
TARGET_GCCLIBS =
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,52 @@
#include <windows.h>
#include <stdio.h>
#include <mmsystem.h>
// WINE's mmsystem.h doesn't seem to define these properly:
#define MIDIOUTCAPS MIDIOUTCAPSA
#define MIDIINCAPS MIDIINCAPSA
#undef midiOutGetDevCaps
#define midiOutGetDevCaps midiOutGetDevCapsA
#undef midiInGetDevCaps
#define midiInGetDevCaps midiInGetDevCapsA
int main()
{
UINT outs = midiOutGetNumDevs();
// UINT ins = midiInGetNumDevs();
MIDIOUTCAPS outcaps;
// MIDIINCAPS incaps;
int c;
printf("MIDI output devices: %d\n", outs);
for (c = 0; c < outs; c ++)
{
if (midiOutGetDevCaps(c, &outcaps, sizeof(MIDIOUTCAPS)) == MMSYSERR_NOERROR)
printf("Device #%d: %s\n", c, outcaps.szPname);
}
printf("Opening MIDI output #0\n");
HMIDIOUT Handle = NULL;
UINT Result = midiOutOpen(&Handle, 0, 0, 0, CALLBACK_NULL);
printf("Result == %d Handle == %d\n", Result, (int)Handle);
// play something:
midiOutShortMsg(Handle, 0x007f3090);
/*
printf("\nMIDI input devices: %d\n", ins);
for (c = 0; c < ins; c ++)
{
midiInGetDevCaps(c, &incaps, sizeof(incaps));
printf("Device #%d: %s\n", c, incaps.szPname);
}
*/
return 0;
}

View file

@ -0,0 +1,30 @@
#include <defines.h>
#include <reactos/resource.h>
#include "resource.h"
IDR_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", ID_FILE_NEW
MENUITEM "&Open...", ID_FILE_OPEN
MENUITEM "Save &As...", ID_FILE_SAVEAS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Close", ID_FILE_CLOSE, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit", GRAYED
BEGIN
MENUITEM "C&ut", ID_EDIT_CUT
MENUITEM "&Copy", ID_EDIT_COPY
MENUITEM "&Paste", ID_EDIT_PASTE
END
POPUP "&Window", GRAYED
BEGIN
MENUITEM "&Tile", ID_WINDOW_TILE
MENUITEM "&Cascade", ID_WINDOW_CASCADE
END
END

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,21 @@
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = moztest
TARGET_SDKLIBS = ntdll.a ws2_32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,250 @@
/*
* Mozilla Test
* Copyright (C) 2004 Filip Navara
*/
#include <winsock.h>
#include <stdio.h>
ULONG DbgPrint(PCH Format,...);
#define DBG(x) \
printf("%s:%i - %s", __FILE__, __LINE__, x); \
DbgPrint("%s:%i - %s", __FILE__, __LINE__, x);
int SocketTest()
{
/*
* A socket pair is often used for interprocess communication,
* so we need to make sure neither socket is associated with
* the I/O completion port; otherwise it can't be used by a
* child process.
*
* The default implementation below cannot be used for NT
* because PR_Accept would have associated the I/O completion
* port with the listening and accepted sockets.
*/
SOCKET listenSock;
SOCKET osfd[2];
struct sockaddr_in selfAddr, peerAddr;
int addrLen;
WORD wVersionRequested;
WSADATA wsaData;
int err;
/*
* Initialization.
*/
wVersionRequested = MAKEWORD( 2, 2 );
DBG("Calling WSAStartup\n");
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
DBG("WSAStartup failed\n");
return 1;
}
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
DBG("WSAStartup version unacceptable\n");
WSACleanup( );
return 1;
}
/* The WinSock DLL is acceptable. Proceed. */
DBG("Calling socket\n");
osfd[0] = osfd[1] = INVALID_SOCKET;
listenSock = socket(AF_INET, SOCK_STREAM, 0);
if (listenSock == INVALID_SOCKET) {
DBG("socket failed\n");
goto failed;
}
selfAddr.sin_family = AF_INET;
selfAddr.sin_port = 0;
selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */
addrLen = sizeof(selfAddr);
DBG("Calling bind\n");
if (bind(listenSock, (struct sockaddr *) &selfAddr,
addrLen) == SOCKET_ERROR) {
DBG("bind failed\n");
goto failed;
}
DBG("Calling getsockname\n");
if (getsockname(listenSock, (struct sockaddr *) &selfAddr,
&addrLen) == SOCKET_ERROR) {
DBG("getsockname failed\n");
goto failed;
}
DBG("Calling listen\n");
if (listen(listenSock, 5) == SOCKET_ERROR) {
DBG("listen failed\n");
goto failed;
}
DBG("Calling socket\n");
osfd[0] = socket(AF_INET, SOCK_STREAM, 0);
if (osfd[0] == INVALID_SOCKET) {
DBG("socket failed\n");
goto failed;
}
selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
/*
* Only a thread is used to do the connect and accept.
* I am relying on the fact that connect returns
* successfully as soon as the connect request is put
* into the listen queue (but before accept is called).
* This is the behavior of the BSD socket code. If
* connect does not return until accept is called, we
* will need to create another thread to call connect.
*/
DBG("Calling connect\n");
if (connect(osfd[0], (struct sockaddr *) &selfAddr,
addrLen) == SOCKET_ERROR) {
DBG("connect failed\n");
goto failed;
}
/*
* A malicious local process may connect to the listening
* socket, so we need to verify that the accepted connection
* is made from our own socket osfd[0].
*/
DBG("Calling getsockname\n");
if (getsockname(osfd[0], (struct sockaddr *) &selfAddr,
&addrLen) == SOCKET_ERROR) {
DBG("getsockname failed\n");
goto failed;
}
DBG("Calling accept\n");
osfd[1] = accept(listenSock, (struct sockaddr *) &peerAddr, &addrLen);
if (osfd[1] == INVALID_SOCKET) {
DBG("accept failed\n");
goto failed;
}
if (peerAddr.sin_port != selfAddr.sin_port) {
/* the connection we accepted is not from osfd[0] */
DBG("peerAddr.sin_port != selfAddr.sin_port\n");
goto failed;
}
DBG("Hurray!\n");
closesocket(listenSock);
closesocket(osfd[0]);
closesocket(osfd[1]);
WSACleanup();
return 0;
failed:
if (listenSock != INVALID_SOCKET) {
closesocket(listenSock);
}
if (osfd[0] != INVALID_SOCKET) {
closesocket(osfd[0]);
}
if (osfd[1] != INVALID_SOCKET) {
closesocket(osfd[1]);
}
WSACleanup();
return 1;
}
int VirtualTest()
{
DWORD dwErr;
SYSTEM_INFO si;
HANDLE hMap;
PBYTE pBufferStart;
PCHAR pszFileName = "test.txt";
ULONG dwMaxSize = strlen(pszFileName);
DBG("Calling CreateFileMappingA\n");
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE | SEC_RESERVE, 0, dwMaxSize, pszFileName);
if (!hMap)
{
DBG("CreateFileMappingA failed\n");
return 1;
}
dwErr = GetLastError();
DBG("Calling MapViewOfFile\n");
pBufferStart = (BYTE *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pBufferStart)
{
DBG("MapViewOfFile failed\n");
return 1;
}
GetSystemInfo(&si);
if (dwErr == ERROR_ALREADY_EXISTS)
{
DBG("MapViewOfFile returned ERROR_ALREADY_EXISTS\n");
DBG("This really shouldn't happen, but it's not fatal.\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 1;
}
else
{
DBG("Calling VirtualAlloc\n");
if (!VirtualAlloc(pBufferStart, si.dwPageSize, MEM_COMMIT, PAGE_READWRITE))
{
DBG("VirtualAlloc failed\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 1;
}
}
DBG("Hurray!\n");
UnmapViewOfFile(pBufferStart);
CloseHandle(hMap);
return 0;
}
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Usage: %s test_name\n\n", argv[0]);
printf("Valid test names:\n");
printf("\tsocket\n");
printf("\tvirtual\n");
return 0;
}
if (!stricmp(argv[1], "socket"))
return SocketTest();
if (!stricmp(argv[1], "virtual"))
return VirtualTest();
printf("Test '%s' doesn't exist\n", argv[1]);
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,52 @@
#
#
#
PATH_TO_TOP = ../../../reactos
include $(PATH_TO_TOP)/config
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS = msserver.o
CLT_OBJECTS = msclient.o
PROGS = msserver.exe msclient.exe
CFLAGS = $(STD_CFLAGS)
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
ifneq ($(BOOTCD_INSTALL),)
install: $(PROGS:%=$(INSTALL_DIR)/%)
$(PROGS:%=$(INSTALL_DIR)/%): $(INSTALL_DIR)/%: %
$(CP) $* $(INSTALL_DIR)/$*
else # BOOTCD_INSTALL
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
endif # BOOTCD_INSTALL
msserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o msserver.exe
$(NM) --numeric-sort msserver.exe > msserver.sym
msclient.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o msclient.exe
$(NM) --numeric-sort msclient.exe > msclient.sym

View file

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <tchar.h>
#define BUFSIZE 1024
#define MAILSLOT_TIMEOUT 1000
int main(int argc, char *argv[])
{
HANDLE hMailslot;
LPSTR lpszMailslotName = "\\\\.\\MAILSLOT\\mymailslot";
LPSTR lpszTestMessage = "Mailslot test message!";
DWORD cbLength, cbWritten;
hMailslot = CreateFile(lpszMailslotName,
GENERIC_WRITE,
FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
printf("hMailslot %x\n", (DWORD)hMailslot);
if (hMailslot == INVALID_HANDLE_VALUE)
{
printf("CreateFile() failed\n");
return 0;
}
cbLength = (ULONG)strlen(lpszTestMessage)+1;
WriteFile(hMailslot,
lpszTestMessage,
cbLength,
&cbWritten,
NULL);
CloseHandle(hMailslot);
return 0;
}
/* EOF */

View file

@ -0,0 +1,40 @@
#include <windows.h>
int main(int argc, char *argv[])
{
HANDLE hMailslot;
CHAR chBuf[512];
BOOL fResult;
DWORD cbRead;
LPTSTR lpszMailslotName = "\\\\.\\mailslot\\mymailslot";
hMailslot = CreateMailslot(lpszMailslotName,
512,
MAILSLOT_WAIT_FOREVER,
NULL);
for (;;)
{
fResult = ReadFile(hMailslot,
chBuf,
512,
&cbRead,
NULL);
if (fResult == FALSE)
{
printf("ReadFile() failed!\n");
CloseHandle(hMailslot);
return 0;
}
printf("Data read: %s\n", chBuf);
}
CloseHandle(hMailslot);
return 0;
}
/* EOF */

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:58:59 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = multithrdwin
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,236 @@
#include <windows.h>
#include <stdio.h>
typedef struct _THRDCREATEWIN
{
HANDLE hThread;
DWORD ThreadId;
LPSTR Caption;
HWND *Parent;
HWND Window;
DWORD Style;
POINT Position;
SIZE Size;
} THRDCREATEWIN, *PTHRDCREATEWIN;
static HINSTANCE hAppInstance;
static HANDLE WinCreatedEvent;
static THRDCREATEWIN wnds[3];
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI
WindowThreadProc(LPVOID lpParameter)
{
MSG msg;
char caption[64];
PTHRDCREATEWIN cw = (PTHRDCREATEWIN)lpParameter;
sprintf(caption, cw->Caption, GetCurrentThreadId());
cw->Window = CreateWindow("MultiClass",
caption,
cw->Style | WS_VISIBLE,
cw->Position.x,
cw->Position.y,
cw->Size.cx,
cw->Size.cy,
(cw->Parent ? *(cw->Parent) : 0),
NULL,
hAppInstance,
NULL);
SetEvent(WinCreatedEvent);
if(!cw->Window)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return 1;
}
CreateWindow("BUTTON","Sleep",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 10, 10, 70, 23, cw->Window, (PVOID)1, hAppInstance, NULL);
CreateWindow("BUTTON","1",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 83, 10, 20, 23, cw->Window, (PVOID)2, hAppInstance, NULL);
CreateWindow("BUTTON","2",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 105, 10, 20, 23, cw->Window, (PVOID)3, hAppInstance, NULL);
CreateWindow("BUTTON","3",WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP|BS_PUSHBUTTON, 127, 10, 20, 23, cw->Window, (PVOID)4, hAppInstance, NULL);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
int i;
HANDLE Threads[3];
hAppInstance = hInstance;
WinCreatedEvent = CreateEvent(NULL,
FALSE,
FALSE,
NULL);
if(!WinCreatedEvent)
{
fprintf(stderr, "Failed to create event (last error 0x%lX)\n",
GetLastError());
return 1;
}
wc.lpszClassName = "MultiClass";
wc.lpfnWndProc = MultiWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR) IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR) IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
wnds[0].Caption = "TopLevel1 (ThreadID: %d)";
wnds[0].Parent = NULL;
wnds[0].Style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[0].Position.x = wnds[0].Position.y = 0;
wnds[0].Size.cx = 320;
wnds[0].Size.cy = 240;
wnds[1].Caption = "Child1 of TopLevel1 (ThreadID: %d)";
wnds[1].Parent = &wnds[0].Window;
wnds[1].Style = WS_CHILD | WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[1].Position.x = 20;
wnds[1].Position.y = 120;
wnds[1].Size.cx = wnds[1].Size.cy = 240;
wnds[2].Caption = "TopLevel2 (ThreadID: %d)";
wnds[2].Parent = NULL;
wnds[2].Style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
wnds[2].Position.x = 400;
wnds[2].Position.y = 0;
wnds[2].Size.cx = 160;
wnds[2].Size.cy = 490;
for(i = 0; i < (sizeof(wnds) / sizeof(THRDCREATEWIN)); i++)
{
wnds[i].hThread = CreateThread(NULL,
0,
WindowThreadProc,
&wnds[i],
0,
&wnds[i].ThreadId);
Threads[i] = wnds[i].hThread;
if(!wnds[i].hThread)
{
fprintf(stderr, "CreateThread #%i failed (last error 0x%lX)\n",
i, GetLastError());
return 1;
}
WaitForSingleObject(WinCreatedEvent, INFINITE);
}
WaitForMultipleObjects(sizeof(Threads) / sizeof(HANDLE), &Threads[0], TRUE, INFINITE);
UnregisterClass("MultiClass", hInstance);
return 0;
}
LRESULT CALLBACK MultiWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT Client;
HBRUSH Brush;
DWORD Ret;
static COLORREF Colors[] =
{
RGB(0x00, 0x00, 0x00),
RGB(0x80, 0x00, 0x00),
RGB(0x00, 0x80, 0x00),
RGB(0x00, 0x00, 0x80),
RGB(0x80, 0x80, 0x00),
RGB(0x80, 0x00, 0x80),
RGB(0x00, 0x80, 0x80),
RGB(0x80, 0x80, 0x80),
RGB(0xff, 0x00, 0x00),
RGB(0x00, 0xff, 0x00),
RGB(0x00, 0x00, 0xff),
RGB(0xff, 0xff, 0x00),
RGB(0xff, 0x00, 0xff),
RGB(0x00, 0xff, 0xff),
RGB(0xff, 0xff, 0xff)
};
static unsigned CurrentColor = 0;
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &Client);
Brush = CreateSolidBrush(Colors[CurrentColor]);
FillRect(hDC, &Client, Brush);
DeleteObject(Brush);
CurrentColor++;
if (sizeof(Colors) / sizeof(Colors[0]) <= CurrentColor)
{
CurrentColor = 0;
}
EndPaint(hWnd, &ps);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case 1:
Sleep(20000);
break;
case 2:
case 3:
case 4:
if(SendMessageTimeout(wnds[LOWORD(wParam) - 2].Window, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 1000, &Ret))
{
DbgPrint("SendMessageTimeout() OK");
MessageBox(hWnd, "SendMessageTimeout() OK", NULL, 0);
}
else
{
if(GetLastError() == ERROR_TIMEOUT)
{
DbgPrint("SendMessageTimeout() Timeout");
MessageBox(hWnd, "SendMessageTimeout() Timeout", NULL, 0);
}
else
{
DbgPrint("SendMessageTimeout() Failed");
MessageBox(hWnd, "SendMessageTimeout() Failed", NULL, 0);
}
}
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:59:00 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = multiwin
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,147 @@
#include <windows.h>
#include <stdio.h>
static UINT WindowCount;
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd1;
HWND hWnd2;
HWND hWndChild;
wc.lpszClassName = "MultiClass";
wc.lpfnWndProc = MultiWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, (LPCTSTR) IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR) IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
hWnd1 = CreateWindow("MultiClass",
"TopLevel1",
WS_OVERLAPPEDWINDOW,
0,
0,
320,
240,
NULL,
NULL,
hInstance,
NULL);
hWndChild = CreateWindow("MultiClass",
"Child1 of TopLevel1",
WS_CHILD | WS_BORDER | WS_CAPTION | WS_VISIBLE | WS_SYSMENU,
20,
120,
200,
200,
hWnd1,
NULL,
hInstance,
NULL);
hWnd2 = CreateWindow("MultiClass",
"TopLevel2",
WS_OVERLAPPEDWINDOW,
400,
0,
160,
490,
NULL,
NULL,
hInstance,
NULL);
if (! hWnd1 || ! hWnd2 || ! hWndChild)
{
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
GetLastError());
return(1);
}
WindowCount = 2;
ShowWindow(hWnd1, SW_NORMAL);
ShowWindow(hWnd2, SW_NORMAL);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK MultiWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
LONG Style;
RECT Client;
HBRUSH Brush;
static COLORREF Colors[] =
{
RGB(0x00, 0x00, 0x00),
RGB(0x80, 0x00, 0x00),
RGB(0x00, 0x80, 0x00),
RGB(0x00, 0x00, 0x80),
RGB(0x80, 0x80, 0x00),
RGB(0x80, 0x00, 0x80),
RGB(0x00, 0x80, 0x80),
RGB(0x80, 0x80, 0x80),
RGB(0xff, 0x00, 0x00),
RGB(0x00, 0xff, 0x00),
RGB(0x00, 0x00, 0xff),
RGB(0xff, 0xff, 0x00),
RGB(0xff, 0x00, 0xff),
RGB(0x00, 0xff, 0xff),
RGB(0xff, 0xff, 0xff)
};
static unsigned CurrentColor = 0;
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &Client);
Brush = CreateSolidBrush(Colors[CurrentColor]);
FillRect(hDC, &Client, Brush);
DeleteObject(Brush);
CurrentColor++;
if (sizeof(Colors) / sizeof(Colors[0]) <= CurrentColor)
{
CurrentColor = 0;
}
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
Style = GetWindowLong(hWnd, GWL_STYLE);
if (0 == (Style & WS_CHILD) && 0 == --WindowCount)
{
PostQuitMessage(0);
}
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,24 @@
#
# $Id: makefile,v 1.1 2004/10/21 04:59:00 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = mutex
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

122
rosapps/tests/mutex/mutex.c Normal file
View file

@ -0,0 +1,122 @@
#include <ddk/ntddk.h>
#include <windows.h>
#include <string.h>
#include <stdio.h>
HANDLE OutputHandle;
HANDLE InputHandle;
HANDLE hThread[2];
DWORD dwCounter = 0;
HANDLE hMutex;
void dprintf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
DWORD WINAPI thread1(LPVOID crap)
{
DWORD dwError = 0;
DWORD i;
dprintf("Thread 1 running!\n");
for (i = 0; i < 10; i++)
{
dwError = WaitForSingleObject(hMutex, INFINITE);
if (dwError == WAIT_FAILED)
{
dprintf("Thread2: WaitForSingleObject failed!\n");
return 1;
}
else if (dwError == WAIT_ABANDONED_0)
{
dprintf("Thread2: WaitForSingleObject returned WAIT_ABANDONED_0\n");
}
dprintf("Thread1: dwCounter : %lu -->", dwCounter);
dwCounter++;
dprintf(" %lu\n", dwCounter);
ReleaseMutex(hMutex);
}
dprintf("Thread 1 done!\n");
return 1;
}
DWORD WINAPI thread2(LPVOID crap)
{
DWORD dwError = 0;
DWORD i;
dprintf("Thread 2 running!\n");
for (i = 0; i < 10; i++)
{
dwError = WaitForSingleObject(hMutex, INFINITE);
if (dwError == WAIT_FAILED)
{
dprintf("Thread2: WaitForSingleObject failed!\n");
return 1;
}
else if (dwError == WAIT_ABANDONED_0)
{
dprintf("Thread2: WaitForSingleObject returned WAIT_ABANDONED_0\n");
}
dprintf("Thread2: dwCounter : %lu -->", dwCounter);
dwCounter++;
dprintf(" %lu\n", dwCounter);
ReleaseMutex(hMutex);
}
dprintf("Thread 2 done!\n");
return 1;
}
int main(int argc, char* argv[])
{
DWORD dwError;
DWORD id1,id2;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
dprintf("Calling CreateMutex()\n");
hMutex = CreateMutexW(NULL, FALSE, L"TestMutex");
if (hMutex == INVALID_HANDLE_VALUE)
{
dprintf("CreateMutex() failed! Error: %lu\n", GetLastError());
return 0;
}
dprintf("CreateMutex() succeeded!\n");
hThread[0] = CreateThread(0, 0, thread1, 0, 0, &id1);
hThread[1] = CreateThread(0, 0, thread2, 0, 0, &id2);
dprintf("Calling WaitForMultipleObject()\n");
dwError = WaitForMultipleObjects(2, hThread, TRUE, INFINITE);
dprintf("WaitForMultipleObject() Error: %lu\n", dwError);
CloseHandle(hThread[0]);
CloseHandle(hThread[1]);
CloseHandle(hMutex);
dprintf("Main thread done!\n");
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,22 @@
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = nameserverlist
TARGET_SDKLIBS = iphlpapi.a ws2_32.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <iphlpapi.h>
int main( int argc, char **argv ) {
ULONG OutBufLen = 0;
PFIXED_INFO pFixedInfo;
PIP_ADDR_STRING Addr;
GetNetworkParams(NULL, &OutBufLen);
pFixedInfo = malloc(OutBufLen);
if (!pFixedInfo) {
printf( "Failed to alloc %d bytes.\n", (int)OutBufLen );
return 1;
}
printf( "%d Bytes allocated\n", (int)OutBufLen );
GetNetworkParams(pFixedInfo,&OutBufLen);
for( Addr = &pFixedInfo->DnsServerList;
Addr;
Addr = Addr->Next ) {
printf( "%c%s\n",
Addr == pFixedInfo->CurrentDnsServer ? '*' : ' ',
Addr->IpAddress.String );
}
free( pFixedInfo );
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,32 @@
#
# $Id: makefile,v 1.1 2004/10/21 04:59:00 sedwards Exp $
#
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = noexecute
TARGET_SDKLIBS = pseh.a
TARGET_PCH =
TARGET_OBJECTS = \
noexecute.o
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -0,0 +1,65 @@
/*
* $Id: noexecute.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <pseh.h>
int test(int x)
{
return x+1;
}
void execute(char* message, int(*func)(int))
{
ULONG status = 0;
ULONG result;
printf("%s ... ", message);
_SEH_TRY
{
result = func(1);
}
_SEH_HANDLE
{
status = _SEH_GetExceptionCode();
}
_SEH_END;
if (status == 0)
{
printf("OK.\n");
}
else
{
printf("Error, status=%lx.\n", status);
}
}
char data[100];
int main(void)
{
unsigned char stack[100];
void* heap;
ULONG protection;
printf("NoExecute\n");
execute("Executing within the code segment", test);
memcpy(data, test, 100);
execute("Executing within the data segment", (int(*)(int))data);
memcpy(stack, test, 100);
execute("Executing on stack segment", (int(*)(int))stack);
heap = VirtualAlloc(NULL, 100, MEM_COMMIT, PAGE_READWRITE);
memcpy(heap, test, 100);
execute("Executing on the heap with protection PAGE_READWRITE", (int(*)(int))heap);
VirtualProtect(heap, 100, PAGE_EXECUTE, &protection);
execute("Executing on the heap with protection PAGE_EXECUTE", (int(*)(int))heap);
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,51 @@
#
#
#
PATH_TO_TOP = ../../../reactos
include $(PATH_TO_TOP)/config
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS = npserver.o
CLT_OBJECTS = npclient.o
PROGS = npserver.exe npclient.exe
CFLAGS = $(STD_CFLAGS)
LIBS = $(SDK_PATH_LIB)/kernel32.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
ifneq ($(BOOTCD_INSTALL),)
install: $(PROGS:%=$(INSTALL_DIR)/%)
$(PROGS:%=$(INSTALL_DIR)/%): $(INSTALL_DIR)/%: %
$(CP) $* $(INSTALL_DIR)/$*
else # BOOTCD_INSTALL
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
endif # BOOTCD_INSTALL
npserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o npserver.exe
$(NM) --numeric-sort npserver.exe > npserver.sym
npclient.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o npclient.exe
$(NM) --numeric-sort npclient.exe > npclient.sym

View file

@ -0,0 +1,100 @@
#include <windows.h>
VOID MyErrExit(LPTSTR Message)
{
// MessageBox(NULL, Message, NULL, MB_OK);
puts(Message);
ExitProcess(0);
}
int main(int argc, char *argv[])
{
HANDLE hPipe;
LPVOID lpvMessage;
CHAR chBuf[512];
BOOL fSuccess;
DWORD cbRead, cbWritten, dwMode;
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
// Try to open a named pipe; wait for it, if necessary.
while (1)
{
hPipe = CreateFile(
lpszPipename, // pipe name
GENERIC_READ | // read and write access
GENERIC_WRITE,
0, // no sharing
NULL, // no security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
if (hPipe != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
if (GetLastError() != ERROR_PIPE_BUSY)
MyErrExit("Could not open pipe");
// All pipe instances are busy, so wait for 20 seconds.
if (! WaitNamedPipe(lpszPipename, 20000) )
MyErrExit("Could not open pipe");
}
// The pipe connected; change to message-read mode.
dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState(
hPipe, // pipe handle
&dwMode, // new pipe mode
NULL, // don't set maximum bytes
NULL); // don't set maximum time
if (!fSuccess)
MyErrExit("SetNamedPipeHandleState");
// Send a message to the pipe server.
lpvMessage = (argc > 1) ? argv[1] : "default message";
fSuccess = WriteFile(
hPipe, // pipe handle
lpvMessage, // message
strlen(lpvMessage) + 1, // message length
&cbWritten, // bytes written
NULL); // not overlapped
if (! fSuccess)
MyErrExit("WriteFile");
do
{
// Read from the pipe.
fSuccess = ReadFile(
hPipe, // pipe handle
chBuf, // buffer to receive reply
512, // size of buffer
&cbRead, // number of bytes read
NULL); // not overlapped
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
break;
// Reply from the pipe is written to STDOUT.
if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
chBuf, cbRead, &cbWritten, NULL))
{
break;
}
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
CloseHandle(hPipe);
return 0;
}

View file

@ -0,0 +1,120 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <tchar.h>
#define BUFSIZE 1024
#define PIPE_TIMEOUT 1000
VOID InstanceThread (LPVOID);
VOID
GetAnswerToRequest(LPTSTR lpRequest,
LPTSTR lpReply,
LPDWORD lpcbReplyBytes)
{
}
VOID MyErrExit(LPTSTR Message)
{
// MessageBox(NULL, Message, NULL, MB_OK);
puts(Message);
ExitProcess(0);
}
int xx = 0;
int main(int argc, char *argv[])
{
BOOL fConnected;
DWORD dwThreadId;
HANDLE hPipe, hThread;
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
// for (;;)
// {
hPipe = CreateNamedPipe(lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
PIPE_TIMEOUT,
NULL);
if (hPipe == INVALID_HANDLE_VALUE)
{
printf("CreateNamedPipe() failed\n");
return 0;
}
fConnected = ConnectNamedPipe(hPipe,
NULL) ? TRUE : (GetLastError () ==
ERROR_PIPE_CONNECTED);
if (fConnected)
{
printf("Pipe connected!\n");
DisconnectNamedPipe(hPipe);
#if 0
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) InstanceThread,
(LPVOID) hPipe,
0,
&dwThreadId);
if (hThread == NULL)
MyErrExit("CreateThread");
#endif
}
else
{
// CloseHandle(hPipe);
}
// }
CloseHandle(hPipe);
return 0;
}
VOID InstanceThread (LPVOID lpvParam)
{
CHAR chRequest[BUFSIZE];
CHAR chReply[BUFSIZE];
DWORD cbBytesRead, cbReplyBytes, cbWritten;
BOOL fSuccess;
HANDLE hPipe;
hPipe = (HANDLE)lpvParam;
while (1)
{
fSuccess = ReadFile(hPipe,
chRequest,
BUFSIZE,
&cbBytesRead,
NULL);
if (!fSuccess || cbBytesRead == 0)
break;
GetAnswerToRequest(chRequest, chReply, &cbReplyBytes);
fSuccess = WriteFile(hPipe,
chReply,
cbReplyBytes,
&cbWritten,
NULL);
if (!fSuccess || cbReplyBytes != cbWritten)
break;
}
FlushFileBuffers(hPipe);
DisconnectNamedPipe(hPipe);
CloseHandle(hPipe);
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,10 @@
from socket import *
import sys
s = socket(AF_INET,SOCK_DGRAM,0)
s.connect(('localhost',5001))
while 1:
sys.stdout.write('>> ')
line = sys.stdin.readline()
s.send('CMD ' + line)

View file

@ -0,0 +1,28 @@
#
# $Id: makefile,v 1.1 2004/10/21 04:59:00 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = oskittcp
TARGET_SDKLIBS = ws2_32.a oskittcp.a ntdll.a
TARGET_OBJECTS = tcptest.o
TARGET_CPPFLAGS = -I$(PATH_TO_TOP)/drivers/lib/oskittcp/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -g
TARGET_GCCLIBS = stdc++
TARGET_LDFLAGS = -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,380 @@
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#endif//_MSC_VER
#include <list>
#include <string>
#include <sstream>
#include <malloc.h>
extern "C" {
typedef unsigned short u_short;
#include <stdio.h>
#include <oskittcp.h>
#include <windows.h>
#ifndef _MSC_VER
#include <winsock2.h>
#endif//_MSC_VER
};
unsigned char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb };
#undef malloc
#undef free
unsigned long TCP_IPIdentification;
#define MAX_DG_SIZE 0x10000
#define TI_DbgPrint(x,y) printf y
std::list<std::string> output_packets;
typedef struct _CONNECTION_ENDPOINT {
OSK_UINT State;
} CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;
extern "C" int is_stack_ptr ( const void* p )
{
MEMORY_BASIC_INFORMATION mbi1, mbi2;
VirtualQuery ( p, &mbi1, sizeof(mbi1) );
VirtualQuery ( _alloca(1), &mbi2, sizeof(mbi2) );
return mbi1.AllocationBase == mbi2.AllocationBase;
}
int TCPSocketState(void *ClientData,
void *WhichSocket,
void *WhichConnection,
OSK_UINT NewState ) {
PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)WhichConnection;
//PLIST_ENTRY Entry;
TI_DbgPrint(MID_TRACE,("Called: NewState %x\n", NewState));
if( !Connection ) {
TI_DbgPrint(MID_TRACE,("Socket closing.\n"));
return 0;
}
if( (NewState & SEL_CONNECT) &&
!(Connection->State & SEL_CONNECT) ) {
} else if( (NewState & SEL_READ) || (NewState & SEL_FIN) ) {
}
return 0;
}
#define STRINGIFY(x) #x
char hdr[14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00 };
int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len ) {
output_packets.push_back( std::string( hdr, 14 ) +
std::string( (char *)data, (int)len ) );
return 0;
}
struct ifaddr *TCPFindInterface( void *ClientData,
OSK_UINT AddrType,
OSK_UINT FindType,
struct sockaddr *ReqAddr ) {
static struct sockaddr_in ifa = { AF_INET }, nm = { AF_INET };
static struct ifaddr a = {
(struct sockaddr *)&ifa,
NULL,
(struct sockaddr *)&nm,
0,
0,
1,
1500
};
ifa.sin_addr.s_addr = inet_addr( "10.10.2.115" );
nm.sin_addr.s_addr = inet_addr( "255.255.255.0" );
return &a;
}
void *TCPMalloc( void *ClientData,
OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line ) {
void *v = malloc( Bytes );
fprintf( stderr, "(%s:%d) malloc( %d ) => %x\n", File, Line, Bytes, v );
return v;
}
void TCPFree( void *ClientData,
void *data, OSK_PCHAR File, OSK_UINT Line ) {
fprintf( stderr, "(%s:%d) free( %x )\n", File, Line, data );
free( data );
}
int TCPSleep( void *ClientData, void *token, int priority, char *msg,
int tmio ) {
#if 0
PSLEEPING_THREAD SleepingThread;
TI_DbgPrint(MID_TRACE,
("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n",
token, priority, msg, tmio));
SleepingThread = ExAllocatePool( NonPagedPool, sizeof( *SleepingThread ) );
if( SleepingThread ) {
KeInitializeEvent( &SleepingThread->Event, NotificationEvent, FALSE );
SleepingThread->SleepToken = token;
ExAcquireFastMutex( &SleepingThreadsLock );
InsertTailList( &SleepingThreadsList, &SleepingThread->Entry );
ExReleaseFastMutex( &SleepingThreadsLock );
TI_DbgPrint(MID_TRACE,("Waiting on %x\n", token));
KeWaitForSingleObject( &SleepingThread->Event,
WrSuspended,
KernelMode,
TRUE,
NULL );
ExAcquireFastMutex( &SleepingThreadsLock );
RemoveEntryList( &SleepingThread->Entry );
ExReleaseFastMutex( &SleepingThreadsLock );
ExFreePool( SleepingThread );
}
TI_DbgPrint(MID_TRACE,("Waiting finished: %x\n", token));
#endif
return 0;
}
void TCPWakeup( void *ClientData, void *token ) {
#if 0
PLIST_ENTRY Entry;
PSLEEPING_THREAD SleepingThread;
ExAcquireFastMutex( &SleepingThreadsLock );
Entry = SleepingThreadsList.Flink;
while( Entry != &SleepingThreadsList ) {
SleepingThread = CONTAINING_RECORD(Entry, SLEEPING_THREAD, Entry);
TI_DbgPrint(MID_TRACE,("Sleeper @ %x\n", SleepingThread));
if( SleepingThread->SleepToken == token ) {
TI_DbgPrint(MID_TRACE,("Setting event to wake %x\n", token));
KeSetEvent( &SleepingThread->Event, IO_NETWORK_INCREMENT, FALSE );
}
Entry = Entry->Flink;
}
ExReleaseFastMutex( &SleepingThreadsLock );
#endif
}
OSKITTCP_EVENT_HANDLERS EventHandlers = {
NULL,
TCPSocketState,
TCPPacketSend,
TCPFindInterface,
TCPMalloc,
TCPFree,
TCPSleep,
TCPWakeup
};
void display_row( char *data, int off, int len ) {
int i;
printf( "%08x:", off );
for( i = off; i < len && i < off + 16; i++ ) {
printf( " %02x", data[i] & 0xff );
}
printf( " -- " );
for( i = off; i < len && i < off + 16; i++ ) {
printf( "%c", (data[i] >= ' ') ? data[i] : '.' );
}
printf( "\n" );
}
int main( int argc, char **argv ) {
int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
char datagram[MAX_DG_SIZE];
void *conn = 0;
struct fd_set readf;
struct timeval tv;
struct sockaddr_in addr_from = { AF_INET }, addr_to = { AF_INET };
std::list<std::string>::iterator i;
WSADATA wsadata;
WSAStartup( 0x101, &wsadata );
if( argc > 1 ) port = atoi(argv[1]);
RegisterOskitTCPEventHandlers( &EventHandlers );
InitOskitTCP();
asock = socket( AF_INET, SOCK_DGRAM, 0 );
addr_from.sin_port = htons( port );
if( bind( asock, (struct sockaddr *)&addr_from, sizeof( addr_from ) ) ) {
printf( "Bind error\n" );
return 0;
}
addr_to.sin_port = htons( port & (~1) );
addr_to.sin_addr.s_addr = inet_addr("127.0.0.1");
while( true ) {
FD_ZERO( &readf );
FD_SET( asock, &readf );
tv.tv_sec = 0;
tv.tv_usec = 10000;
selret = select( asock + 1, &readf, NULL, NULL, &tv );
if( FD_ISSET( asock, &readf ) ) {
fromsize = sizeof( addr_from );
dgrecv = recvfrom( asock, datagram, sizeof(datagram), 0,
(struct sockaddr *)&addr_from, &fromsize );
if( datagram[0] == 'C' && datagram[1] == 'M' &&
datagram[2] == 'D' && datagram[3] == ' ' ) {
int theport, bytes, /*recvret,*/ off, bytin;
struct sockaddr_in nam;
std::string faddr, word;
std::istringstream
cmdin( std::string( datagram + 4, dgrecv - 4 ) );
cmdin >> word;
if( word == "socket" ) {
cmdin >> faddr >> theport;
nam.sin_family = AF_INET;
nam.sin_addr.s_addr = inet_addr(faddr.c_str());
nam.sin_port = htons(theport);
if( (err = OskitTCPSocket( NULL, &conn, AF_INET,
SOCK_STREAM, 0 )) != 0 ) {
fprintf( stderr, "OskitTCPSocket: error %d\n", err );
}
if( (err = OskitTCPConnect( conn, NULL, &nam,
sizeof(nam) )) != 0 ) {
fprintf( stderr, "OskitTCPConnect: error %d\n", err );
} else {
printf( "Socket created\n" );
}
}
/* The rest of the commands apply only to an open socket */
if( !conn ) continue;
if( word == "recv" ) {
cmdin >> bytes;
if( (err = OskitTCPRecv( conn, (OSK_PCHAR)datagram,
sizeof(datagram),
(unsigned int *)&bytin, 0 )) != 0 ) {
fprintf( stderr, "OskitTCPRecv: error %d\n", err );
} else {
for( off = 0; off < bytin; off += 16 ) {
display_row( datagram, off, bytin );
}
printf( "\n" );
}
} else if ( word == "type" ) {
std::string therest = &cmdin.str()[word.size()];
char* p = &therest[0];
p += strspn ( p, " \t" );
char* src = p;
char* dst = p;
while ( *src )
{
char c = *src++;
if ( c == '\r' || c == '\n' ) break;
if ( c == '\\' )
{
c = *src++;
switch ( c )
{
case 'b': c = '\b'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'v': c = '\v'; break;
}
}
*dst++ = c;
}
*dst = '\0';
if ( (err = OskitTCPSend ( conn, (OSK_PCHAR)p, strlen(p), (OSK_UINT*)&bytin, 0 ))
!= 0 ) {
fprintf ( stderr, "OskitTCPConnect: error %d\n", err );
} else {
printf ( "wrote %d bytes\n", bytin );
}
} else if( word == "send" ) {
off = 0;
while( cmdin >> word ) {
datagram[off++] =
atoi( (std::string("0x") + word).c_str() );
}
if( (err = OskitTCPSend( conn, (OSK_PCHAR)datagram,
off, (OSK_UINT *)&bytin, 0 ))
!= 0 ) {
fprintf( stderr, "OskitTCPConnect: error %d\n", err );
} else {
printf( "wrote %d bytes\n", bytin );
}
} else if( word == "close" ) {
OskitTCPClose( conn );
conn = NULL;
}
} else if( dgrecv > 14 ) {
addr_to = addr_from;
if( datagram[12] == 8 && datagram[13] == 6 ) {
/* Answer arp query */
char laddr[4];
/* Mark patch as to the previous sender */
memcpy( datagram + 32, datagram + 6, 6 );
memcpy( datagram, datagram + 6, 6 );
/* Mark packet as from us */
memcpy( datagram + 22, hwaddr, 6 );
memcpy( datagram + 6, hwaddr, 6 );
/* Swap inet addresses */
memcpy( laddr, datagram + 28, 4 );
memcpy( datagram + 28, datagram + 38, 4 );
memcpy( datagram + 38, laddr, 4 );
/* Set reply opcode */
datagram[21] = 2;
err = sendto( asock, datagram, dgrecv, 0,
(struct sockaddr *)&addr_to,
sizeof(addr_to) );
if( err != 0 )
printf( "sendto: %d\n", err );
} else {
memcpy( hdr, datagram + 6, 6 );
memcpy( hdr + 6, datagram, 6 );
memcpy( hdr + 12, datagram + 12, 2 );
OskitTCPReceiveDatagram
( (unsigned char *)datagram + 14,
dgrecv - 14, 20 );
}
}
}
TimerOskitTCP();
for( i = output_packets.begin(); i != output_packets.end(); i++ ) {
err = sendto( asock, i->c_str(), i->size(), 0,
(struct sockaddr *)&addr_to, sizeof(addr_to) );
fprintf( stderr, "** SENDING PACKET %d bytes **\n", i->size() );
if( err != 0 )
printf( "sendto: %d\n", err );
}
output_packets.clear();
}
}

View file

@ -0,0 +1,434 @@
# Microsoft Developer Studio Project File - Name="tcptest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=tcptest - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "tcptest.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "tcptest.mak" CFG="tcptest - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "tcptest - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "tcptest - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "tcptest - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "tcptest - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../drivers/lib/oskittcp/include" /I "../../../drivers\lib\oskittcp\include\freebsd\src\sys" /I "../../../drivers\lib\oskittcp\include\freebsd\dev\include" /I "../../../drivers\lib\oskittcp\include\freebsd\net\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "KERNEL" /D __REACTOS__=1 /D "FREEZAP" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "tcptest - Win32 Release"
# Name "tcptest - Win32 Debug"
# Begin Group "tcptest"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\tcptest.cpp
!IF "$(CFG)" == "tcptest - Win32 Release"
!ELSEIF "$(CFG)" == "tcptest - Win32 Debug"
# SUBTRACT CPP /D "KERNEL"
!ENDIF
# End Source File
# End Group
# Begin Group "oskittcp"
# PROP Default_Filter ""
# Begin Group "src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\defaults.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\in.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\in_cksum.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\in_pcb.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\in_proto.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\in_rmx.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\inet_ntoa.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\interface.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\ip_input.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\ip_output.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\kern_clock.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\kern_subr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\param.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\radix.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\random.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\raw_cb.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\raw_ip.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\raw_usrreq.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\route.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\rtsock.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\scanc.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\sleep.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_debug.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_input.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_output.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_subr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_timer.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\tcp_usrreq.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\uipc_domain.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\uipc_mbuf.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\uipc_socket.c
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\oskittcp\uipc_socket2.c
# End Source File
# End Group
# Begin Group "include"
# PROP Default_Filter ""
# Begin Group "freebsd"
# PROP Default_Filter ""
# Begin Group "src No. 1"
# PROP Default_Filter ""
# Begin Group "sys"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\buf.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\callout.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\cdefs.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\domain.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\errno.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\fcntl.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\file.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\filedesc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\filio.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\ioccom.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\ioctl.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\kernel.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\libkern.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\malloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\mbuf.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\param.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\proc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\protosw.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\queue.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\resource.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\resourcevar.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\rtprio.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\select.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\signal.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\signalvar.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\socket.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\socketvar.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\sockio.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\stat.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\sysctl.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\syslimits.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\syslog.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\systm.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\time.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\ttycom.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\types.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\ucred.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\uio.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\freebsd\src\sys\sys\unistd.h
# End Source File
# End Group
# End Group
# End Group
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\memtrack.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\oskitdebug.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\oskiterrno.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\oskitfreebsd.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\oskittcp.h
# End Source File
# Begin Source File
SOURCE=..\..\..\drivers\lib\oskittcp\include\oskittypes.h
# End Source File
# End Group
# End Group
# End Target
# End Project

View file

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "tcptest"=.\tcptest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: makefile,v 1.1 2004/10/21 04:59:00 sedwards Exp $
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = p_dup_handle
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,69 @@
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
/* This tests the ability of the target win32 to duplicate a process handle,
* spawn a child, and have the child dup it's own handle back into the parent
* using the duplicated handle.
*/
int main( int argc, char **argv ) {
HANDLE h_process;
HANDLE h_process_in_parent;
fprintf( stderr, "%lu: Starting\n", GetCurrentProcessId() );
if( argc == 2 ) {
h_process = (HANDLE)atoi(argv[1]);
} else {
if( !DuplicateHandle( GetCurrentProcess(),
GetCurrentProcess(),
GetCurrentProcess(),
&h_process,
0,
TRUE,
DUPLICATE_SAME_ACCESS) ) {
fprintf( stderr, "%lu: Could not duplicate my own process handle.\n",
GetCurrentProcessId() );
return 101;
}
}
if( argc == 1 ) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
char cmdline[1000];
memset( &si, 0, sizeof( si ) );
memset( &pi, 0, sizeof( pi ) );
sprintf( cmdline, "%s %lu", argv[0], (DWORD)h_process );
if( !CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL,
&si, &pi ) ) {
fprintf( stderr, "%lu: Could not create child process.\n",
GetCurrentProcessId() );
return 5;
}
if( WaitForSingleObject( pi.hThread, INFINITE ) != WAIT_OBJECT_0 ) {
fprintf( stderr, "%lu: Failed to wait for child process to terminate.\n",
GetCurrentProcessId() );
return 6;
}
} else {
if( !DuplicateHandle( GetCurrentProcess(),
GetCurrentProcess(),
h_process,
&h_process_in_parent,
0,
TRUE,
DUPLICATE_SAME_ACCESS) ) {
fprintf( stderr, "%lu: Could not duplicate my handle into the parent.\n",
GetCurrentProcessId() );
return 102;
}
}
return 0;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,21 @@
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = palbitblt
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = pal.o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,201 @@
/* The idea of this test app is inspired from tutorial *
* found at http://www.theparticle.com/pgraph.html *
* *
* Developed by: Aleksey Bragin <aleksey@studiocerebral.com> *
* Version: 1.0 */
#include <windows.h>
#include <stdlib.h>
#define W_WIDTH 320
#define W_HEIGHT 240
// special version of BITMAPINFO and LOGPALETTE for max of 256 palette entries
typedef struct
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
} BITMAPINFO256;
typedef struct {
WORD palVersion;
WORD palNumEntries;
PALETTEENTRY palPalEntry[256];
} LOGPALETTE256;
// The only global variable --- contents of the DIBitmap
BYTE* dibits;
void GeneratePalette(RGBQUAD* p)
{
int i;
for(i=0;i<256;i++)
{
p[i].rgbRed = i;
p[i].rgbGreen = i;
p[i].rgbBlue = i;
p[i].rgbReserved = 0;
}
}
void DoBlt(HBITMAP hBM)
{
HDC hDC,Context;
HWND ActiveWindow;
RECT dest;
HBITMAP dflBmp;
if((ActiveWindow = GetActiveWindow()) == NULL)
return;
hDC = GetDC(ActiveWindow);
GetClientRect(ActiveWindow,&dest);
Context = CreateCompatibleDC(0);
dflBmp = SelectObject(Context, hBM);
BitBlt(hDC, 0, 0, dest.right, dest.bottom, Context, 0, 0, SRCCOPY);
SelectObject(Context, dflBmp);
DeleteDC(Context);
DeleteObject(dflBmp);
ReleaseDC(ActiveWindow, hDC);
}
void UpdatePalette(HBITMAP hBM){
int i,y;
static unsigned int c=0;
for(i=0;i<W_WIDTH;i++){
for(y=0;y<=W_HEIGHT-1;y++)
dibits[y*320+i] = c % 256;
if (c > 512)
c = 0;
else
c++; // It's operation of incrementing of c variable, not reference of a cool OO language :-)
}
DoBlt(hBM);
}
void InitBitmap(HANDLE *hBM){
HPALETTE PalHan;
HWND ActiveWindow;
HDC hDC;
RGBQUAD palette[256];
int i;
BITMAPINFO256 bmInf;
LOGPALETTE256 palInf;
ActiveWindow = GetActiveWindow();
hDC = GetDC(ActiveWindow);
bmInf.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInf.bmiHeader.biWidth = W_WIDTH;
bmInf.bmiHeader.biHeight = -abs(W_HEIGHT);
bmInf.bmiHeader.biPlanes = 1;
bmInf.bmiHeader.biBitCount = 8;
bmInf.bmiHeader.biCompression = BI_RGB;
bmInf.bmiHeader.biSizeImage = 0;
bmInf.bmiHeader.biXPelsPerMeter = 0;
bmInf.bmiHeader.biYPelsPerMeter = 0;
bmInf.bmiHeader.biClrUsed = 256;
bmInf.bmiHeader.biClrImportant = 256;
GeneratePalette(palette);
for(i=0;i<256;i++)
bmInf.bmiColors[i] = palette[i];
palInf.palVersion = 0x300;
palInf.palNumEntries = 256;
for(i=0;i<256;i++){
palInf.palPalEntry[i].peRed = palette[i].rgbRed;
palInf.palPalEntry[i].peGreen = palette[i].rgbGreen;
palInf.palPalEntry[i].peBlue = palette[i].rgbBlue;
palInf.palPalEntry[i].peFlags = PC_NOCOLLAPSE;
}
// Create palette
PalHan = CreatePalette((LOGPALETTE*)&palInf);
// Select it into hDC
SelectPalette(hDC,PalHan,FALSE);
// Realize palette in hDC
RealizePalette(hDC);
// Delete handle to palette
DeleteObject(PalHan);
// Create dib section
*hBM = CreateDIBSection(hDC,(BITMAPINFO*)&bmInf,
DIB_RGB_COLORS,(void**)&dibits,0,0);
// Release dc
ReleaseDC(ActiveWindow,hDC);
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT msg, WPARAM wParam,LPARAM lParam)
{
switch(msg){
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd,msg,wParam,lParam);
}
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpszCmdParam,int nCmdShow)
{
WNDCLASS WndClass;
HWND hWnd;
MSG msg;
char szName[] = "Palette BitBlt test";
BOOL exit = FALSE;
HBITMAP hBM;
// Create and register window class (not modified!!!!!!!!!!!1)
WndClass.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = NULL;//GetStockObject(BLACK_BRUSH);
WndClass.hIcon = NULL;//LoadIcon(hInstance,NULL);
WndClass.hCursor = NULL;//LoadCursor(NULL,IDC_ARROW);
WndClass.hInstance = hInstance;
WndClass.lpszClassName = szName;
WndClass.lpszMenuName = 0;
RegisterClass(&WndClass);
// Create and show window (change styles !!!!!!!!)
hWnd = CreateWindow(szName, "ReactOS palette bitblt test",
WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,
CW_USEDEFAULT,CW_USEDEFAULT,W_WIDTH,W_HEIGHT,
0,0,hInstance,0);
ShowWindow(hWnd,nCmdShow);
// Prepare bitmap to be bitblt
InitBitmap(&hBM);
// Main message loop
while (!exit)
{
UpdatePalette(hBM);
Sleep(200);
if(PeekMessage(&msg,0,0,0,PM_NOREMOVE) == TRUE)
{
if (!GetMessage(&msg,0,0,0))
exit = TRUE;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,45 @@
// main.c :
//
#include <windows.h>
#include <stdio.h>
#include "regdump.h"
HANDLE OutputHandle;
HANDLE InputHandle;
DWORD GetInput(char* Buffer, int buflen)
{
DWORD Result;
ReadConsoleA(InputHandle, Buffer, buflen, &Result, NULL);
return Result;
}
int __cdecl main(int argc, char* argv[])
{
//AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
//return regmain(argc, argv);
return regdump(argc, argv);
}
#ifndef __GNUC__
//__declspec(dllimport) int __stdcall DllMain(void* hinstDll, unsigned long dwReason, void* reserved);
char* args[] = { "regdump.exe", "0", "ansi", "verbose"};
int __cdecl mainCRTStartup(void)
{
//DllMain(NULL, DLL_PROCESS_ATTACH, NULL);
main(1, args);
return 0;
}
#endif /*__GNUC__*/

View file

@ -0,0 +1,27 @@
#
# $Id: makefile,v 1.0
PATH_TO_TOP = ../../../reactos
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = regdump
#TARGET_CFLAGS = -DWIN32_REGDBG -DUNICODE -D_UNICODE
TARGET_CFLAGS = -DWIN32_REGDBG
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
TARGET_OBJECTS = $(TARGET_NAME).o regcmds.o regproc.o main.o
TARGET_CFLAGS = -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,224 @@
/* $Id: regcmds.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
*
* ReactOS regedit
*
* regcmds.c
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* Original Work Copyright 2002 Andriy Palamarchuk
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#ifdef WIN32_REGDBG
#else
#include <ctype.h>
#endif
#include "regproc.h"
////////////////////////////////////////////////////////////////////////////////
// Global Variables:
//
static char *usage =
"Usage:\n"
" regedit filename\n"
" regedit /E filename [regpath]\n"
" regedit /D regpath\n"
"\n"
"filename - registry file name\n"
"regpath - name of the registry key\n"
"\n"
"When is called without any switches adds contents of the specified\n"
"registry file to the registry\n"
"\n"
"Switches:\n"
" /E - exports contents of the specified registry key to the specified\n"
" file. Exports the whole registry if no key is specified.\n"
" /D - deletes specified registry key\n"
" /S - silent execution, can be used with any other switch.\n"
" The only existing mode, exists for compatibility with Windows regedit.\n"
" /V - advanced mode, can be used with any other switch.\n"
" Ignored, exists for compatibility with Windows regedit.\n"
" /L - location of system.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n"
" /R - location of user.dat file. Can be used with any other switch.\n"
" Ignored. Exists for compatibility with Windows regedit.\n"
" /? - print this help. Any other switches are ignored.\n"
" /C - create registry from. Not implemented.\n"
"\n"
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
"This program is command-line compatible with Microsoft Windows\n"
"regedit. The difference with Windows regedit - this application has\n"
"command-line interface only.\n";
typedef enum {
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE, ACTION_VIEW
} REGEDIT_ACTION;
/**
* Process unknown switch.
*
* Params:
* chu - the switch character in upper-case.
* s - the command line string where s points to the switch character.
*/
void error_unknown_switch(char chu, char *s)
{
if (isalpha(chu)) {
printf("Undefined switch /%c!\n", chu);
} else {
printf("Alphabetic character is expected after '%c' "
"in switch specification\n", *(s - 1));
}
//exit(1);
}
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
{
TCHAR filename[MAX_PATH];
TCHAR reg_key_name[KEY_MAX_LEN];
switch (action) {
case ACTION_ADD:
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
while (filename[0]) {
if (!import_registry_file(filename)) {
perror("");
printf("Can't open file \"%s\"\n", filename);
return FALSE;
//exit(1);
}
get_file_name(&s, filename, MAX_PATH);
}
break;
case ACTION_DELETE:
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
if (!reg_key_name[0]) {
printf("No registry key is specified for removal\n%s", usage);
return FALSE;
//exit(1);
}
delete_registry_key(reg_key_name);
break;
case ACTION_EXPORT:
filename[0] = '\0';
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
if (s[0]) {
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
break;
default:
printf("Unhandled action!\n");
return FALSE;
}
return TRUE;
}
BOOL ProcessCmdLine(LPSTR lpCmdLine)
{
REGEDIT_ACTION action = ACTION_UNDEF;
LPSTR s = lpCmdLine; /* command line pointer */
CHAR ch = *s; /* current character */
while (ch && ((ch == '-') || (ch == '/'))) {
char chu;
char ch2;
s++;
ch = *s;
ch2 = *(s+1);
chu = toupper(ch);
if (!ch2 || isspace(ch2)) {
if (chu == 'S' || chu == 'V') {
/* ignore these switches */
} else {
switch (chu) {
case 'D':
action = ACTION_DELETE;
break;
case 'E':
action = ACTION_EXPORT;
break;
case 'V':
action = ACTION_VIEW;
break;
case '?':
printf(usage);
return FALSE;
//exit(0);
break;
default:
error_unknown_switch(chu, s);
return FALSE;
break;
}
}
s++;
} else {
if (ch2 == ':') {
switch (chu) {
case 'L':
/* fall through */
case 'R':
s += 2;
while (*s && !isspace(*s)) {
s++;
}
break;
default:
error_unknown_switch(chu, s);
return FALSE;
break;
}
} else {
/* this is a file name, starting from '/' */
s--;
break;
}
}
/* skip spaces to the next parameter */
ch = *s;
while (ch && isspace(ch)) {
s++;
ch = *s;
}
}
if (action == ACTION_UNDEF) {
action = ACTION_ADD;
}
return PerformRegAction(action, s);
}

View file

@ -0,0 +1,167 @@
/* $Id: regdump.c,v 1.1 2004/10/21 04:59:00 sedwards Exp $
*
* ReactOS regedit
*
* regdump.c
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "regdump.h"
#ifdef UNICODE
//#define dprintf _tprintf
#define dprintf printf
#else
#define dprintf printf
#endif
void RegKeyPrint(int which);
const char* default_cmd_line1 = "/E HKLM_EXPORT.TXT HKEY_LOCAL_MACHINE";
const char* default_cmd_line2 = "TEST_IMPORT.TXT";
const char* default_cmd_line3 = "/P HKEY_LOCAL_MACHINE\\SYSTEM";
const char* default_cmd_line4 = "/P HKEY_LOCAL_MACHINE\\SOFTWARE";
const char* default_cmd_line5 = "/P HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
const char* default_cmd_line6 = "/E HKCR_EXPORT.TXT HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
const char* default_cmd_line7 = "/D HKEY_LOCAL_MACHINE\\SYSTEM";
const char* default_cmd_line8 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
const char* default_cmd_line9 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
/* Show usage */
void usage(const char* appName)
{
fprintf(stderr, "%s: Dump registry key to console\n", appName);
fprintf(stderr, "%s HKCR | HKCU | HKLM | HKU | HKCC | HKRR\n", appName);
}
void show_menu(void)
{
_tprintf(_T("\nchoose test :\n"));
_tprintf(_T(" 0 = Exit\n"));
printf(" 1 = %s\n", default_cmd_line1);
printf(" 2 = %s\n", default_cmd_line2);
printf(" 3 = %s\n", default_cmd_line3);
printf(" 4 = %s\n", default_cmd_line4);
printf(" 5 = %s\n", default_cmd_line5);
printf(" 6 = %s\n", default_cmd_line6);
printf(" 7 = %s\n", default_cmd_line7);
printf(" 8 = %s\n", default_cmd_line8);
printf(" 9 = %s\n", default_cmd_line9);
/*
_tprintf(_T(" 1 = %s\n"), default_cmd_line1);
_tprintf(_T(" 2 = %s\n"), default_cmd_line2);
_tprintf(_T(" 3 = %s\n"), default_cmd_line3);
_tprintf(_T(" 4 = %s\n"), default_cmd_line4);
_tprintf(_T(" 5 = %s\n"), default_cmd_line5);
_tprintf(_T(" 6 = %s\n"), default_cmd_line6);
_tprintf(_T(" 7 = %s\n"), default_cmd_line7);
_tprintf(_T(" 8 = %s\n"), default_cmd_line8);
_tprintf(_T(" 9 = %s\n"), default_cmd_line9);
*/
// _tprintf(_T(" A = HKEY_CLASSES_ROOT\n"));
// _tprintf(_T(" B = HKEY_CURRENT_USER\n"));
// _tprintf(_T(" C = HKEY_LOCAL_MACHINE\n"));
// _tprintf(_T(" D = HKEY_USERS\n"));
// _tprintf(_T(" E = HKEY_CURRENT_CONFIG\n"));
// _tprintf(_T(" F = REGISTRY ROOT\n"));
}
int regdump(int argc, char* argv[])
{
char Buffer[500];
if (argc > 1) {
// if (0 == _tcsstr(argv[1], _T("HKLM"))) {
if (strstr(argv[1], "help")) {
usage(argv[0]);
} else if (strstr(argv[1], "HKCR")) {
RegKeyPrint('1');
} else if (strstr(argv[1], "HKCU")) {
RegKeyPrint('2');
} else if (strstr(argv[1], "HKLM")) {
RegKeyPrint('3');
} else if (strstr(argv[1], "HKU")) {
RegKeyPrint('4');
} else if (strstr(argv[1], "HKCC")) {
RegKeyPrint('5');
} else if (strstr(argv[1], "HKRR")) {
RegKeyPrint('6');
} else {
dprintf("started with argc = %d, argv[1] = %s (unknown?)\n", argc, argv[1]);
}
return 0;
}
show_menu();
while (1) {
GetInput(Buffer, sizeof(Buffer));
switch (toupper(Buffer[0])) {
case '0':
return(0);
case '1':
strcpy(Buffer, default_cmd_line1);
goto doit;
case '2':
strcpy(Buffer, default_cmd_line2);
goto doit;
case '3':
strcpy(Buffer, default_cmd_line3);
goto doit;
case '4':
strcpy(Buffer, default_cmd_line4);
goto doit;
case '5':
strcpy(Buffer, default_cmd_line5);
goto doit;
case '6':
strcpy(Buffer, default_cmd_line6);
goto doit;
case '7':
strcpy(Buffer, default_cmd_line7);
goto doit;
case '8':
strcpy(Buffer, default_cmd_line8);
goto doit;
case '9':
strcpy(Buffer, default_cmd_line9);
goto doit;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
RegKeyPrint(toupper(Buffer[0]) - 'A' + 1);
break;
default: doit:
if (!ProcessCmdLine(Buffer)) {
dprintf("invalid input.\n");
show_menu();
} else {
dprintf("done.\n");
}
break;
}
}
return 0;
}

View file

@ -0,0 +1,44 @@
/*
* ReactOS
*
* regdump.h
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __REGDUMP_H__
#define __REGDUMP_H__
#ifdef __cplusplus
extern "C" {
#endif
extern HANDLE OutputHandle;
extern HANDLE InputHandle;
DWORD GetInput(char* Buffer, int buflen);
//void dprintf(char* fmt, ...);
int regdump(int argc, char* argv[]);
BOOL ProcessCmdLine(LPSTR lpCmdLine);
#ifdef __cplusplus
};
#endif
#endif // __REGDUMP_H__

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,110 @@
/*
* Copyright 1999 Sylvain St-Germain
* Copyright 2002 Andriy Palamarchuk
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/******************************************************************************
* Defines and consts
*/
#define KEY_MAX_LEN 1024
/* Return values */
#define SUCCESS 0
#define KEY_VALUE_ALREADY_SET 2
typedef void (*CommandAPI)(LPTSTR lpsLine);
void doSetValue(LPTSTR lpsLine);
void doDeleteValue(LPTSTR lpsLine);
void doCreateKey(LPTSTR lpsLine);
void doDeleteKey(LPTSTR lpsLine);
void doQueryValue(LPTSTR lpsLine);
void doRegisterDLL(LPTSTR lpsLine);
void doUnregisterDLL(LPTSTR lpsLine);
BOOL export_registry_key(TCHAR* file_name, TCHAR* reg_key_name);
BOOL import_registry_file(LPTSTR filename);
void delete_registry_key(TCHAR* reg_key_name);
void processRegLines(FILE* in, CommandAPI command);
/*
* Generic prototypes
*/
#ifdef _UNICODE
#define get_file_name get_file_nameW
#else
#define get_file_name get_file_nameA
#endif
char* getToken(char** str, const char* delims);
void get_file_nameA(CHAR** command_line, CHAR* filename, int max_filename);
void get_file_nameW(CHAR** command_line, WCHAR* filename, int max_filename);
DWORD convertHexToDWord(TCHAR* str, BYTE* buf);
DWORD convertHexCSVToHex(TCHAR* str, BYTE* buf, ULONG bufLen);
LPTSTR convertHexToHexCSV(BYTE* buf, ULONG len);
LPTSTR convertHexToDWORDStr(BYTE* buf, ULONG len);
LPTSTR getRegKeyName(LPTSTR lpLine);
HKEY getRegClass(LPTSTR lpLine);
DWORD getDataType(LPTSTR* lpValue, DWORD* parse_type);
LPTSTR getArg(LPTSTR arg);
HRESULT openKey(LPTSTR stdInput);
void closeKey(VOID);
/*
* api setValue prototypes
*/
void processSetValue(LPTSTR cmdline);
HRESULT setValue(LPTSTR val_name, LPTSTR val_data);
/*
* api queryValue prototypes
*/
void processQueryValue(LPTSTR cmdline);
#ifdef __GNUC__
#ifdef WIN32_REGDBG
//typedef UINT_PTR SIZE_T, *PSIZE_T;
//#define _MAX_PATH 260 /* max. length of full pathname */
#endif /*WIN32_REGDBG*/
#ifdef UNICODE
#define _tfopen _wfopen
#else
#define _tfopen fopen
#endif
#endif /*__GNUC__*/
LPVOID RegHeapAlloc(
HANDLE hHeap, // handle to private heap block
DWORD dwFlags, // heap allocation control
SIZE_T dwBytes // number of bytes to allocate
);
LPVOID RegHeapReAlloc(
HANDLE hHeap, // handle to heap block
DWORD dwFlags, // heap reallocation options
LPVOID lpMem, // pointer to memory to reallocate
SIZE_T dwBytes // number of bytes to reallocate
);
BOOL RegHeapFree(
HANDLE hHeap, // handle to heap
DWORD dwFlags, // heap free options
LPVOID lpMem // pointer to memory
);

View file

@ -0,0 +1,7 @@
*.o
*.d
*.a
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,54 @@
#
#
#
PATH_TO_TOP = ../../../reactos
include $(PATH_TO_TOP)/config
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS= shmsrv.o
CLT_OBJECTS= shmclt.o
PROGS= shmsrv.exe shmclt.exe
CFLAGS = $(STD_CFLAGS)
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
ifneq ($(BOOTCD_INSTALL),)
install: $(PROGS:%=$(INSTALL_DIR)/%)
$(PROGS:%=$(INSTALL_DIR)/%): $(INSTALL_DIR)/%: %
$(CP) $* $(INSTALL_DIR)/$*
else # BOOTCD_INSTALL
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
endif # BOOTCD_INSTALL
shmsrv.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o shmsrv.exe
$(NM) --numeric-sort shmsrv.exe > shmsrv.sym
shmclt.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o shmclt.exe
$(NM) --numeric-sort shmsrv.exe > shmclt.sym
# EOF

View file

@ -0,0 +1,61 @@
#include <ddk/ntddk.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int
main(int argc, char* argv[])
{
HANDLE Section;
PVOID BaseAddress;
char buffer[256];
printf("Shm test server\n");
Section = OpenFileMappingW (
// PAGE_EXECUTE_READWRITE, invalid parameter
FILE_MAP_WRITE,
FALSE,
L"TestSection"
);
if (Section == NULL)
{
printf("Failed to open section (err=%d)", GetLastError());
return 1;
}
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
0,
8192);
if (BaseAddress == NULL)
{
printf("Failed to map section (err=%d)\n", GetLastError());
return 1;
}
printf("BaseAddress %x\n", (UINT) BaseAddress);
printf("Copying from section\n");
strcpy(buffer, BaseAddress);
printf("Copyed <%s>\n", buffer);
// for(;;);
return 0;
}

View file

@ -0,0 +1,53 @@
/* $Id: shmsrv.c,v 1.1 2004/10/21 04:59:01 sedwards Exp $
*
* FILE : reactos/apps/shm/shmsrv.c
* AUTHOR: David Welch
*/
#include <ddk/ntddk.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
HANDLE Section;
PVOID BaseAddress;
printf("Shm test server\n");
Section = CreateFileMappingW (
(HANDLE) 0xFFFFFFFF,
NULL,
PAGE_READWRITE,
0,
8192,
L"TestSection"
);
if (Section == NULL)
{
printf("Failed to create section (err=%d)", GetLastError());
return 1;
}
printf("Mapping view of section\n");
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
0,
8192);
printf("BaseAddress %x\n", (UINT) BaseAddress);
if (BaseAddress == NULL)
{
printf("Failed to map section\n");
}
printf("Copying to section\n");
printf("Copying %s\n", GetCommandLineA());
strcpy(BaseAddress, GetCommandLineA());
Sleep(INFINITE);
return 0;
}