mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 05:05:09 +00:00
Thats it. the tests are now in rosapps.
svn path=/trunk/; revision=11372
This commit is contained in:
parent
2ecd28627f
commit
4cd92d7bd7
|
@ -1,79 +0,0 @@
|
|||
#
|
||||
# ReactOS test applications makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
# test_old tests
|
||||
TEST_APPS = accelerator alive alphablend apc args atomtest bench bitblt button \
|
||||
button2 capclock carets combo consume copymove count dibtest dump_shared_data \
|
||||
edit enumwnd enumws event global_mem gradient hello mdi \
|
||||
hivetest icontest isotest lineclip linetest lpc \
|
||||
mktime mstest multithrdwin multiwin mutex nptest patblt primitives pteb \
|
||||
regtest sectest sertest shaptest shm statst statst2 stretchblt suspend \
|
||||
tcpsvr terminate txtscale thread thread_msg tokentest user32 vmtest \
|
||||
winhello wm_erasebkgnd wm_paint eventpair threadwait popupmenu \
|
||||
map_dup_inherit p_dup_handle apc2 enhmetafile dirdlg guithreadinfo fiber
|
||||
# Build failure:
|
||||
# kernel32
|
||||
|
||||
TEST_MISC =
|
||||
|
||||
all: $(TEST_APPS) $(TEST_MISC)
|
||||
|
||||
depends:
|
||||
|
||||
implib: $(TEST_APPS:%=%_implib) \
|
||||
$(TEST_MISC:%=%_implib)
|
||||
|
||||
clean: $(TEST_APPS:%=%_clean) \
|
||||
$(TEST_MISC:%=%_clean)
|
||||
|
||||
install: $(TEST_APPS:%=%_install) \
|
||||
$(TEST_MISC:%=%_install)
|
||||
|
||||
.PHONY: all depends implib clean install
|
||||
|
||||
|
||||
#
|
||||
# Test Applications
|
||||
#
|
||||
$(TEST_APPS): %:
|
||||
$(MAKE) -C $*
|
||||
|
||||
$(TEST_APPS:%=%_implib): %_implib:
|
||||
$(MAKE) -C $* implib
|
||||
|
||||
$(TEST_APPS:%=%_clean): %_clean:
|
||||
$(MAKE) -C $* clean
|
||||
|
||||
$(TEST_APPS:%=%_install): %_install:
|
||||
$(MAKE) -C $* install
|
||||
|
||||
.PHONY: $(TEST_APPS) $(TEST_APPS:%=%_implib) $(TEST_APPS:%=%_clean) $(TEST_APPS:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# Misc Test Applications
|
||||
#
|
||||
$(TEST_MISC): %:
|
||||
$(MAKE) -C tests/$*
|
||||
|
||||
$(TEST_MISC:%=%_implib): %_implib:
|
||||
$(MAKE) -C tests/$* implib
|
||||
|
||||
$(TEST_MISC:%=%_clean): %_clean:
|
||||
$(MAKE) -C tests/$* clean
|
||||
|
||||
$(TEST_MISC:%=%_install): %_install:
|
||||
$(MAKE) -C tests/$* install
|
||||
|
||||
.PHONY: $(TEST_MISC) $(TEST_MISC:%=%_implib) $(TEST_MISC:%=%_clean) $(TEST_MISC:%=%_install)
|
||||
|
||||
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,166 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.exe
|
||||
*.sym
|
||||
*.coff
|
||||
*.d
|
||||
*.o
|
||||
*.map
|
|
@ -1,181 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.exe
|
||||
*.sym
|
||||
*.coff
|
||||
*.d
|
||||
*.o
|
||||
*.map
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,205 +0,0 @@
|
|||
/* $Id: conport.c,v 1.6 2000/04/25 23:22:46 ea 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 */
|
|
@ -1,192 +0,0 @@
|
|||
/* $Id: creport.c,v 1.2 1999/07/17 23:10:12 ea 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 */
|
|
@ -1,239 +0,0 @@
|
|||
/* $Id: dumpinfo.c,v 1.2 1999/07/17 23:10:12 ea 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 */
|
|
@ -1,8 +0,0 @@
|
|||
VOID
|
||||
DumpInfo (
|
||||
LPCWSTR Name,
|
||||
NTSTATUS Status,
|
||||
LPCWSTR Comment,
|
||||
HANDLE Port
|
||||
);
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* $Id: lpcclt.c,v 1.14 2004/01/06 16:07:21 ekohl 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;
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
/* $Id: lpcsrv.c,v 1.14 2004/01/06 16:07:21 ekohl 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 */
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _LPCTEST_H
|
||||
#define _LPCTEST_H
|
||||
#define TEST_PORT_NAME "\\TestPort"
|
||||
#define TEST_PORT_NAME_U L"\\TestPort"
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,91 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.3 2004/09/22 22:25:12 sedwards Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,523 +0,0 @@
|
|||
/*
|
||||
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;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#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
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
//{{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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,52 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#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
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:17 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = mktime
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
struct tm time_str;
|
||||
|
||||
char daybuf[20];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Testing mktime() by asking\n");
|
||||
printf("What day of the week is July 4, 2001?\n");
|
||||
|
||||
time_str.tm_year = 2001 - 1900;
|
||||
time_str.tm_mon = 7 - 1;
|
||||
time_str.tm_mday = 4;
|
||||
time_str.tm_hour = 0;
|
||||
time_str.tm_min = 0;
|
||||
time_str.tm_sec = 1;
|
||||
time_str.tm_isdst = -1;
|
||||
if (mktime(&time_str) == -1)
|
||||
(void)puts("-unknown-");
|
||||
else {
|
||||
(void)strftime(daybuf, sizeof(daybuf), "%A", &time_str);
|
||||
(void)puts(daybuf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,250 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,46 +0,0 @@
|
|||
#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 */
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
|
||||
#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 */
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2004/03/11 14:44:48 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,236 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:18 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,147 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.3 2003/11/14 17:13:18 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,122 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,32 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.1 2004/09/26 17:00:15 hbirr Exp $
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* $Id: noexecute.c,v 1.1 2004/09/26 17:00:15 hbirr 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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,100 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
#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);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
*.d
|
||||
*.exe
|
||||
*.map
|
||||
*.ncb
|
||||
*.opt
|
||||
*.plg
|
||||
*.sym
|
||||
Debug
|
||||
Release
|
|
@ -1,10 +0,0 @@
|
|||
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)
|
|
@ -1,28 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.5 2004/09/21 04:06:15 arty Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,380 +0,0 @@
|
|||
#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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,434 +0,0 @@
|
|||
# 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
|
|
@ -1,29 +0,0 @@
|
|||
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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:18 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,69 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,201 +0,0 @@
|
|||
/* 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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
Binary file not shown.
Before Width: | Height: | Size: 104 KiB |
|
@ -1,31 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = patblt
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_CFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -Werror -Wall
|
||||
|
||||
TARGET_CPPFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -Wall -Werror
|
||||
|
||||
TARGET_SDKLIBS = \
|
||||
kernel32.a \
|
||||
user32.a \
|
||||
gdi32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
patblt.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# overide LD_CC to use g++ for linking of the executable
|
||||
LD_CC = $(CXX)
|
||||
|
||||
# EOF
|
|
@ -1,270 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 2 - Listing 2.1 (PatBlt Tracking Rect Demo)
|
||||
//
|
||||
// Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
// Updates can be downloaded at: <www.coriolis.com>
|
||||
//
|
||||
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
// if you have any questions about this code.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#include <windows.h>
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
HINSTANCE HInst;
|
||||
const char* WndClassName = "GMainWnd";
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam);
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE, LPTSTR,
|
||||
int nCmdShow)
|
||||
{
|
||||
HInst = HInstance;
|
||||
|
||||
WNDCLASS wc;
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.lpszClassName = WndClassName;
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.hInstance = HInstance;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = static_cast<HBRUSH>(
|
||||
GetStockObject(BLACK_BRUSH)
|
||||
);
|
||||
|
||||
if (RegisterClass(&wc))
|
||||
{
|
||||
HWND HWnd =
|
||||
CreateWindow(WndClassName,
|
||||
TEXT("PatBlt Tracking Rect Demo"),
|
||||
WS_OVERLAPPEDWINDOW | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
|
||||
NULL, NULL, HInst, NULL);
|
||||
|
||||
if (HWnd)
|
||||
{
|
||||
ShowWindow(HWnd, nCmdShow);
|
||||
UpdateWindow(HWnd);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// image related
|
||||
HDC HMemDC = NULL;
|
||||
HBITMAP HOldBmp = NULL;
|
||||
const char* filename = "PENGUIN.BMP";
|
||||
RECT RImage = {225, 110, 225, 110};
|
||||
|
||||
// tracking related
|
||||
bool is_tracking = false;
|
||||
HDC HScreenDC = NULL;
|
||||
POINT PMouse = {0, 0};
|
||||
RECT RTrack = {0, 0, 0, 0};
|
||||
const int line_width = 5;
|
||||
|
||||
|
||||
// utility function to map to/from window coordinates
|
||||
void MapRect(IN HWND HWndFrom, IN HWND HWndTo, IN OUT RECT& RMap)
|
||||
{
|
||||
MapWindowPoints(
|
||||
HWndFrom, HWndTo,
|
||||
reinterpret_cast<LPPOINT>(&RMap), 2
|
||||
);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// utility function that uses the PatBlt function to
|
||||
// render a tracking rectangle
|
||||
void RenderTrackingRect(IN HDC HDestDC, IN const RECT& RRender)
|
||||
{
|
||||
const int width = RRender.right - RRender.left;
|
||||
const int height = RRender.bottom - RRender.top;
|
||||
const DWORD dwROP3 = DSTINVERT; // experiment with others
|
||||
|
||||
// render top bar
|
||||
PatBlt(HDestDC,
|
||||
RRender.left, RRender.top,
|
||||
width, line_width,
|
||||
dwROP3);
|
||||
// render bottom bar
|
||||
PatBlt(HDestDC,
|
||||
RRender.left, RRender.bottom - line_width,
|
||||
width, line_width,
|
||||
dwROP3);
|
||||
// render left bar
|
||||
PatBlt(HDestDC,
|
||||
RRender.left, RRender.top + line_width,
|
||||
line_width, height - (2 * line_width),
|
||||
dwROP3);
|
||||
// render right bar
|
||||
PatBlt(HDestDC,
|
||||
RRender.right - line_width, RRender.top + line_width,
|
||||
line_width, height - (2 * line_width),
|
||||
dwROP3);
|
||||
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam)
|
||||
{
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
// create a memory DC
|
||||
HMemDC = CreateCompatibleDC(NULL);
|
||||
if (HMemDC)
|
||||
{
|
||||
// load the penguin bitmap
|
||||
HBITMAP HBmp = static_cast<HBITMAP>(
|
||||
LoadImage(HInst, filename, IMAGE_BITMAP, 0, 0,
|
||||
LR_LOADFROMFILE | LR_DEFAULTSIZE)
|
||||
);
|
||||
if (HBmp)
|
||||
{
|
||||
// get the bitmap's dimensions
|
||||
BITMAP bmp;
|
||||
if (GetObject(HBmp, sizeof(BITMAP), &bmp))
|
||||
{
|
||||
RImage.right += bmp.bmWidth;
|
||||
RImage.bottom += bmp.bmHeight;
|
||||
|
||||
// realize the bitmap
|
||||
HOldBmp = static_cast<HBITMAP>(
|
||||
SelectObject(HMemDC, HBmp)
|
||||
);
|
||||
}
|
||||
else DeleteObject(HBmp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
PMouse.x = LOWORD(LParam);
|
||||
PMouse.y = HIWORD(LParam);
|
||||
|
||||
RECT RClient;
|
||||
if (PtInRect(&RImage, PMouse) &&
|
||||
GetClientRect(HWnd, &RClient))
|
||||
{
|
||||
MapRect(HWnd, HWND_DESKTOP, RClient);
|
||||
ClipCursor(&RClient);
|
||||
|
||||
// grab a handle to the screen DC and clip
|
||||
// all output to the client area of our window
|
||||
HScreenDC = GetDC(NULL);
|
||||
HRGN HClipRgn = CreateRectRgnIndirect(&RClient);
|
||||
SelectClipRgn(HScreenDC, HClipRgn);
|
||||
DeleteObject(HClipRgn);
|
||||
|
||||
CopyRect(&RTrack, &RImage);
|
||||
MapRect(HWnd, HWND_DESKTOP, RTrack);
|
||||
|
||||
// render the first tracking rect
|
||||
RenderTrackingRect(HScreenDC, RTrack);
|
||||
is_tracking = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (HScreenDC && is_tracking)
|
||||
{
|
||||
POINT PCurrent = {LOWORD(LParam), HIWORD(LParam)};
|
||||
const int dX = PCurrent.x - PMouse.x;
|
||||
const int dY = PCurrent.y - PMouse.y;
|
||||
|
||||
// erase the previous rectangle
|
||||
RenderTrackingRect(HScreenDC, RTrack);
|
||||
// update the postion
|
||||
OffsetRect(&RTrack, dX, dY);
|
||||
// render the new tracking rectangle
|
||||
RenderTrackingRect(HScreenDC, RTrack);
|
||||
|
||||
// update the mouse position
|
||||
memcpy(&PMouse, &PCurrent, sizeof(POINT));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
// clean up
|
||||
if (is_tracking)
|
||||
{
|
||||
is_tracking = false;
|
||||
SelectClipRgn(HScreenDC, NULL);
|
||||
ReleaseDC(NULL, HScreenDC);
|
||||
|
||||
InvalidateRect(HWnd, &RImage, true);
|
||||
CopyRect(&RImage, &RTrack);
|
||||
MapRect(HWND_DESKTOP, HWnd, RImage);
|
||||
InvalidateRect(HWnd, &RImage, true);
|
||||
|
||||
ClipCursor(NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC Hdc = BeginPaint(HWnd, &ps);
|
||||
try
|
||||
{
|
||||
//
|
||||
// TODO: Add palette support...
|
||||
//
|
||||
|
||||
// render the penguin
|
||||
BitBlt(Hdc, RImage.left, RImage.top,
|
||||
RImage.right - RImage.left,
|
||||
RImage.bottom - RImage.top,
|
||||
HMemDC, 0, 0,
|
||||
SRCCOPY);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EndPaint(HWnd, &ps);
|
||||
}
|
||||
EndPaint(HWnd, &ps);
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
// clean up
|
||||
if (HOldBmp)
|
||||
{
|
||||
DeleteObject(SelectObject(HMemDC, HOldBmp));
|
||||
}
|
||||
if (HMemDC)
|
||||
{
|
||||
DeleteDC(HMemDC);
|
||||
}
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(HWnd, Msg, WParam, LParam);
|
||||
}
|
||||
//------------------------------------------------------------------
|
|
@ -1,10 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
||||
*.ncb
|
||||
*.opt
|
||||
Debug
|
||||
Release
|
|
@ -1,874 +0,0 @@
|
|||
// this is a little 'sandbox' application I put together that duplicates
|
||||
// the 'guts' of the Polygon algorithm. It allows for quick turn-around
|
||||
// in testing the algorithm to see what effect your changes have.
|
||||
//
|
||||
// Royce3
|
||||
|
||||
// the stuff immediately following is support so that the sandbox code
|
||||
// is nearly identical to the real thing.
|
||||
// search for the _tagFILL_EDGE struct to find the beginning of the
|
||||
// real stuff.
|
||||
|
||||
#include <memory.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <conio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define FASTCALL
|
||||
#define STDCALL
|
||||
#define INT int
|
||||
#define CLIPOBJ int
|
||||
#define SURFOBJ int
|
||||
#define PBRUSHOBJ int
|
||||
#define MIX char
|
||||
#define BOOL bool
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
#define CONST const
|
||||
#define MmCopyFromCaller memmove
|
||||
#define ALTERNATE 0
|
||||
#define WINDING 1
|
||||
|
||||
#define ASSERT assert
|
||||
|
||||
typedef struct W
|
||||
{
|
||||
int polyFillMode;
|
||||
} W;
|
||||
|
||||
typedef struct DC
|
||||
{
|
||||
CLIPOBJ CombinedClip;
|
||||
W w;
|
||||
} DC, *PDC;
|
||||
|
||||
typedef struct tagPOINT
|
||||
{
|
||||
long x, y;
|
||||
} POINT, *PPOINT, *LPPOINT;
|
||||
|
||||
typedef struct RECTL
|
||||
{
|
||||
long left, top, right, bottom;
|
||||
} RECTL, *PRECTL;
|
||||
|
||||
#define EngFreeMem free
|
||||
|
||||
#define FL_ZERO_MEMORY 1
|
||||
|
||||
#define DPRINT1 printf("%i:",__LINE__);printf
|
||||
inline void DPRINT(...){}
|
||||
|
||||
#define SCREENX 25
|
||||
#define SCREENY 15
|
||||
char screen[SCREENY][SCREENX];
|
||||
|
||||
#define EDGE_CHAR '*'
|
||||
#define FILL_CHAR 'o'
|
||||
|
||||
void* EngAllocMem ( int zero, unsigned long size, int tag=0 )
|
||||
{
|
||||
void* p = malloc ( size );
|
||||
if ( zero )
|
||||
memset ( p, 0, size );
|
||||
return p;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T MIN ( T a, T b )
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T MAX ( T a, T b )
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T abs ( T t )
|
||||
{
|
||||
return t < 0 ? -t : t;
|
||||
}
|
||||
|
||||
void putpixel ( int x, int y, char c )
|
||||
{
|
||||
ASSERT( x >= 0 && x < SCREENX && y >= 0 && y < SCREENY );
|
||||
if ( screen[y][x] == c )
|
||||
return;
|
||||
if ( screen[y][x] == ' ' )
|
||||
screen[y][x] = c;
|
||||
else
|
||||
screen[y][x] = '#';
|
||||
}
|
||||
|
||||
void IntEngLineTo (
|
||||
SURFOBJ*,
|
||||
CLIPOBJ,
|
||||
PBRUSHOBJ,
|
||||
int x1, int y1, int x2, int y2,
|
||||
RECTL*,
|
||||
MIX mix )
|
||||
{
|
||||
int dx = x2 - x1;
|
||||
int dy = y2 - y1;
|
||||
int absdx = abs(dx);
|
||||
int absdy = abs(dy);
|
||||
int EMax = MAX(absdx,absdy);
|
||||
int E = EMax/2;
|
||||
int xinc = dx < 0 ? -1 : 1,
|
||||
yinc = dy < 0 ? -1 : 1;
|
||||
if ( !dy )
|
||||
{
|
||||
while ( x1 != x2 )
|
||||
{
|
||||
putpixel ( x1, y1, mix );
|
||||
x1 += xinc;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( !dx )
|
||||
{
|
||||
while ( y1 != y2 )
|
||||
{
|
||||
putpixel ( x1, y1, mix );
|
||||
y1 += yinc;
|
||||
}
|
||||
return;
|
||||
}
|
||||
for ( int i = 0; i < EMax; i++ )
|
||||
{
|
||||
putpixel ( x1, y1, mix );
|
||||
if ( absdy > absdx )
|
||||
{
|
||||
y1 += yinc;
|
||||
E += absdx;
|
||||
if ( E >= EMax )
|
||||
{
|
||||
E -= absdy;
|
||||
x1 += xinc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 += xinc;
|
||||
E += absdy;
|
||||
if ( E >= EMax )
|
||||
{
|
||||
E -= absdx;
|
||||
y1 += yinc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define FILL_EDGE_ALLOC_TAG 0x45465044
|
||||
|
||||
/*
|
||||
** This struct is used for book keeping during polygon filling routines.
|
||||
*/
|
||||
typedef struct _tagFILL_EDGE
|
||||
{
|
||||
/*Basic line information*/
|
||||
int FromX;
|
||||
int FromY;
|
||||
int ToX;
|
||||
int ToY;
|
||||
int dx;
|
||||
int dy;
|
||||
int absdx, absdy;
|
||||
int x, y;
|
||||
int xmajor;
|
||||
|
||||
/*Active Edge List information*/
|
||||
int XIntercept[2];
|
||||
int Error;
|
||||
int ErrorMax;
|
||||
int XDirection, YDirection;
|
||||
|
||||
/* The next edge in the active Edge List*/
|
||||
struct _tagFILL_EDGE * pNext;
|
||||
} FILL_EDGE;
|
||||
|
||||
typedef struct _FILL_EDGE_LIST
|
||||
{
|
||||
int Count;
|
||||
FILL_EDGE** Edges;
|
||||
} FILL_EDGE_LIST;
|
||||
|
||||
#if 0
|
||||
static
|
||||
void
|
||||
DEBUG_PRINT_ACTIVE_EDGELIST ( FILL_EDGE* list )
|
||||
{
|
||||
FILL_EDGE* pThis = list;
|
||||
if (0 == list)
|
||||
{
|
||||
DPRINT1("List is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while(0 != pThis)
|
||||
{
|
||||
//DPRINT1("EDGE: (%d, %d) to (%d, %d)\n", pThis->FromX, pThis->FromY, pThis->ToX, pThis->ToY);
|
||||
DPRINT1("EDGE: [%d,%d]\n", pThis->XIntercept[0], pThis->XIntercept[1] );
|
||||
pThis = pThis->pNext;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define DEBUG_PRINT_ACTIVE_EDGELIST(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Hide memory clean up.
|
||||
*/
|
||||
static
|
||||
void
|
||||
FASTCALL
|
||||
POLYGONFILL_DestroyEdgeList(FILL_EDGE_LIST* list)
|
||||
{
|
||||
int i;
|
||||
if ( list )
|
||||
{
|
||||
if ( list->Edges )
|
||||
{
|
||||
for ( i = 0; i < list->Count; i++ )
|
||||
{
|
||||
if ( list->Edges[i] )
|
||||
EngFreeMem ( list->Edges[i] );
|
||||
}
|
||||
EngFreeMem ( list->Edges );
|
||||
}
|
||||
EngFreeMem ( list );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This makes and initiaizes an Edge struct for a line between two points.
|
||||
*/
|
||||
static
|
||||
FILL_EDGE*
|
||||
FASTCALL
|
||||
POLYGONFILL_MakeEdge(POINT From, POINT To)
|
||||
{
|
||||
FILL_EDGE* rc = (FILL_EDGE*)EngAllocMem(FL_ZERO_MEMORY, sizeof(FILL_EDGE), FILL_EDGE_ALLOC_TAG);
|
||||
|
||||
if (0 == rc)
|
||||
return NULL;
|
||||
|
||||
//DPRINT1("Making Edge: (%d, %d) to (%d, %d)\n", From.x, From.y, To.x, To.y);
|
||||
//Now Fill the struct.
|
||||
if ( To.y < From.y )
|
||||
{
|
||||
rc->FromX = To.x;
|
||||
rc->FromY = To.y;
|
||||
rc->ToX = From.x;
|
||||
rc->ToY = From.y;
|
||||
rc->YDirection = -1;
|
||||
|
||||
// lines that go up get walked backwards, so need to be offset
|
||||
// by -1 in order to make the walk identically on a pixel-level
|
||||
rc->Error = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc->FromX = From.x;
|
||||
rc->FromY = From.y;
|
||||
rc->ToX = To.x;
|
||||
rc->ToY = To.y;
|
||||
rc->YDirection = 1;
|
||||
|
||||
rc->Error = 0;
|
||||
}
|
||||
|
||||
rc->x = rc->FromX;
|
||||
rc->y = rc->FromY;
|
||||
rc->dx = rc->ToX - rc->FromX;
|
||||
rc->dy = rc->ToY - rc->FromY;
|
||||
rc->absdx = abs(rc->dx);
|
||||
rc->absdy = abs(rc->dy);
|
||||
|
||||
rc->xmajor = rc->absdx > rc->absdy;
|
||||
|
||||
rc->ErrorMax = MAX(rc->absdx,rc->absdy);
|
||||
|
||||
rc->Error += rc->ErrorMax / 2;
|
||||
|
||||
rc->XDirection = (rc->dx < 0)?(-1):(1);
|
||||
|
||||
rc->pNext = 0;
|
||||
|
||||
DPRINT("MakeEdge (%i,%i)->(%i,%i) d=(%i,%i) dir=(%i,%i) err=%i max=%i\n",
|
||||
From.x, From.y, To.x, To.y, rc->dx, rc->dy, rc->XDirection, rc->YDirection, rc->Error, rc->ErrorMax );
|
||||
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
** My Edge comparison routine.
|
||||
** This is for scan converting polygon fill.
|
||||
** First sort by MinY, then Minx, then slope.
|
||||
**
|
||||
** This comparison will help us determine which
|
||||
** lines will become active first when scanning from
|
||||
** top (min y) to bottom (max y).
|
||||
**
|
||||
** Return Value Meaning
|
||||
** Negative integer element1 < element2
|
||||
** Zero element1 = element2
|
||||
** Positive integer element1 > element2
|
||||
*/
|
||||
static
|
||||
INT
|
||||
FASTCALL
|
||||
FILL_EDGE_Compare(FILL_EDGE* Edge1, FILL_EDGE* Edge2)
|
||||
{
|
||||
int e1 = Edge1->XIntercept[0] + Edge1->XIntercept[1];
|
||||
int e2 = Edge2->XIntercept[0] + Edge2->XIntercept[1];
|
||||
|
||||
return e1 - e2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Insert an edge into a list keeping the list in order.
|
||||
*/
|
||||
static
|
||||
void
|
||||
FASTCALL
|
||||
POLYGONFILL_ActiveListInsert(FILL_EDGE** activehead, FILL_EDGE* NewEdge )
|
||||
{
|
||||
FILL_EDGE *pPrev, *pThis;
|
||||
//DPRINT1("In POLYGONFILL_ActiveListInsert()\n");
|
||||
ASSERT ( activehead && NewEdge );
|
||||
if ( !*activehead )
|
||||
{
|
||||
NewEdge->pNext = NULL;
|
||||
*activehead = NewEdge;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
** First lets check to see if we have a new smallest value.
|
||||
*/
|
||||
if (FILL_EDGE_Compare(NewEdge, *activehead) <= 0)
|
||||
{
|
||||
NewEdge->pNext = *activehead;
|
||||
*activehead = NewEdge;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
** Ok, now scan to the next spot to put this item.
|
||||
*/
|
||||
pThis = *activehead;
|
||||
pPrev = NULL;
|
||||
while ( pThis && FILL_EDGE_Compare(pThis, NewEdge) < 0 )
|
||||
{
|
||||
pPrev = pThis;
|
||||
pThis = pThis->pNext;
|
||||
}
|
||||
|
||||
ASSERT(pPrev);
|
||||
NewEdge->pNext = pPrev->pNext;
|
||||
pPrev->pNext = NewEdge;
|
||||
//DEBUG_PRINT_ACTIVE_EDGELIST(*activehead);
|
||||
}
|
||||
|
||||
/*
|
||||
** Create a list of edges for a list of points.
|
||||
*/
|
||||
static
|
||||
FILL_EDGE_LIST*
|
||||
FASTCALL
|
||||
POLYGONFILL_MakeEdgeList(PPOINT Points, int Count)
|
||||
{
|
||||
int CurPt = 0;
|
||||
FILL_EDGE_LIST* list = 0;
|
||||
FILL_EDGE* e = 0;
|
||||
|
||||
if ( 0 == Points || 2 > Count )
|
||||
return 0;
|
||||
|
||||
list = (FILL_EDGE_LIST*)EngAllocMem(FL_ZERO_MEMORY, sizeof(FILL_EDGE_LIST), FILL_EDGE_ALLOC_TAG);
|
||||
if ( 0 == list )
|
||||
goto fail;
|
||||
list->Count = 0;
|
||||
list->Edges = (FILL_EDGE**)EngAllocMem(FL_ZERO_MEMORY, Count*sizeof(FILL_EDGE*), FILL_EDGE_ALLOC_TAG);
|
||||
if ( !list->Edges )
|
||||
goto fail;
|
||||
memset ( list->Edges, 0, Count * sizeof(FILL_EDGE*) );
|
||||
|
||||
for ( CurPt = 1; CurPt < Count; ++CurPt )
|
||||
{
|
||||
e = POLYGONFILL_MakeEdge ( Points[CurPt-1], Points[CurPt] );
|
||||
if ( !e )
|
||||
goto fail;
|
||||
// if a straight horizontal line - who cares?
|
||||
if ( !e->absdy )
|
||||
EngFreeMem ( e );
|
||||
else
|
||||
list->Edges[list->Count++] = e;
|
||||
}
|
||||
e = POLYGONFILL_MakeEdge ( Points[CurPt-1], Points[0] );
|
||||
if ( !e )
|
||||
goto fail;
|
||||
if ( !e->absdy )
|
||||
EngFreeMem ( e );
|
||||
else
|
||||
list->Edges[list->Count++] = e;
|
||||
return list;
|
||||
|
||||
fail:
|
||||
DPRINT1("Out Of MEMORY!!\n");
|
||||
POLYGONFILL_DestroyEdgeList ( list );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** This slow routine uses the data stored in the edge list to
|
||||
** calculate the x intercepts for each line in the edge list
|
||||
** for scanline Scanline.
|
||||
**TODO: Get rid of this floating point arithmetic
|
||||
*/
|
||||
static
|
||||
void
|
||||
FASTCALL
|
||||
POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
|
||||
{
|
||||
if ( 0 == pEdge->dy )
|
||||
return;
|
||||
|
||||
ASSERT ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline );
|
||||
|
||||
if ( pEdge->xmajor )
|
||||
{
|
||||
int steps;
|
||||
|
||||
ASSERT ( pEdge->y == Scanline );
|
||||
|
||||
// now shoot to end of scanline collision
|
||||
steps = (pEdge->ErrorMax-pEdge->Error-1)/pEdge->absdy;
|
||||
if ( steps )
|
||||
{
|
||||
// record first collision with scanline
|
||||
int x1 = pEdge->x;
|
||||
pEdge->x += steps * pEdge->XDirection;
|
||||
pEdge->Error += steps * pEdge->absdy;
|
||||
ASSERT ( pEdge->Error < pEdge->ErrorMax );
|
||||
pEdge->XIntercept[0] = MIN(x1,pEdge->x);
|
||||
pEdge->XIntercept[1] = MAX(x1,pEdge->x);
|
||||
}
|
||||
else
|
||||
{
|
||||
pEdge->XIntercept[0] = pEdge->x;
|
||||
pEdge->XIntercept[1] = pEdge->x;
|
||||
}
|
||||
|
||||
// we should require exactly 1 step to step onto next scanline...
|
||||
ASSERT ( (pEdge->ErrorMax-pEdge->Error-1) / pEdge->absdy == 0 );
|
||||
pEdge->x += pEdge->XDirection;
|
||||
pEdge->Error += pEdge->absdy;
|
||||
ASSERT ( pEdge->Error >= pEdge->ErrorMax );
|
||||
|
||||
// now step onto next scanline...
|
||||
pEdge->Error -= pEdge->absdx;
|
||||
pEdge->y++;
|
||||
}
|
||||
else // then this is a y-major line
|
||||
{
|
||||
pEdge->XIntercept[0] = pEdge->x;
|
||||
pEdge->XIntercept[1] = pEdge->x;
|
||||
|
||||
pEdge->Error += pEdge->absdx;
|
||||
pEdge->y++;
|
||||
|
||||
if ( pEdge->Error >= pEdge->ErrorMax )
|
||||
{
|
||||
pEdge->Error -= pEdge->ErrorMax;
|
||||
pEdge->x += pEdge->XDirection;
|
||||
ASSERT ( pEdge->Error < pEdge->ErrorMax );
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("Line (%d, %d) to (%d, %d) intersects scanline %d at (%d,%d)\n",
|
||||
pEdge->FromX, pEdge->FromY, pEdge->ToX, pEdge->ToY, Scanline, pEdge->XIntercept[0], pEdge->XIntercept[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
** This method updates the Active edge collection for the scanline Scanline.
|
||||
*/
|
||||
static
|
||||
void
|
||||
STDCALL
|
||||
POLYGONFILL_BuildActiveList ( int Scanline, FILL_EDGE_LIST* list, FILL_EDGE** ActiveHead )
|
||||
{
|
||||
int i;
|
||||
|
||||
ASSERT ( list && ActiveHead );
|
||||
*ActiveHead = 0;
|
||||
for ( i = 0; i < list->Count; i++ )
|
||||
{
|
||||
FILL_EDGE* pEdge = list->Edges[i];
|
||||
ASSERT(pEdge);
|
||||
if ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline )
|
||||
{
|
||||
POLYGONFILL_UpdateScanline ( pEdge, Scanline );
|
||||
POLYGONFILL_ActiveListInsert ( ActiveHead, pEdge );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This method fills the portion of the polygon that intersects with the scanline
|
||||
** Scanline.
|
||||
*/
|
||||
static
|
||||
void
|
||||
STDCALL
|
||||
POLYGONFILL_FillScanLineAlternate(
|
||||
PDC dc,
|
||||
int ScanLine,
|
||||
FILL_EDGE* ActiveHead,
|
||||
SURFOBJ *SurfObj,
|
||||
PBRUSHOBJ BrushObj,
|
||||
MIX RopMode )
|
||||
{
|
||||
FILL_EDGE *pLeft, *pRight;
|
||||
|
||||
if ( !ActiveHead )
|
||||
return;
|
||||
|
||||
pLeft = ActiveHead;
|
||||
pRight = pLeft->pNext;
|
||||
ASSERT(pRight);
|
||||
|
||||
while ( NULL != pRight )
|
||||
{
|
||||
int x1 = pLeft->XIntercept[0];
|
||||
int x2 = pRight->XIntercept[1];
|
||||
if ( x2 > x1 )
|
||||
{
|
||||
RECTL BoundRect;
|
||||
BoundRect.top = ScanLine;
|
||||
BoundRect.bottom = ScanLine + 1;
|
||||
BoundRect.left = x1;
|
||||
BoundRect.right = x2;
|
||||
|
||||
DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
|
||||
IntEngLineTo( SurfObj,
|
||||
dc->CombinedClip,
|
||||
BrushObj,
|
||||
x1,
|
||||
ScanLine,
|
||||
x2,
|
||||
ScanLine,
|
||||
&BoundRect, // Bounding rectangle
|
||||
RopMode); // MIX
|
||||
}
|
||||
pLeft = pRight->pNext;
|
||||
pRight = pLeft ? pLeft->pNext : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
STDCALL
|
||||
POLYGONFILL_FillScanLineWinding(
|
||||
PDC dc,
|
||||
int ScanLine,
|
||||
FILL_EDGE* ActiveHead,
|
||||
SURFOBJ *SurfObj,
|
||||
PBRUSHOBJ BrushObj,
|
||||
MIX RopMode )
|
||||
{
|
||||
FILL_EDGE *pLeft, *pRight;
|
||||
int x1, x2, winding = 0;
|
||||
RECTL BoundRect;
|
||||
|
||||
if ( !ActiveHead )
|
||||
return;
|
||||
|
||||
BoundRect.top = ScanLine;
|
||||
BoundRect.bottom = ScanLine + 1;
|
||||
|
||||
pLeft = ActiveHead;
|
||||
winding = pLeft->YDirection;
|
||||
pRight = pLeft->pNext;
|
||||
ASSERT(pRight);
|
||||
|
||||
// setup first line...
|
||||
x1 = pLeft->XIntercept[0];
|
||||
x2 = pRight->XIntercept[1];
|
||||
|
||||
pLeft = pRight;
|
||||
pRight = pLeft->pNext;
|
||||
winding += pLeft->YDirection;
|
||||
|
||||
while ( NULL != pRight )
|
||||
{
|
||||
int newx1 = pLeft->XIntercept[0];
|
||||
int newx2 = pRight->XIntercept[1];
|
||||
if ( winding )
|
||||
{
|
||||
// check and see if this new line touches the previous...
|
||||
if ( (newx1 >= x1 && newx1 <= x2)
|
||||
|| (newx2 >= x1 && newx2 <= x2)
|
||||
|| (x1 >= newx1 && x1 <= newx2)
|
||||
|| (x2 >= newx2 && x2 <= newx2)
|
||||
)
|
||||
{
|
||||
// yup, just tack it on to our existing line
|
||||
x1 = MIN(x1,newx1);
|
||||
x2 = MAX(x2,newx2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// nope - render the old line..
|
||||
BoundRect.left = x1;
|
||||
BoundRect.right = x2;
|
||||
|
||||
DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
|
||||
IntEngLineTo( SurfObj,
|
||||
dc->CombinedClip,
|
||||
BrushObj,
|
||||
x1,
|
||||
ScanLine,
|
||||
x2,
|
||||
ScanLine,
|
||||
&BoundRect, // Bounding rectangle
|
||||
RopMode); // MIX
|
||||
|
||||
x1 = newx1;
|
||||
x2 = newx2;
|
||||
}
|
||||
}
|
||||
pLeft = pRight;
|
||||
pRight = pLeft->pNext;
|
||||
winding += pLeft->YDirection;
|
||||
}
|
||||
// there will always be a line left-over, render it now...
|
||||
BoundRect.left = x1;
|
||||
BoundRect.right = x2;
|
||||
|
||||
DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
|
||||
IntEngLineTo( SurfObj,
|
||||
dc->CombinedClip,
|
||||
BrushObj,
|
||||
x1,
|
||||
ScanLine,
|
||||
x2,
|
||||
ScanLine,
|
||||
&BoundRect, // Bounding rectangle
|
||||
RopMode); // MIX
|
||||
}
|
||||
|
||||
//When the fill mode is ALTERNATE, GDI fills the area between odd-numbered and
|
||||
//even-numbered polygon sides on each scan line. That is, GDI fills the area between the
|
||||
//first and second side, between the third and fourth side, and so on.
|
||||
|
||||
//WINDING Selects winding mode (fills any region with a nonzero winding value).
|
||||
//When the fill mode is WINDING, GDI fills any region that has a nonzero winding value.
|
||||
//This value is defined as the number of times a pen used to draw the polygon would go around the region.
|
||||
//The direction of each edge of the polygon is important.
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
FillPolygon(
|
||||
PDC dc,
|
||||
SURFOBJ *SurfObj,
|
||||
PBRUSHOBJ BrushObj,
|
||||
MIX RopMode,
|
||||
CONST PPOINT Points,
|
||||
int Count,
|
||||
RECTL BoundRect )
|
||||
{
|
||||
FILL_EDGE_LIST *list = 0;
|
||||
FILL_EDGE *ActiveHead = 0;
|
||||
int ScanLine;
|
||||
|
||||
void
|
||||
STDCALL
|
||||
(*FillScanLine)(
|
||||
PDC dc,
|
||||
int ScanLine,
|
||||
FILL_EDGE* ActiveHead,
|
||||
SURFOBJ *SurfObj,
|
||||
PBRUSHOBJ BrushObj,
|
||||
MIX RopMode );
|
||||
|
||||
DPRINT("FillPolygon\n");
|
||||
|
||||
/* Create Edge List. */
|
||||
list = POLYGONFILL_MakeEdgeList(Points, Count);
|
||||
/* DEBUG_PRINT_EDGELIST(list); */
|
||||
if (NULL == list)
|
||||
return FALSE;
|
||||
|
||||
if ( WINDING == dc->w.polyFillMode )
|
||||
FillScanLine = POLYGONFILL_FillScanLineWinding;
|
||||
else /* default */
|
||||
FillScanLine = POLYGONFILL_FillScanLineAlternate;
|
||||
|
||||
/* For each Scanline from BoundRect.bottom to BoundRect.top,
|
||||
* determine line segments to draw
|
||||
*/
|
||||
for ( ScanLine = BoundRect.top; ScanLine < BoundRect.bottom; ++ScanLine )
|
||||
{
|
||||
POLYGONFILL_BuildActiveList(ScanLine, list, &ActiveHead);
|
||||
//DEBUG_PRINT_ACTIVE_EDGELIST(ActiveHead);
|
||||
FillScanLine ( dc, ScanLine, ActiveHead, SurfObj, BrushObj, RopMode );
|
||||
}
|
||||
|
||||
/* Free Edge List. If any are left. */
|
||||
POLYGONFILL_DestroyEdgeList(list);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// this is highly hacked from W32kPolygon...
|
||||
BOOL
|
||||
Polygon ( CONST PPOINT UnsafePoints, int Count, int polyFillMode )
|
||||
{
|
||||
BOOL ret;
|
||||
RECTL DestRect;
|
||||
int CurrentPoint;
|
||||
PPOINT Points;
|
||||
SURFOBJ* SurfObj = 0;
|
||||
DC dc;
|
||||
PBRUSHOBJ OutBrushObj = 0;
|
||||
|
||||
dc.CombinedClip = 0;
|
||||
dc.w.polyFillMode = polyFillMode;
|
||||
|
||||
DPRINT1("In W32kPolygon()\n");
|
||||
|
||||
if ( NULL == UnsafePoints || Count < 2)
|
||||
{
|
||||
DPRINT1("ERROR_INVALID_PARAMETER\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Copy points from userspace to kernelspace */
|
||||
Points = (PPOINT)EngAllocMem(0, Count * sizeof(POINT));
|
||||
if (NULL == Points)
|
||||
{
|
||||
DPRINT1("ERROR_NOT_ENOUGH_MEMORY\n");
|
||||
return FALSE;
|
||||
}
|
||||
MmCopyFromCaller(Points, UnsafePoints, Count * sizeof(POINT));
|
||||
if ( memcmp ( Points, UnsafePoints, Count * sizeof(POINT) ) )
|
||||
{
|
||||
free(Points);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DestRect.left = Points[0].x;
|
||||
DestRect.right = Points[0].x;
|
||||
DestRect.top = Points[0].y;
|
||||
DestRect.bottom = Points[0].y;
|
||||
|
||||
for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint)
|
||||
{
|
||||
DestRect.left = MIN(DestRect.left, Points[CurrentPoint].x);
|
||||
DestRect.right = MAX(DestRect.right, Points[CurrentPoint].x);
|
||||
DestRect.top = MIN(DestRect.top, Points[CurrentPoint].y);
|
||||
DestRect.bottom = MAX(DestRect.bottom, Points[CurrentPoint].y);
|
||||
}
|
||||
|
||||
// Draw the Polygon Edges with the current pen
|
||||
for (CurrentPoint = 0; CurrentPoint < Count; ++CurrentPoint)
|
||||
{
|
||||
POINT To, From; //, Next;
|
||||
|
||||
/* Let CurrentPoint be i
|
||||
* if i+1 > Count, Draw a line from Points[i] to Points[0]
|
||||
* Draw a line from Points[i] to Points[i+1]
|
||||
*/
|
||||
From = Points[CurrentPoint];
|
||||
if ( CurrentPoint + 1 >= Count)
|
||||
{
|
||||
To = Points[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
To = Points[CurrentPoint + 1];
|
||||
}
|
||||
|
||||
DPRINT1("Polygon Making line from (%d,%d) to (%d,%d)\n", From.x, From.y, To.x, To.y );
|
||||
IntEngLineTo(SurfObj,
|
||||
dc.CombinedClip,
|
||||
OutBrushObj,
|
||||
From.x,
|
||||
From.y,
|
||||
To.x,
|
||||
To.y,
|
||||
&DestRect,
|
||||
EDGE_CHAR); /* MIX */
|
||||
}
|
||||
/* determine the fill mode to fill the polygon. */
|
||||
ret = FillPolygon(&dc, SurfObj, OutBrushObj, FILL_CHAR, Points, Count, DestRect );
|
||||
free(Points);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
memset ( screen, ' ', sizeof(screen) );
|
||||
POINT pts[] =
|
||||
{
|
||||
#if 0
|
||||
{ 0, 0 },
|
||||
{ 12, 4 },
|
||||
{ 4, 8 },
|
||||
#elif 0
|
||||
{ 3, 0 },
|
||||
{ 0, 3 },
|
||||
{ 3, 6 },
|
||||
#elif 0
|
||||
{ 1, 1 },
|
||||
{ 3, 1 },
|
||||
{ 3, 3 },
|
||||
{ 1, 3 }
|
||||
#elif 0
|
||||
{ 0, 0 },
|
||||
{ 4, 0 },
|
||||
{ 4, 4 },
|
||||
{ 8, 4 },
|
||||
{ 8, 8 },
|
||||
{ 4, 8 },
|
||||
{ 4, 4 },
|
||||
{ 0, 4 },
|
||||
#else
|
||||
{ 4, 12 },
|
||||
{ 12, 0 },
|
||||
{ 18, 12 },
|
||||
{ 4, 4 },
|
||||
{ 20, 4 }
|
||||
#endif
|
||||
};
|
||||
const int pts_count = sizeof(pts)/sizeof(pts[0]);
|
||||
|
||||
// use ALTERNATE or WINDING for 3rd param
|
||||
Polygon ( pts, pts_count, ALTERNATE );
|
||||
|
||||
// print out our "screen"
|
||||
for ( int y = 0; y < SCREENY; y++ )
|
||||
{
|
||||
for ( int x = 0; x < SCREENX; x++ )
|
||||
{
|
||||
printf("%c", screen[y][x] );
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
DPRINT1("Done!\n");
|
||||
(void)getch();
|
||||
}
|
||||
/* EOF */
|
|
@ -1,88 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="polytest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=polytest - 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 "polytest.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 "polytest.mak" CFG="polytest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "polytest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "polytest - 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)" == "polytest - 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)" == "polytest - 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 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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "polytest - Win32 Release"
|
||||
# Name "polytest - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\polytest.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,29 +0,0 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "polytest"=".\polytest.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.1 2003/12/27 23:45:48 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = no
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = popupmenu
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a user32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,102 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "resource.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 = "MenuTestClass";
|
||||
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 = (LPCTSTR)IDM_MAINMENU;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClass(&wc) == 0)
|
||||
{
|
||||
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow("MenuTestClass",
|
||||
"PopupMenu Test",
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
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);
|
||||
}
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case IDM_EXIT:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
POINT pos;
|
||||
HMENU Menu;
|
||||
|
||||
pos.x = LOWORD(lParam);
|
||||
pos.y = HIWORD(lParam);
|
||||
ClientToScreen(hWnd, &pos);
|
||||
|
||||
if((Menu = GetMenu(hWnd)) && (Menu = GetSubMenu(Menu, 1)))
|
||||
{
|
||||
TrackPopupMenu(Menu, 0, pos.x, pos.y, 0, hWnd, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
#include "resource.h"
|
||||
|
||||
IDM_MAINMENU MENU LOADONCALL MOVEABLE DISCARDABLE
|
||||
{
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "&New\tCtrl+N", 1
|
||||
MENUITEM "&Open\tCtrl+O", 2
|
||||
POPUP "Open &Recent"
|
||||
{
|
||||
MENUITEM "&1", 11
|
||||
MENUITEM "&2", 12
|
||||
MENUITEM "&3", 13
|
||||
MENUITEM "&4", 14
|
||||
MENUITEM "&5", 15
|
||||
MENUITEM "&6", 16
|
||||
MENUITEM "&7", 17
|
||||
MENUITEM "&8", 18
|
||||
MENUITEM "&9", 19
|
||||
}
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Save\tCtrl+S", 3
|
||||
MENUITEM "Save &as...", 4
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tAlt-F4", IDM_EXIT
|
||||
}
|
||||
POPUP "&Edit"
|
||||
{
|
||||
MENUITEM "&Undo\tCtrl+Z", 20
|
||||
MENUITEM "&Redo\tShift+Ctrl+Z", 21
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Cut\tCtrl+X", 22
|
||||
MENUITEM "&Copy\tCtrl+C", 23
|
||||
MENUITEM "&Paste\tCtrl+V", 24
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select &all", 25
|
||||
MENUITEM "&Delete\tDel", 26
|
||||
}
|
||||
POPUP "&Help"
|
||||
{
|
||||
MENUITEM "&Help Topics\tF1", 30
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About...", 31
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
#define IDM_MAINMENU 101
|
||||
#define IDM_EXIT 199
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,37 +0,0 @@
|
|||
#
|
||||
# ReactOS explorer
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = primitives
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_CFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -Wall -Werror
|
||||
|
||||
TARGET_CPPFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -Wall -Werror
|
||||
|
||||
TARGET_SDKLIBS = \
|
||||
kernel32.a \
|
||||
user32.a \
|
||||
gdi32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
primitives.o \
|
||||
mk_font.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# overide LD_CC to use g++ for linking of the executable
|
||||
LD_CC = $(CXX)
|
||||
|
||||
# EOF
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Utility functions
|
||||
//
|
||||
// Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
// Updates can be downloaded at: <www.coriolis.com>
|
||||
//
|
||||
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
// if you have any questions about this code.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#include <windows.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "mk_font.h"
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
namespace font {
|
||||
|
||||
// creates a logical font
|
||||
HFONT MakeFont(
|
||||
IN HDC hDestDC, // handle to target DC
|
||||
IN LPCSTR typeface_name, // font's typeface name
|
||||
IN int point_size, // font's point size
|
||||
IN const BYTE charset, // font's character set
|
||||
IN const DWORD style // font's styles
|
||||
)
|
||||
{
|
||||
//
|
||||
// NOTE: On Windows 9x/Me, GetWorldTransform is not
|
||||
// supported. For compatibility with these platforms you
|
||||
// should initialize the XFORM::eM22 data member to 1.0.
|
||||
//
|
||||
XFORM xf = {0, 0, 0, 1.0, 0, 0};
|
||||
GetWorldTransform(hDestDC, &xf);
|
||||
int pixels_per_inch = GetDeviceCaps(hDestDC, LOGPIXELSY);
|
||||
|
||||
POINT PSize = {
|
||||
0,
|
||||
-MulDiv(static_cast<int>(xf.eM22 * point_size + 0.5),
|
||||
pixels_per_inch, 72)
|
||||
};
|
||||
|
||||
HFONT hResult = NULL;
|
||||
if (DPtoLP(hDestDC, &PSize, 1))
|
||||
{
|
||||
LOGFONT lf;
|
||||
memset(&lf, 0, sizeof(LOGFONT));
|
||||
|
||||
lf.lfHeight = PSize.y;
|
||||
lf.lfCharSet = charset;
|
||||
lstrcpyn(reinterpret_cast<LPTSTR>(&lf.lfFaceName),
|
||||
typeface_name, LF_FACESIZE);
|
||||
|
||||
lf.lfWeight = (style & FS_BOLD) ? FW_BOLD : FW_DONTCARE;
|
||||
lf.lfItalic = (style & FS_ITALIC) ? true : false;
|
||||
lf.lfUnderline = (style & FS_UNDERLINE) ? true : false;
|
||||
lf.lfStrikeOut = (style & FS_STRIKEOUT) ? true : false;
|
||||
|
||||
// create the logical font
|
||||
hResult = CreateFontIndirect(&lf);
|
||||
}
|
||||
return hResult;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
} // namespace font
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Utility functions
|
||||
//
|
||||
// Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
// Updates can be downloaded at: <www.coriolis.com>
|
||||
//
|
||||
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
// if you have any questions about this code.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#ifndef CH4_UTILS_H
|
||||
#define CH4_UTILS_H
|
||||
|
||||
#include <windows.h>
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
// change namespace name appropriately to suit your needs
|
||||
namespace font {
|
||||
|
||||
// font options
|
||||
static const ULONG FS_NONE = 0x00000000;
|
||||
static const ULONG FS_BOLD = 0x00000001;
|
||||
static const ULONG FS_ITALIC = 0x00000002;
|
||||
static const ULONG FS_UNDERLINE = 0x00000004;
|
||||
static const ULONG FS_STRIKEOUT = 0x00000008;
|
||||
|
||||
// creates a logical font
|
||||
HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
|
||||
IN int point_size, IN const BYTE charset = ANSI_CHARSET,
|
||||
IN const DWORD style = FS_NONE);
|
||||
|
||||
}
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#endif // CH4_UTILS_H
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
@ -1,351 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 5 - Listing 5.1 (Output Primitives Demo)
|
||||
//
|
||||
// Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
// Updates can be downloaded at: <www.coriolis.com>
|
||||
//
|
||||
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
// if you have any questions about this code.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#include <windows.h>
|
||||
#include <cassert>
|
||||
|
||||
// for the MakeFont() function...
|
||||
#include "mk_font.h"
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
HINSTANCE hInst;
|
||||
const char* WndClassName = "GMainWnd";
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam);
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR,
|
||||
int nCmdShow)
|
||||
{
|
||||
hInst = hInstance;
|
||||
|
||||
WNDCLASS wc;
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.lpszClassName = WndClassName;
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.hInstance = hInst;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = reinterpret_cast<HBRUSH>(
|
||||
COLOR_BTNFACE + 1
|
||||
);
|
||||
|
||||
if (RegisterClass(&wc))
|
||||
{
|
||||
HWND hWnd =
|
||||
CreateWindow(
|
||||
WndClassName, TEXT("Output Primitives Demo"),
|
||||
WS_OVERLAPPEDWINDOW | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
|
||||
NULL, NULL, hInst, NULL
|
||||
);
|
||||
|
||||
if (hWnd)
|
||||
{
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
enum OutPrimitive {
|
||||
opLine, opBezier, opRectangle, opRoundRect,
|
||||
opEllipse, opArc, opPie, opChord, opCustom
|
||||
};
|
||||
|
||||
void DrawPrimitive(IN HDC hDC, IN const RECT& RPrimitive,
|
||||
IN OutPrimitive PrimitiveID)
|
||||
{
|
||||
RECT R = RPrimitive;
|
||||
InflateRect(&R, -10, -10);
|
||||
|
||||
switch (PrimitiveID)
|
||||
{
|
||||
case opLine:
|
||||
{
|
||||
const POINT PLine[] = {{R.left, R.top}, {R.right, R.bottom}};
|
||||
Polyline(hDC, PLine, 2);
|
||||
break;
|
||||
}
|
||||
case opBezier:
|
||||
{
|
||||
const POINT PControlPoints[] = {
|
||||
{R.left, R.top},
|
||||
{(R.right - R.left) / 2, R.top},
|
||||
{(R.right - R.left) / 2, R.bottom},
|
||||
{R.right, R.bottom}
|
||||
};
|
||||
PolyBezier(hDC, PControlPoints, 4);
|
||||
break;
|
||||
}
|
||||
case opRectangle:
|
||||
{
|
||||
Rectangle(hDC, R.left, R.top, R.right, R.bottom);
|
||||
break;
|
||||
}
|
||||
case opRoundRect:
|
||||
{
|
||||
RoundRect(hDC, R.left, R.top, R.right, R.bottom, 20, 20);
|
||||
break;
|
||||
}
|
||||
case opEllipse:
|
||||
{
|
||||
Ellipse(hDC, R.left, R.top, R.right, R.bottom);
|
||||
break;
|
||||
}
|
||||
case opArc:
|
||||
{
|
||||
const POINT PRads[] = {
|
||||
{(R.right - R.left) / 3 + R.left, R.top},
|
||||
{(R.right - R.left) / 3 + R.left, R.bottom}
|
||||
};
|
||||
Arc(hDC, R.left, R.top, R.right, R.bottom,
|
||||
PRads[0].x, PRads[0].y, PRads[1].x, PRads[1].y);
|
||||
break;
|
||||
}
|
||||
case opPie:
|
||||
{
|
||||
const POINT PRads[] = {
|
||||
{(R.right - R.left) / 3 + R.left, R.top},
|
||||
{(R.right - R.left) / 3 + R.left, R.bottom}
|
||||
};
|
||||
Pie(hDC, R.left, R.top, R.right, R.bottom,
|
||||
PRads[0].x, PRads[0].y, PRads[1].x, PRads[1].y);
|
||||
break;
|
||||
}
|
||||
case opChord:
|
||||
{
|
||||
const POINT PRads[] = {
|
||||
{(R.right - R.left) / 3 + R.left, R.top},
|
||||
{(R.right - R.left) / 3 + R.left, R.bottom}
|
||||
};
|
||||
Chord(hDC, R.left, R.top, R.right, R.bottom,
|
||||
PRads[0].x, PRads[0].y, PRads[1].x, PRads[1].y);
|
||||
break;
|
||||
}
|
||||
case opCustom:
|
||||
{
|
||||
const POINT PVertices[] = {
|
||||
{R.left, (R.bottom - R.top) / 2 + R.top},
|
||||
{(R.right - R.left) / 2 + R.left, R.top},
|
||||
{R.right, (R.bottom - R.top) / 2 + R.top},
|
||||
{(R.right - R.left) / 2 + R.left, R.bottom}
|
||||
};
|
||||
Polygon(hDC, PVertices, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
HWND hListBox = NULL; // handle to the list box
|
||||
HBRUSH hListBrush = NULL; // handle to the list box brush
|
||||
HPEN hListPen = NULL; // handle to the list box pen
|
||||
HFONT hListFont = NULL; // handle to the list box font
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
hListBox =
|
||||
CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE, TEXT("LISTBOX"), TEXT(""),
|
||||
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
|
||||
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT |
|
||||
LBS_OWNERDRAWFIXED,
|
||||
0, 0, 640, 480,
|
||||
hWnd, NULL, hInst, NULL
|
||||
);
|
||||
assert(hListBox != NULL);
|
||||
|
||||
SetWindowLong(
|
||||
hListBox, GWL_ID, reinterpret_cast<LONG>(hListBox)
|
||||
);
|
||||
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Line")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Bezier Curve")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Rectangle")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Rounded Rectangle")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Ellipse")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Arc")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Pie Slice")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Chord")));
|
||||
SNDMSG(hListBox, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(TEXT("Custom")));
|
||||
|
||||
hListBrush = CreateSolidBrush(PALETTERGB(64, 192, 64));
|
||||
hListPen = CreatePen(PS_SOLID, 3, PALETTERGB(0, 0, 0));
|
||||
HDC hScreenDC = GetDC(NULL);
|
||||
#if 0
|
||||
try
|
||||
#endif
|
||||
{
|
||||
// MakeFont() from Chapter 4
|
||||
hListFont = font::MakeFont(
|
||||
hScreenDC, "Impact", 20, ANSI_CHARSET,
|
||||
font::FS_BOLD | font::FS_UNDERLINE
|
||||
);
|
||||
}
|
||||
#if 0
|
||||
catch (...)
|
||||
#endif
|
||||
{
|
||||
ReleaseDC(NULL, hScreenDC);
|
||||
}
|
||||
ReleaseDC(NULL, hScreenDC);
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_MEASUREITEM:
|
||||
{
|
||||
LPMEASUREITEMSTRUCT lpmis =
|
||||
reinterpret_cast<LPMEASUREITEMSTRUCT>(lParam);
|
||||
assert(lpmis != NULL);
|
||||
|
||||
if (lpmis->CtlID == reinterpret_cast<UINT>(hListBox))
|
||||
{
|
||||
lpmis->itemHeight = 150;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
LPDRAWITEMSTRUCT lpdis =
|
||||
reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
|
||||
assert(lpdis != NULL);
|
||||
|
||||
if (lpdis->CtlID == reinterpret_cast<UINT>(hListBox))
|
||||
{
|
||||
SaveDC(lpdis->hDC);
|
||||
#if 0
|
||||
try
|
||||
#endif
|
||||
{
|
||||
SelectObject(lpdis->hDC, hListBrush);
|
||||
SelectObject(lpdis->hDC, hListPen);
|
||||
SelectObject(lpdis->hDC, hListFont);
|
||||
|
||||
bool selected = (lpdis->itemState & ODS_SELECTED);
|
||||
COLORREF clrText = GetSysColor(
|
||||
selected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT
|
||||
);
|
||||
HBRUSH hListBrush = GetSysColorBrush(
|
||||
selected ? COLOR_HIGHLIGHT : COLOR_WINDOW
|
||||
);
|
||||
|
||||
// fill the background
|
||||
FillRect(lpdis->hDC, &lpdis->rcItem, hListBrush);
|
||||
|
||||
// render the output primitive
|
||||
RECT RPrimitive = lpdis->rcItem;
|
||||
InflateRect(&RPrimitive, -5, -5);
|
||||
RPrimitive.right = static_cast<int>(
|
||||
0.6 * lpdis->rcItem.right + 0.5
|
||||
);
|
||||
FillRect(
|
||||
lpdis->hDC, &RPrimitive,
|
||||
reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1)
|
||||
);
|
||||
DrawPrimitive(
|
||||
lpdis->hDC, RPrimitive,
|
||||
static_cast<OutPrimitive>(lpdis->itemID)
|
||||
);
|
||||
if (selected) InvertRect(lpdis->hDC, &RPrimitive);
|
||||
DrawEdge(lpdis->hDC, &RPrimitive, EDGE_SUNKEN, BF_RECT);
|
||||
|
||||
// render the text
|
||||
TCHAR text[13];
|
||||
if (SNDMSG(hListBox, LB_GETTEXT, lpdis->itemID,
|
||||
reinterpret_cast<LPARAM>(&text)) != LB_ERR)
|
||||
{
|
||||
RECT RText = RPrimitive;
|
||||
RText.left = RPrimitive.right;
|
||||
RText.right = lpdis->rcItem.right;
|
||||
|
||||
SelectObject(lpdis->hDC, hListFont);
|
||||
SetBkMode(lpdis->hDC, TRANSPARENT);
|
||||
SetTextColor(lpdis->hDC, clrText);
|
||||
|
||||
DrawText(lpdis->hDC, text, -1, &RText,
|
||||
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
}
|
||||
|
||||
// indicate keyboard focus
|
||||
if (lpdis->itemState & ODS_FOCUS)
|
||||
{
|
||||
RECT RFocus = lpdis->rcItem;
|
||||
InflateRect(&RFocus, -1, -1);
|
||||
DrawFocusRect(lpdis->hDC, &RFocus);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
catch (...)
|
||||
#endif
|
||||
{
|
||||
RestoreDC(lpdis->hDC, -1);
|
||||
}
|
||||
RestoreDC(lpdis->hDC, -1);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_SIZE:
|
||||
{
|
||||
MoveWindow(
|
||||
hListBox, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (hListBrush) DeleteObject(hListBrush);
|
||||
if (hListPen) DeleteObject(hListPen);
|
||||
if (hListFont) DeleteObject(hListFont);
|
||||
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: Makefile,v 1.1 2004/06/03 04:15:40 hyperion Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = pseh
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
|
||||
|
||||
TARGET_SDKLIBS = pseh.a
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: Makefile,v 1.9 2003/11/14 17:13:19 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = pteb
|
||||
|
||||
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
|
|
@ -1,23 +0,0 @@
|
|||
#include <ntos.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int x;
|
||||
PTEB Teb;
|
||||
|
||||
printf("TEB dumpper\n");
|
||||
__asm__("movl %%fs:0x18, %0\n\t"
|
||||
: "=a" (x)
|
||||
: /* no inputs */);
|
||||
printf("fs[0x18] %x\n", x);
|
||||
|
||||
Teb = (PTEB)x;
|
||||
|
||||
printf("StackBase: 0x%08lX\n", (DWORD)Teb->Tib.StackBase);
|
||||
printf("StackLimit: 0x%08lX\n", (DWORD)Teb->Tib.StackLimit);
|
||||
printf("DeallocationStack: 0x%08lX\n", (DWORD)Teb->DeallocationStack);
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,45 +0,0 @@
|
|||
// 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__*/
|
|
@ -1,27 +0,0 @@
|
|||
#
|
||||
# $Id: makefile,v 1.0
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,224 +0,0 @@
|
|||
/* $Id: regcmds.c,v 1.2 2003/01/01 11:16:18 robd 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);
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
/* $Id: regdump.c,v 1.3 2003/01/01 11:16:18 robd 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;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* 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
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
);
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = regqueryvalue
|
||||
|
||||
TARGET_SDKLIBS = advapi32.a ws2_32.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -g
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue